/* * 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"; export type ComputeProviderHealth = { degraded: boolean; error: string | null; healthy: boolean; lastPollAt: Date; latencyMs: number; offerCount: number; /** * Opaque compute-provider identifier. Supported values are deployment-specific. */ provider: string; }; /** @internal */ export const ComputeProviderHealth$inboundSchema: z.ZodType< ComputeProviderHealth, z.ZodTypeDef, unknown > = z.object({ degraded: z.boolean(), error: z.nullable(z.string()), healthy: z.boolean(), last_poll_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), latency_ms: z.number().int(), offer_count: z.number().int(), provider: z.string(), }).transform((v) => { return remap$(v, { "last_poll_at": "lastPollAt", "latency_ms": "latencyMs", "offer_count": "offerCount", }); }); /** @internal */ export type ComputeProviderHealth$Outbound = { degraded: boolean; error: string | null; healthy: boolean; last_poll_at: string; latency_ms: number; offer_count: number; provider: string; }; /** @internal */ export const ComputeProviderHealth$outboundSchema: z.ZodType< ComputeProviderHealth$Outbound, z.ZodTypeDef, ComputeProviderHealth > = z.object({ degraded: z.boolean(), error: z.nullable(z.string()), healthy: z.boolean(), lastPollAt: z.date().transform(v => v.toISOString()), latencyMs: z.number().int(), offerCount: z.number().int(), provider: z.string(), }).transform((v) => { return remap$(v, { lastPollAt: "last_poll_at", latencyMs: "latency_ms", offerCount: "offer_count", }); }); export function computeProviderHealthToJSON( computeProviderHealth: ComputeProviderHealth, ): string { return JSON.stringify( ComputeProviderHealth$outboundSchema.parse(computeProviderHealth), ); } export function computeProviderHealthFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ComputeProviderHealth$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ComputeProviderHealth' from JSON`, ); }