import {z} from 'zod' export type GoogleCloudDataprocV1WorkflowTemplateEncryptionConfig = {kmsKey?: string | undefined}; export type LoggingConfig = {driverLogLevels?: ({[key: string]: 'LEVEL_UNSPECIFIED' | 'ALL' | 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL' | 'OFF'}) | undefined}; export type FlinkJob = {args?: Array | undefined, jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, mainClass?: string | undefined, mainJarFileUri?: string | undefined, properties?: {[key: string]: string} | undefined, savepointUri?: string | undefined}; export type HadoopJob = {archiveUris?: Array | undefined, args?: Array | undefined, fileUris?: Array | undefined, jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, mainClass?: string | undefined, mainJarFileUri?: string | undefined, properties?: {[key: string]: string} | undefined}; export type QueryList = {queries?: Array | undefined}; export type HiveJob = {continueOnFailure?: boolean | undefined, jarFileUris?: Array | undefined, properties?: {[key: string]: string} | undefined, queryFileUri?: string | undefined, queryList?: QueryList | undefined, scriptVariables?: {[key: string]: string} | undefined}; export type PigJob = {continueOnFailure?: boolean | undefined, jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, properties?: {[key: string]: string} | undefined, queryFileUri?: string | undefined, queryList?: QueryList | undefined, scriptVariables?: {[key: string]: string} | undefined}; export type PrestoJob = {clientTags?: Array | undefined, continueOnFailure?: boolean | undefined, loggingConfig?: LoggingConfig | undefined, outputFormat?: string | undefined, properties?: {[key: string]: string} | undefined, queryFileUri?: string | undefined, queryList?: QueryList | undefined}; export type PySparkJob = {archiveUris?: Array | undefined, args?: Array | undefined, fileUris?: Array | undefined, jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, mainPythonFileUri?: string | undefined, properties?: {[key: string]: string} | undefined, pythonFileUris?: Array | undefined}; export type JobScheduling = {maxFailuresPerHour?: number | undefined, maxFailuresTotal?: number | undefined}; export type SparkJob = {archiveUris?: Array | undefined, args?: Array | undefined, fileUris?: Array | undefined, jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, mainClass?: string | undefined, mainJarFileUri?: string | undefined, properties?: {[key: string]: string} | undefined}; export type SparkRJob = {archiveUris?: Array | undefined, args?: Array | undefined, fileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, mainRFileUri?: string | undefined, properties?: {[key: string]: string} | undefined}; export type SparkSqlJob = {jarFileUris?: Array | undefined, loggingConfig?: LoggingConfig | undefined, properties?: {[key: string]: string} | undefined, queryFileUri?: string | undefined, queryList?: QueryList | undefined, scriptVariables?: {[key: string]: string} | undefined}; export type TrinoJob = {clientTags?: Array | undefined, continueOnFailure?: boolean | undefined, loggingConfig?: LoggingConfig | undefined, outputFormat?: string | undefined, properties?: {[key: string]: string} | undefined, queryFileUri?: string | undefined, queryList?: QueryList | undefined}; export type OrderedJob = {flinkJob?: FlinkJob | undefined, hadoopJob?: HadoopJob | undefined, hiveJob?: HiveJob | undefined, labels?: {[key: string]: string} | undefined, pigJob?: PigJob | undefined, prerequisiteStepIds?: Array | undefined, prestoJob?: PrestoJob | undefined, pysparkJob?: PySparkJob | undefined, scheduling?: JobScheduling | undefined, sparkJob?: SparkJob | undefined, sparkRJob?: SparkRJob | undefined, sparkSqlJob?: SparkSqlJob | undefined, stepId?: string | undefined, trinoJob?: TrinoJob | undefined}; export type RegexValidation = {regexes?: Array | undefined}; export type ValueValidation = {values?: Array | undefined}; export type ParameterValidation = {regex?: RegexValidation | undefined, values?: ValueValidation | undefined}; export type TemplateParameter = {description?: string | undefined, fields?: Array | undefined, name?: string | undefined, validation?: ParameterValidation | undefined}; export type ClusterSelector = {clusterLabels?: {[key: string]: string} | undefined, zone?: string | undefined}; export type AutoscalingConfig = {policyUri?: string | undefined}; export type AcceleratorConfig = {acceleratorCount?: number | undefined, acceleratorTypeUri?: string | undefined}; export type AttachedDiskConfig = {diskSizeGb?: number | undefined, diskType?: ('DISK_TYPE_UNSPECIFIED' | 'HYPERDISK_BALANCED' | 'HYPERDISK_EXTREME' | 'HYPERDISK_ML' | 'HYPERDISK_THROUGHPUT') | undefined, provisionedIops?: unknown | undefined, provisionedThroughput?: unknown | undefined, type?: string | undefined}; export type DiskConfig = {attachedDiskConfigs?: Array | undefined, bootDiskProvisionedIops?: unknown | undefined, bootDiskProvisionedThroughput?: unknown | undefined, bootDiskSizeGb?: number | undefined, bootDiskType?: string | undefined, localSsdInterface?: string | undefined, numLocalSsds?: number | undefined}; export type InstanceSelection = {diskConfig?: DiskConfig | undefined, machineTypes?: Array | undefined, rank?: number | undefined}; export type InstanceSelectionResult = {machineType?: string | undefined, vmCount?: number | undefined}; export type ProvisioningModelMix = {standardCapacityBase?: number | undefined, standardCapacityPercentAboveBase?: number | undefined}; export type InstanceFlexibilityPolicy = {instanceMachineTypes?: {[key: string]: string} | undefined, instanceSelectionList?: Array | undefined, instanceSelectionResults?: Array | undefined, provisioningModelMix?: ProvisioningModelMix | undefined}; export type InstanceReference = {instanceId?: string | undefined, instanceName?: string | undefined, publicEciesKey?: string | undefined, publicKey?: string | undefined}; export type ManagedGroupConfig = {instanceGroupManagerName?: string | undefined, instanceGroupManagerUri?: string | undefined, instanceTemplateName?: string | undefined}; export type StartupConfig = {requiredRegistrationFraction?: number | undefined}; export type InstanceGroupConfig = {accelerators?: Array | undefined, diskConfig?: DiskConfig | undefined, imageUri?: string | undefined, instanceFlexibilityPolicy?: InstanceFlexibilityPolicy | undefined, instanceNames?: Array | undefined, instanceReferences?: Array | undefined, isPreemptible?: boolean | undefined, machineTypeUri?: string | undefined, managedGroupConfig?: ManagedGroupConfig | undefined, minCpuPlatform?: string | undefined, minNumInstances?: number | undefined, numInstances?: number | undefined, preemptibility?: ('PREEMPTIBILITY_UNSPECIFIED' | 'NON_PREEMPTIBLE' | 'PREEMPTIBLE' | 'SPOT') | undefined, startupConfig?: StartupConfig | undefined}; export type NodeGroup = {labels?: {[key: string]: string} | undefined, name?: string | undefined, nodeGroupConfig?: InstanceGroupConfig | undefined, roles?: (Array<'ROLE_UNSPECIFIED' | 'DRIVER'>) | undefined}; export type AuxiliaryNodeGroup = {nodeGroup?: NodeGroup | undefined, nodeGroupId?: string | undefined}; export type Metric = {metricOverrides?: Array | undefined, metricSource?: ('METRIC_SOURCE_UNSPECIFIED' | 'MONITORING_AGENT_DEFAULTS' | 'HDFS' | 'SPARK' | 'YARN' | 'SPARK_HISTORY_SERVER' | 'HIVESERVER2' | 'HIVEMETASTORE' | 'FLINK') | undefined}; export type DataprocMetricConfig = {metrics?: Array | undefined}; export type EncryptionConfig = {gcePdKmsKeyName?: string | undefined, kmsKey?: string | undefined}; export type EndpointConfig = {enableHttpPortAccess?: boolean | undefined, httpPorts?: {[key: string]: string} | undefined}; export type ConfidentialInstanceConfig = {confidentialInstanceType?: ('CONFIDENTIAL_INSTANCE_TYPE_UNSPECIFIED' | 'SEV' | 'SEV_SNP' | 'TDX') | undefined, enableConfidentialCompute?: boolean | undefined}; export type MultiZoneConfig = {targetShape?: ('TARGET_SHAPE_UNSPECIFIED' | 'ANY') | undefined}; export type NodeGroupAffinity = {nodeGroupUri?: string | undefined}; export type ReservationAffinity = {consumeReservationType?: ('TYPE_UNSPECIFIED' | 'NO_RESERVATION' | 'ANY_RESERVATION' | 'SPECIFIC_RESERVATION') | undefined, key?: string | undefined, values?: Array | undefined}; export type ShieldedInstanceConfig = {enableIntegrityMonitoring?: boolean | undefined, enableSecureBoot?: boolean | undefined, enableVtpm?: boolean | undefined}; export type GceClusterConfig = {autoZoneExcludeZoneUris?: Array | undefined, confidentialInstanceConfig?: ConfidentialInstanceConfig | undefined, internalIpOnly?: boolean | undefined, metadata?: {[key: string]: string} | undefined, multiZoneConfig?: MultiZoneConfig | undefined, networkUri?: string | undefined, nodeGroupAffinity?: NodeGroupAffinity | undefined, privateIpv6GoogleAccess?: ('PRIVATE_IPV6_GOOGLE_ACCESS_UNSPECIFIED' | 'INHERIT_FROM_SUBNETWORK' | 'OUTBOUND' | 'BIDIRECTIONAL') | undefined, reservationAffinity?: ReservationAffinity | undefined, resourceManagerTags?: {[key: string]: string} | undefined, serviceAccount?: string | undefined, serviceAccountScopes?: Array | undefined, shieldedInstanceConfig?: ShieldedInstanceConfig | undefined, subnetworkUri?: string | undefined, tags?: Array | undefined, zoneUri?: string | undefined}; export type NamespacedGkeDeploymentTarget = {clusterNamespace?: string | undefined, targetGkeCluster?: string | undefined}; export type GkeNodePoolAutoscalingConfig = {maxNodeCount?: number | undefined, minNodeCount?: number | undefined}; export type GkeNodePoolAcceleratorConfig = {acceleratorCount?: unknown | undefined, acceleratorType?: string | undefined, gpuPartitionSize?: string | undefined}; export type GkeNodeConfig = {accelerators?: Array | undefined, bootDiskKmsKey?: string | undefined, localSsdCount?: number | undefined, machineType?: string | undefined, minCpuPlatform?: string | undefined, preemptible?: boolean | undefined, serviceAccount?: string | undefined, spot?: boolean | undefined}; export type GkeNodePoolConfig = {autoscaling?: GkeNodePoolAutoscalingConfig | undefined, config?: GkeNodeConfig | undefined, locations?: Array | undefined}; export type GkeNodePoolTarget = {nodePool?: string | undefined, nodePoolConfig?: GkeNodePoolConfig | undefined, roles?: (Array<'ROLE_UNSPECIFIED' | 'DEFAULT' | 'CONTROLLER' | 'SPARK_DRIVER' | 'SPARK_EXECUTOR'>) | undefined}; export type GkeClusterConfig = {gkeClusterTarget?: string | undefined, namespacedGkeDeploymentTarget?: NamespacedGkeDeploymentTarget | undefined, nodePoolTarget?: Array | undefined}; export type NodeInitializationAction = {executableFile?: string | undefined, executionTimeout?: unknown | undefined}; export type LifecycleConfig = {autoDeleteTime?: unknown | undefined, autoDeleteTtl?: unknown | undefined, autoStopTime?: unknown | undefined, autoStopTtl?: unknown | undefined, idleDeleteTtl?: unknown | undefined, idleStartTime?: unknown | undefined, idleStopTtl?: unknown | undefined}; export type FlexibleInstanceGroupConfig = {bootDiskSizeGb?: number | undefined, coreCount?: number | undefined, hardwareClass?: ('HARDWARE_CLASS_UNSPECIFIED' | 'STANDARD' | 'PERFORMANCE') | undefined, numInstances?: number | undefined}; export type MetastoreConfig = {dataprocMetastoreService?: string | undefined}; export type SchedulingConfig = {requestedRunDuration?: unknown | undefined, schedulingTimeout?: unknown | undefined}; export type IdentityConfig = {enableSsh?: boolean | undefined, userServiceAccountMapping?: {[key: string]: string} | undefined}; export type KerberosConfig = {crossRealmTrustAdminServer?: string | undefined, crossRealmTrustKdc?: string | undefined, crossRealmTrustRealm?: string | undefined, crossRealmTrustSharedPasswordUri?: string | undefined, enableKerberos?: boolean | undefined, kdcDbKeyUri?: string | undefined, keyPasswordUri?: string | undefined, keystorePasswordUri?: string | undefined, keystoreUri?: string | undefined, kmsKeyUri?: string | undefined, realm?: string | undefined, rootPrincipalPasswordUri?: string | undefined, tgtLifetimeHours?: number | undefined, truststorePasswordUri?: string | undefined, truststoreUri?: string | undefined}; export type SecurityConfig = {identityConfig?: IdentityConfig | undefined, kerberosConfig?: KerberosConfig | undefined}; export type SoftwareConfig = {imageVersion?: string | undefined, optionalComponents?: (Array<'COMPONENT_UNSPECIFIED' | 'ALLOYDB_CONNECTOR' | 'ANACONDA' | 'DELTA' | 'DOCKER' | 'DRUID' | 'FLINK' | 'HBASE' | 'HIVE_WEBHCAT' | 'HUDI' | 'ICEBERG' | 'JUPYTER' | 'PIG' | 'PRESTO' | 'TRINO' | 'RANGER' | 'SOLR' | 'ZEPPELIN' | 'ZOOKEEPER' | 'JUPYTER_KERNEL_GATEWAY'>) | undefined, properties?: {[key: string]: string} | undefined}; export type ClusterConfig = {autoscalingConfig?: AutoscalingConfig | undefined, auxiliaryNodeGroups?: Array | undefined, clusterTier?: ('CLUSTER_TIER_UNSPECIFIED' | 'CLUSTER_TIER_STANDARD' | 'CLUSTER_TIER_PREMIUM') | undefined, clusterType?: ('CLUSTER_TYPE_UNSPECIFIED' | 'STANDARD' | 'SINGLE_NODE' | 'ZERO_SCALE') | undefined, configBucket?: string | undefined, dataprocMetricConfig?: DataprocMetricConfig | undefined, diagnosticBucket?: string | undefined, encryptionConfig?: EncryptionConfig | undefined, endpointConfig?: EndpointConfig | undefined, engine?: ('ENGINE_UNSPECIFIED' | 'DEFAULT' | 'LIGHTNING') | undefined, gceClusterConfig?: GceClusterConfig | undefined, gkeClusterConfig?: GkeClusterConfig | undefined, initializationActions?: Array | undefined, lifecycleConfig?: LifecycleConfig | undefined, masterConfig?: InstanceGroupConfig | undefined, masterFlexibleConfig?: FlexibleInstanceGroupConfig | undefined, metastoreConfig?: MetastoreConfig | undefined, schedulingConfig?: SchedulingConfig | undefined, secondaryWorkerConfig?: InstanceGroupConfig | undefined, secondaryWorkerFlexibleConfig?: FlexibleInstanceGroupConfig | undefined, securityConfig?: SecurityConfig | undefined, softwareConfig?: SoftwareConfig | undefined, tempBucket?: string | undefined, workerConfig?: InstanceGroupConfig | undefined, workerFlexibleConfig?: FlexibleInstanceGroupConfig | undefined}; export type ManagedCluster = {clusterName?: string | undefined, config?: ClusterConfig | undefined, labels?: {[key: string]: string} | undefined}; export type WorkflowTemplatePlacement = {clusterSelector?: ClusterSelector | undefined, managedCluster?: ManagedCluster | undefined}; export type WorkflowTemplate = {createTime?: unknown | undefined, dagTimeout?: unknown | undefined, encryptionConfig?: GoogleCloudDataprocV1WorkflowTemplateEncryptionConfig | undefined, id?: string | undefined, jobs?: Array | undefined, labels?: {[key: string]: string} | undefined, name?: string | undefined, parameters?: Array | undefined, placement?: WorkflowTemplatePlacement | undefined, updateTime?: unknown | undefined, version?: number | undefined}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdWorkflowTemplatesInstantiateInlineArgs = {projectsId: string, locationsId: string, requestId?: string | undefined, body: WorkflowTemplate}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdWorkflowTemplatesInstantiateInlineOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const status = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const operation = z.object({done: z.boolean().optional(), error: status.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 }; /** * Instantiates a template and begins execution.This method is equivalent to executing the sequence CreateWorkflowTemplate, InstantiateWorkflowTemplate, DeleteWorkflowTemplate.The returned Operation can be used to track execution of workflow by polling operations.get. The Operation will complete when entire workflow is finished.The running workflow can be aborted via operations.cancel. This will cause any inflight jobs to be cancelled and workflow-owned clusters to be deleted.The Operation.metadata will be WorkflowMetadata (https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). Also see Using WorkflowMetadata (https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata).On successful completion, Operation.response will be Empty. * * POST /v1/projects/{projectsId}/locations/{locationsId}/workflowTemplates:instantiateInline * * Also accepts auth: Oauth2 + Oauth2c */ export const createApiV1ProjectsProjectsIdLocationsLocationsIdWorkflowTemplatesInstantiateInline = async (args: CreateApiV1ProjectsProjectsIdLocationsLocationsIdWorkflowTemplatesInstantiateInlineArgs, options?: CreateApiV1ProjectsProjectsIdLocationsLocationsIdWorkflowTemplatesInstantiateInlineOptions) => { const {baseUrl = "https://dataproc.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.requestId != null) query.append("requestId", String(args.requestId)) 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))}/workflowTemplates:instantiateInline${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(operation, await res.json()) };