import {z} from 'zod' 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 ClusterMetrics = {hdfsMetrics?: {[key: string]: unknown} | undefined, yarnMetrics?: {[key: string]: unknown} | undefined}; export type ClusterStatus = {detail?: string | undefined, state?: ('UNKNOWN' | 'CREATING' | 'RUNNING' | 'ERROR' | 'ERROR_DUE_TO_UPDATE' | 'DELETING' | 'UPDATING' | 'STOPPING' | 'STOPPED' | 'STARTING' | 'REPAIRING' | 'SCHEDULED') | undefined, stateStartTime?: unknown | undefined, substate?: ('UNSPECIFIED' | 'UNHEALTHY' | 'STALE_STATUS') | undefined}; export type SparkHistoryServerConfig = {dataprocCluster?: string | undefined}; export type AuxiliaryServicesConfig = {metastoreConfig?: MetastoreConfig | undefined, sparkHistoryServerConfig?: SparkHistoryServerConfig | undefined}; export type KubernetesSoftwareConfig = {componentVersion?: {[key: string]: string} | undefined, properties?: {[key: string]: string} | undefined}; export type KubernetesClusterConfig = {gkeClusterConfig?: GkeClusterConfig | undefined, kubernetesNamespace?: string | undefined, kubernetesSoftwareConfig?: KubernetesSoftwareConfig | undefined}; export type VirtualClusterConfig = {auxiliaryServicesConfig?: AuxiliaryServicesConfig | undefined, kubernetesClusterConfig?: KubernetesClusterConfig | undefined, stagingBucket?: string | undefined}; export type Cluster = {clusterName?: string | undefined, clusterUuid?: string | undefined, config?: ClusterConfig | undefined, labels?: {[key: string]: string} | undefined, metrics?: ClusterMetrics | undefined, projectId?: string | undefined, status?: ClusterStatus | undefined, statusHistory?: Array | undefined, virtualClusterConfig?: VirtualClusterConfig | undefined}; export type CreateApiV1ProjectsProjectIdRegionsRegionClustersArgs = {projectId: string, region: string, actionOnFailedPrimaryWorkers?: ('FAILURE_ACTION_UNSPECIFIED' | 'NO_ACTION' | 'DELETE') | undefined, requestId?: string | undefined, body: Cluster}; export type CreateApiV1ProjectsProjectIdRegionsRegionClustersOptions = {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 }; /** * Creates a cluster in a project. The returned Operation.metadata will be ClusterOperationMetadata (https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). * * POST /v1/projects/{projectId}/regions/{region}/clusters * * Also accepts auth: Oauth2 + Oauth2c */ export const createApiV1ProjectsProjectIdRegionsRegionClusters = async (args: CreateApiV1ProjectsProjectIdRegionsRegionClustersArgs, options?: CreateApiV1ProjectsProjectIdRegionsRegionClustersOptions) => { 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.actionOnFailedPrimaryWorkers != null) query.append("actionOnFailedPrimaryWorkers", String(args.actionOnFailedPrimaryWorkers)) 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.projectId))}/regions/${encodeURIComponent(String(args.region))}/clusters${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()) };