/* * 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 SetUserDefaultBudgetOwner = { Cluster: "cluster", Org: "org", } as const; /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ export type SetUserDefaultBudgetOwner = ClosedEnum< typeof SetUserDefaultBudgetOwner >; export const SetUserDefaultBudgetPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetUserDefaultBudgetPeriod = ClosedEnum< typeof SetUserDefaultBudgetPeriod >; export const SetUserDefaultBudgetAction = { Alert: "alert", Block: "block", } as const; export type SetUserDefaultBudgetAction = ClosedEnum< typeof SetUserDefaultBudgetAction >; export type SetUserDefaultBudgetThresholds = { pct: number; action: SetUserDefaultBudgetAction; }; export type SetUserDefaultBudgetRequestBody = { /** * cluster = operator ceiling (org-admin read-only); org = self-budget */ owner?: SetUserDefaultBudgetOwner | undefined; period: SetUserDefaultBudgetPeriod; /** * Spend limit in major currency units */ limit: number; thresholds: Array; webhookUrl?: string | null | undefined; webhookSecret?: string | null | undefined; }; export type SetUserDefaultBudgetRequest = { orgId?: string | undefined; requestBody: SetUserDefaultBudgetRequestBody; }; export const SetUserDefaultBudgetScope = { 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 SetUserDefaultBudgetScope = ClosedEnum< typeof SetUserDefaultBudgetScope >; export const SetUserDefaultBudgetBudgetsOwner = { Cluster: "cluster", Org: "org", } as const; export type SetUserDefaultBudgetBudgetsOwner = ClosedEnum< typeof SetUserDefaultBudgetBudgetsOwner >; export const SetUserDefaultBudgetBudgetsPeriod = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; export type SetUserDefaultBudgetBudgetsPeriod = ClosedEnum< typeof SetUserDefaultBudgetBudgetsPeriod >; export const SetUserDefaultBudgetBudgetsAction = { Alert: "alert", Block: "block", } as const; export type SetUserDefaultBudgetBudgetsAction = ClosedEnum< typeof SetUserDefaultBudgetBudgetsAction >; export type SetUserDefaultBudgetBudgetsThresholds = { pct: number; action: SetUserDefaultBudgetBudgetsAction; }; /** * OK */ export type SetUserDefaultBudgetResponseBody = { id: string; scope: SetUserDefaultBudgetScope; scopeId: string; scopeOrgId: string | null; owner: SetUserDefaultBudgetBudgetsOwner; period: SetUserDefaultBudgetBudgetsPeriod; limit: number; thresholds: Array; alertWebhookUrl: string | null; }; /** @internal */ export const SetUserDefaultBudgetOwner$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetOwner > = z.nativeEnum(SetUserDefaultBudgetOwner); /** @internal */ export const SetUserDefaultBudgetOwner$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetOwner > = SetUserDefaultBudgetOwner$inboundSchema; /** @internal */ export const SetUserDefaultBudgetPeriod$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetPeriod > = z.nativeEnum(SetUserDefaultBudgetPeriod); /** @internal */ export const SetUserDefaultBudgetPeriod$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetPeriod > = SetUserDefaultBudgetPeriod$inboundSchema; /** @internal */ export const SetUserDefaultBudgetAction$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetAction > = z.nativeEnum(SetUserDefaultBudgetAction); /** @internal */ export const SetUserDefaultBudgetAction$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetAction > = SetUserDefaultBudgetAction$inboundSchema; /** @internal */ export const SetUserDefaultBudgetThresholds$inboundSchema: z.ZodType< SetUserDefaultBudgetThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetUserDefaultBudgetAction$inboundSchema, }); /** @internal */ export type SetUserDefaultBudgetThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetUserDefaultBudgetThresholds$outboundSchema: z.ZodType< SetUserDefaultBudgetThresholds$Outbound, z.ZodTypeDef, SetUserDefaultBudgetThresholds > = z.object({ pct: z.number().int(), action: SetUserDefaultBudgetAction$outboundSchema, }); export function setUserDefaultBudgetThresholdsToJSON( setUserDefaultBudgetThresholds: SetUserDefaultBudgetThresholds, ): string { return JSON.stringify( SetUserDefaultBudgetThresholds$outboundSchema.parse( setUserDefaultBudgetThresholds, ), ); } export function setUserDefaultBudgetThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetUserDefaultBudgetThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetUserDefaultBudgetThresholds' from JSON`, ); } /** @internal */ export const SetUserDefaultBudgetRequestBody$inboundSchema: z.ZodType< SetUserDefaultBudgetRequestBody, z.ZodTypeDef, unknown > = z.object({ owner: SetUserDefaultBudgetOwner$inboundSchema.default("org"), period: SetUserDefaultBudgetPeriod$inboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetUserDefaultBudgetThresholds$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 SetUserDefaultBudgetRequestBody$Outbound = { owner: string; period: string; limit: number; thresholds: Array; webhook_url?: string | null | undefined; webhook_secret?: string | null | undefined; }; /** @internal */ export const SetUserDefaultBudgetRequestBody$outboundSchema: z.ZodType< SetUserDefaultBudgetRequestBody$Outbound, z.ZodTypeDef, SetUserDefaultBudgetRequestBody > = z.object({ owner: SetUserDefaultBudgetOwner$outboundSchema.default("org"), period: SetUserDefaultBudgetPeriod$outboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetUserDefaultBudgetThresholds$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 setUserDefaultBudgetRequestBodyToJSON( setUserDefaultBudgetRequestBody: SetUserDefaultBudgetRequestBody, ): string { return JSON.stringify( SetUserDefaultBudgetRequestBody$outboundSchema.parse( setUserDefaultBudgetRequestBody, ), ); } export function setUserDefaultBudgetRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetUserDefaultBudgetRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetUserDefaultBudgetRequestBody' from JSON`, ); } /** @internal */ export const SetUserDefaultBudgetRequest$inboundSchema: z.ZodType< SetUserDefaultBudgetRequest, z.ZodTypeDef, unknown > = z.object({ org_id: z.string().optional(), RequestBody: z.lazy(() => SetUserDefaultBudgetRequestBody$inboundSchema), }).transform((v) => { return remap$(v, { "org_id": "orgId", "RequestBody": "requestBody", }); }); /** @internal */ export type SetUserDefaultBudgetRequest$Outbound = { org_id?: string | undefined; RequestBody: SetUserDefaultBudgetRequestBody$Outbound; }; /** @internal */ export const SetUserDefaultBudgetRequest$outboundSchema: z.ZodType< SetUserDefaultBudgetRequest$Outbound, z.ZodTypeDef, SetUserDefaultBudgetRequest > = z.object({ orgId: z.string().optional(), requestBody: z.lazy(() => SetUserDefaultBudgetRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { orgId: "org_id", requestBody: "RequestBody", }); }); export function setUserDefaultBudgetRequestToJSON( setUserDefaultBudgetRequest: SetUserDefaultBudgetRequest, ): string { return JSON.stringify( SetUserDefaultBudgetRequest$outboundSchema.parse( setUserDefaultBudgetRequest, ), ); } export function setUserDefaultBudgetRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetUserDefaultBudgetRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetUserDefaultBudgetRequest' from JSON`, ); } /** @internal */ export const SetUserDefaultBudgetScope$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetScope > = z.nativeEnum(SetUserDefaultBudgetScope); /** @internal */ export const SetUserDefaultBudgetScope$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetScope > = SetUserDefaultBudgetScope$inboundSchema; /** @internal */ export const SetUserDefaultBudgetBudgetsOwner$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsOwner > = z.nativeEnum(SetUserDefaultBudgetBudgetsOwner); /** @internal */ export const SetUserDefaultBudgetBudgetsOwner$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsOwner > = SetUserDefaultBudgetBudgetsOwner$inboundSchema; /** @internal */ export const SetUserDefaultBudgetBudgetsPeriod$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsPeriod > = z.nativeEnum(SetUserDefaultBudgetBudgetsPeriod); /** @internal */ export const SetUserDefaultBudgetBudgetsPeriod$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsPeriod > = SetUserDefaultBudgetBudgetsPeriod$inboundSchema; /** @internal */ export const SetUserDefaultBudgetBudgetsAction$inboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsAction > = z.nativeEnum(SetUserDefaultBudgetBudgetsAction); /** @internal */ export const SetUserDefaultBudgetBudgetsAction$outboundSchema: z.ZodNativeEnum< typeof SetUserDefaultBudgetBudgetsAction > = SetUserDefaultBudgetBudgetsAction$inboundSchema; /** @internal */ export const SetUserDefaultBudgetBudgetsThresholds$inboundSchema: z.ZodType< SetUserDefaultBudgetBudgetsThresholds, z.ZodTypeDef, unknown > = z.object({ pct: z.number().int(), action: SetUserDefaultBudgetBudgetsAction$inboundSchema, }); /** @internal */ export type SetUserDefaultBudgetBudgetsThresholds$Outbound = { pct: number; action: string; }; /** @internal */ export const SetUserDefaultBudgetBudgetsThresholds$outboundSchema: z.ZodType< SetUserDefaultBudgetBudgetsThresholds$Outbound, z.ZodTypeDef, SetUserDefaultBudgetBudgetsThresholds > = z.object({ pct: z.number().int(), action: SetUserDefaultBudgetBudgetsAction$outboundSchema, }); export function setUserDefaultBudgetBudgetsThresholdsToJSON( setUserDefaultBudgetBudgetsThresholds: SetUserDefaultBudgetBudgetsThresholds, ): string { return JSON.stringify( SetUserDefaultBudgetBudgetsThresholds$outboundSchema.parse( setUserDefaultBudgetBudgetsThresholds, ), ); } export function setUserDefaultBudgetBudgetsThresholdsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetUserDefaultBudgetBudgetsThresholds$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetUserDefaultBudgetBudgetsThresholds' from JSON`, ); } /** @internal */ export const SetUserDefaultBudgetResponseBody$inboundSchema: z.ZodType< SetUserDefaultBudgetResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), scope: SetUserDefaultBudgetScope$inboundSchema, scope_id: z.string(), scope_org_id: z.nullable(z.string()), owner: SetUserDefaultBudgetBudgetsOwner$inboundSchema, period: SetUserDefaultBudgetBudgetsPeriod$inboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetUserDefaultBudgetBudgetsThresholds$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 SetUserDefaultBudgetResponseBody$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 SetUserDefaultBudgetResponseBody$outboundSchema: z.ZodType< SetUserDefaultBudgetResponseBody$Outbound, z.ZodTypeDef, SetUserDefaultBudgetResponseBody > = z.object({ id: z.string(), scope: SetUserDefaultBudgetScope$outboundSchema, scopeId: z.string(), scopeOrgId: z.nullable(z.string()), owner: SetUserDefaultBudgetBudgetsOwner$outboundSchema, period: SetUserDefaultBudgetBudgetsPeriod$outboundSchema, limit: z.number(), thresholds: z.array( z.lazy(() => SetUserDefaultBudgetBudgetsThresholds$outboundSchema), ), alertWebhookUrl: z.nullable(z.string()), }).transform((v) => { return remap$(v, { scopeId: "scope_id", scopeOrgId: "scope_org_id", alertWebhookUrl: "alert_webhook_url", }); }); export function setUserDefaultBudgetResponseBodyToJSON( setUserDefaultBudgetResponseBody: SetUserDefaultBudgetResponseBody, ): string { return JSON.stringify( SetUserDefaultBudgetResponseBody$outboundSchema.parse( setUserDefaultBudgetResponseBody, ), ); } export function setUserDefaultBudgetResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SetUserDefaultBudgetResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetUserDefaultBudgetResponseBody' from JSON`, ); }