/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Time bucket width for aggregation */ export const BucketWidth = { Hour: "hour", Day: "day", } as const; /** * Time bucket width for aggregation */ export type BucketWidth = ClosedEnum; export const BreakdownType = { VoiceId: "voice_id", VoiceName: "voice_name", ApiKey: "api_key", Model: "model", } as const; export type BreakdownType = ClosedEnum; export type GetUsageRequest = { /** * Start time in RFC3339 format */ startTime: string; /** * End time in RFC3339 format */ endTime: string; /** * Time bucket width for aggregation */ bucketWidth?: BucketWidth | undefined; /** * Dimensions to break down usage data */ breakdownType?: Array | undefined; /** * Number of results per page */ pageSize?: number | undefined; /** * Pagination token from previous response */ nextPageToken?: string | undefined; }; /** @internal */ export const BucketWidth$inboundSchema: z.ZodNativeEnum = z .nativeEnum(BucketWidth); /** @internal */ export const BucketWidth$outboundSchema: z.ZodNativeEnum = BucketWidth$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BucketWidth$ { /** @deprecated use `BucketWidth$inboundSchema` instead. */ export const inboundSchema = BucketWidth$inboundSchema; /** @deprecated use `BucketWidth$outboundSchema` instead. */ export const outboundSchema = BucketWidth$outboundSchema; } /** @internal */ export const BreakdownType$inboundSchema: z.ZodNativeEnum< typeof BreakdownType > = z.nativeEnum(BreakdownType); /** @internal */ export const BreakdownType$outboundSchema: z.ZodNativeEnum< typeof BreakdownType > = BreakdownType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BreakdownType$ { /** @deprecated use `BreakdownType$inboundSchema` instead. */ export const inboundSchema = BreakdownType$inboundSchema; /** @deprecated use `BreakdownType$outboundSchema` instead. */ export const outboundSchema = BreakdownType$outboundSchema; } /** @internal */ export const GetUsageRequest$inboundSchema: z.ZodType< GetUsageRequest, z.ZodTypeDef, unknown > = z.object({ start_time: z.string(), end_time: z.string(), bucket_width: BucketWidth$inboundSchema.default("day"), breakdown_type: z.array(BreakdownType$inboundSchema).optional(), page_size: z.number().default(10), next_page_token: z.string().optional(), }).transform((v) => { return remap$(v, { "start_time": "startTime", "end_time": "endTime", "bucket_width": "bucketWidth", "breakdown_type": "breakdownType", "page_size": "pageSize", "next_page_token": "nextPageToken", }); }); /** @internal */ export type GetUsageRequest$Outbound = { start_time: string; end_time: string; bucket_width: string; breakdown_type?: Array | undefined; page_size: number; next_page_token?: string | undefined; }; /** @internal */ export const GetUsageRequest$outboundSchema: z.ZodType< GetUsageRequest$Outbound, z.ZodTypeDef, GetUsageRequest > = z.object({ startTime: z.string(), endTime: z.string(), bucketWidth: BucketWidth$outboundSchema.default("day"), breakdownType: z.array(BreakdownType$outboundSchema).optional(), pageSize: z.number().default(10), nextPageToken: z.string().optional(), }).transform((v) => { return remap$(v, { startTime: "start_time", endTime: "end_time", bucketWidth: "bucket_width", breakdownType: "breakdown_type", pageSize: "page_size", nextPageToken: "next_page_token", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetUsageRequest$ { /** @deprecated use `GetUsageRequest$inboundSchema` instead. */ export const inboundSchema = GetUsageRequest$inboundSchema; /** @deprecated use `GetUsageRequest$outboundSchema` instead. */ export const outboundSchema = GetUsageRequest$outboundSchema; /** @deprecated use `GetUsageRequest$Outbound` instead. */ export type Outbound = GetUsageRequest$Outbound; } export function getUsageRequestToJSON( getUsageRequest: GetUsageRequest, ): string { return JSON.stringify(GetUsageRequest$outboundSchema.parse(getUsageRequest)); } export function getUsageRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUsageRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUsageRequest' from JSON`, ); }