/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 { UsageResult, UsageResult$inboundSchema, UsageResult$Outbound, UsageResult$outboundSchema, } from "./usageresult.js"; export type UsageBucket = { /** * RFC3339 timestamp for bucket start */ startingAt: string; /** * RFC3339 timestamp for bucket end */ endingAt: string; /** * Array of usage results within this time bucket */ results: Array; }; /** @internal */ export const UsageBucket$inboundSchema: z.ZodType< UsageBucket, z.ZodTypeDef, unknown > = z.object({ starting_at: z.string(), ending_at: z.string(), results: z.array(UsageResult$inboundSchema), }).transform((v) => { return remap$(v, { "starting_at": "startingAt", "ending_at": "endingAt", }); }); /** @internal */ export type UsageBucket$Outbound = { starting_at: string; ending_at: string; results: Array; }; /** @internal */ export const UsageBucket$outboundSchema: z.ZodType< UsageBucket$Outbound, z.ZodTypeDef, UsageBucket > = z.object({ startingAt: z.string(), endingAt: z.string(), results: z.array(UsageResult$outboundSchema), }).transform((v) => { return remap$(v, { startingAt: "starting_at", endingAt: "ending_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UsageBucket$ { /** @deprecated use `UsageBucket$inboundSchema` instead. */ export const inboundSchema = UsageBucket$inboundSchema; /** @deprecated use `UsageBucket$outboundSchema` instead. */ export const outboundSchema = UsageBucket$outboundSchema; /** @deprecated use `UsageBucket$Outbound` instead. */ export type Outbound = UsageBucket$Outbound; } export function usageBucketToJSON(usageBucket: UsageBucket): string { return JSON.stringify(UsageBucket$outboundSchema.parse(usageBucket)); } export function usageBucketFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UsageBucket$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UsageBucket' from JSON`, ); }