/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetUserBudgetsRequest = { id: string; orgId?: string | undefined; }; export const GetUserBudgetsScope = { Org: "org", Apikey: "apikey", User: "user", Team: "team", ExternalUser: "external_user", UserDefault: "user_default", TeamDefault: "team_default", ExternalUserDefault: "external_user_default", } as const; export type GetUserBudgetsScope = ClosedEnum; export const GetUserBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type GetUserBudgetsOwner = ClosedEnum; export const GetUserBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type GetUserBudgetsPeriod = ClosedEnum; export const GetUserBudgetsAction = { Alert: "alert", Block: "block", } as const; export type GetUserBudgetsAction = ClosedEnum; export type GetUserBudgetsThresholds = { pct: number; action: GetUserBudgetsAction; }; export const GetUserBudgetsStatus = { Ok: "ok", Blocked: "blocked", } as const; export type GetUserBudgetsStatus = ClosedEnum; export type GetUserBudgetsSpend = { /** * Current period bucket, e.g. 2026-07 / 2026-W28 / 2026-07-07 */ window: string; /** * Live spend this window, major currency units */ costSpent: number; limit: number; pct: number; status: GetUserBudgetsStatus; }; export type GetUserBudgetsData = { id: string; scope: GetUserBudgetsScope; scopeId: string; scopeOrgId: string | null; owner: GetUserBudgetsOwner; period: GetUserBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; spend: GetUserBudgetsSpend; }; /** * OK */ export type GetUserBudgetsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const GetUserBudgetsRequest$inboundSchema: z.ZodType< GetUserBudgetsRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "org_id": "orgId", }); }); /** @internal */ export type GetUserBudgetsRequest$Outbound = { id: string; org_id?: string | undefined; }; /** @internal */ export const GetUserBudgetsRequest$outboundSchema: z.ZodType< GetUserBudgetsRequest$Outbound, z.ZodTypeDef, GetUserBudgetsRequest > = z.object({ id: z.string(), orgId: z.string().optional(), }).transform((v) => { return remap$(v, { orgId: "org_id", }); }); export function getUserBudgetsRequestToJSON( getUserBudgetsRequest: GetUserBudgetsRequest, ): string { return JSON.stringify( GetUserBudgetsRequest$outboundSchema.parse(getUserBudgetsRequest), ); } export function getUserBudgetsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUserBudgetsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUserBudgetsRequest' from JSON`, ); } /** @internal */ export const GetUserBudgetsScope$inboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsScope > = z.nativeEnum(GetUserBudgetsScope); /** @internal */ export const GetUserBudgetsScope$outboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsScope > = GetUserBudgetsScope$inboundSchema; /** @internal */ export const GetUserBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsOwner > = z.nativeEnum(GetUserBudgetsOwner); /** @internal */ export const GetUserBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsOwner > = GetUserBudgetsOwner$inboundSchema; /** @internal */ export const GetUserBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsPeriod > = z.nativeEnum(GetUserBudgetsPeriod); /** @internal */ export const GetUserBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsPeriod > = GetUserBudgetsPeriod$inboundSchema; /** @internal */ export const GetUserBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsAction > = z.nativeEnum(GetUserBudgetsAction); /** @internal */ export const GetUserBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsAction > = GetUserBudgetsAction$inboundSchema; /** @internal */ export const GetUserBudgetsThresholds$inboundSchema: z.ZodType< GetUserBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: GetUserBudgetsAction$inboundSchema, }); /** @internal */ export type GetUserBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const GetUserBudgetsThresholds$outboundSchema: z.ZodType< GetUserBudgetsThresholds$Outbound, z.ZodTypeDef, GetUserBudgetsThresholds > = z.object({ pct: z.number().int(), action: GetUserBudgetsAction$outboundSchema, }); export function getUserBudgetsThresholdsToJSON( getUserBudgetsThresholds: GetUserBudgetsThresholds, ): string { return JSON.stringify( GetUserBudgetsThresholds$outboundSchema.parse(getUserBudgetsThresholds), ); } export function getUserBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUserBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUserBudgetsThresholds' from JSON`, ); } /** @internal */ export const GetUserBudgetsStatus$inboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsStatus > = z.nativeEnum(GetUserBudgetsStatus); /** @internal */ export const GetUserBudgetsStatus$outboundSchema: z.ZodNativeEnum< typeof GetUserBudgetsStatus > = GetUserBudgetsStatus$inboundSchema; /** @internal */ export const GetUserBudgetsSpend$inboundSchema: z.ZodType< GetUserBudgetsSpend, z.ZodTypeDef, unknown > = z.object({ window: z.string(), cost_spent: z.number(), limit: z.number(), pct: z.number().int(), status: GetUserBudgetsStatus$inboundSchema, }).transform((v) => { return remap$(v, { "cost_spent": "costSpent", }); }); /** @internal */ export type GetUserBudgetsSpend$Outbound = { window: string; cost_spent: number; limit: number; pct: number; status: string; }; /** @internal */ export const GetUserBudgetsSpend$outboundSchema: z.ZodType< GetUserBudgetsSpend$Outbound, z.ZodTypeDef, GetUserBudgetsSpend > = z.object({ window: z.string(), costSpent: z.number(), limit: z.number(), pct: z.number().int(), status: GetUserBudgetsStatus$outboundSchema, }).transform((v) => { return remap$(v, { costSpent: "cost_spent", }); }); export function getUserBudgetsSpendToJSON( getUserBudgetsSpend: GetUserBudgetsSpend, ): string { return JSON.stringify( GetUserBudgetsSpend$outboundSchema.parse(getUserBudgetsSpend), ); } export function getUserBudgetsSpendFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUserBudgetsSpend$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUserBudgetsSpend' from JSON`, ); } /** @internal */ export const GetUserBudgetsData$inboundSchema: z.ZodType< GetUserBudgetsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: GetUserBudgetsScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: GetUserBudgetsOwner$inboundSchema, period: GetUserBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetUserBudgetsThresholds$inboundSchema)), alert_webhook_url: z.nullable(z.string()), spend: z.lazy(() => GetUserBudgetsSpend$inboundSchema), }).transform((v) => { return remap$(v, { "scope_id": "scopeId", "scope_org_id": "scopeOrgId", "alert_webhook_url": "alertWebhookUrl", }); }); /** @internal */ export type GetUserBudgetsData$Outbound = { id: string; scope: string; scope_id: string; scope_org_id: string | null; owner: string; period: string; limit: number; thresholds: Array; alert_webhook_url: string | null; spend: GetUserBudgetsSpend$Outbound; }; /** @internal */ export const GetUserBudgetsData$outboundSchema: z.ZodType< GetUserBudgetsData$Outbound, z.ZodTypeDef, GetUserBudgetsData > = z.object({ id: z.string(), scope: GetUserBudgetsScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: GetUserBudgetsOwner$outboundSchema, period: GetUserBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetUserBudgetsThresholds$outboundSchema)), alertWebhookUrl: z.nullable(z.string()), spend: z.lazy(() => GetUserBudgetsSpend$outboundSchema), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function getUserBudgetsDataToJSON( getUserBudgetsData: GetUserBudgetsData, ): string { return JSON.stringify( GetUserBudgetsData$outboundSchema.parse(getUserBudgetsData), ); } export function getUserBudgetsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUserBudgetsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUserBudgetsData' from JSON`, ); } /** @internal */ export const GetUserBudgetsResponseBody$inboundSchema: z.ZodType< GetUserBudgetsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetUserBudgetsData$inboundSchema)), }); /** @internal */ export type GetUserBudgetsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const GetUserBudgetsResponseBody$outboundSchema: z.ZodType< GetUserBudgetsResponseBody$Outbound, z.ZodTypeDef, GetUserBudgetsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetUserBudgetsData$outboundSchema)), }); export function getUserBudgetsResponseBodyToJSON( getUserBudgetsResponseBody: GetUserBudgetsResponseBody, ): string { return JSON.stringify( GetUserBudgetsResponseBody$outboundSchema.parse(getUserBudgetsResponseBody), ); } export function getUserBudgetsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUserBudgetsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUserBudgetsResponseBody' from JSON`, ); }