/* * 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 GetTeamBudgetsRequest = { id: string; orgId?: string | undefined; }; export const GetTeamBudgetsScope = { 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 GetTeamBudgetsScope = ClosedEnum; export const GetTeamBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type GetTeamBudgetsOwner = ClosedEnum; export const GetTeamBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type GetTeamBudgetsPeriod = ClosedEnum; export const GetTeamBudgetsAction = { Alert: "alert", Block: "block", } as const; export type GetTeamBudgetsAction = ClosedEnum; export type GetTeamBudgetsThresholds = { pct: number; action: GetTeamBudgetsAction; }; export const GetTeamBudgetsStatus = { Ok: "ok", Blocked: "blocked", } as const; export type GetTeamBudgetsStatus = ClosedEnum; export type GetTeamBudgetsSpend = { /** * 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: GetTeamBudgetsStatus; }; export type GetTeamBudgetsData = { id: string; scope: GetTeamBudgetsScope; scopeId: string; scopeOrgId: string | null; owner: GetTeamBudgetsOwner; period: GetTeamBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; spend: GetTeamBudgetsSpend; }; /** * OK */ export type GetTeamBudgetsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const GetTeamBudgetsRequest$inboundSchema: z.ZodType< GetTeamBudgetsRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "org_id": "orgId", }); }); /** @internal */ export type GetTeamBudgetsRequest$Outbound = { id: string; org_id?: string | undefined; }; /** @internal */ export const GetTeamBudgetsRequest$outboundSchema: z.ZodType< GetTeamBudgetsRequest$Outbound, z.ZodTypeDef, GetTeamBudgetsRequest > = z.object({ id: z.string(), orgId: z.string().optional(), }).transform((v) => { return remap$(v, { orgId: "org_id", }); }); export function getTeamBudgetsRequestToJSON( getTeamBudgetsRequest: GetTeamBudgetsRequest, ): string { return JSON.stringify( GetTeamBudgetsRequest$outboundSchema.parse(getTeamBudgetsRequest), ); } export function getTeamBudgetsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTeamBudgetsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTeamBudgetsRequest' from JSON`, ); } /** @internal */ export const GetTeamBudgetsScope$inboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsScope > = z.nativeEnum(GetTeamBudgetsScope); /** @internal */ export const GetTeamBudgetsScope$outboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsScope > = GetTeamBudgetsScope$inboundSchema; /** @internal */ export const GetTeamBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsOwner > = z.nativeEnum(GetTeamBudgetsOwner); /** @internal */ export const GetTeamBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsOwner > = GetTeamBudgetsOwner$inboundSchema; /** @internal */ export const GetTeamBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsPeriod > = z.nativeEnum(GetTeamBudgetsPeriod); /** @internal */ export const GetTeamBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsPeriod > = GetTeamBudgetsPeriod$inboundSchema; /** @internal */ export const GetTeamBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsAction > = z.nativeEnum(GetTeamBudgetsAction); /** @internal */ export const GetTeamBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsAction > = GetTeamBudgetsAction$inboundSchema; /** @internal */ export const GetTeamBudgetsThresholds$inboundSchema: z.ZodType< GetTeamBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: GetTeamBudgetsAction$inboundSchema, }); /** @internal */ export type GetTeamBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const GetTeamBudgetsThresholds$outboundSchema: z.ZodType< GetTeamBudgetsThresholds$Outbound, z.ZodTypeDef, GetTeamBudgetsThresholds > = z.object({ pct: z.number().int(), action: GetTeamBudgetsAction$outboundSchema, }); export function getTeamBudgetsThresholdsToJSON( getTeamBudgetsThresholds: GetTeamBudgetsThresholds, ): string { return JSON.stringify( GetTeamBudgetsThresholds$outboundSchema.parse(getTeamBudgetsThresholds), ); } export function getTeamBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTeamBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTeamBudgetsThresholds' from JSON`, ); } /** @internal */ export const GetTeamBudgetsStatus$inboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsStatus > = z.nativeEnum(GetTeamBudgetsStatus); /** @internal */ export const GetTeamBudgetsStatus$outboundSchema: z.ZodNativeEnum< typeof GetTeamBudgetsStatus > = GetTeamBudgetsStatus$inboundSchema; /** @internal */ export const GetTeamBudgetsSpend$inboundSchema: z.ZodType< GetTeamBudgetsSpend, z.ZodTypeDef, unknown > = z.object({ window: z.string(), cost_spent: z.number(), limit: z.number(), pct: z.number().int(), status: GetTeamBudgetsStatus$inboundSchema, }).transform((v) => { return remap$(v, { "cost_spent": "costSpent", }); }); /** @internal */ export type GetTeamBudgetsSpend$Outbound = { window: string; cost_spent: number; limit: number; pct: number; status: string; }; /** @internal */ export const GetTeamBudgetsSpend$outboundSchema: z.ZodType< GetTeamBudgetsSpend$Outbound, z.ZodTypeDef, GetTeamBudgetsSpend > = z.object({ window: z.string(), costSpent: z.number(), limit: z.number(), pct: z.number().int(), status: GetTeamBudgetsStatus$outboundSchema, }).transform((v) => { return remap$(v, { costSpent: "cost_spent", }); }); export function getTeamBudgetsSpendToJSON( getTeamBudgetsSpend: GetTeamBudgetsSpend, ): string { return JSON.stringify( GetTeamBudgetsSpend$outboundSchema.parse(getTeamBudgetsSpend), ); } export function getTeamBudgetsSpendFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTeamBudgetsSpend$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTeamBudgetsSpend' from JSON`, ); } /** @internal */ export const GetTeamBudgetsData$inboundSchema: z.ZodType< GetTeamBudgetsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: GetTeamBudgetsScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: GetTeamBudgetsOwner$inboundSchema, period: GetTeamBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetTeamBudgetsThresholds$inboundSchema)), alert_webhook_url: z.nullable(z.string()), spend: z.lazy(() => GetTeamBudgetsSpend$inboundSchema), }).transform((v) => { return remap$(v, { "scope_id": "scopeId", "scope_org_id": "scopeOrgId", "alert_webhook_url": "alertWebhookUrl", }); }); /** @internal */ export type GetTeamBudgetsData$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: GetTeamBudgetsSpend$Outbound; }; /** @internal */ export const GetTeamBudgetsData$outboundSchema: z.ZodType< GetTeamBudgetsData$Outbound, z.ZodTypeDef, GetTeamBudgetsData > = z.object({ id: z.string(), scope: GetTeamBudgetsScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: GetTeamBudgetsOwner$outboundSchema, period: GetTeamBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetTeamBudgetsThresholds$outboundSchema)), alertWebhookUrl: z.nullable(z.string()), spend: z.lazy(() => GetTeamBudgetsSpend$outboundSchema), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function getTeamBudgetsDataToJSON( getTeamBudgetsData: GetTeamBudgetsData, ): string { return JSON.stringify( GetTeamBudgetsData$outboundSchema.parse(getTeamBudgetsData), ); } export function getTeamBudgetsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTeamBudgetsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTeamBudgetsData' from JSON`, ); } /** @internal */ export const GetTeamBudgetsResponseBody$inboundSchema: z.ZodType< GetTeamBudgetsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetTeamBudgetsData$inboundSchema)), }); /** @internal */ export type GetTeamBudgetsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const GetTeamBudgetsResponseBody$outboundSchema: z.ZodType< GetTeamBudgetsResponseBody$Outbound, z.ZodTypeDef, GetTeamBudgetsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetTeamBudgetsData$outboundSchema)), }); export function getTeamBudgetsResponseBodyToJSON( getTeamBudgetsResponseBody: GetTeamBudgetsResponseBody, ): string { return JSON.stringify( GetTeamBudgetsResponseBody$outboundSchema.parse(getTeamBudgetsResponseBody), ); } export function getTeamBudgetsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTeamBudgetsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTeamBudgetsResponseBody' from JSON`, ); }