/* * 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 GetOrgBudgetsRequest = { orgId?: string | undefined; }; export const GetOrgBudgetsScope = { 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 GetOrgBudgetsScope = ClosedEnum; export const GetOrgBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type GetOrgBudgetsOwner = ClosedEnum; export const GetOrgBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type GetOrgBudgetsPeriod = ClosedEnum; export const GetOrgBudgetsAction = { Alert: "alert", Block: "block", } as const; export type GetOrgBudgetsAction = ClosedEnum; export type GetOrgBudgetsThresholds = { pct: number; action: GetOrgBudgetsAction; }; export const GetOrgBudgetsStatus = { Ok: "ok", Blocked: "blocked", } as const; export type GetOrgBudgetsStatus = ClosedEnum; export type GetOrgBudgetsSpend = { /** * 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: GetOrgBudgetsStatus; }; export type GetOrgBudgetsData = { id: string; scope: GetOrgBudgetsScope; scopeId: string; scopeOrgId: string | null; owner: GetOrgBudgetsOwner; period: GetOrgBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; spend: GetOrgBudgetsSpend; }; /** * OK */ export type GetOrgBudgetsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const GetOrgBudgetsRequest$inboundSchema: z.ZodType< GetOrgBudgetsRequest, z.ZodTypeDef, unknown > = z.object({ org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "org_id": "orgId", }); }); /** @internal */ export type GetOrgBudgetsRequest$Outbound = { org_id?: string | undefined; }; /** @internal */ export const GetOrgBudgetsRequest$outboundSchema: z.ZodType< GetOrgBudgetsRequest$Outbound, z.ZodTypeDef, GetOrgBudgetsRequest > = z.object({ orgId: z.string().optional(), }).transform((v) => { return remap$(v, { orgId: "org_id", }); }); export function getOrgBudgetsRequestToJSON( getOrgBudgetsRequest: GetOrgBudgetsRequest, ): string { return JSON.stringify( GetOrgBudgetsRequest$outboundSchema.parse(getOrgBudgetsRequest), ); } export function getOrgBudgetsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetOrgBudgetsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetOrgBudgetsRequest' from JSON`, ); } /** @internal */ export const GetOrgBudgetsScope$inboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsScope > = z.nativeEnum(GetOrgBudgetsScope); /** @internal */ export const GetOrgBudgetsScope$outboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsScope > = GetOrgBudgetsScope$inboundSchema; /** @internal */ export const GetOrgBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsOwner > = z.nativeEnum(GetOrgBudgetsOwner); /** @internal */ export const GetOrgBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsOwner > = GetOrgBudgetsOwner$inboundSchema; /** @internal */ export const GetOrgBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsPeriod > = z.nativeEnum(GetOrgBudgetsPeriod); /** @internal */ export const GetOrgBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsPeriod > = GetOrgBudgetsPeriod$inboundSchema; /** @internal */ export const GetOrgBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsAction > = z.nativeEnum(GetOrgBudgetsAction); /** @internal */ export const GetOrgBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsAction > = GetOrgBudgetsAction$inboundSchema; /** @internal */ export const GetOrgBudgetsThresholds$inboundSchema: z.ZodType< GetOrgBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: GetOrgBudgetsAction$inboundSchema, }); /** @internal */ export type GetOrgBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const GetOrgBudgetsThresholds$outboundSchema: z.ZodType< GetOrgBudgetsThresholds$Outbound, z.ZodTypeDef, GetOrgBudgetsThresholds > = z.object({ pct: z.number().int(), action: GetOrgBudgetsAction$outboundSchema, }); export function getOrgBudgetsThresholdsToJSON( getOrgBudgetsThresholds: GetOrgBudgetsThresholds, ): string { return JSON.stringify( GetOrgBudgetsThresholds$outboundSchema.parse(getOrgBudgetsThresholds), ); } export function getOrgBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetOrgBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetOrgBudgetsThresholds' from JSON`, ); } /** @internal */ export const GetOrgBudgetsStatus$inboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsStatus > = z.nativeEnum(GetOrgBudgetsStatus); /** @internal */ export const GetOrgBudgetsStatus$outboundSchema: z.ZodNativeEnum< typeof GetOrgBudgetsStatus > = GetOrgBudgetsStatus$inboundSchema; /** @internal */ export const GetOrgBudgetsSpend$inboundSchema: z.ZodType< GetOrgBudgetsSpend, z.ZodTypeDef, unknown > = z.object({ window: z.string(), cost_spent: z.number(), limit: z.number(), pct: z.number().int(), status: GetOrgBudgetsStatus$inboundSchema, }).transform((v) => { return remap$(v, { "cost_spent": "costSpent", }); }); /** @internal */ export type GetOrgBudgetsSpend$Outbound = { window: string; cost_spent: number; limit: number; pct: number; status: string; }; /** @internal */ export const GetOrgBudgetsSpend$outboundSchema: z.ZodType< GetOrgBudgetsSpend$Outbound, z.ZodTypeDef, GetOrgBudgetsSpend > = z.object({ window: z.string(), costSpent: z.number(), limit: z.number(), pct: z.number().int(), status: GetOrgBudgetsStatus$outboundSchema, }).transform((v) => { return remap$(v, { costSpent: "cost_spent", }); }); export function getOrgBudgetsSpendToJSON( getOrgBudgetsSpend: GetOrgBudgetsSpend, ): string { return JSON.stringify( GetOrgBudgetsSpend$outboundSchema.parse(getOrgBudgetsSpend), ); } export function getOrgBudgetsSpendFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetOrgBudgetsSpend$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetOrgBudgetsSpend' from JSON`, ); } /** @internal */ export const GetOrgBudgetsData$inboundSchema: z.ZodType< GetOrgBudgetsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: GetOrgBudgetsScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: GetOrgBudgetsOwner$inboundSchema, period: GetOrgBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetOrgBudgetsThresholds$inboundSchema)), alert_webhook_url: z.nullable(z.string()), spend: z.lazy(() => GetOrgBudgetsSpend$inboundSchema), }).transform((v) => { return remap$(v, { "scope_id": "scopeId", "scope_org_id": "scopeOrgId", "alert_webhook_url": "alertWebhookUrl", }); }); /** @internal */ export type GetOrgBudgetsData$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: GetOrgBudgetsSpend$Outbound; }; /** @internal */ export const GetOrgBudgetsData$outboundSchema: z.ZodType< GetOrgBudgetsData$Outbound, z.ZodTypeDef, GetOrgBudgetsData > = z.object({ id: z.string(), scope: GetOrgBudgetsScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: GetOrgBudgetsOwner$outboundSchema, period: GetOrgBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array(z.lazy(() => GetOrgBudgetsThresholds$outboundSchema)), alertWebhookUrl: z.nullable(z.string()), spend: z.lazy(() => GetOrgBudgetsSpend$outboundSchema), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function getOrgBudgetsDataToJSON( getOrgBudgetsData: GetOrgBudgetsData, ): string { return JSON.stringify( GetOrgBudgetsData$outboundSchema.parse(getOrgBudgetsData), ); } export function getOrgBudgetsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetOrgBudgetsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetOrgBudgetsData' from JSON`, ); } /** @internal */ export const GetOrgBudgetsResponseBody$inboundSchema: z.ZodType< GetOrgBudgetsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetOrgBudgetsData$inboundSchema)), }); /** @internal */ export type GetOrgBudgetsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const GetOrgBudgetsResponseBody$outboundSchema: z.ZodType< GetOrgBudgetsResponseBody$Outbound, z.ZodTypeDef, GetOrgBudgetsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => GetOrgBudgetsData$outboundSchema)), }); export function getOrgBudgetsResponseBodyToJSON( getOrgBudgetsResponseBody: GetOrgBudgetsResponseBody, ): string { return JSON.stringify( GetOrgBudgetsResponseBody$outboundSchema.parse(getOrgBudgetsResponseBody), ); } export function getOrgBudgetsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetOrgBudgetsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetOrgBudgetsResponseBody' from JSON`, ); }