import {z} from 'zod' export type AirflowMetadataRetentionPolicyConfig = {retentionDays?: number | undefined, retentionMode?: ('RETENTION_MODE_UNSPECIFIED' | 'RETENTION_MODE_ENABLED' | 'RETENTION_MODE_DISABLED') | undefined}; export type TaskLogsRetentionConfig = {storageMode?: ('TASK_LOGS_STORAGE_MODE_UNSPECIFIED' | 'CLOUD_LOGGING_AND_CLOUD_STORAGE' | 'CLOUD_LOGGING_ONLY') | undefined}; export type DataRetentionConfig = {airflowMetadataRetentionConfig?: AirflowMetadataRetentionPolicyConfig | undefined, taskLogsRetentionConfig?: TaskLogsRetentionConfig | undefined}; export type DatabaseConfig = {machineType?: string | undefined, zone?: string | undefined}; export type EncryptionConfig = {kmsKeyName?: string | undefined}; export type MaintenanceWindow = {endTime?: unknown | undefined, recurrence?: string | undefined, startTime?: unknown | undefined}; export type CidrBlock = {cidrBlock?: string | undefined, displayName?: string | undefined}; export type MasterAuthorizedNetworksConfig = {cidrBlocks?: Array | undefined, enabled?: boolean | undefined}; export type IPAllocationPolicy = {clusterIpv4CidrBlock?: string | undefined, clusterSecondaryRangeName?: string | undefined, servicesIpv4CidrBlock?: string | undefined, servicesSecondaryRangeName?: string | undefined, useIpAliases?: boolean | undefined}; export type NodeConfig = {composerInternalIpv4CidrBlock?: string | undefined, composerNetworkAttachment?: string | undefined, diskSizeGb?: number | undefined, enableIpMasqAgent?: boolean | undefined, ipAllocationPolicy?: IPAllocationPolicy | undefined, location?: string | undefined, machineType?: string | undefined, network?: string | undefined, oauthScopes?: Array | undefined, serviceAccount?: string | undefined, subnetwork?: string | undefined, tags?: Array | undefined}; export type NetworkingConfig = {connectionType?: ('CONNECTION_TYPE_UNSPECIFIED' | 'VPC_PEERING' | 'PRIVATE_SERVICE_CONNECT') | undefined}; export type PrivateClusterConfig = {enablePrivateEndpoint?: boolean | undefined, masterIpv4CidrBlock?: string | undefined, masterIpv4ReservedRange?: string | undefined}; export type PrivateEnvironmentConfig = {cloudComposerConnectionSubnetwork?: string | undefined, cloudComposerNetworkIpv4CidrBlock?: string | undefined, cloudComposerNetworkIpv4ReservedRange?: string | undefined, cloudSqlIpv4CidrBlock?: string | undefined, enablePrivateBuildsOnly?: boolean | undefined, enablePrivateEnvironment?: boolean | undefined, enablePrivatelyUsedPublicIps?: boolean | undefined, networkingConfig?: NetworkingConfig | undefined, networkingType?: ('NETWORKING_TYPE_UNSPECIFIED' | 'PRIVATE' | 'PUBLIC') | undefined, privateClusterConfig?: PrivateClusterConfig | undefined, webServerIpv4CidrBlock?: string | undefined, webServerIpv4ReservedRange?: string | undefined}; export type ScheduledSnapshotsConfig = {enabled?: boolean | undefined, snapshotCreationSchedule?: string | undefined, snapshotLocation?: string | undefined, timeZone?: string | undefined}; export type RecoveryConfig = {scheduledSnapshotsConfig?: ScheduledSnapshotsConfig | undefined}; export type CloudDataLineageIntegration = {enabled?: boolean | undefined}; export type ImageVersionRollbackTarget = {imageVersion?: string | undefined, lastActiveTime?: unknown | undefined}; export type SoftwareConfig = {airflowConfigOverrides?: {[key: string]: string} | undefined, auditLogsReplicationMode?: ('AUDIT_LOGS_REPLICATION_MODE_UNSPECIFIED' | 'AUDIT_LOGS_REPLICATION_DISABLED' | 'AUDIT_LOGS_REPLICATION_ENABLED') | undefined, cloudDataLineageIntegration?: CloudDataLineageIntegration | undefined, envVariables?: {[key: string]: string} | undefined, imageVersion?: string | undefined, imageVersionRollbackTargets?: Array | undefined, pypiPackages?: {[key: string]: string} | undefined, pythonVersion?: string | undefined, schedulerCount?: number | undefined, webServerPluginsMode?: ('WEB_SERVER_PLUGINS_MODE_UNSPECIFIED' | 'PLUGINS_DISABLED' | 'PLUGINS_ENABLED') | undefined}; export type WebServerConfig = {machineType?: string | undefined}; export type AllowedIpRange = {description?: string | undefined, value?: string | undefined}; export type WebServerNetworkAccessControl = {allowedIpRanges?: Array | undefined}; export type DagProcessorResource = {count?: number | undefined, cpu?: number | undefined, memoryGb?: number | undefined, storageGb?: number | undefined}; export type SchedulerResource = {count?: number | undefined, cpu?: number | undefined, memoryGb?: number | undefined, storageGb?: number | undefined}; export type TriggererResource = {count?: number | undefined, cpu?: number | undefined, memoryGb?: number | undefined}; export type WebServerResource = {cpu?: number | undefined, memoryGb?: number | undefined, storageGb?: number | undefined}; export type WorkerResource = {cpu?: number | undefined, maxCount?: number | undefined, memoryGb?: number | undefined, minCount?: number | undefined, storageGb?: number | undefined}; export type WorkloadsConfig = {dagProcessor?: DagProcessorResource | undefined, scheduler?: SchedulerResource | undefined, triggerer?: TriggererResource | undefined, webServer?: WebServerResource | undefined, worker?: WorkerResource | undefined}; export type EnvironmentConfig = {airflowByoidUri?: string | undefined, airflowUri?: string | undefined, dagGcsPrefix?: string | undefined, dataRetentionConfig?: DataRetentionConfig | undefined, databaseConfig?: DatabaseConfig | undefined, encryptionConfig?: EncryptionConfig | undefined, environmentSize?: ('ENVIRONMENT_SIZE_UNSPECIFIED' | 'ENVIRONMENT_SIZE_SMALL' | 'ENVIRONMENT_SIZE_MEDIUM' | 'ENVIRONMENT_SIZE_LARGE' | 'ENVIRONMENT_SIZE_EXTRA_LARGE' | 'ENVIRONMENT_SIZE_X_EXTRA_LARGE') | undefined, gkeCluster?: string | undefined, maintenanceWindow?: MaintenanceWindow | undefined, masterAuthorizedNetworksConfig?: MasterAuthorizedNetworksConfig | undefined, nodeConfig?: NodeConfig | undefined, nodeCount?: number | undefined, privateEnvironmentConfig?: PrivateEnvironmentConfig | undefined, recoveryConfig?: RecoveryConfig | undefined, resilienceMode?: ('RESILIENCE_MODE_UNSPECIFIED' | 'HIGH_RESILIENCE') | undefined, softwareConfig?: SoftwareConfig | undefined, webServerConfig?: WebServerConfig | undefined, webServerNetworkAccessControl?: WebServerNetworkAccessControl | undefined, workloadsConfig?: WorkloadsConfig | undefined}; export type StorageConfig = {bucket?: string | undefined}; export type Environment = {config?: EnvironmentConfig | undefined, createTime?: unknown | undefined, labels?: {[key: string]: string} | undefined, mode?: ('MODE_UNSPECIFIED' | 'DEVELOPMENT') | undefined, name?: string | undefined, satisfiesPzi?: boolean | undefined, satisfiesPzs?: boolean | undefined, state?: ('STATE_UNSPECIFIED' | 'CREATING' | 'RUNNING' | 'UPDATING' | 'HIBERNATED' | 'DELETING' | 'ERROR') | undefined, storageConfig?: StorageConfig | undefined, updateTime?: unknown | undefined, uuid?: string | undefined}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdEnvironmentsEnvironmentsIdArgs = {projectsId: string, locationsId: string, environmentsId: string, updateMask?: unknown | undefined, body: Environment}; export type PatchApiV1ProjectsProjectsIdLocationsLocationsIdEnvironmentsEnvironmentsIdOptions = {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 }; /** * Update an environment. * * PATCH /v1/projects/{projectsId}/locations/{locationsId}/environments/{environmentsId} * * Also accepts auth: Oauth2 + Oauth2c */ export const patchApiV1ProjectsProjectsIdLocationsLocationsIdEnvironmentsEnvironmentsId = async (args: PatchApiV1ProjectsProjectsIdLocationsLocationsIdEnvironmentsEnvironmentsIdArgs, options?: PatchApiV1ProjectsProjectsIdLocationsLocationsIdEnvironmentsEnvironmentsIdOptions) => { const {baseUrl = "https://composer.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))}/environments/${encodeURIComponent(String(args.environmentsId))}${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(operation, await res.json()) };