/* * 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 SetTeamDefaultBudgetOwner = { Cluster: "cluster", Org: "org", } as const; /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ export type SetTeamDefaultBudgetOwner = ClosedEnum< typeof SetTeamDefaultBudgetOwner >; export const SetTeamDefaultBudgetPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetTeamDefaultBudgetPeriod = ClosedEnum< typeof SetTeamDefaultBudgetPeriod >; export const SetTeamDefaultBudgetAction = { Alert: "alert", Block: "block", } as const; export type SetTeamDefaultBudgetAction = ClosedEnum< typeof SetTeamDefaultBudgetAction >; export type SetTeamDefaultBudgetThresholds = { pct: number; action: SetTeamDefaultBudgetAction; }; export type SetTeamDefaultBudgetRequestBody = { /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ owner?: SetTeamDefaultBudgetOwner | undefined; period: SetTeamDefaultBudgetPeriod; /** * Spend limit in major currency units */ limit: number; thresholds: Array; webhookUrl?: string | null | undefined; webhookSecret?: string | null | undefined; }; export type SetTeamDefaultBudgetRequest = { orgId?: string | undefined; requestBody: SetTeamDefaultBudgetRequestBody; }; export const SetTeamDefaultBudgetScope = { 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 SetTeamDefaultBudgetScope = ClosedEnum< typeof SetTeamDefaultBudgetScope >; export const SetTeamDefaultBudgetBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type SetTeamDefaultBudgetBudgetsOwner = ClosedEnum< typeof SetTeamDefaultBudgetBudgetsOwner >; export const SetTeamDefaultBudgetBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetTeamDefaultBudgetBudgetsPeriod = ClosedEnum< typeof SetTeamDefaultBudgetBudgetsPeriod >; export const SetTeamDefaultBudgetBudgetsAction = { Alert: "alert", Block: "block", } as const; export type SetTeamDefaultBudgetBudgetsAction = ClosedEnum< typeof SetTeamDefaultBudgetBudgetsAction >; export type SetTeamDefaultBudgetBudgetsThresholds = { pct: number; action: SetTeamDefaultBudgetBudgetsAction; }; /** * OK */ export type SetTeamDefaultBudgetResponseBody = { id: string; scope: SetTeamDefaultBudgetScope; scopeId: string; scopeOrgId: string | null; owner: SetTeamDefaultBudgetBudgetsOwner; period: SetTeamDefaultBudgetBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; }; /** @internal */ export const SetTeamDefaultBudgetOwner$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetOwner > = z.nativeEnum(SetTeamDefaultBudgetOwner); /** @internal */ export const SetTeamDefaultBudgetOwner$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetOwner > = SetTeamDefaultBudgetOwner$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetPeriod$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetPeriod > = z.nativeEnum(SetTeamDefaultBudgetPeriod); /** @internal */ export const SetTeamDefaultBudgetPeriod$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetPeriod > = SetTeamDefaultBudgetPeriod$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetAction$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetAction > = z.nativeEnum(SetTeamDefaultBudgetAction); /** @internal */ export const SetTeamDefaultBudgetAction$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetAction > = SetTeamDefaultBudgetAction$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetThresholds$inboundSchema: z.ZodType< SetTeamDefaultBudgetThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetTeamDefaultBudgetAction$inboundSchema, }); /** @internal */ export type SetTeamDefaultBudgetThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetTeamDefaultBudgetThresholds$outboundSchema: z.ZodType< SetTeamDefaultBudgetThresholds$Outbound, z.ZodTypeDef, SetTeamDefaultBudgetThresholds > = z.object({ pct: z.number().int(), action: SetTeamDefaultBudgetAction$outboundSchema, }); export function setTeamDefaultBudgetThresholdsToJSON( setTeamDefaultBudgetThresholds: SetTeamDefaultBudgetThresholds, ): string { return JSON.stringify( SetTeamDefaultBudgetThresholds$outboundSchema.parse( setTeamDefaultBudgetThresholds, ), ); } export function setTeamDefaultBudgetThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamDefaultBudgetThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamDefaultBudgetThresholds' from JSON`, ); } /** @internal */ export const SetTeamDefaultBudgetRequestBody$inboundSchema: z.ZodType< SetTeamDefaultBudgetRequestBody, z.ZodTypeDef, unknown > = z.object({ owner: SetTeamDefaultBudgetOwner$inboundSchema.default("org"), period: SetTeamDefaultBudgetPeriod$inboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamDefaultBudgetThresholds$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 SetTeamDefaultBudgetRequestBody$Outbound = { owner: string; period: string; limit: number; thresholds: Array; webhook_url?: string | null | undefined; webhook_secret?: string | null | undefined; }; /** @internal */ export const SetTeamDefaultBudgetRequestBody$outboundSchema: z.ZodType< SetTeamDefaultBudgetRequestBody$Outbound, z.ZodTypeDef, SetTeamDefaultBudgetRequestBody > = z.object({ owner: SetTeamDefaultBudgetOwner$outboundSchema.default("org"), period: SetTeamDefaultBudgetPeriod$outboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamDefaultBudgetThresholds$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 setTeamDefaultBudgetRequestBodyToJSON( setTeamDefaultBudgetRequestBody: SetTeamDefaultBudgetRequestBody, ): string { return JSON.stringify( SetTeamDefaultBudgetRequestBody$outboundSchema.parse( setTeamDefaultBudgetRequestBody, ), ); } export function setTeamDefaultBudgetRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamDefaultBudgetRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamDefaultBudgetRequestBody' from JSON`, ); } /** @internal */ export const SetTeamDefaultBudgetRequest$inboundSchema: z.ZodType< SetTeamDefaultBudgetRequest, z.ZodTypeDef, unknown > = z.object({ org_id: z.string().optional(), RequestBody: z.lazy(() => SetTeamDefaultBudgetRequestBody$inboundSchema), }).transform((v) => { return remap$(v, { "org_id": "orgId", "RequestBody": "requestBody", }); }); /** @internal */ export type SetTeamDefaultBudgetRequest$Outbound = { org_id?: string | undefined; RequestBody: SetTeamDefaultBudgetRequestBody$Outbound; }; /** @internal */ export const SetTeamDefaultBudgetRequest$outboundSchema: z.ZodType< SetTeamDefaultBudgetRequest$Outbound, z.ZodTypeDef, SetTeamDefaultBudgetRequest > = z.object({ orgId: z.string().optional(), requestBody: z.lazy(() => SetTeamDefaultBudgetRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { orgId: "org_id", requestBody: "RequestBody", }); }); export function setTeamDefaultBudgetRequestToJSON( setTeamDefaultBudgetRequest: SetTeamDefaultBudgetRequest, ): string { return JSON.stringify( SetTeamDefaultBudgetRequest$outboundSchema.parse( setTeamDefaultBudgetRequest, ), ); } export function setTeamDefaultBudgetRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamDefaultBudgetRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamDefaultBudgetRequest' from JSON`, ); } /** @internal */ export const SetTeamDefaultBudgetScope$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetScope > = z.nativeEnum(SetTeamDefaultBudgetScope); /** @internal */ export const SetTeamDefaultBudgetScope$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetScope > = SetTeamDefaultBudgetScope$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsOwner > = z.nativeEnum(SetTeamDefaultBudgetBudgetsOwner); /** @internal */ export const SetTeamDefaultBudgetBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsOwner > = SetTeamDefaultBudgetBudgetsOwner$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsPeriod > = z.nativeEnum(SetTeamDefaultBudgetBudgetsPeriod); /** @internal */ export const SetTeamDefaultBudgetBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsPeriod > = SetTeamDefaultBudgetBudgetsPeriod$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsAction > = z.nativeEnum(SetTeamDefaultBudgetBudgetsAction); /** @internal */ export const SetTeamDefaultBudgetBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof SetTeamDefaultBudgetBudgetsAction > = SetTeamDefaultBudgetBudgetsAction$inboundSchema; /** @internal */ export const SetTeamDefaultBudgetBudgetsThresholds$inboundSchema: z.ZodType< SetTeamDefaultBudgetBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetTeamDefaultBudgetBudgetsAction$inboundSchema, }); /** @internal */ export type SetTeamDefaultBudgetBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetTeamDefaultBudgetBudgetsThresholds$outboundSchema: z.ZodType< SetTeamDefaultBudgetBudgetsThresholds$Outbound, z.ZodTypeDef, SetTeamDefaultBudgetBudgetsThresholds > = z.object({ pct: z.number().int(), action: SetTeamDefaultBudgetBudgetsAction$outboundSchema, }); export function setTeamDefaultBudgetBudgetsThresholdsToJSON( setTeamDefaultBudgetBudgetsThresholds: SetTeamDefaultBudgetBudgetsThresholds, ): string { return JSON.stringify( SetTeamDefaultBudgetBudgetsThresholds$outboundSchema.parse( setTeamDefaultBudgetBudgetsThresholds, ), ); } export function setTeamDefaultBudgetBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamDefaultBudgetBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamDefaultBudgetBudgetsThresholds' from JSON`, ); } /** @internal */ export const SetTeamDefaultBudgetResponseBody$inboundSchema: z.ZodType< SetTeamDefaultBudgetResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: SetTeamDefaultBudgetScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: SetTeamDefaultBudgetBudgetsOwner$inboundSchema, period: SetTeamDefaultBudgetBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamDefaultBudgetBudgetsThresholds$inboundSchema), ), alert_webhook_url: z.nullable(z.string()), }).transform((v) => { return remap$(v, { "scope_id": "scopeId", "scope_org_id": "scopeOrgId", "alert_webhook_url": "alertWebhookUrl", }); }); /** @internal */ export type SetTeamDefaultBudgetResponseBody$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; }; /** @internal */ export const SetTeamDefaultBudgetResponseBody$outboundSchema: z.ZodType< SetTeamDefaultBudgetResponseBody$Outbound, z.ZodTypeDef, SetTeamDefaultBudgetResponseBody > = z.object({ id: z.string(), scope: SetTeamDefaultBudgetScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: SetTeamDefaultBudgetBudgetsOwner$outboundSchema, period: SetTeamDefaultBudgetBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetTeamDefaultBudgetBudgetsThresholds$outboundSchema), ), alertWebhookUrl: z.nullable(z.string()), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function setTeamDefaultBudgetResponseBodyToJSON( setTeamDefaultBudgetResponseBody: SetTeamDefaultBudgetResponseBody, ): string { return JSON.stringify( SetTeamDefaultBudgetResponseBody$outboundSchema.parse( setTeamDefaultBudgetResponseBody, ), ); } export function setTeamDefaultBudgetResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetTeamDefaultBudgetResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetTeamDefaultBudgetResponseBody' from JSON`, ); }