
    (                        S r SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SS	K
Jr  SS
K
Jr  \	R"                  R$                  4S jr " S S5      rS rS rS rS rS r\	R"                  R$                  4S jr\	R"                  R$                  4S jr\	R"                  R8                  4S jr\	R"                  R8                  4S jr\	R"                  R8                  4S jr\	R"                  R8                  4S jr \	R"                  R8                  4S jr!\	R"                  R8                  4S jr"\	R"                  R8                  4S jr#\	R"                  R$                  4S jr$\	R"                  RJ                  4S jr&\	R"                  R$                  4S jr'S\	R"                  R$                  4S  jr(\	R"                  R$                  4S! jr)S" r*S# r+S$ r,S% r-g)&z4Utilities for calling the Composer Environments API.    )
exceptions)util)base)CONNECTION_TYPE_FLAG_ALPHA)CONNECTION_TYPE_FLAG_BETA)CONNECTION_TYPE_FLAG_GA)ENVIRONMENT_SIZE_ALPHA)ENVIRONMENT_SIZE_BETA)ENVIRONMENT_SIZE_GAc                 B    [         R                  " U 5      R                  $ N)api_utilGetClientInstanceprojects_locations_environmentsrelease_tracks    8lib/googlecloudsdk/api_lib/composer/environments_util.py
GetServicer      s    		#	#
445    c            P           \ rS rSrSrSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\R                  R                  SSSSSSSSSSSSSSSSSSSSSSS4PS jrSr	g)CreateEnvironmentFlags#   am"  Container holding environment creation flag values.

Attributes:
  node_count: int or None, the number of VMs to create for the environment
  environment_size: str or None, one of small, medium and large.
  labels: dict(str->str), a dict of user-provided resource labels to apply to
    the environment and its downstream resources
  location: str or None, the Compute Engine zone in which to create the
    environment specified as relative resource name.
  machine_type: str or None, the Compute Engine machine type of the VMs to
    create specified as relative resource name.
  network: str or None, the Compute Engine network to which to connect the
    environment specified as relative resource name.
  subnetwork: str or None, the Compute Engine subnetwork to which to connect
    the environment specified as relative resource name.
  network_attachment: str or None, the Compute Engine network attachment that
    is used as PSC Network entry point.
  env_variables: dict(str->str), a dict of user-provided environment variables
    to provide to the Airflow scheduler, worker, and webserver processes.
  airflow_config_overrides: dict(str->str), a dict of user-provided Airflow
    configuration overrides.
  service_account: str or None, the user-provided service account
  oauth_scopes: [str], the user-provided OAuth scopes
  tags: [str], the user-provided networking tags
  disk_size_gb: int, the disk size of node VMs, in GB
  python_version: str or None, major python version to use within created
    environment.
  image_version: str or None, the desired image for created environment in the
    format of 'composer-(version)-airflow-(version)'
  airflow_executor_type: str or None, the airflow executor type to run task
    instances.
  use_ip_aliases: bool or None, create env cluster nodes using alias IPs.
  cluster_secondary_range_name: str or None, the name of secondary range to
    allocate IP addresses to pods in GKE cluster.
  services_secondary_range_name: str or None, the name of the secondary range
    to allocate IP addresses to services in GKE cluster.
  cluster_ipv4_cidr_block: str or None, the IP address range to allocate IP
    adresses to pods in GKE cluster.
  services_ipv4_cidr_block: str or None, the IP address range to allocate IP
    addresses to services in GKE cluster.
  max_pods_per_node: int or None, the maximum number of pods that can be
    assigned to a GKE cluster node.
  enable_ip_masq_agent: bool or None, when enabled, the GKE IP Masq Agent is
    deployed to the cluster.
  enable_private_environment: bool or None, create env cluster nodes with no
    public IP addresses.
  disable_private_environment: bool or None, disable private environment.
  private_endpoint: bool or None, managed env cluster using the private IP
    address of the master API endpoint.
  master_ipv4_cidr: IPv4 CIDR range to use for the cluster master network.
  privately_used_public_ips: bool or None, when enabled, GKE pod and services
    can use IPs from public (non-RFC1918) ranges.
  web_server_ipv4_cidr: IPv4 CIDR range to use for Web Server network.
  cloud_sql_ipv4_cidr: IPv4 CIDR range to use for Cloud SQL network.
  composer_network_ipv4_cidr: IPv4 CIDR range to use for Composer network.
  connection_subnetwork: str or None, the Compute Engine subnetwork from which
    to reserve the IP address for internal connections, specified as relative
    resource name.
  connection_type: str or None, mode of internal connectivity within the Cloud
    Composer environment. Can be VPC_PEERING or PRIVATE_SERVICE_CONNECT.
  web_server_access_control: [{string: string}], List of IP ranges with
    descriptions to allow access to the web server.
  cloud_sql_machine_type: str or None, Cloud SQL machine type used by the
    Airflow database.
  cloud_sql_preferred_zone: str or None, Cloud SQL db preferred zone. Can be
    specified only in Composer 2.0.0.
  web_server_machine_type: str or None, machine type used by the Airflow web
    server
  kms_key: str or None, the user-provided customer-managed encryption key
    resource name
  scheduler_cpu: float or None, CPU allocated to Airflow scheduler. Can be
    specified only in Composer 2.0.0.
  worker_cpu: float or None, CPU allocated to each Airflow worker. Can be
    specified only in Composer 2.0.0.
  web_server_cpu: float or None, CPU allocated to Airflow web server. Can be
    specified only in Composer 2.0.0.
  scheduler_memory_gb: float or None, memory allocated to Airflow scheduler.
    Can be specified only in Composer 2.0.0.
  worker_memory_gb: float or None, memory allocated to each Airflow worker.
    Can be specified only in Composer 2.0.0.
  web_server_memory_gb: float or None, memory allocated to Airflow web server.
    Can be specified only in Composer 2.0.0.
  scheduler_storage_gb: float or None, storage allocated to Airflow scheduler.
    Can be specified only in Composer 2.0.0.
  worker_storage_gb: float or None, storage allocated to each Airflow worker.
    Can be specified only in Composer 2.0.0.
  web_server_storage_gb: float or None, storage allocated to Airflow web
    server. Can be specified only in Composer 2.0.0.
  min_workers: int or None, minimum number of workers in the Environment. Can
    be specified only in Composer 2.0.0.
  max_workers: int or None, maximum number of workers in the Environment. Can
    be specified only in Composer 2.0.0.
  scheduler_count: int or None, number of schedulers in the Environment.
  maintenance_window_start: Datetime or None, the starting time of the
    maintenance window
  maintenance_window_end: Datetime or None, the ending time of the maintenance
    window
  maintenance_window_recurrence: str or None, the recurrence of the
    maintenance window
  enable_master_authorized_networks: bool or None, whether master authorized
    networks should be enabled
  master_authorized_networks: list(str), master authorized networks
  airflow_database_retention_days: Optional[int], the number of retention days
    for airflow database data retention mechanism. Infinite retention will be
    applied in case `0` or no integer is provided.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.
  enable_triggerer: bool or None, enable triggerer in the Environment. Can be
    specified only in Airflow 2.2.x and greater
  triggerer_cpu: float or None, CPU allocated to Airflow triggerer. Can be
    specified only in Airflow 2.2.x and greater
  triggerer_count: int or None, number of Airflow triggerers. Can be specified
    only in Airflow 2.2.x and greater
  triggerer_memory_gb: float or None, memory allocated to Airflow triggerer.
    Can be specified only in Airflow 2.2.x and greater
  enable_scheduled_snapshot_creation: bool or None, whether the automatic
    snapshot creation should be enabled
  snapshot_creation_schedule: str or None, cron expression that specifies when
    snapshots will be created
  snapshot_location: str or None, a Cloud Storage location used to store
    automatically created snapshots
  snapshot_schedule_timezone: str or None, time zone that sets the context to
    interpret snapshot_creation_schedule
  enable_cloud_data_lineage_integration: bool or None, whether Cloud Data
    Lineage integration should be enabled
  disable_cloud_data_lineage_integration: bool or None, whether Cloud Data
    Lineage integration should be disabled
  enable_high_resilience: bool or None, whether high resilience should be
    enabled
  enable_logs_in_cloud_logging_only: bool or None, whether logs in cloud
    logging only should be enabled
  disable_logs_in_cloud_logging_only: bool or None, whether logs in cloud
    logging only should be disabled
  support_web_server_plugins: bool or None, whether to enable/disable the
    support for web server plugins
  dag_processor_cpu: float or None, CPU allocated to Airflow dag processor.
    Can be specified only in Composer 3.
  dag_processor_count: int or None, number of Airflow dag processors. Can be
    specified only in Composer 3.
  dag_processor_memory_gb: float or None, memory allocated to Airflow dag
    processor. Can be specified only in Composer 3.
  dag_processor_storage_gb: float or None, storage allocated to Airflow dag
    processor. Can be specified only in Composer 3.
  composer_internal_ipv4_cidr_block: str or None. The IP range in CIDR
    notation to use internally by Cloud Composer. Can be specified only in
    Composer 3.
  enable_private_builds_only: bool or None, whether to enable the support for
    private only builds.
  disable_private_builds_only: bool or None, whether to disable the support
    for private only builds.
  storage_bucket: str or None. An existing Cloud Storage bucket to be used by
    the environment.
NcQ                 F   Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        Xl        Xl        Xl        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        U U l        U!U l         U"U l!        U#U l"        U$U l#        U%U l$        U&U l%        U'U l&        U(U l'        U)U l(        U*U l)        U+U l*        U,U l+        U-U l,        U.U l-        U/U l.        U0U l/        U1U l0        U2U l1        U:U l2        U;U l3        U<U l4        U=U l5        U3U l6        U4U l7        U5U l8        U6U l9        U7U l:        U8U l;        U9U l<        U>U l=        U?U l>        W@U l?        WAU l@        WBU lA        WCU lB        WDU lC        WEU lD        WFU lE        WGU lF        WHU lG        WIU lH        WLU lI        WKU lJ        WJU lK        WMU lL        WNU lM        WOU lN        WPU lO        g r   )P
node_countenvironment_sizelabelslocationmachine_typenetwork
subnetworknetwork_attachmentenv_variablesairflow_config_overridesservice_accountoauth_scopestagsdisk_size_gbpython_versionimage_versionairflow_executor_typeuse_ip_aliasescluster_secondary_range_nameservices_secondary_range_namecluster_ipv4_cidr_blockservices_ipv4_cidr_blockmax_pods_per_nodeenable_ip_masq_agentenable_private_environmentdisable_private_environmentprivate_endpointmaster_ipv4_cidrprivately_used_public_ipsweb_server_ipv4_cidrcloud_sql_ipv4_cidrcomposer_network_ipv4_cidrconnection_subnetworkconnection_typeweb_server_access_controlcloud_sql_machine_typeweb_server_machine_typekms_keyscheduler_cpu
worker_cpuweb_server_cpuscheduler_memory_gbworker_memory_gbweb_server_memory_gbscheduler_storage_gbworker_storage_gbweb_server_storage_gbmin_workersmax_workersscheduler_countenable_triggerertriggerer_cputriggerer_counttriggerer_memory_gbmaintenance_window_startmaintenance_window_endmaintenance_window_recurrence!enable_master_authorized_networksmaster_authorized_networksairflow_database_retention_daysr   "enable_scheduled_snapshot_creationsnapshot_creation_schedulesnapshot_locationsnapshot_schedule_timezone%enable_cloud_data_lineage_integration&disable_cloud_data_lineage_integrationenable_high_resilience!enable_logs_in_cloud_logging_only"disable_logs_in_cloud_logging_onlycloud_sql_preferred_zonesupport_web_server_pluginsdag_processor_cpudag_processor_storage_gbdag_processor_memory_gbdag_processor_count!composer_internal_ipv4_cidr_blockenable_private_builds_onlydisable_private_builds_onlystorage_bucket)Qselfr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rP   rQ   rR   rS   rT   rU   r   rL   rM   rN   rO   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rd   rc   rb   re   rf   rg   rh   sQ                                                                                    r   __init__CreateEnvironmentFlags.__init__   si   f !O,KM$L O0&$<!*$I$(&D!6D(D(DD%)FD&#:D $<D!.D 4D&@D#'BD$,D,D%>D" 4D2D&@D#!6D*D%>D""8D#:D DL&D DO(D2D,D 4D 4D.D!6D"D"D*D,D&D*D2D$<D!"8D)FD&-ND*&@D#+JD(&D.PD+&@D#.D&@D#- 	. 	/ 	/ #9D-ND*.PD+$<D!&@D#.D$<D!#:D 2D-ND*&@D#'BD$(Dr   )Pr#   rU   r*   r8   r=   r_   r.   r,   re   r9   r:   r;   rd   ra   rc   rb   r[   r^   rg   r3   r'   rZ   r\   r1   r]   rS   rf   r2   rV   rL   r"   r   r)   r?   r   r   r   rQ   rR   rP   rT   r5   r0   rJ   rI   r   r!   r   r%   r4   r6   r(   r   rK   r@   rC   rF   r$   r/   r-   rW   rX   rY   rh   r    r`   r&   rN   rM   rO   r+   r<   rB   r7   r>   rE   rH   rA   rD   rG   )
__name__
__module____qualname____firstlineno____doc__r   ReleaseTrackGArj   __static_attributes__ r   r   r   r   #   s   XB # #'$("#!%"& $!%  $!" #!$((,!%&*%%(()-!%!%,0-1!(,)-#!%"#(,!%"&cf)r   r   c           	      P   UR                   (       Gd   UR                  (       d  UR                  (       d  UR                  (       d  UR                  (       d  UR
                  (       d  UR                  (       d  UR                  (       d  UR                  (       dx  UR                  (       dg  UR                  (       dV  UR                  (       dE  UR                  (       d4  UR                  (       d#  UR                  (       d  UR                  (       d  gU R!                  UR                   UR                  UR                  UR                  UR                  UR                  S9nUR                  (       a  UR                  Ul        UR                  (       a  UR                  Ul        UR
                  (       a8  ['        UR
                   Vs/ s H  o3R)                  5       PM     sn5      Ul        UR                  (       a8  ['        UR                   Vs/ s H  oDR)                  5       PM     sn5      Ul        UR                  (       dD  UR                  (       d3  UR                  (       d"  UR                  (       d  UR                  (       al  U R-                  UR                  UR                  UR                  UR                  UR                  S9Ul        UR0                  (       a  UR0                  Ul        UR                  (       a  UR                  Ul        U$ s  snf s  snf )zECreates node config from parameters, returns None if config is empty.N)r   machineTyper   r    serviceAccount
diskSizeGb)useIpAliasesclusterSecondaryRangeNameservicesSecondaryRangeNameclusterIpv4CidrBlockservicesIpv4CidrBlock)r   r   r   r    r$   r%   r&   r'   r+   r,   r!   r-   r.   r/   r1   re   
NodeConfigcomposerNetworkAttachmentcomposerInternalIpv4CidrBlocksortedstripoauthScopesIPAllocationPolicyipAllocationPolicyr0   maxPodsPerNodeenableIpMasqAgent)messagesflagsconfigsts        r   _CreateNodeConfigr   l  s   
...E..%--


e33u7I7I
****e.B.B

,
,0H0H

-
-1N1N++u/I/I

1
1~~$$mm!!**##  %& ','?'?F$
,,// ( E4F4F G4Fq4F GHF
ZZUZZ8Z'')Z89FKe@@))U-J-J$$ ( ; ;))"'"D"D#(#F#F"::#<< !< !F #55f
$99F	-' !H8s   LL#c                    [        X5      nU(       Gd  UR                  (       Gd  UR                  (       Gdz  UR                  (       Gdh  UR                  (       GdV  UR
                  (       GdD  UR                  (       Gd2  UR                  (       Gd   UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                  (       Gd  UR                   (       Gd~  UR"                  (       Gdl  UR$                  (       GdZ  UR&                  (       GdH  UR(                  (       Gd6  UR*                  (       Gd$  UR,                  (       Gd  UR.                  (       Gd   UR0                  (       d  UR2                  (       d  UR4                  (       d  UR6                  (       d  UR8                  (       d  UR:                  (       d  UR<                  (       d  UR>                  (       dx  UR@                  (       dg  URB                  (       dV  URD                  (       dE  URF                  (       d4  URH                  (       d#  URJ                  (       d  URL                  (       d  gU RO                  5       nUR                  (       a  UR                  Ul(        U(       a  X4l)        UR                  (       a  U RU                  UR                  S9Ul+        UR2                  (       a  URX                  [Z        R\                  R^                  :X  a&  [`        Rb                  " UR2                  5      Ul2        OURX                  [Z        R\                  Rf                  :X  a&  [h        Rb                  " UR2                  5      Ul2        OMURX                  [Z        R\                  Rj                  :X  a%  [l        Rb                  " UR2                  5      Ul2        UR                  (       d  UR                  (       dn  UR
                  (       d]  UR                  (       dL  UR                  (       d;  UR8                  (       a  U(       d#  URJ                  (       d  URL                  (       Gad  U Ro                  5       Ul8        UR                  (       a  UR                  URp                  l9        UR                  (       aD  [t        Rv                  " UR                  U Rn                  Rx                  5      URp                  l=        UR
                  (       aD  [t        Rv                  " UR
                  U Rn                  R|                  5      URp                  l?        UR                  (       a  UR                  URp                  l@        UR                  (       a9  [        U Rn                  R                  UR                  5      URp                  lC        UR                  bp  UR                  (       a0  U Rn                  R                  R                  URp                  lG        O/U Rn                  R                  R                  URp                  lG        UR8                  (       a"  U(       a  UR8                  URp                  lI        URJ                  (       d  URL                  (       a1  U R                  URJ                  (       a  SOSS9URp                  lK        UR                  (       a  UR                  (       d   S5       eUR                  (       d   S5       eU R                  UR                  R                  5       UR                  R                  5       UR                  S9UlN        UR:                  b  UR:                  S	:X  a@  U R                  U R                  U R                  R                  R                  S
9S9UlS        OJU R                  U R                  UR:                  U R                  R                  R                  S9S9UlS        URB                  (       aL  U R                  U R                  URB                  URD                  URF                  URH                  S9S9UlW        UR                  (       d4  UR                  (       d#  UR                  (       d  UR                  (       GaQ  SnSnUR                  (       d  UR                  (       a$  U R                  UR                  UR                  S9nUR                  (       a  URX                  [Z        R\                  R^                  :X  a!  [        Rb                  " UR                  5      nOURX                  [Z        R\                  Rf                  :X  a!  [        Rb                  " UR                  5      nOHURX                  [Z        R\                  Rj                  :X  a   [        Rb                  " UR                  5      nU R                  WS9nUR                  (       a  SnOUR                  (       a  SnOSnUUUS.n	UR                  b  UR                  U	S'   UR                  b  UR                  U	S'   UR                  b  UR                  U	S'   UR                  b  UR                  U	S'   UR                  b  UR                  U	S'   UR                  (       d  UR                  (       a  UR                  (       a  SOSU	S'   U R                  " S0 U	D6Ulh        UR                  b%  [        UR                  URX                  5      Ulj        UR                  (       a%  U RN                  R                  R                  Uln        UR                  (       aA  U R                  U R                  R                  R                  S9n
U R                  U
S9UlS        UR                  (       aA  U R                  U R                  R                  R                  S9n
U R                  U
S9UlS        UR                  (       a  U R                  UR                  S9Ulv        UR                  (       a  U R                  UR                  S9Ulv        UR                  (       a  U R                  UR                  S9Uly        UR                  (       aQ  UR                  (       a  UR                  O/ nU R                  SU Vs/ s H  oR                  US9PM     snS9Ul~        UR                   UR"                  UR$                  UR&                  UR(                  UR*                  UR,                  UR.                  UR0                  UR4                  UR6                  UR                  UR<                  UR@                  UGR                   UGR                  UGR                  UGR                  UGR                  /nG[        S U 5       5      nU(       d  UR8                  (       a  U(       d  G[        X5      Ul        U$ s  snf ) zLCreates environment config from parameters, returns None if config is empty.N)
kmsKeyNameTF)enabledz!maintenance_window_end is missingz(maintenance_window_recurrence is missing)	startTimeendTime
recurrencer   )retentionMode)airflowMetadataRetentionConfig)retentionDaysr   )r   snapshotCreationSchedulesnapshotLocationtimeZone)scheduledSnapshotsConfig)enablePrivateEndpointmasterIpv4CidrBlock)connectionType)enablePrivateEnvironmentprivateClusterConfignetworkingConfigwebServerIpv4CidrBlockcloudSqlIpv4CidrBlock!cloudComposerNetworkIpv4CidrBlockenablePrivatelyUsedPublicIps!cloudComposerConnectionSubnetworkenablePrivateBuildsOnly)storageMode)taskLogsRetentionConfig)rv   )zone)	cidrBlock)r   
cidrBlocksc              3   (   #    U  H  oS Lv   M
     g 7fr   rt   ).0flags     r   	<genexpr> _CreateConfig.<locals>.<genexpr>  s     M;L4$.;Ls   rt   )r   r   r?   r)   r"   r#   r(   r*   rP   rQ   rR   r2   r3   r<   r=   r>   r@   rA   rB   rC   rD   rE   rF   rG   rH   r   rI   rJ   rK   rU   rM   triggerer_memoryrL   rV   rW   rX   rY   rZ   r[   EnvironmentConfig	nodeCount
nodeConfigEncryptionConfigencryptionConfigr   r   rq   rr   r   GetEnumForChoiceenvironmentSizeBETAr
   ALPHAr	   SoftwareConfigsoftwareConfigimageVersionr   DictToMessageEnvVariablesValueenvVariablesAirflowConfigOverridesValueairflowConfigOverridespythonVersionConvertToTypeEnum"AirflowExecutorTypeValueValuesEnumairflowExecutorTyper`   #WebServerPluginsModeValueValuesEnumPLUGINS_ENABLEDwebServerPluginsModePLUGINS_DISABLEDschedulerCountCloudDataLineageIntegrationcloudDataLineageIntegrationMaintenanceWindow	isoformatmaintenanceWindowDataRetentionConfig$AirflowMetadataRetentionPolicyConfigRetentionModeValueValuesEnumRETENTION_MODE_DISABLEDdataRetentionConfigRETENTION_MODE_ENABLEDRecoveryConfigScheduledSnapshotsConfigrecoveryConfigrf   rg   r4   r5   PrivateClusterConfigr;   r   r   r   NetworkingConfigr7   r8   r9   r6   r:   PrivateEnvironmentConfigprivateEnvironmentConfig"BuildWebServerNetworkAccessControlwebServerNetworkAccessControlr\   ResilienceModeValueValuesEnumHIGH_RESILIENCEresilienceModer]   TaskLogsRetentionConfigStorageModeValueValuesEnumCLOUD_LOGGING_ONLYr^   CLOUD_LOGGING_AND_CLOUD_STORAGEDatabaseConfigdatabaseConfigr_   WebServerConfigwebServerConfigrS   rT   MasterAuthorizedNetworksConfig	CidrBlockmasterAuthorizedNetworksConfigrO   rN   ra   rd   rc   rb   any_CreateWorkloadConfigworkloadsConfig)r   r   is_composer_v1node_configr   private_cluster_confignetworking_configr;   r2   private_env_config_argstask_logs_retention_confignetworksr   composer_v2_flagscomposer_v2_flag_useds                  r   _CreateConfigr     sC   !(2+
)))U]]]



!4!4!4

(
(
(E,@,@,@

%
%
%)G)G)G

&
&
&%*M*M*M

*
*
*

+
+
+

)
)
)U-I-I-I

'
'
'5+>+>+>



e222

#
#
#u'='='=

$
$
$(B(B(B

!
!
!U%@%@

 
 E$5$59J9J


5#H#H


!7!7

 
 E$L$L

*
*e.E.E

*
*

5
5

6
6%%'&
''F#
]]&77== 8 "F
d//2222CC

 
  "f			 1 1 6 6	64EE

 
  "f			 1 1 7 7	75FF

 
  "f 					'	'					$	$


N		4	4		5	5	5$335F+0+>+>f(+3+A+A


x66HH,Jf(%%5=5K5K

(
(

!
!
=
=6?f2 ,1,@,@f)""2C

!
!
D
D

%
%3f/ ''3		)	)##GGWW 	2
 ##GGXX 	2 -2-B-Bf*3377 
.
.EE$5 /  7 ##''L)LL'.. 424.'9900::<,,66866  :  8F **6,,1#+#?#?)1)V)V$IIff~~ *W * $@ $f  $,#?#?)1)V)V!AA$IIff}} *W * $@ $f  --$33!)!B!B<<%*%E%E"4455	 "C "7 4 8F &&%*K*K		)	)		*	*	* "!7!7'<< % 6 6#44  =  6 			 1 1 4 4	41BB!!#$"3"3"8"883DD!!#$"3"3"9"994EE!!#"33( 4 * ''#' 		*	*#( #'  %? 6- !!-&+&@&@ 
"$  ,%*%>%> 
!#''3161Q1Q 
-/&&2,1,K,K 
(*"".161L1L 
-/''5+L+L22$ 78 '/&G&G '#
!'#F# $$0+M'')<)<,>F( !!""@@PP  ,,!)!A!A44OObb "B " "*!=!= : "> "F --!)!A!A44OOoo "B " "*!=!= : "> "F !!$3300 4 2F
##$33++ 4 F ""%5511 6 3F ,,383S3Su//Y[H,4,S,SAI
AIg1
 -T -F)     !!##$$'* M;LMMu44^28CF	-9
s   y
c                    [        U R                  UR                  UR                  UR                  UR
                  S9U R                  UR                  UR                  UR                  S9U R                  UR                  UR                  UR                  UR                  UR                  S9S9nUR                   (       d/  UR"                  (       d  UR$                  (       d  UR&                  bV  UR                   (       a  SOSnUR&                  b  UR&                  nU R)                  UR"                  UR$                  US9US'   UR*                  (       d/  UR,                  c"  UR.                  (       d  UR0                  (       a=  U R3                  UR*                  UR.                  UR0                  UR,                  S9US	'   U R4                  " S
0 UD6$ )z(Creates workload config from parameters.)cpumemoryGb	storageGbcount)r   r   r   )r   r   r   minCountmaxCount)	scheduler	webServerworker   r   )r   r   r   	triggererdagProcessorrt   )dictSchedulerResourcer@   rC   rF   rK   WebServerResourcerB   rE   rH   WorkerResourcerA   rD   rG   rI   rJ   rL   rM   rO   rN   TriggererResourcera   rd   rc   rb   DagProcessorResourceWorkloadsConfig)r   r   workload_resourcesrN   s       r   r   r     s   **!!,,..%%	 + '
 **""--// + 1 $$))++$$$$ % &'" 					"	"				* 11aqO(--o&.&@&@** 'A '{# 		"	"	.		&	&		'	')1)F)F##..00''	 *G *~& 
	!	!	7$6	77r   c                    [         R                  " UR                  S9nUR                  U R	                  5       S9n[        X1U5      Ul        UR                  (       a:  [         R                  " UR                  UR                  R                  5      Ul        UR                  (       a  UR                  UR                  S9Ul         [        UR                  S9R                  [         R                  " UR                  S9R                  UU R!                  5       R	                  5       S95      $ ! ["        R$                   a  n[&        R(                  " USS9eSnAff = f)a  Calls the Composer Environments.Create method.

Args:
  environment_ref: Resource, the Composer environment resource to create.
  flags: CreateEnvironmentFlags, the flags provided for environment creation.
  is_composer_v1: boolean representing if creation request is for Composer
    1.*.* image versions.

Returns:
  Operation: the operation corresponding to the creation of the environment
r   name)bucket)environmentparentzCreation operation failed because of lack of proper permissions. Please, refer to https://cloud.google.com/composer/docs/how-to/managing/creating and Composer Creation Troubleshooting pages to resolve this issue.error_formatN)r   GetMessagesModuler   EnvironmentRelativeNamer   r   r   r   LabelsValuerh   StorageConfigstorageConfigr   Create2ComposerProjectsLocationsEnvironmentsCreateRequestParentapitools_exceptionsHttpForbiddenErrorr   HttpException)environment_refr   r   r   r  es         r   r  r    s3    ''e6I6IJ($$/*F*F*H$I+$XnE+
\\!//h**668K  ( 6 6## !7 !KE$7$78??""1D1DE	;	;#"))+88: 
< 
<= =
 
	/	/ 

"
"	Q s   A'D0 0EEEc                     U " U5      $ )a  Converts airflow executor type string to enum.

Args:
  type_enum: AirflowExecutorTypeValueValuesEnum, executor type enum value.
  airflow_executor_type: string, executor type string value.

Returns:
  AirflowExecutorTypeValueValuesEnum: the executor type enum value.
rt   )	type_enumr*   s     r   r   r     s     
(	))r   c                     [        US9R                  [        R                  " US9R	                  U R                  5       S95      $ )aU  Calls the Composer Environments.Delete method.

Args:
  environment_ref: Resource, the Composer environment resource to delete.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Operation: the operation corresponding to the deletion of the environment
r   r  )r   Deleter   r  2ComposerProjectsLocationsEnvironmentsDeleteRequestr  r$  r   s     r   r)  r)    sF     
-	0	7	7  }=99++- : /
0 0r   c                     [         R                  " US9nUR                  U R                  5       S9n[	        US9R                  U5      $ )au  Calls the Composer Environments.RestartWebServer method.

Args:
  environment_ref: Resource, the Composer environment resource to restart the
    web server for.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Operation: the operation corresponding to the restart of the web server
r   r  )r   r  <ComposerProjectsLocationsEnvironmentsRestartWebServerRequestr  r   RestartWebServerr$  r   message_modulerequest_messages       r   r.  r.    sR     --MJ."__'') ` +/	!
##3#3O#DEr   c                     [         R                  " US9nUR                  U R                  5       UR	                  US9S9n[        US9R                  U5      $ )a  Calls the Composer Environments.SaveSnapshot method.

Args:
  environment_ref: Resource, the Composer environment resource to save the
    snapshot for.
  snapshot_location: location to save the snapshot of the environment.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Operation: the operation corresponding to saving the snapshot.
r   )r   )r  saveSnapshotRequest)r   r  8ComposerProjectsLocationsEnvironmentsSaveSnapshotRequestr  SaveSnapshotRequestr   SaveSnapshot)r$  rX   r   r0  r1  s        r   r6  r6  &  sd     --MJ."[[!..0(<<, = . \ // 
-	0	=	=o	NNr   c                     [         R                  " US9nUR                  U R                  5       UR	                  UUUUUS9S9n[        US9R                  U5      $ )a  Calls the Composer Environments.LoadSnapshot method.

Args:
  environment_ref: Resource, the Composer environment resource to Load the
    snapshot for.
  skip_pypi_packages_installation: skip installing the pypi packages during
    the operation.
  skip_environment_variables_setting: skip setting environment variables
    during the operation.
  skip_airflow_overrides_setting: skip setting Airflow overrides during the
    operation.
  skip_gcs_data_copying: skip copying GCS data during the operation.
  snapshot_path: path of the specific snapshot to load the snapshot.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Operation: the operation corresponding to loading the snapshot.
r   )skipPypiPackagesInstallationskipEnvironmentVariablesSettingskipAirflowOverridesSettingskipGcsDataCopyingsnapshotPath)r  loadSnapshotRequest)r   r  8ComposerProjectsLocationsEnvironmentsLoadSnapshotRequestr  LoadSnapshotRequestr   LoadSnapshot)	r$  skip_pypi_packages_installation"skip_environment_variables_settingskip_airflow_overrides_settingskip_gcs_data_copyingsnapshot_pathr   r0  r1  s	            r   r@  r@  =  sp    4 --MJ."[[!..0(<<'F*L&D2$ = & \ '/ 
-	0	=	=o	NNr   c           	          [         R                  " US9nUR                  UR                  5       UR	                  U UUS9S9n[        US9R                  U5      $ )a  Starts execution of an Airflow CLI command through Composer API.

Args:
  command: string, the command to execute.
  subcommand: string, the subcommand to execute.
  parameters: string[], optional, additinal parameters for the command.
  environment_ref: Resource, the Composer environment to execute the command.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  ExecuteAirflowCommandResponse: information about the execution.
r   )command
subcommand
parameters)r  executeAirflowCommandRequest)r   r  AComposerProjectsLocationsEnvironmentsExecuteAirflowCommandRequestr  ExecuteAirflowCommandRequestr   ExecuteAirflowCommand)rG  rH  rI  r$  r   r0  r1  s          r   rM  rM  c  sp    ( --MJ."dd!..0#1#N#N $O $ e / 
-	0	F	F
 r   c           
          [         R                  " US9nUR                  UR                  5       UR	                  U UUUS9S9n[        US9R                  U5      $ )a  Stops the execution of an Airflow CLI command.

Args:
  execution_id: string, the unique ID of execution.
  pod_name: string, the pod the execution is running on.
  pod_namespace: string, the pod's namespace.
  force: boolean, If true, the execution is terminated forcefully (SIGKILL).
    If false, the  execution is stopped gracefully, giving it time for
    cleanup.
  environment_ref: Resource, the Composer environment to stop the command.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  StopAirflowCommandResponse: information whether stopping the execution was
  successful.
r   )executionIdpodpodNamespaceforce)r  stopAirflowCommandRequest)r   r  >ComposerProjectsLocationsEnvironmentsStopAirflowCommandRequestr  StopAirflowCommandRequestr   StopAirflowCommand)execution_idpod_namepod_namespacerR  r$  r   r0  r1  s           r   rV  rV    ss    2 --MJ."aa!..0 . H H"$	 !I ! b / 
-	0	C	C
 r   c           
          [         R                  " US9nUR                  UR                  5       UR	                  U UUUS9S9n[        US9R                  U5      $ )ay  Polls the execution of an Airflow CLI command through Composer API.

Args:
  execution_id: string, the unique ID of execution.
  pod_name: string, the pod the execution is running on.
  pod_namespace: string, the pod's namespace.
  next_line_number: int, line of the output which should be fetched.
  environment_ref: Resource, the Composer environment to poll the command.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  PollAirflowCommandResponse: the next output lines from the execution and
  information whether the execution is still running.
r   )rO  rP  rQ  nextLineNumber)r  pollAirflowCommandRequest)r   r  >ComposerProjectsLocationsEnvironmentsPollAirflowCommandRequestr  PollAirflowCommandRequestr   PollAirflowCommand)rW  rX  rY  next_line_numberr$  r   r0  r1  s           r   r_  r_    ss    . --MJ."aa!..0 . H H"$)	 !I ! b / 
-	0	C	C
 r   c                     [         R                  " US9nUR                  U R                  5       UR	                  5       S9n[        US9R                  U5      $ )a  Triggers the database failover (only for highly resilient environments).

Args:
  environment_ref: Resource, the Composer environment resource to trigger the
    database failover for.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  Operation: the operation corresponding to triggering a database failover.
r   )r  databaseFailoverRequest)r   r  <ComposerProjectsLocationsEnvironmentsDatabaseFailoverRequestr  DatabaseFailoverRequestr   DatabaseFailoverr/  s       r   re  re    s`     --MJ."__!..0,DDF ` H/ 
-	0	A	A
 r   c                     [         R                  " US9nUR                  U R                  5       S9n[	        US9R                  U5      $ )aP  Fetch database properties.

Args:
  environment_ref: Resource, the Composer environment resource to fetch the
    database properties for.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  DatabaseProperties: database properties for a given environment.
r   )r  )r   r  CComposerProjectsLocationsEnvironmentsFetchDatabasePropertiesRequestr  r   FetchDatabasePropertiesr/  s       r   rh  rh    sQ     --MJ."ff!..0 g 2/	-	0	H	H
 r   c                     [         R                  " US9nUR                  U R                  5       UR	                  US9S9n[        US9R                  U5      $ )a  Calls the Composer Environments.CheckUpgrade method.

Args:
  environment_ref: Resource, the Composer environment resource to check
    upgrade for.
  image_version: Image version to upgrade to.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  Operation: the operation corresponding to the upgrade check
r   )r   )r  checkUpgradeRequest)r   r  8ComposerProjectsLocationsEnvironmentsCheckUpgradeRequestr  CheckUpgradeRequestr   CheckUpgrade)r$  r)   r   r0  r1  s        r   rm  rm    sd     --MJ."[[!..0(<<$ = & \ '/ 
-	0	=	=o	NNr   c                     [         R                  " US9nUR                  U R                  5       US9n[	        US9R                  U5      $ )ae  Calls the Composer Environments.Migrate method.

Args:
  environment_ref: Resource, the Composer environment resource to migrate.
  request: MigrateEnvironmentRequest.
  release_track: base.ReleaseTrack, the release track of command. Determines
    which Composer client library is used.

Returns:
  Operation: the operation corresponding to the migration.
r   )r  migrateEnvironmentRequest)r   r  3ComposerProjectsLocationsEnvironmentsMigrateRequestr  r   Migrate)r$  requestr   r0  r1  s        r   rq  rq    sT      --MJ.HH++-$+ I -  
-	0	8	8	IIr   c                     [        US9R                  [        R                  " US9R	                  U R                  5       S95      $ )a1  Calls the Composer Environments.Get method.

Args:
  environment_ref: Resource, the Composer environment resource to retrieve.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Environment: the requested environment
r   r  )r   Getr   r  /ComposerProjectsLocationsEnvironmentsGetRequestr  r+  s     r   rt  rt  ,  sF     
-	0	4	4  }=66++- 7 /
0 0r   Nc           	      z    [         R                  " [         R                  " US9R                  [	        US9U SUUS9$ )a,  Lists Composer Environments across all locations.

Uses a hardcoded list of locations, as there is no way to dynamically
discover the list of supported locations. Support for new locations
will be aligned with Cloud SDK releases.

Args:
  location_refs: [core.resources.Resource], a list of resource reference to
    locations in which to list environments.
  page_size: An integer specifying the maximum number of resources to be
    returned in a single list call.
  limit: An integer specifying the maximum number of environments to list.
    None if all available environments should be returned.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  list: a generator over Environments in the locations in `location_refs`
r   environments)limit)r   AggregateListResultsr  0ComposerProjectsLocationsEnvironmentsListRequestr   )location_refs	page_sizerx  r   s       r   Listr}  =  s?    . 
	&	&  }=77}-
 r   c                      [        US9R                  [        R                  " US9R	                  U R                  5       UUS95      $ ! [        R                   a  n[        R                  " USS9eSnAff = f)a  Calls the Composer Environments.Update method.

Args:
  environment_ref: Resource, the Composer environment resource to update.
  environment_patch: The Environment message specifying the patch associated
    with the update_mask.
  update_mask: A field mask defining the patch.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  Operation: the operation corresponding to the environment update
r   )r  r  
updateMaskzUpdate operation failed because of lack of proper permissions. Please, refer to https://cloud.google.com/composer/docs/how-to/managing/updating and Composer Update Troubleshooting pages to resolve this issue.r  N)
r   Patchr   r  1ComposerProjectsLocationsEnvironmentsPatchRequestr  r!  r"  r   r#  )r$  environment_patchupdate_maskr   r%  s        r   r  r  ^  s    "QM288""?	:	: --/)" 
; 
$% % 
	/	/ Q

"
"	OQ QQs   AA	 	A7A22A7c                     [         R                  " US9nUR                  U  Vs/ s H%  nUR                  US   UR	                  S5      S9PM'     snS9$ s  snf )a  Builds a WebServerNetworkAccessControl proto given an IP range list.

If the list is empty, the returned policy is set to ALLOW by default.
Otherwise, the default policy is DENY with a list of ALLOW rules for each
of the IP ranges.

Args:
  web_server_access_control: [{string: string}], list of IP ranges with
    descriptions.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  WebServerNetworkAccessControl: proto to be sent to the API.
r   ip_rangedescription)valuer  )allowedIpRanges)r   r  WebServerNetworkAccessControlAllowedIpRangeget)r<   r   r   r  s       r   r   r     su    " ''mD(		/	/ 0A 0( $(,,}2M  O/A	/ 
  As   ,Ac                 :    U(       a  / $ U(       a
  SSS.SSS./$ U $ )a  Returns the list of IP ranges that will be sent to the API.

The resulting IP range list is determined by the options specified in
environment create or update flags.

Args:
  allowed_ip_list: [{string: string}], list of IP ranges with descriptions.
  allow_all: bool, True if allow all flag was set.
  deny_all: bool, True if deny all flag was set.

Returns:
  [{string: string}]: list of IP ranges that will be sent to the API, taking
      into account the values of allow all and deny all flags.
z	0.0.0.0/0z5Allows access from all IPv4 addresses (default value))r  r  z::0/0z5Allows access from all IPv6 addresses (default value)rt   )allowed_ip_list	allow_alldeny_alls      r   BuildWebServerAllowedIpsr    s9     IN N  
r   c                     U (       a  U S-	  $ U $ )zReturns a disk size value in GB.

Args:
  disk_size: int, size in bytes, or None for default value

Returns:
  int, size in GB
   rt   )	disk_sizes    r   DiskSizeBytesToGBr    s     &b494r   c                 D    U (       d  U $ [        U [        S5      -  S5      $ )zReturns a memory size value in GB.

Args:
  memory_size: int, size in bytes, or None for default value

Returns:
  float, size in GB rounded to 3 decimal places
i   @   )roundfloat)memory_sizes    r   MemorySizeBytesToGBr    s#     
	{U7^+Q	//r   ).rp   apitools.base.pyr   r!  googlecloudsdk.api_lib.composerr   r   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   )googlecloudsdk.command_lib.composer.flagsr   r   r   r	   r
   r   rq   rr   r   r   r   r   r   r  r   r)  r.  r   r6  r@  rM  rV  r_  re  rh  rm  r   rq  rt  r}  r  r   r  r  r  rt   r   r   <module>r     s   ; ? < 2 ( P O M L K I "..11 5
F) F)R
,^|~-8`(V
* +/*;*;*>*> 0" 594E4E4H4H E*  $0066O:  $0066#OV ##))P ##))%\ ##))#L 594E4E4K4K , +/*;*;*A*A.  $0033O4 ##((J0 (,'8'8';'; 0& ((++H )),,QD28	50r   