/* * 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"; /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ export const SetTeamBudgetOwner = { Cluster: "cluster", Org: "org", } as const; /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ export type SetTeamBudgetOwner = ClosedEnum; export const SetTeamBudgetPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetTeamBudgetPeriod = ClosedEnum; export const SetTeamBudgetAction = { Alert: "alert", Block: "block", } as const; export type SetTeamBudgetAction = ClosedEnum; export type SetTeamBudgetThresholds = { pct: number; action: SetTeamBudgetAction; }; export type SetTeamBudgetRequestBody = { /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ owner?: SetTeamBudgetOwner | undefined; period: SetTeamBudgetPeriod; /** * Spend limit in major currency units */ limit: number; thresholds: Array; webhookUrl?: string | null | undefined; webhookSecret?: string | null | undefined; }; export type SetTeamBudgetRequest = { id: string; orgId?: string | undefined; requestBody: SetTeamBudgetRequestBody; }; export const SetTeamBudgetScope = { 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 SetTeamBudgetScope = ClosedEnum; export const SetTeamBudgetBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type SetTeamBudgetBudgetsOwner = ClosedEnum< typeof SetTeamBudgetBudgetsOwner >; export const SetTeamBudgetBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetTeamBudgetBudgetsPeriod = ClosedEnum< typeof SetTeamBudgetBudgetsPeriod >; export const SetTeamBudgetBudgetsAction = { Alert: "alert", Block: "block", } as const; export type SetTeamBudgetBudgetsAction = ClosedEnum< typeof SetTeamBudgetBudgetsAction >; export type SetTeamBudgetBudgetsThresholds = { pct: number; action: SetTeamBudgetBudgetsAction; }; export const SetTeamBudgetStatus = { Ok: "ok", Blocked: "blocked", } as const; export type SetTeamBudgetStatus = ClosedEnum; export type SetTeamBudgetSpend = { /** * 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: SetTeamBudgetStatus; }; /** * OK */ export type SetTeamBudgetResponseBody = { id: string; scope: SetTeamBudgetScope; scopeId: string; scopeOrgId: string | null; owner: SetTeamBudgetBudgetsOwner; period: SetTeamBudgetBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; spend: SetTeamBudgetSpend; }; /** @internal */ export const SetTeamBudgetOwner$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetOwner > = z.nativeEnum(SetTeamBudgetOwner); /** @internal */ export const SetTeamBudgetOwner$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetOwner > = SetTeamBudgetOwner$inboundSchema; /** @internal */ export const SetTeamBudgetPeriod$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetPeriod > = z.nativeEnum(SetTeamBudgetPeriod); /** @internal */ export const SetTeamBudgetPeriod$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetPeriod > = SetTeamBudgetPeriod$inboundSchema; /** @internal */ export const SetTeamBudgetAction$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetAction > = z.nativeEnum(SetTeamBudgetAction); /** @internal */ export const SetTeamBudgetAction$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetAction > = SetTeamBudgetAction$inboundSchema; /** @internal */ export const SetTeamBudgetThresholds$inboundSchema: z.ZodType< SetTeamBudgetThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetTeamBudgetAction$inboundSchema, }); /** @internal */ export type SetTeamBudgetThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetTeamBudgetThresholds$outboundSchema: z.ZodType< SetTeamBudgetThresholds$Outbound, z.ZodTypeDef, SetTeamBudgetThresholds > = z.object({ pct: z.number().int(), action: SetTeamBudgetAction$outboundSchema, }); export function setTeamBudgetThresholdsToJSON( setTeamBudgetThresholds: SetTeamBudgetThresholds, ): string { return JSON.stringify( SetTeamBudgetThresholds$outboundSchema.parse(setTeamBudgetThresholds), ); } export function setTeamBudgetThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetThresholds' from JSON`, ); } /** @internal */ export const SetTeamBudgetRequestBody$inboundSchema: z.ZodType< SetTeamBudgetRequestBody, z.ZodTypeDef, unknown > = z.object({ owner: SetTeamBudgetOwner$inboundSchema.default("org"), period: SetTeamBudgetPeriod$inboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => SetTeamBudgetThresholds$inboundSchema)), webhook_url: z.nullable(z.string()).optional(), webhook_secret: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "webhook_url": "webhookUrl", "webhook_secret": "webhookSecret", }); }); /** @internal */ export type SetTeamBudgetRequestBody$Outbound = { owner: string; period: string; limit: number; thresholds: Array; webhook_url?: string | null | undefined; webhook_secret?: string | null | undefined; }; /** @internal */ export const SetTeamBudgetRequestBody$outboundSchema: z.ZodType< SetTeamBudgetRequestBody$Outbound, z.ZodTypeDef, SetTeamBudgetRequestBody > = z.object({ owner: SetTeamBudgetOwner$outboundSchema.default("org"), period: SetTeamBudgetPeriod$outboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => SetTeamBudgetThresholds$outboundSchema)), webhookUrl: z.nullable(z.string()).optional(), webhookSecret: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { webhookUrl: "webhook_url", webhookSecret: "webhook_secret", }); }); export function setTeamBudgetRequestBodyToJSON( setTeamBudgetRequestBody: SetTeamBudgetRequestBody, ): string { return JSON.stringify( SetTeamBudgetRequestBody$outboundSchema.parse(setTeamBudgetRequestBody), ); } export function setTeamBudgetRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetRequestBody' from JSON`, ); } /** @internal */ export const SetTeamBudgetRequest$inboundSchema: z.ZodType< SetTeamBudgetRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), org_id: z.string().optional(), RequestBody: z.lazy(() => SetTeamBudgetRequestBody$inboundSchema), }).transform((v) => { return remap$(v, { "org_id": "orgId", "RequestBody": "requestBody", }); }); /** @internal */ export type SetTeamBudgetRequest$Outbound = { id: string; org_id?: string | undefined; RequestBody: SetTeamBudgetRequestBody$Outbound; }; /** @internal */ export const SetTeamBudgetRequest$outboundSchema: z.ZodType< SetTeamBudgetRequest$Outbound, z.ZodTypeDef, SetTeamBudgetRequest > = z.object({ id: z.string(), orgId: z.string().optional(), requestBody: z.lazy(() => SetTeamBudgetRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { orgId: "org_id", requestBody: "RequestBody", }); }); export function setTeamBudgetRequestToJSON( setTeamBudgetRequest: SetTeamBudgetRequest, ): string { return JSON.stringify( SetTeamBudgetRequest$outboundSchema.parse(setTeamBudgetRequest), ); } export function setTeamBudgetRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetRequest' from JSON`, ); } /** @internal */ export const SetTeamBudgetScope$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetScope > = z.nativeEnum(SetTeamBudgetScope); /** @internal */ export const SetTeamBudgetScope$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetScope > = SetTeamBudgetScope$inboundSchema; /** @internal */ export const SetTeamBudgetBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsOwner > = z.nativeEnum(SetTeamBudgetBudgetsOwner); /** @internal */ export const SetTeamBudgetBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsOwner > = SetTeamBudgetBudgetsOwner$inboundSchema; /** @internal */ export const SetTeamBudgetBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsPeriod > = z.nativeEnum(SetTeamBudgetBudgetsPeriod); /** @internal */ export const SetTeamBudgetBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsPeriod > = SetTeamBudgetBudgetsPeriod$inboundSchema; /** @internal */ export const SetTeamBudgetBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsAction > = z.nativeEnum(SetTeamBudgetBudgetsAction); /** @internal */ export const SetTeamBudgetBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetBudgetsAction > = SetTeamBudgetBudgetsAction$inboundSchema; /** @internal */ export const SetTeamBudgetBudgetsThresholds$inboundSchema: z.ZodType< SetTeamBudgetBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetTeamBudgetBudgetsAction$inboundSchema, }); /** @internal */ export type SetTeamBudgetBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetTeamBudgetBudgetsThresholds$outboundSchema: z.ZodType< SetTeamBudgetBudgetsThresholds$Outbound, z.ZodTypeDef, SetTeamBudgetBudgetsThresholds > = z.object({ pct: z.number().int(), action: SetTeamBudgetBudgetsAction$outboundSchema, }); export function setTeamBudgetBudgetsThresholdsToJSON( setTeamBudgetBudgetsThresholds: SetTeamBudgetBudgetsThresholds, ): string { return JSON.stringify( SetTeamBudgetBudgetsThresholds$outboundSchema.parse( setTeamBudgetBudgetsThresholds, ), ); } export function setTeamBudgetBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetBudgetsThresholds' from JSON`, ); } /** @internal */ export const SetTeamBudgetStatus$inboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetStatus > = z.nativeEnum(SetTeamBudgetStatus); /** @internal */ export const SetTeamBudgetStatus$outboundSchema: z.ZodNativeEnum< typeof SetTeamBudgetStatus > = SetTeamBudgetStatus$inboundSchema; /** @internal */ export const SetTeamBudgetSpend$inboundSchema: z.ZodType< SetTeamBudgetSpend, z.ZodTypeDef, unknown > = z.object({ window: z.string(), cost_spent: z.number(), limit: z.number(), pct: z.number().int(), status: SetTeamBudgetStatus$inboundSchema, }).transform((v) => { return remap$(v, { "cost_spent": "costSpent", }); }); /** @internal */ export type SetTeamBudgetSpend$Outbound = { window: string; cost_spent: number; limit: number; pct: number; status: string; }; /** @internal */ export const SetTeamBudgetSpend$outboundSchema: z.ZodType< SetTeamBudgetSpend$Outbound, z.ZodTypeDef, SetTeamBudgetSpend > = z.object({ window: z.string(), costSpent: z.number(), limit: z.number(), pct: z.number().int(), status: SetTeamBudgetStatus$outboundSchema, }).transform((v) => { return remap$(v, { costSpent: "cost_spent", }); }); export function setTeamBudgetSpendToJSON( setTeamBudgetSpend: SetTeamBudgetSpend, ): string { return JSON.stringify( SetTeamBudgetSpend$outboundSchema.parse(setTeamBudgetSpend), ); } export function setTeamBudgetSpendFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetSpend$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetSpend' from JSON`, ); } /** @internal */ export const SetTeamBudgetResponseBody$inboundSchema: z.ZodType< SetTeamBudgetResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: SetTeamBudgetScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: SetTeamBudgetBudgetsOwner$inboundSchema, period: SetTeamBudgetBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamBudgetBudgetsThresholds$inboundSchema), ), alert_webhook_url: z.nullable(z.string()), spend: z.lazy(() => SetTeamBudgetSpend$inboundSchema), }).transform((v) => { return remap$(v, { "scope_id": "scopeId", "scope_org_id": "scopeOrgId", "alert_webhook_url": "alertWebhookUrl", }); }); /** @internal */ export type SetTeamBudgetResponseBody$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: SetTeamBudgetSpend$Outbound; }; /** @internal */ export const SetTeamBudgetResponseBody$outboundSchema: z.ZodType< SetTeamBudgetResponseBody$Outbound, z.ZodTypeDef, SetTeamBudgetResponseBody > = z.object({ id: z.string(), scope: SetTeamBudgetScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: SetTeamBudgetBudgetsOwner$outboundSchema, period: SetTeamBudgetBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamBudgetBudgetsThresholds$outboundSchema), ), alertWebhookUrl: z.nullable(z.string()), spend: z.lazy(() => SetTeamBudgetSpend$outboundSchema), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function setTeamBudgetResponseBodyToJSON( setTeamBudgetResponseBody: SetTeamBudgetResponseBody, ): string { return JSON.stringify( SetTeamBudgetResponseBody$outboundSchema.parse(setTeamBudgetResponseBody), ); } export function setTeamBudgetResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamBudgetResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamBudgetResponseBody' from JSON`, ); }