import {z} from 'zod' export type KubernetesCostAllocationV1QuerySchema = {projectId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, kubernetesClusterId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, clusterName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sClusterEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, windowStart?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, windowEnd?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, namespace?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, controllerKind?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, controllerName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, podName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, containerName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, nodeName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, providerId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, labels?: ({[key: string]: string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Search', value: string}}) | undefined, labelKeys?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, cpuCoreHours?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, cpuCoreRequestAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, cpuCoreUsageAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, cpuCoreLimitAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, cpuCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, gpuHours?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, gpuCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramByteHours?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramBytesRequestAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramBytesUsageAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramBytesLimitAverage?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramBytesUsageMax?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, pvByteHours?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, pvCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, networkCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, loadBalancerCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, sharedCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, externalCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, totalCost?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, cpuEfficiency?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, ramEfficiency?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, totalEfficiency?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, currency?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, shipmentId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, shipmentChunk?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, _id?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, createdAt?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined}; export type CreateApiKubernetesCostAllocationCountArgs = {body: {query?: KubernetesCostAllocationV1QuerySchema | undefined}}; export type CreateApiKubernetesCostAllocationCountOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiKubernetesCostAllocationCountResponse = z.object({count: z.number().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 }; /** * Count Kubernetes Cost Allocation * * POST /kubernetes-cost-allocation/count */ export const createApiKubernetesCostAllocationCount = async (args: CreateApiKubernetesCostAllocationCountArgs, options?: CreateApiKubernetesCostAllocationCountOptions) => { 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/count${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(createApiKubernetesCostAllocationCountResponse, await res.json()) };