/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ConsumerMetadata, ConsumerMetadata$inboundSchema, } from "./consumermetadata.js"; import { Links, Links$inboundSchema } from "./links.js"; import { Meta, Meta$inboundSchema } from "./meta.js"; import { RequestCountAllocation, RequestCountAllocation$inboundSchema, } from "./requestcountallocation.js"; export type Data = { consumerId?: string | undefined; applicationId?: string | undefined; /** * The metadata of the consumer. This is used to display the consumer in the sidebar. This is optional, but recommended. */ metadata?: ConsumerMetadata | undefined; aggregatedRequestCount?: number | undefined; requestCounts?: RequestCountAllocation | undefined; created?: string | undefined; modified?: string | undefined; requestCountUpdated?: string | undefined; services?: Array | undefined; }; /** * Consumers */ export type GetConsumersResponse = { /** * HTTP Response Status Code */ statusCode: number; /** * HTTP Response Status */ status: string; data: Array; /** * Response metadata */ meta?: Meta | undefined; /** * Links to navigate to previous or next pages through the API */ links?: Links | undefined; /** * Raw response from the integration when raw=true query param is provided */ raw?: { [k: string]: any } | null | undefined; }; /** @internal */ export const Data$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ consumer_id: types.optional(types.string()), application_id: types.optional(types.string()), metadata: types.optional(ConsumerMetadata$inboundSchema), aggregated_request_count: types.optional(types.number()), request_counts: types.optional(RequestCountAllocation$inboundSchema), created: types.optional(types.string()), modified: types.optional(types.string()), request_count_updated: types.optional(types.string()), services: types.optional(z.array(types.string())), }).transform((v) => { return remap$(v, { "consumer_id": "consumerId", "application_id": "applicationId", "aggregated_request_count": "aggregatedRequestCount", "request_counts": "requestCounts", "request_count_updated": "requestCountUpdated", }); }) ); export function dataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Data$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Data' from JSON`, ); } /** @internal */ export const GetConsumersResponse$inboundSchema: z.ZodType< GetConsumersResponse, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ status_code: types.number(), status: types.string(), data: z.array(z.lazy(() => Data$inboundSchema)), meta: types.optional(Meta$inboundSchema), links: types.optional(Links$inboundSchema), _raw: z.nullable(z.record(z.any())).optional(), }).transform((v) => { return remap$(v, { "status_code": "statusCode", "_raw": "raw", }); }) ); export function getConsumersResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetConsumersResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetConsumersResponse' from JSON`, ); }