import {z} from 'zod' export type GoogleCloudAiplatformV1AutomaticResources = {maxReplicaCount?: number | undefined, minReplicaCount?: number | undefined}; export type GoogleCloudAiplatformV1AutoscalingMetricSpec = {metricName?: string | undefined, target?: number | undefined}; export type GoogleCloudAiplatformV1ReservationAffinity = {key?: string | undefined, reservationAffinityType?: ('TYPE_UNSPECIFIED' | 'NO_RESERVATION' | 'ANY_RESERVATION' | 'SPECIFIC_RESERVATION') | undefined, values?: Array | undefined}; export type GoogleCloudAiplatformV1MachineSpec = {acceleratorCount?: number | undefined, acceleratorType?: ('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') | undefined, gpuPartitionSize?: string | undefined, machineType?: string | undefined, reservationAffinity?: GoogleCloudAiplatformV1ReservationAffinity | undefined, tpuTopology?: string | undefined}; export type GoogleCloudAiplatformV1DedicatedResources = {autoscalingMetricSpecs?: Array | undefined, machineSpec?: GoogleCloudAiplatformV1MachineSpec | undefined, maxReplicaCount?: number | undefined, minReplicaCount?: number | undefined, requiredReplicaCount?: number | undefined, spot?: boolean | undefined}; export type GoogleCloudAiplatformV1DeployedIndexAuthConfigAuthProvider = {allowedIssuers?: Array | undefined, audiences?: Array | undefined}; export type GoogleCloudAiplatformV1DeployedIndexAuthConfig = {authProvider?: GoogleCloudAiplatformV1DeployedIndexAuthConfigAuthProvider | undefined}; export type GoogleCloudAiplatformV1PscAutomatedEndpoints = {matchAddress?: string | undefined, network?: string | undefined, projectId?: string | undefined}; export type GoogleCloudAiplatformV1IndexPrivateEndpoints = {matchGrpcAddress?: string | undefined, pscAutomatedEndpoints?: Array | undefined, serviceAttachment?: string | undefined}; export type GoogleCloudAiplatformV1PSCAutomationConfig = {errorMessage?: string | undefined, forwardingRule?: string | undefined, ipAddress?: string | undefined, network?: string | undefined, projectId?: string | undefined, state?: ('PSC_AUTOMATION_STATE_UNSPECIFIED' | 'PSC_AUTOMATION_STATE_SUCCESSFUL' | 'PSC_AUTOMATION_STATE_FAILED') | undefined}; export type GoogleCloudAiplatformV1DeployedIndex = {automaticResources?: GoogleCloudAiplatformV1AutomaticResources | undefined, createTime?: unknown | undefined, dedicatedResources?: GoogleCloudAiplatformV1DedicatedResources | undefined, deployedIndexAuthConfig?: GoogleCloudAiplatformV1DeployedIndexAuthConfig | undefined, deploymentGroup?: string | undefined, deploymentTier?: ('DEPLOYMENT_TIER_UNSPECIFIED' | 'STORAGE') | undefined, displayName?: string | undefined, enableAccessLogging?: boolean | undefined, enableDatapointUpsertLogging?: boolean | undefined, id?: string | undefined, index?: string | undefined, indexSyncTime?: unknown | undefined, privateEndpoints?: GoogleCloudAiplatformV1IndexPrivateEndpoints | undefined, pscAutomationConfigs?: Array | undefined, reservedIpRanges?: Array | undefined}; export type GoogleCloudAiplatformV1EncryptionSpec = {kmsKeyName?: string | undefined}; export type GoogleCloudAiplatformV1PrivateServiceConnectConfig = {enablePrivateServiceConnect?: boolean | undefined, projectAllowlist?: Array | undefined, pscAutomationConfigs?: Array | undefined, serviceAttachment?: string | undefined}; export type GoogleCloudAiplatformV1IndexEndpoint = {createTime?: unknown | undefined, deployedIndexes?: Array | undefined, description?: string | undefined, displayName?: string | undefined, enablePrivateServiceConnect?: boolean | undefined, encryptionSpec?: GoogleCloudAiplatformV1EncryptionSpec | undefined, etag?: string | undefined, labels?: {[key: string]: string} | undefined, name?: string | undefined, network?: string | undefined, privateServiceConnectConfig?: GoogleCloudAiplatformV1PrivateServiceConnectConfig | undefined, publicEndpointDomainName?: string | undefined, publicEndpointEnabled?: boolean | undefined, satisfiesPzi?: boolean | undefined, satisfiesPzs?: boolean | undefined, updateTime?: unknown | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdIndexEndpointsIndexEndpointsIdArgs = {projectsId: string, locationsId: string, indexEndpointsId: string, updateMask?: unknown | undefined, body: GoogleCloudAiplatformV1IndexEndpoint}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdIndexEndpointsIndexEndpointsIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleCloudAiplatformV1AutomaticResources = z.object({maxReplicaCount: z.number().int().optional(), minReplicaCount: z.number().int().optional()}); 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 googleCloudAiplatformV1DeployedIndexAuthConfigAuthProvider = z.object({allowedIssuers: z.array(z.string()).optional(), audiences: z.array(z.string()).optional()}); export const googleCloudAiplatformV1DeployedIndexAuthConfig = z.object({authProvider: googleCloudAiplatformV1DeployedIndexAuthConfigAuthProvider.optional()}); export const googleCloudAiplatformV1PscAutomatedEndpoints = z.object({matchAddress: z.string().optional(), network: z.string().optional(), projectId: z.string().optional()}); export const googleCloudAiplatformV1IndexPrivateEndpoints = z.object({matchGrpcAddress: z.string().optional(), pscAutomatedEndpoints: z.array(googleCloudAiplatformV1PscAutomatedEndpoints).optional(), serviceAttachment: z.string().optional()}); export const googleCloudAiplatformV1PSCAutomationConfig = z.object({errorMessage: z.string().optional(), forwardingRule: z.string().optional(), ipAddress: z.string().optional(), network: z.string().optional(), projectId: z.string().optional(), state: z.enum(["PSC_AUTOMATION_STATE_UNSPECIFIED", "PSC_AUTOMATION_STATE_SUCCESSFUL", "PSC_AUTOMATION_STATE_FAILED"]).optional()}); export const googleCloudAiplatformV1DeployedIndex = z.object({automaticResources: googleCloudAiplatformV1AutomaticResources.optional(), createTime: z.string().optional(), dedicatedResources: googleCloudAiplatformV1DedicatedResources.optional(), deployedIndexAuthConfig: googleCloudAiplatformV1DeployedIndexAuthConfig.optional(), deploymentGroup: z.string().optional(), deploymentTier: z.enum(["DEPLOYMENT_TIER_UNSPECIFIED", "STORAGE"]).optional(), displayName: z.string().optional(), enableAccessLogging: z.boolean().optional(), enableDatapointUpsertLogging: z.boolean().optional(), id: z.string().optional(), index: z.string().optional(), indexSyncTime: z.string().optional(), privateEndpoints: googleCloudAiplatformV1IndexPrivateEndpoints.optional(), pscAutomationConfigs: z.array(googleCloudAiplatformV1PSCAutomationConfig).optional(), reservedIpRanges: z.array(z.string()).optional()}); export const googleCloudAiplatformV1EncryptionSpec = z.object({kmsKeyName: z.string().optional()}); export const googleCloudAiplatformV1PrivateServiceConnectConfig = z.object({enablePrivateServiceConnect: z.boolean().optional(), projectAllowlist: z.array(z.string()).optional(), pscAutomationConfigs: z.array(googleCloudAiplatformV1PSCAutomationConfig).optional(), serviceAttachment: z.string().optional()}); export const googleCloudAiplatformV1IndexEndpoint = z.object({createTime: z.string().optional(), deployedIndexes: z.array(googleCloudAiplatformV1DeployedIndex).optional(), description: z.string().optional(), displayName: z.string().optional(), enablePrivateServiceConnect: z.boolean().optional(), encryptionSpec: googleCloudAiplatformV1EncryptionSpec.optional(), etag: z.string().optional(), labels: z.record(z.string(), z.string()).optional(), name: z.string().optional(), network: z.string().optional(), privateServiceConnectConfig: googleCloudAiplatformV1PrivateServiceConnectConfig.optional(), publicEndpointDomainName: z.string().optional(), publicEndpointEnabled: z.boolean().optional(), satisfiesPzi: z.boolean().optional(), satisfiesPzs: z.boolean().optional(), updateTime: 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 }; /** * Updates an IndexEndpoint. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/indexEndpoints/{indexEndpointsId} */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdIndexEndpointsIndexEndpointsId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdIndexEndpointsIndexEndpointsIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdIndexEndpointsIndexEndpointsIdOptions) => { const {baseUrl = "https://aiplatform.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.updateMask != null) query.append("updateMask", String(args.updateMask)) 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))}/indexEndpoints/${encodeURIComponent(String(args.indexEndpointsId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(googleCloudAiplatformV1IndexEndpoint, await res.json()) };