
    a                         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
\R                  5      rg)z''logging cmek-settings update' command.    )absolute_import)division)unicode_literals)util)base)resource_args)
completersc                   .    \ rS rSrSr\S 5       rS rSrg)Update   a  Update the CMEK settings for the Cloud Logging Logs Router.

Use this command to update the *--kms-key-name* associated with the
Cloud Logging Logs Router.

The Cloud KMS key must already exist and Cloud Logging must have
permission to access it.

Customer-managed encryption keys (CMEK) for the Logs Router can currently
only be configured at the organization-level and will apply to all projects
in the organization.

## EXAMPLES

To enable CMEK for the Logs Router for an organization, run:

  $ {command} --organization=[ORGANIZATION_ID]
  --kms-key-name='projects/my-project/locations/my-location/keyRings/my-keyring/cryptoKeys/key'

To disable CMEK for the Logs Router for an organization, run:

  $ {command} --organization=[ORGANIZATION_ID] --clear-kms-key
c                     U R                  SSS[        R                  SS9  U R                  SS9n[        R
                  " USSS	S
9  UR                  SSSS9  g)z Register flags for this command.z--organizationTORGANIZATION_IDz5Organization to update Logs Router CMEK settings for.)requiredmetavar	completerhelp)r   z5logs being processed by the Cloud Logging Logs RouterzqThe Cloud KMS CryptoKey Encrypter/Decryper role must be assigned to the Cloud Logging Logs Router service accountz--kms-key-name)resourcepermission_infonamez--clear-kms-key
store_trueziDisable CMEK for the Logs Router by clearing out Cloud KMS cryptokey in the organization's CMEK settings.)actionr   N)add_argumentr	   OrganizationCompleteradd_mutually_exclusive_groupkms_resource_argsAddKmsKeyResourceArg)parsergroups     +lib/surface/logging/cmek_settings/update.pyArgsUpdate.Args7   s     !22D  F ///>E**H#  
@  B    c           
         0 nUR                  S5      (       a5  UR                  R                  R                  5       R	                  5       US'   UR                  S5      (       a  SUS'   [
        R                  " U5      n[
        R                  " 5       R                  R                  [
        R                  " 5       R                  U[
        R                  " 5       R                  " S0 UD6SS95      $ )zThis is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  The updated CMEK settings.
kms_key_name
kmsKeyNameclear_kms_key )r   cmekSettings
updateMask )IsSpecifiedCONCEPTSr$   ParseRelativeNamer   GetParentFromArgs	GetClientorganizationsUpdateCmekSettingsGetMessages-LoggingOrganizationsUpdateCmekSettingsRequestCmekSettings)selfargscmek_settingsparent_names       r   Run
Update.RunQ   s     M''
--
$
$
*
*
,
9
9
; L! (($&mL!((.K>>))<<HH))+88I=I% 	I 	'( (r"   r*   N)	__name__
__module____qualname____firstlineno____doc__staticmethodr    r:   __static_attributes__r*   r"   r   r   r      s"    0 B B2(r"   r   N)r@   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr   r   +googlecloudsdk.command_lib.resource_managerr	   Commandr   r*   r"   r   <module>rI      s3     . '  ' / ( M BK(T\\ K(r"   