/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { BackupType, BackupType$inboundSchema, BackupType$outboundSchema, } from "./backuptype.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type BackupResource = { id?: number | undefined; name?: string | null | undefined; path?: string | null | undefined; type?: BackupType | undefined; size?: number | undefined; time?: Date | undefined; }; /** @internal */ export const BackupResource$inboundSchema: z.ZodType< BackupResource, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.nullable(z.string()).optional(), path: z.nullable(z.string()).optional(), type: BackupType$inboundSchema.optional(), size: z.number().int().optional(), time: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type BackupResource$Outbound = { id?: number | undefined; name?: string | null | undefined; path?: string | null | undefined; type?: string | undefined; size?: number | undefined; time?: string | undefined; }; /** @internal */ export const BackupResource$outboundSchema: z.ZodType< BackupResource$Outbound, z.ZodTypeDef, BackupResource > = z.object({ id: z.number().int().optional(), name: z.nullable(z.string()).optional(), path: z.nullable(z.string()).optional(), type: BackupType$outboundSchema.optional(), size: z.number().int().optional(), time: z.date().transform(v => v.toISOString()).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BackupResource$ { /** @deprecated use `BackupResource$inboundSchema` instead. */ export const inboundSchema = BackupResource$inboundSchema; /** @deprecated use `BackupResource$outboundSchema` instead. */ export const outboundSchema = BackupResource$outboundSchema; /** @deprecated use `BackupResource$Outbound` instead. */ export type Outbound = BackupResource$Outbound; } export function backupResourceToJSON(backupResource: BackupResource): string { return JSON.stringify(BackupResource$outboundSchema.parse(backupResource)); } export function backupResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BackupResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BackupResource' from JSON`, ); }