/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 4095e72cdd61 */ import * as z from "zod/v4"; 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 GetProjectSandboxMetricsGlobals = { /** * Workspace name. Platform API keys already select a workspace; other authentication methods can configure it once on the SDK client. */ workspace?: string | undefined; }; export const GetProjectSandboxMetricsQueryParamRange = { TwentyFourh: "24h", Sevend: "7d", Thirtyd: "30d", } as const; export type GetProjectSandboxMetricsQueryParamRange = ClosedEnum< typeof GetProjectSandboxMetricsQueryParamRange >; export type GetProjectSandboxMetricsRequest = { /** * Project ID or name. */ idOrName: string; range?: GetProjectSandboxMetricsQueryParamRange | undefined; }; export const GetProjectSandboxMetricsRangeResponse = { TwentyFourh: "24h", Sevend: "7d", Thirtyd: "30d", } as const; export type GetProjectSandboxMetricsRangeResponse = ClosedEnum< typeof GetProjectSandboxMetricsRangeResponse >; export type GetProjectSandboxMetricsTotals = { sessions: number; commands: number; outcomeUnknown: number; errors: number; p95LatencyMs: number | null; }; export type GetProjectSandboxMetricsTimeSery = { sessions: number; commands: number; outcomeUnknown: number; errors: number; p95LatencyMs: number | null; bucket: Date; }; export type GetProjectSandboxMetricsCustomer = { deploymentGroupId: string; externalId: string | null; sessions: number; commands: number; lastSeenAt: Date; }; export type GetProjectSandboxMetricsAvailable = { status: "available"; range: GetProjectSandboxMetricsRangeResponse; totals: GetProjectSandboxMetricsTotals; timeSeries: Array; customers: Array; customersTruncated: boolean; }; export const GetProjectSandboxMetricsReason = { NotConfigured: "not-configured", TemporarilyUnavailable: "temporarily-unavailable", } as const; export type GetProjectSandboxMetricsReason = ClosedEnum< typeof GetProjectSandboxMetricsReason >; export type GetProjectSandboxMetricsUnavailable = { status: "unavailable"; reason: GetProjectSandboxMetricsReason; }; /** * Privacy-safe Sandbox Gateway usage aggregates. */ export type GetProjectSandboxMetricsResponse = | GetProjectSandboxMetricsUnavailable | GetProjectSandboxMetricsAvailable; /** @internal */ export const GetProjectSandboxMetricsQueryParamRange$outboundSchema: z.ZodEnum< typeof GetProjectSandboxMetricsQueryParamRange > = z.enum(GetProjectSandboxMetricsQueryParamRange); /** @internal */ export type GetProjectSandboxMetricsRequest$Outbound = { idOrName: string; range: string; }; /** @internal */ export const GetProjectSandboxMetricsRequest$outboundSchema: z.ZodType< GetProjectSandboxMetricsRequest$Outbound, GetProjectSandboxMetricsRequest > = z.object({ idOrName: z.string(), range: GetProjectSandboxMetricsQueryParamRange$outboundSchema.default("24h"), }); export function getProjectSandboxMetricsRequestToJSON( getProjectSandboxMetricsRequest: GetProjectSandboxMetricsRequest, ): string { return JSON.stringify( GetProjectSandboxMetricsRequest$outboundSchema.parse( getProjectSandboxMetricsRequest, ), ); } /** @internal */ export const GetProjectSandboxMetricsRangeResponse$inboundSchema: z.ZodEnum< typeof GetProjectSandboxMetricsRangeResponse > = z.enum(GetProjectSandboxMetricsRangeResponse); /** @internal */ export const GetProjectSandboxMetricsTotals$inboundSchema: z.ZodType< GetProjectSandboxMetricsTotals, unknown > = z.object({ sessions: z.int(), commands: z.int(), outcomeUnknown: z.int(), errors: z.int(), p95LatencyMs: z.nullable(z.number()), }); export function getProjectSandboxMetricsTotalsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsTotals$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsTotals' from JSON`, ); } /** @internal */ export const GetProjectSandboxMetricsTimeSery$inboundSchema: z.ZodType< GetProjectSandboxMetricsTimeSery, unknown > = z.object({ sessions: z.int(), commands: z.int(), outcomeUnknown: z.int(), errors: z.int(), p95LatencyMs: z.nullable(z.number()), bucket: z.iso.datetime({ offset: true }).transform(v => new Date(v)), }); export function getProjectSandboxMetricsTimeSeryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsTimeSery$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsTimeSery' from JSON`, ); } /** @internal */ export const GetProjectSandboxMetricsCustomer$inboundSchema: z.ZodType< GetProjectSandboxMetricsCustomer, unknown > = z.object({ deploymentGroupId: z.string(), externalId: z.nullable(z.string()), sessions: z.int(), commands: z.int(), lastSeenAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), }); export function getProjectSandboxMetricsCustomerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsCustomer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsCustomer' from JSON`, ); } /** @internal */ export const GetProjectSandboxMetricsAvailable$inboundSchema: z.ZodType< GetProjectSandboxMetricsAvailable, unknown > = z.object({ status: z.literal("available"), range: GetProjectSandboxMetricsRangeResponse$inboundSchema, totals: z.lazy(() => GetProjectSandboxMetricsTotals$inboundSchema), timeSeries: z.array( z.lazy(() => GetProjectSandboxMetricsTimeSery$inboundSchema), ), customers: z.array( z.lazy(() => GetProjectSandboxMetricsCustomer$inboundSchema), ), customersTruncated: z.boolean(), }); export function getProjectSandboxMetricsAvailableFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsAvailable$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsAvailable' from JSON`, ); } /** @internal */ export const GetProjectSandboxMetricsReason$inboundSchema: z.ZodEnum< typeof GetProjectSandboxMetricsReason > = z.enum(GetProjectSandboxMetricsReason); /** @internal */ export const GetProjectSandboxMetricsUnavailable$inboundSchema: z.ZodType< GetProjectSandboxMetricsUnavailable, unknown > = z.object({ status: z.literal("unavailable"), reason: GetProjectSandboxMetricsReason$inboundSchema, }); export function getProjectSandboxMetricsUnavailableFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsUnavailable$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsUnavailable' from JSON`, ); } /** @internal */ export const GetProjectSandboxMetricsResponse$inboundSchema: z.ZodType< GetProjectSandboxMetricsResponse, unknown > = z.union([ z.lazy(() => GetProjectSandboxMetricsUnavailable$inboundSchema), z.lazy(() => GetProjectSandboxMetricsAvailable$inboundSchema), ]); export function getProjectSandboxMetricsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetProjectSandboxMetricsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetProjectSandboxMetricsResponse' from JSON`, ); }