/* * 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 CreateServiceRequest = { idempotencyKey: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; computeResourceCreate: components.ComputeResourceCreate; }; export type CreateServiceResponse = | components.ComputeService | components.ComputeErrorEnvelope; /** @internal */ export const CreateServiceRequest$inboundSchema: z.ZodType< CreateServiceRequest, z.ZodTypeDef, unknown > = z.object({ "Idempotency-Key": z.string(), "X-On-Behalf-Of": z.string().optional(), ComputeResourceCreate: components.ComputeResourceCreate$inboundSchema, }).transform((v) => { return remap$(v, { "Idempotency-Key": "idempotencyKey", "X-On-Behalf-Of": "xOnBehalfOf", "ComputeResourceCreate": "computeResourceCreate", }); }); /** @internal */ export type CreateServiceRequest$Outbound = { "Idempotency-Key": string; "X-On-Behalf-Of"?: string | undefined; ComputeResourceCreate: components.ComputeResourceCreate$Outbound; }; /** @internal */ export const CreateServiceRequest$outboundSchema: z.ZodType< CreateServiceRequest$Outbound, z.ZodTypeDef, CreateServiceRequest > = z.object({ idempotencyKey: z.string(), xOnBehalfOf: z.string().optional(), computeResourceCreate: components.ComputeResourceCreate$outboundSchema, }).transform((v) => { return remap$(v, { idempotencyKey: "Idempotency-Key", xOnBehalfOf: "X-On-Behalf-Of", computeResourceCreate: "ComputeResourceCreate", }); }); export function createServiceRequestToJSON( createServiceRequest: CreateServiceRequest, ): string { return JSON.stringify( CreateServiceRequest$outboundSchema.parse(createServiceRequest), ); } export function createServiceRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateServiceRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateServiceRequest' from JSON`, ); } /** @internal */ export const CreateServiceResponse$inboundSchema: z.ZodType< CreateServiceResponse, z.ZodTypeDef, unknown > = z.union([ components.ComputeService$inboundSchema, components.ComputeErrorEnvelope$inboundSchema, ]); /** @internal */ export type CreateServiceResponse$Outbound = | components.ComputeService$Outbound | components.ComputeErrorEnvelope$Outbound; /** @internal */ export const CreateServiceResponse$outboundSchema: z.ZodType< CreateServiceResponse$Outbound, z.ZodTypeDef, CreateServiceResponse > = z.union([ components.ComputeService$outboundSchema, components.ComputeErrorEnvelope$outboundSchema, ]); export function createServiceResponseToJSON( createServiceResponse: CreateServiceResponse, ): string { return JSON.stringify( CreateServiceResponse$outboundSchema.parse(createServiceResponse), ); } export function createServiceResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateServiceResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateServiceResponse' from JSON`, ); }