/* * 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 CreateJobRequest = { idempotencyKey: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; computeJobCreate: components.ComputeJobCreate; }; export type CreateJobResponse = | components.ComputeJob | components.ComputeErrorEnvelope; /** @internal */ export const CreateJobRequest$inboundSchema: z.ZodType< CreateJobRequest, z.ZodTypeDef, unknown > = z.object({ "Idempotency-Key": z.string(), "X-On-Behalf-Of": z.string().optional(), ComputeJobCreate: components.ComputeJobCreate$inboundSchema, }).transform((v) => { return remap$(v, { "Idempotency-Key": "idempotencyKey", "X-On-Behalf-Of": "xOnBehalfOf", "ComputeJobCreate": "computeJobCreate", }); }); /** @internal */ export type CreateJobRequest$Outbound = { "Idempotency-Key": string; "X-On-Behalf-Of"?: string | undefined; ComputeJobCreate: components.ComputeJobCreate$Outbound; }; /** @internal */ export const CreateJobRequest$outboundSchema: z.ZodType< CreateJobRequest$Outbound, z.ZodTypeDef, CreateJobRequest > = z.object({ idempotencyKey: z.string(), xOnBehalfOf: z.string().optional(), computeJobCreate: components.ComputeJobCreate$outboundSchema, }).transform((v) => { return remap$(v, { idempotencyKey: "Idempotency-Key", xOnBehalfOf: "X-On-Behalf-Of", computeJobCreate: "ComputeJobCreate", }); }); export function createJobRequestToJSON( createJobRequest: CreateJobRequest, ): string { return JSON.stringify( CreateJobRequest$outboundSchema.parse(createJobRequest), ); } export function createJobRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateJobRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateJobRequest' from JSON`, ); } /** @internal */ export const CreateJobResponse$inboundSchema: z.ZodType< CreateJobResponse, z.ZodTypeDef, unknown > = z.union([ components.ComputeJob$inboundSchema, components.ComputeErrorEnvelope$inboundSchema, ]); /** @internal */ export type CreateJobResponse$Outbound = | components.ComputeJob$Outbound | components.ComputeErrorEnvelope$Outbound; /** @internal */ export const CreateJobResponse$outboundSchema: z.ZodType< CreateJobResponse$Outbound, z.ZodTypeDef, CreateJobResponse > = z.union([ components.ComputeJob$outboundSchema, components.ComputeErrorEnvelope$outboundSchema, ]); export function createJobResponseToJSON( createJobResponse: CreateJobResponse, ): string { return JSON.stringify( CreateJobResponse$outboundSchema.parse(createJobResponse), ); } export function createJobResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateJobResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateJobResponse' from JSON`, ); }