import {z} from 'zod' export type KubernetesCostAllocationV1SelectSchema = {projectId?: boolean | undefined, kubernetesClusterId?: boolean | undefined, clusterName?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, windowStart?: boolean | undefined, windowEnd?: boolean | undefined, namespace?: boolean | undefined, controllerKind?: boolean | undefined, controllerName?: boolean | undefined, podName?: boolean | undefined, containerName?: boolean | undefined, nodeName?: boolean | undefined, providerId?: boolean | undefined, labels?: boolean | undefined, labelKeys?: boolean | undefined, cpuCoreHours?: boolean | undefined, cpuCoreRequestAverage?: boolean | undefined, cpuCoreUsageAverage?: boolean | undefined, cpuCoreLimitAverage?: boolean | undefined, cpuCost?: boolean | undefined, gpuHours?: boolean | undefined, gpuCost?: boolean | undefined, ramByteHours?: boolean | undefined, ramBytesRequestAverage?: boolean | undefined, ramBytesUsageAverage?: boolean | undefined, ramBytesLimitAverage?: boolean | undefined, ramBytesUsageMax?: boolean | undefined, ramCost?: boolean | undefined, pvByteHours?: boolean | undefined, pvCost?: boolean | undefined, networkCost?: boolean | undefined, loadBalancerCost?: boolean | undefined, sharedCost?: boolean | undefined, externalCost?: boolean | undefined, totalCost?: boolean | undefined, cpuEfficiency?: boolean | undefined, ramEfficiency?: boolean | undefined, totalEfficiency?: boolean | undefined, currency?: boolean | undefined, shipmentId?: boolean | undefined, shipmentChunk?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiKubernetesCostAllocationIdGetItemArgs = {id: string, body: {select?: KubernetesCostAllocationV1SelectSchema | undefined}}; export type CreateApiKubernetesCostAllocationIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const kubernetesCostAllocationV1 = z.object({projectId: z.string(), kubernetesClusterId: z.string(), clusterName: z.string(), k8sClusterEntityKey: z.string().optional(), windowStart: z.string().optional(), windowEnd: z.string().optional(), namespace: z.string().optional(), controllerKind: z.string().optional(), controllerName: z.string().optional(), podName: z.string().optional(), containerName: z.string().optional(), nodeName: z.string().optional(), providerId: z.string().optional(), labels: z.string().optional(), labelKeys: z.array(z.string()).optional(), cpuCoreHours: z.number().optional(), cpuCoreRequestAverage: z.number().optional(), cpuCoreUsageAverage: z.number().optional(), cpuCoreLimitAverage: z.number().optional(), cpuCost: z.number().optional(), gpuHours: z.number().optional(), gpuCost: z.number().optional(), ramByteHours: z.number().optional(), ramBytesRequestAverage: z.number().optional(), ramBytesUsageAverage: z.number().optional(), ramBytesLimitAverage: z.number().optional(), ramBytesUsageMax: z.number().optional(), ramCost: z.number().optional(), pvByteHours: z.number().optional(), pvCost: z.number().optional(), networkCost: z.number().optional(), loadBalancerCost: z.number().optional(), sharedCost: z.number().optional(), externalCost: z.number().optional(), totalCost: z.number().optional(), cpuEfficiency: z.number().optional(), ramEfficiency: z.number().optional(), totalEfficiency: z.number().optional(), currency: z.string().optional(), shipmentId: z.string().optional(), shipmentChunk: z.number().optional()}); export const createApiKubernetesCostAllocationIdGetItemResponse = z.object({data: kubernetesCostAllocationV1.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get Kubernetes Cost Allocation * * POST /kubernetes-cost-allocation/{id}/get-item */ export const createApiKubernetesCostAllocationIdGetItem = async (args: CreateApiKubernetesCostAllocationIdGetItemArgs, options?: CreateApiKubernetesCostAllocationIdGetItemOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/kubernetes-cost-allocation/${encodeURIComponent(String(args.id))}/get-item${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiKubernetesCostAllocationIdGetItemResponse, await res.json()) };