/* * 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 ListServiceEventsRequest = { id: string; cursor?: string | undefined; limit?: number | undefined; /** * asc pages oldest-first (default); desc pages newest-first. A cursor is only valid within a traversal that keeps the same order. */ order?: components.ComputeOrder | undefined; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export type ListServiceEventsResponse = | components.ComputeEventList | components.ComputeErrorEnvelope; /** @internal */ export const ListServiceEventsRequest$inboundSchema: z.ZodType< ListServiceEventsRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), cursor: z.string().optional(), limit: z.number().int().default(50), order: components.ComputeOrder$inboundSchema.default("asc"), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ListServiceEventsRequest$Outbound = { id: string; cursor?: string | undefined; limit: number; order: string; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ListServiceEventsRequest$outboundSchema: z.ZodType< ListServiceEventsRequest$Outbound, z.ZodTypeDef, ListServiceEventsRequest > = z.object({ id: z.string(), cursor: z.string().optional(), limit: z.number().int().default(50), order: components.ComputeOrder$outboundSchema.default("asc"), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", }); }); export function listServiceEventsRequestToJSON( listServiceEventsRequest: ListServiceEventsRequest, ): string { return JSON.stringify( ListServiceEventsRequest$outboundSchema.parse(listServiceEventsRequest), ); } export function listServiceEventsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceEventsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceEventsRequest' from JSON`, ); } /** @internal */ export const ListServiceEventsResponse$inboundSchema: z.ZodType< ListServiceEventsResponse, z.ZodTypeDef, unknown > = z.union([ components.ComputeEventList$inboundSchema, components.ComputeErrorEnvelope$inboundSchema, ]); /** @internal */ export type ListServiceEventsResponse$Outbound = | components.ComputeEventList$Outbound | components.ComputeErrorEnvelope$Outbound; /** @internal */ export const ListServiceEventsResponse$outboundSchema: z.ZodType< ListServiceEventsResponse$Outbound, z.ZodTypeDef, ListServiceEventsResponse > = z.union([ components.ComputeEventList$outboundSchema, components.ComputeErrorEnvelope$outboundSchema, ]); export function listServiceEventsResponseToJSON( listServiceEventsResponse: ListServiceEventsResponse, ): string { return JSON.stringify( ListServiceEventsResponse$outboundSchema.parse(listServiceEventsResponse), ); } export function listServiceEventsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceEventsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceEventsResponse' from JSON`, ); }