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 GoogleCloudAiplatformV1ExplanationMetadataInputMetadataFeatureValueDomain = {maxValue?: number | undefined, minValue?: number | undefined, originalMean?: number | undefined, originalStddev?: number | undefined}; export type GoogleCloudAiplatformV1ExplanationMetadataInputMetadataVisualization = {clipPercentLowerbound?: number | undefined, clipPercentUpperbound?: number | undefined, colorMap?: ('COLOR_MAP_UNSPECIFIED' | 'PINK_GREEN' | 'VIRIDIS' | 'RED' | 'GREEN' | 'RED_GREEN' | 'PINK_WHITE_GREEN') | undefined, overlayType?: ('OVERLAY_TYPE_UNSPECIFIED' | 'NONE' | 'ORIGINAL' | 'GRAYSCALE' | 'MASK_BLACK') | undefined, polarity?: ('POLARITY_UNSPECIFIED' | 'POSITIVE' | 'NEGATIVE' | 'BOTH') | undefined, type?: ('TYPE_UNSPECIFIED' | 'PIXELS' | 'OUTLINES') | undefined}; export type GoogleCloudAiplatformV1ExplanationMetadataInputMetadata = {denseShapeTensorName?: string | undefined, encodedBaselines?: Array | undefined, encodedTensorName?: string | undefined, encoding?: ('ENCODING_UNSPECIFIED' | 'IDENTITY' | 'BAG_OF_FEATURES' | 'BAG_OF_FEATURES_SPARSE' | 'INDICATOR' | 'COMBINED_EMBEDDING' | 'CONCAT_EMBEDDING') | undefined, featureValueDomain?: GoogleCloudAiplatformV1ExplanationMetadataInputMetadataFeatureValueDomain | undefined, groupName?: string | undefined, indexFeatureMapping?: Array | undefined, indicesTensorName?: string | undefined, inputBaselines?: Array | undefined, inputTensorName?: string | undefined, modality?: string | undefined, visualization?: GoogleCloudAiplatformV1ExplanationMetadataInputMetadataVisualization | undefined}; export type GoogleCloudAiplatformV1ExplanationMetadataOutputMetadata = {displayNameMappingKey?: string | undefined, indexDisplayNameMapping: unknown, outputTensorName?: string | undefined}; export type GoogleCloudAiplatformV1ExplanationMetadata = {featureAttributionsSchemaUri?: string | undefined, inputs?: {[key: string]: GoogleCloudAiplatformV1ExplanationMetadataInputMetadata} | undefined, latentSpaceSource?: string | undefined, outputs?: {[key: string]: GoogleCloudAiplatformV1ExplanationMetadataOutputMetadata} | undefined}; export type GoogleCloudAiplatformV1GcsSource = {uris?: Array | undefined}; export type GoogleCloudAiplatformV1ExamplesExampleGcsSource = {dataFormat?: ('DATA_FORMAT_UNSPECIFIED' | 'JSONL') | undefined, gcsSource?: GoogleCloudAiplatformV1GcsSource | undefined}; export type GoogleCloudAiplatformV1Presets = {modality?: ('MODALITY_UNSPECIFIED' | 'IMAGE' | 'TEXT' | 'TABULAR') | undefined, query?: ('PRECISE' | 'FAST') | undefined}; export type GoogleCloudAiplatformV1Examples = {exampleGcsSource?: GoogleCloudAiplatformV1ExamplesExampleGcsSource | undefined, nearestNeighborSearchConfig: unknown, neighborCount?: number | undefined, presets?: GoogleCloudAiplatformV1Presets | undefined}; export type GoogleCloudAiplatformV1BlurBaselineConfig = {maxBlurSigma?: number | undefined}; export type GoogleCloudAiplatformV1FeatureNoiseSigmaNoiseSigmaForFeature = {name?: string | undefined, sigma?: number | undefined}; export type GoogleCloudAiplatformV1FeatureNoiseSigma = {noiseSigma?: Array | undefined}; export type GoogleCloudAiplatformV1SmoothGradConfig = {featureNoiseSigma?: GoogleCloudAiplatformV1FeatureNoiseSigma | undefined, noiseSigma?: number | undefined, noisySampleCount?: number | undefined}; export type GoogleCloudAiplatformV1IntegratedGradientsAttribution = {blurBaselineConfig?: GoogleCloudAiplatformV1BlurBaselineConfig | undefined, smoothGradConfig?: GoogleCloudAiplatformV1SmoothGradConfig | undefined, stepCount?: number | undefined}; export type GoogleCloudAiplatformV1SampledShapleyAttribution = {pathCount?: number | undefined}; export type GoogleCloudAiplatformV1XraiAttribution = {blurBaselineConfig?: GoogleCloudAiplatformV1BlurBaselineConfig | undefined, smoothGradConfig?: GoogleCloudAiplatformV1SmoothGradConfig | undefined, stepCount?: number | undefined}; export type GoogleCloudAiplatformV1ExplanationParameters = {examples?: GoogleCloudAiplatformV1Examples | undefined, integratedGradientsAttribution?: GoogleCloudAiplatformV1IntegratedGradientsAttribution | undefined, outputIndices?: Array | undefined, sampledShapleyAttribution?: GoogleCloudAiplatformV1SampledShapleyAttribution | undefined, topK?: number | undefined, xraiAttribution?: GoogleCloudAiplatformV1XraiAttribution | undefined}; export type GoogleCloudAiplatformV1ExplanationSpec = {metadata?: GoogleCloudAiplatformV1ExplanationMetadata | undefined, parameters?: GoogleCloudAiplatformV1ExplanationParameters | undefined}; export type GoogleCloudAiplatformV1FasterDeploymentConfig = {fastTryoutEnabled?: boolean | undefined}; export type GoogleCloudAiplatformV1PrivateEndpoints = {explainHttpUri?: string | undefined, healthHttpUri?: string | undefined, predictHttpUri?: string | undefined, serviceAttachment?: string | undefined}; export type GoogleCloudAiplatformV1SpeculativeDecodingSpecDraftModelSpeculation = {draftModel?: string | undefined}; export type GoogleCloudAiplatformV1SpeculativeDecodingSpecNgramSpeculation = {ngramSize?: number | undefined}; export type GoogleCloudAiplatformV1SpeculativeDecodingSpec = {draftModelSpeculation?: GoogleCloudAiplatformV1SpeculativeDecodingSpecDraftModelSpeculation | undefined, ngramSpeculation?: GoogleCloudAiplatformV1SpeculativeDecodingSpecNgramSpeculation | undefined, speculativeTokenCount?: number | undefined}; export type GoogleCloudAiplatformV1DeployedModelStatus = {availableReplicaCount?: number | undefined, lastUpdateTime?: unknown | undefined, message?: string | undefined}; export type GoogleCloudAiplatformV1DeployedModel = {automaticResources?: GoogleCloudAiplatformV1AutomaticResources | undefined, checkpointId?: string | undefined, createTime?: unknown | undefined, dedicatedResources?: GoogleCloudAiplatformV1DedicatedResources | undefined, disableContainerLogging?: boolean | undefined, disableExplanations?: boolean | undefined, displayName?: string | undefined, enableAccessLogging?: boolean | undefined, explanationSpec?: GoogleCloudAiplatformV1ExplanationSpec | undefined, fasterDeploymentConfig?: GoogleCloudAiplatformV1FasterDeploymentConfig | undefined, gdcConnectedModel?: string | undefined, id?: string | undefined, model?: string | undefined, modelVersionId?: string | undefined, privateEndpoints?: GoogleCloudAiplatformV1PrivateEndpoints | undefined, serviceAccount?: string | undefined, sharedResources?: string | undefined, speculativeDecodingSpec?: GoogleCloudAiplatformV1SpeculativeDecodingSpec | undefined, status?: GoogleCloudAiplatformV1DeployedModelStatus | undefined, systemLabels?: {[key: string]: string} | undefined}; export type GoogleCloudAiplatformV1MutateDeployedModelRequest = {deployedModel?: GoogleCloudAiplatformV1DeployedModel | undefined, updateMask?: unknown | undefined}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdEndpointsEndpointsIdMutateDeployedModelArgs = {projectsId: string, locationsId: string, endpointsId: string, body: GoogleCloudAiplatformV1MutateDeployedModelRequest}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdEndpointsEndpointsIdMutateDeployedModelOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleLongrunningOperation = z.object({done: z.boolean().optional(), error: googleRpcStatus.optional(), metadata: z.record(z.string(), z.unknown()).optional(), name: z.string().optional(), response: z.record(z.string(), z.unknown()).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 existing deployed model. Updatable fields include `min_replica_count`, `max_replica_count`, `required_replica_count`, `autoscaling_metric_specs`, `disable_container_logging` (v1 only), and `enable_container_logging` (v1beta1 only). * * POST /v1/projects/{projectsId}/locations/{locationsId}/endpoints/{endpointsId}:mutateDeployedModel * * Also accepts auth: Oauth2 + Oauth2c */ export const createApiV1ProjectsProjectsIdLocationsLocationsIdEndpointsEndpointsIdMutateDeployedModel = async (args: CreateApiV1ProjectsProjectsIdLocationsLocationsIdEndpointsEndpointsIdMutateDeployedModelArgs, options?: CreateApiV1ProjectsProjectsIdLocationsLocationsIdEndpointsEndpointsIdMutateDeployedModelOptions) => { 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 (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))}/endpoints/${encodeURIComponent(String(args.endpointsId))}:mutateDeployedModel${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(googleLongrunningOperation, await res.json()) };