import {z} from 'zod' export type GetApiProjectsProjectIdKubernetesNodepoolsNodePoolIdArgs = {project_id: string, node_pool_id: string}; export type GetApiProjectsProjectIdKubernetesNodepoolsNodePoolIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const instanceDetails = z.object({id: z.string(), using_latest_config: z.boolean()}); export const kubernetesNodeTaint = z.object({effect: z.enum(["NoSchedule", "PreferNoSchedule", "NoExecute"]), key: z.string(), value: z.string().max(63).optional()}); export const kubernetesNodePool = z.object({cluster_id: z.string(), count: z.number().int(), created_at: z.string(), ephemeral_storage_for_containerd: z.boolean(), id: z.string(), image_id: z.string(), instance_details: z.array(instanceDetails).optional(), instance_ids: z.array(z.string()), name: z.string(), node_labels: z.record(z.string(), z.string()), node_taints: z.array(kubernetesNodeTaint), nvlink_domain_id: z.string().optional(), project_id: z.string(), public_ip_type: z.string().optional(), reservation_id: z.string(), state: z.string(), subnet_id: z.string(), type: z.string(), updated_at: z.string()}); 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 }; /** * Returns details for a single Kubernetes node pool in the project. * * GET /projects/{project_id}/kubernetes/nodepools/{node_pool_id} */ export const getApiProjectsProjectIdKubernetesNodepoolsNodePoolId = async (args: GetApiProjectsProjectIdKubernetesNodepoolsNodePoolIdArgs, options?: GetApiProjectsProjectIdKubernetesNodepoolsNodePoolIdOptions) => { const {baseUrl = "https://api.cloud.crusoe.ai/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.project_id))}/kubernetes/nodepools/${encodeURIComponent(String(args.node_pool_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(kubernetesNodePool, await res.json()) };