
                         n    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 d Zd	 Zd
 Zd Zd Zy)zOUtils for cluster maintenance window and maintenance exclusion window commands.    )absolute_import)division)unicode_literals)util)
exceptions)flagsc                    ~ t        j                  |d      s|S |j                  j                         }|j                  (t        j                  |      j                         |_        |j                  j                  4t        j                  |      }|j                         |j                  _        |j                  |j                  j                  _        t        d|       |S )zUpdates the cluster.control_plane_encryption if --control-plane-kms-key flag is specified.

  Args:
    ref: reference to the cluster object.
    args: command line arguments.
    request: API request to be issued

  Returns:
    modified request
  control_plane_kms_keycontrolPlaneEncryption)r   FlagIsExplicitlySetcalliope_commandReleaseTrackclusterr   GetMessagesModuleClusterr   ControlPlaneEncryptionr
   kmsKey_AddFieldToUpdateMaskrefargsrequestrelease_trackmessagess        :lib/googlecloudsdk/command_lib/edge_cloud/container/kms.pyUpdateKmsKeyr      s     
		"	"4)@	AN''446-__,,];CCEGO__++3%%m4H-5-L-L-NGOO*262L2L'//((/0':	.    c                 R   ~ t        j                  |d      s|S |j                  st        j                  dd      |j
                  B|j                  j                         }t        j                  |      j                         |_        d|j
                  _        t        d|       |S )a  Clears cluster.control_plane_encryption in the request if --use-google-managed-key flag is specified.

  Args:
    ref: reference to the cluster object.
    args: command line arguments.
    request: API request to be issued

  Returns:
    modified request
  use_google_managed_keyz--no-use-google-managed-keyThe flag is not supportedNr   )r   r   r   r   BadArgumentExceptionr   r   r   r   r   r   r   r   r   r   r   r   s       r   UseGoogleManagedKeyr#   9   s     
		"	"4)A	BN		$	$

)
)%'B  __))668M,,];CCEGO+/'//(0':	.r   c                    ~ t        j                  |d      s|S |j                  j                         }|j                  (t        j                  |      j                         |_        |j                  j                  4t        j                  |      }|j                         |j                  _        |j                  |j                  j                  _        t        d|       |S )zUpdates the cluster.zone_storage_encryption if --zone-storage-kms-key flag is specified.

  Args:
    ref: reference to the cluster object.
    args: command line arguments.
    request: API request to be issued

  Returns:
    modified request
  zone_storage_kms_keyzoneStorageEncryption)r   r   r   r   r   r   r   r   r&   ZoneStorageEncryptionr%   r   r   r   s        r   UpdateZoneKmsKeyr(   Y   s     
		"	"4)?	@N''446-__,,];CCEGO__**2%%m4H,4,J,J,LGOO)151J1J'//''./9	.r   c                 R   ~ t        j                  |d      s|S |j                  st        j                  dd      |j
                  B|j                  j                         }t        j                  |      j                         |_        d|j
                  _        t        d|       |S )a  Clears cluster.zone_storage_encryption in the request if --use-google-managed-zone-key flag is specified.

  Args:
    ref: reference to the cluster object.
    args: command line arguments.
    request: API request to be issued

  Returns:
    modified request
  use_google_managed_zone_keyz --no-use-google-managed-zone-keyr    Nr&   )r   r   r*   r   r!   r   r   r   r   r   r   r&   r   r"   s       r   UseGoogleManagedZoneKeyr+   y   s     
		"	"4)F	GN		)	)

)
)*,G  __))668M,,];CCEGO*.'//'/9	.r   c                 z    |j                   s	| |_         |S | |j                   vr|j                   dz   | z   |_         |S )N,)
updateMask)fieldr   s     r   r   r      sC    			GN
'$$$ ++c1E9G	.r   N)__doc__
__future__r   r   r   +googlecloudsdk.api_lib.edge_cloud.containerr   googlecloudsdk.callioper   googlecloudsdk.command_lib.runr   r   r#   r(   r+   r    r   r   <module>r6      s:    V &  ' < . 0@@@@r   