import {z} from 'zod' export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentResourcePoolsArgs = {projectsId: string, locationsId: string, pageSize?: number | undefined, pageToken?: string | undefined}; export type GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentResourcePoolsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudAiplatformV1AutoscalingMetricSpec = z.object({metricName: z.string().optional(), target: z.number().int().optional()}); export const googleCloudAiplatformV1ReservationAffinity = z.object({key: z.string().optional(), reservationAffinityType: z.enum(["TYPE_UNSPECIFIED", "NO_RESERVATION", "ANY_RESERVATION", "SPECIFIC_RESERVATION"]).optional(), values: z.array(z.string()).optional()}); export const googleCloudAiplatformV1MachineSpec = z.object({acceleratorCount: z.number().int().optional(), acceleratorType: z.enum(["ACCELERATOR_TYPE_UNSPECIFIED", "NVIDIA_TESLA_K80", "NVIDIA_TESLA_P100", "NVIDIA_TESLA_V100", "NVIDIA_TESLA_P4", "NVIDIA_TESLA_T4", "NVIDIA_TESLA_A100", "NVIDIA_A100_80GB", "NVIDIA_L4", "NVIDIA_H100_80GB", "NVIDIA_H100_MEGA_80GB", "NVIDIA_H200_141GB", "NVIDIA_B200", "NVIDIA_GB200", "NVIDIA_RTX_PRO_6000", "TPU_V2", "TPU_V3", "TPU_V4_POD", "TPU_V5_LITEPOD"]).optional(), gpuPartitionSize: z.string().optional(), machineType: z.string().optional(), reservationAffinity: googleCloudAiplatformV1ReservationAffinity.optional(), tpuTopology: z.string().optional()}); export const googleCloudAiplatformV1DedicatedResources = z.object({autoscalingMetricSpecs: z.array(googleCloudAiplatformV1AutoscalingMetricSpec).optional(), machineSpec: googleCloudAiplatformV1MachineSpec.optional(), maxReplicaCount: z.number().int().optional(), minReplicaCount: z.number().int().optional(), requiredReplicaCount: z.number().int().optional(), spot: z.boolean().optional()}); export const googleCloudAiplatformV1EncryptionSpec = z.object({kmsKeyName: z.string().optional()}); export const googleCloudAiplatformV1DeploymentResourcePool = z.object({createTime: z.string().optional(), dedicatedResources: googleCloudAiplatformV1DedicatedResources.optional(), disableContainerLogging: z.boolean().optional(), encryptionSpec: googleCloudAiplatformV1EncryptionSpec.optional(), name: z.string().optional(), satisfiesPzi: z.boolean().optional(), satisfiesPzs: z.boolean().optional(), serviceAccount: z.string().optional()}); export const googleCloudAiplatformV1ListDeploymentResourcePoolsResponse = z.object({deploymentResourcePools: z.array(googleCloudAiplatformV1DeploymentResourcePool).optional(), nextPageToken: z.string().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 }; /** * List DeploymentResourcePools in a location. * * GET /v1/projects/{projectsId}/locations/{locationsId}/deploymentResourcePools */ export const getApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentResourcePools = async (args: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentResourcePoolsArgs, options?: GetApiV1ProjectsProjectsIdLocationsLocationsIdDeploymentResourcePoolsOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/deploymentResourcePools${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(googleCloudAiplatformV1ListDeploymentResourcePoolsResponse, await res.json()) };