/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ConsumerConnection, ConsumerConnection$inboundSchema, ConsumerConnection$Outbound, ConsumerConnection$outboundSchema, } from "./consumerconnection.js"; import { ConsumerMetadata, ConsumerMetadata$inboundSchema, ConsumerMetadata$Outbound, ConsumerMetadata$outboundSchema, } from "./consumermetadata.js"; import { RequestCountAllocation, RequestCountAllocation$inboundSchema, RequestCountAllocation$Outbound, RequestCountAllocation$outboundSchema, } from "./requestcountallocation.js"; export type Consumer = { /** * Unique consumer identifier. You can freely choose a consumer ID yourself. Most of the time, this is an ID of your internal data model that represents a user or account in your system (for example account:12345). If the consumer doesn't exist yet, Vault will upsert a consumer based on your ID. */ consumerId: string; /** * ID of your Apideck Application */ 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; connections?: Array | undefined; services?: Array | undefined; aggregatedRequestCount?: number | undefined; requestCounts?: RequestCountAllocation | undefined; created?: string | undefined; modified?: string | undefined; requestCountUpdated?: string | undefined; }; /** @internal */ export const Consumer$inboundSchema: z.ZodType< Consumer, z.ZodTypeDef, unknown > = z.object({ consumer_id: z.string(), application_id: z.string().optional(), metadata: ConsumerMetadata$inboundSchema.optional(), connections: z.array(ConsumerConnection$inboundSchema).optional(), services: z.array(z.string()).optional(), aggregated_request_count: z.number().optional(), request_counts: RequestCountAllocation$inboundSchema.optional(), created: z.string().optional(), modified: z.string().optional(), request_count_updated: z.string().optional(), }).transform((v) => { return remap$(v, { "consumer_id": "consumerId", "application_id": "applicationId", "aggregated_request_count": "aggregatedRequestCount", "request_counts": "requestCounts", "request_count_updated": "requestCountUpdated", }); }); /** @internal */ export type Consumer$Outbound = { consumer_id: string; application_id?: string | undefined; metadata?: ConsumerMetadata$Outbound | undefined; connections?: Array | undefined; services?: Array | undefined; aggregated_request_count?: number | undefined; request_counts?: RequestCountAllocation$Outbound | undefined; created?: string | undefined; modified?: string | undefined; request_count_updated?: string | undefined; }; /** @internal */ export const Consumer$outboundSchema: z.ZodType< Consumer$Outbound, z.ZodTypeDef, Consumer > = z.object({ consumerId: z.string(), applicationId: z.string().optional(), metadata: ConsumerMetadata$outboundSchema.optional(), connections: z.array(ConsumerConnection$outboundSchema).optional(), services: z.array(z.string()).optional(), aggregatedRequestCount: z.number().optional(), requestCounts: RequestCountAllocation$outboundSchema.optional(), created: z.string().optional(), modified: z.string().optional(), requestCountUpdated: z.string().optional(), }).transform((v) => { return remap$(v, { consumerId: "consumer_id", applicationId: "application_id", aggregatedRequestCount: "aggregated_request_count", requestCounts: "request_counts", requestCountUpdated: "request_count_updated", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Consumer$ { /** @deprecated use `Consumer$inboundSchema` instead. */ export const inboundSchema = Consumer$inboundSchema; /** @deprecated use `Consumer$outboundSchema` instead. */ export const outboundSchema = Consumer$outboundSchema; /** @deprecated use `Consumer$Outbound` instead. */ export type Outbound = Consumer$Outbound; } export function consumerToJSON(consumer: Consumer): string { return JSON.stringify(Consumer$outboundSchema.parse(consumer)); } export function consumerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Consumer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Consumer' from JSON`, ); }