/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 7066e44b6e2e */ import * as z from "zod/v4"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListInventoryGlobals = { /** * Workspace name. Platform API keys already select a workspace; other authentication methods can configure it once on the SDK client. */ workspace?: string | undefined; }; export type ListInventoryRequest = { /** * Filter by project ID or name. */ project: string; deploymentGroupId?: string | undefined; deploymentId?: string | undefined; }; export type ResourceObserved = { source: "observed"; deploymentId: string; deploymentName: string; deploymentGroupId: string | null; deploymentGroupName: string | null; resourceType: string; resourceId: string; name: string; rawKind: string; alienResourceId: string | null; backend: string; controllerPlatform: string; health: string; lifecycle: string; message: string | null; partial: boolean; providerStale: boolean; platformStale: boolean; desiredCount: number | null; currentCount: number | null; readyCount: number | null; deploymentCount: number; attentionCount: number; lastObservedAt: Date; }; export type ResourceManaged = { resourceType: string; resourceId: string; name: string; backend: string; controllerPlatform: string; health: string; lifecycle: string; message: string | null; partial: boolean; providerStale: boolean; platformStale: boolean; desiredCount: number | null; currentCount: number | null; readyCount: number | null; deploymentCount: number; attentionCount: number; lastObservedAt: Date; source: "managed"; deploymentId: string; deploymentName: string; }; export type Resource = ResourceManaged | ResourceObserved; /** * Unified managed and observed resource inventory rows. */ export type ListInventoryResponse = { resources: Array; }; /** @internal */ export type ListInventoryRequest$Outbound = { project: string; deploymentGroupId?: string | undefined; deploymentId?: string | undefined; }; /** @internal */ export const ListInventoryRequest$outboundSchema: z.ZodType< ListInventoryRequest$Outbound, ListInventoryRequest > = z.object({ project: z.string(), deploymentGroupId: z.string().optional(), deploymentId: z.string().optional(), }); export function listInventoryRequestToJSON( listInventoryRequest: ListInventoryRequest, ): string { return JSON.stringify( ListInventoryRequest$outboundSchema.parse(listInventoryRequest), ); } /** @internal */ export const ResourceObserved$inboundSchema: z.ZodType< ResourceObserved, unknown > = z.object({ source: z.literal("observed"), deploymentId: z.string(), deploymentName: z.string(), deploymentGroupId: z.nullable(z.string()), deploymentGroupName: z.nullable(z.string()), resourceType: z.string(), resourceId: z.string(), name: z.string(), rawKind: z.string(), alienResourceId: z.nullable(z.string()), backend: z.string(), controllerPlatform: z.string(), health: z.string(), lifecycle: z.string(), message: z.nullable(z.string()), partial: z.boolean(), providerStale: z.boolean(), platformStale: z.boolean(), desiredCount: z.nullable(z.int()), currentCount: z.nullable(z.int()), readyCount: z.nullable(z.int()), deploymentCount: z.int(), attentionCount: z.int(), lastObservedAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), }); export function resourceObservedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceObserved$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceObserved' from JSON`, ); } /** @internal */ export const ResourceManaged$inboundSchema: z.ZodType< ResourceManaged, unknown > = z.object({ resourceType: z.string(), resourceId: z.string(), name: z.string(), backend: z.string(), controllerPlatform: z.string(), health: z.string(), lifecycle: z.string(), message: z.nullable(z.string()), partial: z.boolean(), providerStale: z.boolean(), platformStale: z.boolean(), desiredCount: z.nullable(z.int()), currentCount: z.nullable(z.int()), readyCount: z.nullable(z.int()), deploymentCount: z.int(), attentionCount: z.int(), lastObservedAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), source: z.literal("managed"), deploymentId: z.string(), deploymentName: z.string(), }); export function resourceManagedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceManaged$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceManaged' from JSON`, ); } /** @internal */ export const Resource$inboundSchema: z.ZodType = z.union([ z.lazy(() => ResourceManaged$inboundSchema), z.lazy(() => ResourceObserved$inboundSchema), ]); export function resourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Resource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Resource' from JSON`, ); } /** @internal */ export const ListInventoryResponse$inboundSchema: z.ZodType< ListInventoryResponse, unknown > = z.object({ resources: z.array( z.union([ z.lazy(() => ResourceManaged$inboundSchema), z.lazy(() => ResourceObserved$inboundSchema), ]), ), }); export function listInventoryResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListInventoryResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListInventoryResponse' from JSON`, ); }