/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListServiceInstancesRequest = { id: string; state?: components.ComputeInstanceState | undefined; cursor?: string | undefined; limit?: number | undefined; /** * asc pages oldest-first (default); desc pages newest-first. A cursor is only valid within a traversal that keeps the same order. */ order?: components.ComputeOrder | undefined; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export type ListServiceInstancesResponse = | components.ComputeInstanceList | components.ComputeErrorEnvelope; /** @internal */ export const ListServiceInstancesRequest$inboundSchema: z.ZodType< ListServiceInstancesRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), state: components.ComputeInstanceState$inboundSchema.optional(), cursor: z.string().optional(), limit: z.number().int().default(50), order: components.ComputeOrder$inboundSchema.default("asc"), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ListServiceInstancesRequest$Outbound = { id: string; state?: string | undefined; cursor?: string | undefined; limit: number; order: string; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ListServiceInstancesRequest$outboundSchema: z.ZodType< ListServiceInstancesRequest$Outbound, z.ZodTypeDef, ListServiceInstancesRequest > = z.object({ id: z.string(), state: components.ComputeInstanceState$outboundSchema.optional(), cursor: z.string().optional(), limit: z.number().int().default(50), order: components.ComputeOrder$outboundSchema.default("asc"), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", }); }); export function listServiceInstancesRequestToJSON( listServiceInstancesRequest: ListServiceInstancesRequest, ): string { return JSON.stringify( ListServiceInstancesRequest$outboundSchema.parse( listServiceInstancesRequest, ), ); } export function listServiceInstancesRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceInstancesRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceInstancesRequest' from JSON`, ); } /** @internal */ export const ListServiceInstancesResponse$inboundSchema: z.ZodType< ListServiceInstancesResponse, z.ZodTypeDef, unknown > = z.union([ components.ComputeInstanceList$inboundSchema, components.ComputeErrorEnvelope$inboundSchema, ]); /** @internal */ export type ListServiceInstancesResponse$Outbound = | components.ComputeInstanceList$Outbound | components.ComputeErrorEnvelope$Outbound; /** @internal */ export const ListServiceInstancesResponse$outboundSchema: z.ZodType< ListServiceInstancesResponse$Outbound, z.ZodTypeDef, ListServiceInstancesResponse > = z.union([ components.ComputeInstanceList$outboundSchema, components.ComputeErrorEnvelope$outboundSchema, ]); export function listServiceInstancesResponseToJSON( listServiceInstancesResponse: ListServiceInstancesResponse, ): string { return JSON.stringify( ListServiceInstancesResponse$outboundSchema.parse( listServiceInstancesResponse, ), ); } export function listServiceInstancesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceInstancesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceInstancesResponse' from JSON`, ); }