/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ComputeEndpoint, ComputeEndpoint$inboundSchema, ComputeEndpoint$Outbound, ComputeEndpoint$outboundSchema, } from "./computeendpoint.js"; import { ComputeHardware, ComputeHardware$inboundSchema, ComputeHardware$Outbound, ComputeHardware$outboundSchema, } from "./computehardware.js"; import { ComputeLimits, ComputeLimits$inboundSchema, ComputeLimits$Outbound, ComputeLimits$outboundSchema, } from "./computelimits.js"; import { ComputeReason, ComputeReason$inboundSchema, ComputeReason$Outbound, ComputeReason$outboundSchema, } from "./computereason.js"; import { ComputeRequest, ComputeRequest$inboundSchema, ComputeRequest$Outbound, ComputeRequest$outboundSchema, } from "./computerequest.js"; import { ComputeResourceState, ComputeResourceState$inboundSchema, ComputeResourceState$outboundSchema, } from "./computeresourcestate.js"; import { ComputeSSH, ComputeSSH$inboundSchema, ComputeSSH$Outbound, ComputeSSH$outboundSchema, } from "./computessh.js"; import { ComputeVolume, ComputeVolume$inboundSchema, ComputeVolume$Outbound, ComputeVolume$outboundSchema, } from "./computevolume.js"; export type ComputeService = { accruedUsd: number; allocatedAt?: Date | undefined; compute: ComputeRequest; createdAt: Date; endpoints: Array; hardware?: ComputeHardware | undefined; id: string; limits: ComputeLimits; name?: string | undefined; priceUsdHr?: number | undefined; /** * Opaque compute-provider identifier. Supported values are deployment-specific. */ provider?: string | undefined; reason: ComputeReason | null; ssh?: ComputeSSH | undefined; startedAt: Date | null; state: ComputeResourceState; terminalAt: Date | null; ready: boolean; volume?: ComputeVolume | undefined; }; /** @internal */ export const ComputeService$inboundSchema: z.ZodType< ComputeService, z.ZodTypeDef, unknown > = z.object({ accrued_usd: z.number(), allocated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), compute: ComputeRequest$inboundSchema, created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), endpoints: z.array(ComputeEndpoint$inboundSchema), hardware: ComputeHardware$inboundSchema.optional(), id: z.string(), limits: ComputeLimits$inboundSchema, name: z.string().optional(), price_usd_hr: z.number().optional(), provider: z.string().optional(), reason: z.nullable(ComputeReason$inboundSchema), ssh: ComputeSSH$inboundSchema.optional(), started_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), state: ComputeResourceState$inboundSchema, terminal_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), ready: z.boolean(), volume: ComputeVolume$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "accrued_usd": "accruedUsd", "allocated_at": "allocatedAt", "created_at": "createdAt", "price_usd_hr": "priceUsdHr", "started_at": "startedAt", "terminal_at": "terminalAt", }); }); /** @internal */ export type ComputeService$Outbound = { accrued_usd: number; allocated_at?: string | undefined; compute: ComputeRequest$Outbound; created_at: string; endpoints: Array; hardware?: ComputeHardware$Outbound | undefined; id: string; limits: ComputeLimits$Outbound; name?: string | undefined; price_usd_hr?: number | undefined; provider?: string | undefined; reason: ComputeReason$Outbound | null; ssh?: ComputeSSH$Outbound | undefined; started_at: string | null; state: string; terminal_at: string | null; ready: boolean; volume?: ComputeVolume$Outbound | undefined; }; /** @internal */ export const ComputeService$outboundSchema: z.ZodType< ComputeService$Outbound, z.ZodTypeDef, ComputeService > = z.object({ accruedUsd: z.number(), allocatedAt: z.date().transform(v => v.toISOString()).optional(), compute: ComputeRequest$outboundSchema, createdAt: z.date().transform(v => v.toISOString()), endpoints: z.array(ComputeEndpoint$outboundSchema), hardware: ComputeHardware$outboundSchema.optional(), id: z.string(), limits: ComputeLimits$outboundSchema, name: z.string().optional(), priceUsdHr: z.number().optional(), provider: z.string().optional(), reason: z.nullable(ComputeReason$outboundSchema), ssh: ComputeSSH$outboundSchema.optional(), startedAt: z.nullable(z.date().transform(v => v.toISOString())), state: ComputeResourceState$outboundSchema, terminalAt: z.nullable(z.date().transform(v => v.toISOString())), ready: z.boolean(), volume: ComputeVolume$outboundSchema.optional(), }).transform((v) => { return remap$(v, { accruedUsd: "accrued_usd", allocatedAt: "allocated_at", createdAt: "created_at", priceUsdHr: "price_usd_hr", startedAt: "started_at", terminalAt: "terminal_at", }); }); export function computeServiceToJSON(computeService: ComputeService): string { return JSON.stringify(ComputeService$outboundSchema.parse(computeService)); } export function computeServiceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ComputeService$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ComputeService' from JSON`, ); }