
                  ?       n   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rS r\R(                  R*                  4S j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
\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
4?S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr\R(                  R*                  4S jr \R(                  R*                  4S jr!\R(                  R*                  4S jr"\R(                  R*                  4S jr#S r$S r%S r&S r'S r(\R(                  R*                  4S jr)\R(                  R*                  4S  jr*S! r+S" r,S# r-g
)$zACommon utility functions for Composer environment patch commands.    )absolute_import)division)unicode_literals)environments_util)operations_util)util)base)logNc                 x   [         R                  " US9nUR                  5       nU S:X  a@  UR                  UR	                  UR                  R
                  R                  S9S9Ul        O@UR                  UR	                  U UR                  R
                  R                  S9S9Ul        SUR                  US94$ )a  Constructs an environment patch for Airflow Database Retention feature.

Args:
  airflow_database_retention_days: int or None, the number of retention days
    for airflow database data retention mechanism
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
release_trackr   )retentionMode)airflowMetadataRetentionConfig)retentionDaysr   z>config.data_retention_config.airflow_metadata_retention_configconfig)
api_utilGetMessagesModuleEnvironmentConfigDataRetentionConfig$AirflowMetadataRetentionPolicyConfigRetentionModeValueValuesEnumRETENTION_MODE_DISABLEDdataRetentionConfigRETENTION_MODE_ENABLEDEnvironment)airflow_database_retention_daysr   messagesr   s       Alib/googlecloudsdk/command_lib/composer/environment_patch_util.py+_ConstructAirflowDatabaseRetentionDaysPatchr       s     ''mD(%%'&$)!)!=!='/'T'T"GGdd|| (U (
 "> "F "*!=!='/'T'T9"GGdd{{ (U (
 "> "F G&)
     c           	         [         R                  " XXS9nSR                  UR                  5      nU(       a'  [        R
                  " U R                  5       SSUS9  U$  [        R                  " USR                  U R                  5       UR                  5      US9  g! [        R                   aM  n[        R                  " SR                  U R                  5       [        R                  " U5      5      5      eSnAff = f)	a  Patches an Environment, optionally waiting for the operation to complete.

This function is intended to perform the common work of an Environment
patching command's Run method. That is, calling the patch API method and
waiting for the result or immediately returning the Operation.

Args:
  env_resource: googlecloudsdk.core.resources.Resource, Resource representing
    the Environment to be patched
  field_mask: str, a field mask string containing comma-separated paths to be
    patched
  patch: Environment, a patch Environment containing updated values to apply
  is_async: bool, whether or not to perform the patch asynchronously
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  an Operation corresponding to the Patch call if `is_async` is True;
  otherwise None is returned after the operation is complete

Raises:
  command_util.Error: if `is_async` is False and the operation encounters
  an error
r   zwith operation [{0}]environmentT)kindis_asyncdetailsz(Waiting for [{}] to be updated with [{}]zError updating [{}]: {}N)environments_api_utilPatchformatnamer
   UpdatedResourceRelativeNameoperations_api_utilWaitForOperationcommand_utilErrorsix	text_type)env_resource
field_maskpatchr%   r   	operationr&   es           r   r(   r(   A   s    : $)):D)")))..9'!!#	
 8((299%%'	9#	%
 
		 8


6==!!#S]]1%57 8 88s    >B D 3AC;;D c@                    U(       a
  [        UU(S9$ U$(       a
  [        U$U(S9$ U(       a   [        S/ [        R                  " U5      U(S9$ U(       d  U(       d  U(       a  [        UUUU(S9$ U<(       d  U=(       a
  [        U<U(S9$ U(       d  U(       d  U	(       a  [        XxU	U(S9$ U
(       d  U(       d  U(       a  [        U
UUU(S9$ U(       d  U(       d  U(       a  [        UUUUU(S9$ U(       a
  [        UU(S9$ Ub
  [        UU(S9$ U(       a
  [        UU(S9$ U(       a
  [        UU(S9$ U%b  [        U%U&U(5      $ U,b  [        U,U/U-U.U(5      $ U2b  [        U2U(5      $ U1b  [!        U1U(5      $ U7c  U8(       d  U9(       d  U:(       a  [#        U7U8U9U:U(5      $ U'b  [%        U'U(5      $ U (       a  U(       a
  ['        UU(S9$ U;(       ab  U (       a  [        R(                  " S5      e[+        S0 SU_SU_SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU(_SU)_SU*_SU+_SU3_SU5_SU4_SU6_6$ U!(       a  U"(       a  U#(       d  U (       a  [-        U!U"U#U U(S9$ U0b  [/        U0U(5      $ U>b  [1        U>U(5      $ U?b  [3        U?U(5      $ [        R(                  " S5      e)a  Constructs an environment patch.

Args:
  is_composer_v1: boolean representing if patch request is for Composer 1.*.*
    Environment.
  env_ref: resource argument, Environment resource argument for environment
    being updated.
  node_count: int, the desired node count
  update_pypi_packages_from_file: str, path to local requirements file
    containing desired pypi dependencies.
  clear_pypi_packages: bool, whether to uninstall all PyPI packages.
  remove_pypi_packages: iterable(string), Iterable of PyPI packages to
    uninstall.
  update_pypi_packages: {string: string}, dict mapping PyPI package name to
    extras and version specifier.
  clear_labels: bool, whether to clear the labels dictionary.
  remove_labels: iterable(string), Iterable of label names to remove.
  update_labels: {string: string}, dict of label names and values to set.
  clear_airflow_configs: bool, whether to clear the Airflow configs
    dictionary.
  remove_airflow_configs: iterable(string), Iterable of Airflow config
    property names to remove.
  update_airflow_configs: {string: string}, dict of Airflow config property
    names and values to set.
  clear_env_variables: bool, whether to clear the environment variables
    dictionary.
  remove_env_variables: iterable(string), Iterable of environment variables to
    remove.
  update_env_variables: {string: string}, dict of environment variable names
    and values to set.
  update_image_version: string, image version to use for environment upgrade
  update_web_server_access_control: [{string: string}], Webserver access
    control to set
  cloud_sql_machine_type: str or None, Cloud SQL machine type used by the
    Airflow database.
  web_server_machine_type: str or None, machine type used by the Airflow web
    server
  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, maximumn 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. Can
    be specified only in Composer 2.0.0.
  clear_maintenance_window: bool or None, specifies if maintenance window
    options should be cleared.
  maintenance_window_start: Datetime or None, a starting date of the
    maintenance window.
  maintenance_window_end: Datetime or None, an ending date of the maintenance
    window.
  maintenance_window_recurrence: str or None, recurrence RRULE for the
    maintenance window.
  environment_size: str or None, one of small, medium and large.
  master_authorized_networks_enabled: bool or None, whether the feature should
    be enabled
  master_authorized_networks: iterable(string) or None, iterable of 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.
  triggerer_cpu: float or None, CPU allocated to Airflow triggerer. 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.
  triggerer_count: int or None, number of triggerers in the Environment. Can
    be specified only in Airflow 2.2.x and greater
  enable_scheduled_snapshot_creation: bool, whether the automatic snapshot
    creation should be enabled
  snapshot_location: str, a Cloud Storage location used to store automatically
    created snapshots
  snapshot_schedule_timezone: str, time zone that sets the context to
    interpret snapshot_creation_schedule.
  snapshot_creation_schedule: str, cron expression that specifies when
    snapshots will be created
  cloud_data_lineage_integration_enabled: bool or None, whether the feature
    should be enabled
  support_web_server_plugins: bool or None, whether to enable/disable the
    support for web server plugins
  support_private_builds_only: bool or None, whether to enable/disable the
    support for private only builds
  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.
  disable_vpc_connectivity: bool or None, defines whether to disable
    connectivity with a user's VPC network. Can be specified only in Composer
    3.
  network: str or None, the Compute Engine network to which to connect the
    environment specified as relative resource name. Can be specified only in
    Composer 3.
  subnetwork: str or None, the Compute Engine subnetwork to which to connect
    the environment specified as relative resource name. Can be specified only
    in Composer 3.
  network_attachment: str or None, the Compute Engine network attachment that
    is used as PSC Network entry point.
  workload_updated: bool or None, verify if workload config has been updated
  enable_private_environment: bool or None, defines whether the internet
    access is disabled from Composer components. Can be specified only in
    Composer 3.
  disable_private_environment: bool or None, defines whether the internet
    access is enabled from Composer components. Can be specified only in
    Composer 3.
  enable_high_resilience: bool or None, defines whether high resilience should
    be enabled for given environment. Can be specified only in Composer 2.
  enable_logs_in_cloud_logging_only: bool or None, defines whether logs in
    cloud logging only feature should be enabled for given environment. Can be
    specified only in composer 2.

Returns:
  (str, Environment), the field mask and environment to use for update.

Raises:
  command_util.Error: if no update type is specified
r   T)scheduler_countr   ziYou cannot use Workloads Config flags introduced in Composer 2.X when updating Composer 1.X environments.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worker_min_countworker_max_countr9   r   triggerer_cputriggerer_memory_gbtriggerer_countdag_processor_cpudag_processor_memory_gbdag_processor_countdag_processor_storage_gbz8Cannot update Environment with no update type specified. )_ConstructNodeCountPatch_ConstructEnvironmentSizePatch_ConstructPyPiPackagesPatchr/   ParseRequirementsFile!_ConstructPrivateEnvironmentPatch_ConstructLabelsPatch_ConstructAirflowConfigsPatch_ConstructEnvVariablesPatch_ConstructImageVersionPatch%_ConstructWebServerAccessControlPatch"_ConstructCloudSqlMachineTypePatch#_ConstructWebServerMachineTypePatch+_ConstructMasterAuthorizedNetworksTypePatch _ConstructScheduledSnapshotPatch _ConstructPrivateBuildsOnlyPatch#_ConstructWebServerPluginsModePatch_ConstructVpcConnectivityPatchr    2_ConstructSoftwareConfigurationSchedulerCountPatchr0   _ConstructAutoscalingPatch _ConstructMaintenanceWindowPatch?_ConstructSoftwareConfigurationCloudDataLineageIntegrationPatch_ConstructHighResiliencePatch%_ConstructLogsInCloudLoggingOnlyPatch)@is_composer_v1env_ref
node_countupdate_pypi_packages_from_fileclear_pypi_packagesremove_pypi_packagesupdate_pypi_packagesclear_labelsremove_labelsupdate_labelsclear_airflow_configsremove_airflow_configsupdate_airflow_configsclear_env_variablesremove_env_variablesupdate_env_variablesupdate_image_version update_web_server_access_controlcloud_sql_machine_typeweb_server_machine_typer:   r;   r<   r=   r>   r?   r@   rA   rB   min_workersmax_workersr9   clear_maintenance_windowmaintenance_window_startmaintenance_window_endmaintenance_window_recurrenceenvironment_size"master_authorized_networks_enabledmaster_authorized_networksr   r   rE   rF   rG   "enable_scheduled_snapshot_creationsnapshot_locationsnapshot_schedule_timezonesnapshot_creation_schedule&cloud_data_lineage_integration_enabledsupport_web_server_pluginssupport_private_builds_onlyrH   rJ   rI   rK   disable_vpc_connectivitynetwork
subnetworknetwork_attachmentworkload_updatedenable_private_environmentdisable_private_environmentenable_high_resilience!enable_logs_in_cloud_logging_onlys@                                                                   r   ConstructPatchr   t   s   V #JmLL)7 7#&b**+IJ#% % 04H&#	% %
  #>,"#% % ]m ]-Q Q5(#	% %
 04H&#% % &M; ;%10(G G-m= =.}> >'36*,F  (3+,N,F,=,F,9	; ; !,+#]   +."M  *			)   %06'8 8='}F F67 7 ( % ( 2	
 ,  4  4 . !6 ' ' * & & 2  *!" .#$ #:%& 2'( $<) . 
 
'	!+ % #  ,7J.  '(  '20)=  	@	 r!   c                     [         R                  " US9nUR                  5       nUR                  US9nSn[	        U 5      Ul        UUR                  US94$ )a  Constructs an environment patch for private environment.

Args:
  enable_private_environment: bool or None, defines whether the internet
    access is disabled from Composer components. Can be specified only in
    Composer 3.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   privateEnvironmentConfigz<config.private_environment_config.enable_private_environmentr   )r   r   PrivateEnvironmentConfigr   boolenablePrivateEnvironmentr   )r   r   r   private_environment_configr   update_masks         r   rQ   rQ     st      ''mD('@@B%%9 & & O+8< 95
 &)
 r!   c                     [         R                  " US9nUR                  5       nUR                  US9nSn[	        U 5      Ul        UUR                  US94$ )a  Constructs an environment patch to enable/disable private builds only.

Args:
  support_private_builds_only: bool or None, defines whether the internet
    access is disabled during builds. Can be specified only in
    Composer 3.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   r   z<config.private_environment_config.enable_private_builds_onlyr   )r   r   r   r   r   enablePrivateBuildsOnlyr   )r   r   r   r   r   r   s         r   r[   r[     st      ''mD('@@B%%9 & & O+7;!84
 &)
 r!   c                     [         R                  " US9nUR                  5       nUR                  US9nSnU (       a  SnO,U(       a	  SnX6l        OU(       a  U(       a  SnXl        X&l        UUR                  US94$ )a  Constructs an environment patch for vpc connectivity.

Used only in Composer 3.

Args:
  disable_vpc_connectivity: bool or None, defines whether to disable
    connectivity with a user's VPC network.
  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.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )
nodeConfigNz8config.node_config.network,config.node_config.subnetworkz.config.node_config.composer_network_attachmentr   )r   r   
NodeConfigr   composerNetworkAttachmentr   r   r   )	r   r   r   r   r   r   node_configr   r   s	            r   r]   r]     s    4 ''mD(##%+%%%=&+LKBK,>):LK!'&)
 r!   c                 j    [         R                  " US9nUR                  U S9nSUR                  US94$ )a2  Constructs an environment patch for node count.

Args:
  node_count: int, the desired node count
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )	nodeCountzconfig.node_countr   r   r   r   r   )rf   r   r   r   s       r   rM   rM   >  s@     ''mD(%%
%;&	h22&2A	AAr!   c                 j    [         R                  " US9nUR                  U S9nSUR                  US94$ )aE  Constructs an environment patch for environment size.

Args:
  environment_size: str, the desired environment size.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )environmentSizezconfig.environment_sizer   r   )r~   r   r   r   s       r   rN   rN   N  sA     ''mD(%%6F%G&	"H$8$8$8$G	GGr!   c                    ^^^ [         R                  " US9mTR                  mTR                  R                  mTR
                  nUUU4S jn[        R                  " XUSXE5      $ )a9  Constructs an environment patch for partially updating PyPI packages.

Args:
  clear_pypi_packages: bool, whether to clear the PyPI packages dictionary.
  remove_pypi_packages: iterable(string), Iterable of PyPI package names to
    remove.
  update_pypi_packages: {string: string}, dict mapping PyPI package name to
    optional extras and version specifier.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   c                 T   > TR                  T" U S9S9nTR                  US9nT" US9$ )NadditionalProperties)pypiPackagessoftwareConfigr   SoftwareConfigr   )entriessoftware_configr   env_clsr   pypi_packages_clss      r   	_BuildEnv._ConstructPyPiPackagesPatch.<locals>._BuildEnvv  ?    --&GD . FO'''GF&!!r!   z$config.software_config.pypi_packages)r   r   r   r   PypiPackagesValueAdditionalPropertyr/   BuildPartialUpdate)	rh   ri   rj   r   	entry_clsr   r   r   r   s	         @@@r   rO   rO   _  sd    $ ''mD(  '..@@22)" 
	(	(1E,i
D Dr!   c                    ^ [         R                  " US9nUR                  mTR                  R                  nU4S jn[
        R                  " XUSUU5      $ )a  Constructs an environment patch for updating labels.

Args:
  clear_labels: bool, whether to clear the labels dictionary.
  remove_labels: iterable(string), Iterable of label names to remove.
  update_labels: {string: string}, dict of label names and values to set.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   c                 *   > T" TR                  U S9S9$ )Nr   )labels)LabelsValue)r   r   s    r   r   (_ConstructLabelsPatch.<locals>._BuildEnv  s    '--7-KLLr!   r   )r   r   r   r   r   r/   r   )rk   rl   rm   r   r   r   r   r   s          @r   rR   rR     sX      ''mD(  '!!44)M 
	(	()6))2
4 4r!   c                    ^^^ [         R                  " US9mTR                  mTR                  R                  mTR
                  nUUU4S jn[        R                  " XUSXE5      $ )a8  Constructs an environment patch for updating Airflow configs.

Args:
  clear_airflow_configs: bool, whether to clear the Airflow configs
    dictionary.
  remove_airflow_configs: iterable(string), Iterable of Airflow config
    property names to remove.
  update_airflow_configs: {string: string}, dict of Airflow config property
    names and values to set.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   c                 T   > TR                  T" U S9S9nTR                  US9nT" US9$ )Nr   )airflowConfigOverridesr   r   r   )r   r   r   airflow_config_overrides_clsr   r   s      r   r   0_ConstructAirflowConfigsPatch.<locals>._BuildEnv  sC    --;!( * . +O '''GF&!!r!   z/config.software_config.airflow_config_overrides)r   r   r   r   AirflowConfigOverridesValuer   r/   r   )	rn   ro   rp   r   r   r   r   r   r   s	         @@@r   rS   rS     sf    & ''mD(  '99 *==)" 
	(	(5K7
O Or!   c           	      f  ^
^^ [         R                  " XS9nUR                  R                  R                  nU(       a  UR
                  O/ n[        R                  " US9mTR                  m
TR                  R                  mTR                  nU
UU4S jn	S[        R                  " UUUXxU	5      4$ )a  Constructs an environment patch for updating environment variables.

Note that environment variable updates do not support partial update masks
unlike other map updates due to comments in (b/78298321). For this reason, we
need to retrieve the Environment, apply an update on EnvVariable dictionary,
and patch the entire dictionary. The potential race condition here
(environment variables being updated between when we retrieve them and when we
send patch request)is not a concern since environment variable updates take
5 mins to complete, and environments cannot be updated while already in the
updating state.

Args:
  env_ref: resource argument, Environment resource argument for environment
    being updated.
  clear_env_variables: bool, whether to clear the environment variables
    dictionary.
  remove_env_variables: iterable(string), Iterable of environment variable
    names to remove.
  update_env_variables: {string: string}, dict of environment variable names
    and values to set.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   c                 T   > TR                  T" U S9S9nTR                  US9nT" US9$ )Nr   )envVariablesr   r   r   )r   r   r   r   env_variables_clsr   s      r   r   ._ConstructEnvVariablesPatch.<locals>._BuildEnv  r   r!   z$config.software_config.env_variables)r'   Getr   r   r   r   r   r   r   r   EnvVariablesValuer   r/   BuildFullMapUpdate)re   rq   rr   rs   r   env_objinitial_env_var_valueinitial_env_var_listr   r   r   r   r   s             @@@r   rT   rT     s    > "%%gK'!..77DD 
 00$&  ''mD(  '--??22)" 1

)
)*=*>*>*>*3	5
6 6r!   c                     [         R                  " US9nUR                  UR                  UR	                  U UUUS9S9S9nSUR                  US94$ )a  Constructs an environment patch for environment image version.

Args:
  enable_scheduled_snapshot_creation: bool, whether the automatic snapshot
    creation should be enabled
  snapshot_creation_schedule: str, cron expression that specifies when
    snapshots will be created
  snapshot_location: str, a Cloud Storage location used to store automatically
    created snapshots
  snapshot_schedule_timezone: str, time zone that sets the context to
    interpret snapshot_creation_schedule.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )enabledsnapshotCreationSchedulesnapshotLocationtimeZone)scheduledSnapshotsConfig)recoveryConfigz1config.recovery_config.scheduled_snapshots_configr   )r   r   r   RecoveryConfigScheduledSnapshotsConfigr   )r   r   r   r   r   r   r   s          r   rZ   rZ     s    , ''mD(%%,,#+#D#D8'A01	 $E $3 - 4 & 5& 
=h>R>R ?S ? 
 r!   c                 .   [         R                  " US9nUR                  5       nU (       a&  UR                  R                  R                  Ul        O%UR                  R                  R                  Ul        UR                  US9nSUR                  US94$ )af  Constructs an environment patch for web server plugins mode patch.

Args:
  support_web_server_plugins: bool, defines if plugins are enabled or not.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   r   z.config.software_config.web_server_plugins_moder   )	r   r   r   #WebServerPluginsModeValueValuesEnumPLUGINS_ENABLEDwebServerPluginsModePLUGINS_DISABLEDr   r   )r   r   r   r   r   s        r   r\   r\     s     ''mD(++-/CCSS (
 	CCTT ( %%_%E&	98;O;O <P < 
 r!   c                     [         R                  " US9nUR                  U S9nUR                  US9nSUR	                  US94$ )aQ  Constructs an environment patch for environment image version.

Args:
  update_image_version: string, the target image version.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )imageVersionr   z$config.software_config.image_versionr   )r   r   r   r   r   )rt   r   r   r   r   s        r   rU   rU   <  s^     ''mD(++9M+N/%%_%E&	/1E1E 2F 2 
 r!   c                     [         R                  " US9nUR                  [        R                  " U U5      S9nSUR                  US94$ )ah  Constructs an environment patch for web server network access control.

Args:
  web_server_access_control: [{string: string}], the target list of IP ranges.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )webServerNetworkAccessControlz(config.web_server_network_access_controlr   )r   r   r   r'   "BuildWebServerNetworkAccessControlr   )web_server_access_controlr   r   r   s       r   rV   rV   P  sg     ''mD(%%$9))%**C*7%9 & :& 
4X5I5I 6J 6 
 r!   c                     [         R                  " US9nUR                  UR                  U S9S9nSUR	                  US94$ )an  Constructs an environment patch for Cloud SQL machine type.

Args:
  cloud_sql_machine_type: str or None, Cloud SQL machine type used by the
    Airflow database.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   machineType)databaseConfigz#config.database_config.machine_typer   )r   r   r   DatabaseConfigr   )rv   r   r   r   s       r   rW   rW   e  sd     ''mD(%%,,, - . & /& 
/0D0D 1E 1 
 r!   c                     [         R                  " US9nUR                  UR                  U S9S9nSUR	                  US94$ )ap  Constructs an environment patch for Airflow web server machine type.

Args:
  web_server_machine_type: str or None, machine type used by the Airflow web
    server.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   r   )webServerConfigz%config.web_server_config.machine_typer   )r   r   r   WebServerConfigr   )rw   r   r   r   s       r   rX   rX   y  sd     ''mD(%%..- / / & 0& 
1(2F2F 3G 3 
 r!   c           
          [         R                  " US9nUR                  5       nUc  / OUnUR                  U U Vs/ s H  oSR	                  US9PM     snS9Ul        SUR                  US94$ s  snf )a  Constructs an environment patch for Master authorized networks feature.

Args:
  enabled: bool, whether master authorized networks should be enabled.
  networks: Iterable(string), master authorized networks.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )	cidrBlock)r   
cidrBlocksz(config.master_authorized_networks_configr   )r   r   r   MasterAuthorizedNetworksConfig	CidrBlockmasterAuthorizedNetworksConfigr   )r   networksr   r   r   r   s         r   rY   rY     s     ''mD(%%'&#R(*2*Q*Q?G?GG

w

/x +R +	&'
 
4X5I5I 6J 6 
 s   A/
c                 x   [         R                  " US9n[        UR                  U UUUS9UR	                  UUUS9UR                  UUUU	U
S9S9nUc  U(       d  U(       a  UR                  XUS9US'   Ub  UR                  UUUUS9US'   UR                  UR                  " S0 UD6S	9nS
UR                  US94$ )a!
  Constructs an environment patch for Airflow web server machine type.

Args:
  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.
  worker_min_count: int or None, minimum number of workers in the Environment.
    Can be specified only in Composer 2.0.0.
  worker_max_count: int or None, maximumn 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. Can
    be specified only in Composer 2.0.0.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.
  triggerer_cpu: float or None, CPU allocated to Airflow triggerer. 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.
  triggerer_count: int or None, number of triggerers in the Environment. Can
    be specified only in Airflow 2.2.x and greater
  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.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )cpumemoryGb	storageGbcount)r   r   r   )r   r   r   minCountmaxCount)	scheduler	webServerworker)r   r   r   	triggererdagProcessor)workloadsConfigzconfig.workloads_configr   rL   )r   r   dictSchedulerResourceWebServerResourceWorkerResourceTriggererResourceDagProcessorResourcer   WorkloadsConfigr   )r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   r9   r   rE   rF   rG   rH   rI   rJ   rK   r   workload_resourcesr   s                          r   r_   r_     s#   p ''mD(**&(	 + !
 **') + + $$#%## % %&  !&.&@&@ 'A '{# $)1)F)F(*!	 *G *~& %%..D1CD & F&	"H$8$8$8$G	GGr!   c                     [         R                  " US9nU(       a  SUR                  5       4$ UR                  U R	                  5       UR	                  5       US9nUR                  US9nSUR                  US94$ )a  Constructs an environment patch for updating maintenance window.

Args:
  maintenance_window_start: Datetime or None, a starting date of the
    maintenance window.
  maintenance_window_end: Datetime or None, an ending date of the maintenance
    window.
  maintenance_window_recurrence: str or None, recurrence RRULE for the
    maintenance window.
  clear_maintenance_window: bool or None, specifies if maintenance window
    options should be cleared.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   zconfig.maintenance_window)	startTimeendTime
recurrence)maintenanceWindowr   )r   r   r   MaintenanceWindow	isoformatr   )r{   r|   r}   rz   r   r   window_valuer   s           r   r`   r`     s    , ''mD(&(<(<(>>>++(224$..0. , 0, %%%E&	$h&:&:&&:&I	IIr!   c           	          [         R                  " US9nSUR                  UR                  UR	                  U S9S9S94$ )aE  Constructs a patch for updating scheduler count for Composer 1.*.*.

Args:
  scheduler_count: number of schedulers.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Composer client library will be used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   z&config.software_config.scheduler_count)schedulerCountr   r   )r   r   r   r   r   )r9   r   r   s      r   r^   r^   '  s]     ''mD(	183G3G''!00, 1 . ( / 4H 40 
0 0r!   c                     [         R                  " US9nSUR                  UR                  UR	                  UR                  U S9S9S9S94$ )ad  Constructs a patch for updating Cloud Data Lineage integration config.

Args:
  enabled: bool, whether Cloud Data Lineage integration should be enabled.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   z5config.software_config.cloud_data_lineage_integration)r   )cloudDataLineageIntegrationr   r   )r   r   r   r   r   CloudDataLineageIntegrationr   r   r   s      r   ra   ra   ;  ss     ''mD(	@(BVBV''!00*2*N*N! +O +# 1 $ ( % CW C& 
& &r!   c                     [         R                  " US9nU (       d  SUR                  UR                  5       S94$ SUR                  UR                  UR                  R                  R
                  S9S94$ )a?  Constructs a patch for updating high resilience.

Args:
  enabled: bool, whether High resilience should be enabled.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   zconfig.resilience_moder   )resilienceMode)r   r   r   r   ResilienceModeValueValuesEnumHIGH_RESILIENCEr  s      r   rb   rb   P  s     ''mD(	#X%9%9))+ &: &   
"8#7#7''((FFVV (  $8 $ 
 r!   c                 L   [         R                  " US9nU (       a.  UR                  UR                  R                  R                  S9nO-UR                  UR                  R                  R
                  S9nUR                  US9nUR                  US9nSUR                  US94$ )a\  Constructs a patch for updating logs in cloud logging only feature.

Args:
  enabled: bool, whether logs in cloud logging onlyshould be enabled.
  release_track: base.ReleaseTrack, the release track of command. It dictates
    which Composer client library is used.

Returns:
  (str, Environment), the field mask and environment to use for update.
r   )storageMode)taskLogsRetentionConfig)r   zDconfig.data_retention_config.task_logs_retention_config.storage_moder   )	r   r   TaskLogsRetentionConfigStorageModeValueValuesEnumCLOUD_LOGGING_ONLYCLOUD_LOGGING_AND_CLOUD_STORAGEr   r   r   )r   r   r   task_logs_retention_configdata_retention_configr   s         r   rc   rc   j  s     ''mD(!)!A!A44OObb "B " "*!A!A44OOoo "B " #668 7  %%:O%P&L&)
 r!   ).__doc__
__future__r   r   r   googlecloudsdk.api_lib.composerr   r'   r   r-   r   r   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.composerr/   googlecloudsdk.corer
   r1   r    ReleaseTrackGAr(   r   rQ   r[   r]   rM   rN   rO   rR   rS   rT   rZ   r\   rU   rV   rW   rX   rY   r_   r`   r^   ra   rb   rc   rL   r!   r   <module>r+     s   H &  ' V R < ( D # 
 N )),,	08j #'%) !!"&'+#$(##&&'+##+/# $ !!# $&*AZ~
 ##&&D ##&&J ##&&*Z 8<7H7H7K7K B" 261B1B1E1EH( /3.?.?.B.BDJ )-(9(9(<(<4> 150A0A0D0D"OR /3.?.?.B.B	56x 483D3D3G3G	 H /3.?.?.B.B@ /3.?.?.B.B(*((2ZHB 483D3D3G3G	!JJ $(#4#4#7#70(&*4r!   