
    #                     b   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  \	R"                  \	R$                  " \	R&                  R(                  \	R&                  R*                  \	R&                  R,                  5       " S S\	R.                  5      5       5       rg)z"'logging settings update' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)
exceptions)resource_args)
completersc                   .    \ rS rSrSr\S 5       rS rSrg)Update   ag  Update the settings for the Cloud Logging Logs Router.

Use this command to update the *--kms-key-name, --storage-location,
--disable-default-sink* and --analytics-mode associated with the Cloud Logging
Logs Router.

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

The storage location must be allowed by Org Policy.

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

To update storage location for the Logs Router for an organization, run:

  $ {command} --organization=[ORGANIZATION_ID]
  --storage-location=[LOCATION_ID]

To update storage location for the Logs Router for a folder, run:

  $ {command} --folder=[FOLDER_ID] --storage-location=[LOCATION_ID]

To disable default sink for the Logs Router for an organization, run:

  $ {command} --organization=[ORGANIZATION_ID] --disable-default-sink=true

To enable default sink for the Logs Router for an organization, run:

  $ {command} --organization=[ORGANIZATION_ID] --disable-default-sink=false

To enable analytics for the log buckets under an organization, run:

  $ {command} --organization=[ORGANIZATION_ID] --disable-default-sink=false
  --analytics-mode=required
c                    U R                  SS9nUR                  SSS[        R                  SS9  UR                  SSS	S
S9  U R                  SSSS9  U R                  SSSS9  U R                  SSS/ SQ[        R
                  " SSS9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.T)requiredz--organizationFORGANIZATION_IDz0Organization to update Logs Router settings for.)r   metavar	completerhelpz--folder	FOLDER_IDz*Folder to update Logs Router settings for.)r   r   r   --storage-locationzUpdate the storage location for ```_Default``` bucket and ```_Required``` bucket. Note: It only applies to the newly created projects and will not affect the projects created before.)r   r   --disable-default-sink
store_truezEnable or disable ```_Default``` sink for the ```_Default``` bucket. Specify --no-disable-default-sink to enable a disabled ```_Default``` sink. Note: It only applies to the newly created projects and will not affect the projects created before.)actionr   z--analytics-mode)r   optionalunspecifiedzxUpdate the analytics mode for newly-created project buckets. Changing this setting does not modify any existing buckets.zThis is not available.
)defaultuniverse_help)r   hiddenchoicesr   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-keyziDisable CMEK for the Logs Router by clearing out Cloud KMS cryptokey in the organization's CMEK settings.N)add_mutually_exclusive_groupadd_argumentr   OrganizationCompleterr   UniverseHelpTextkms_resource_argsAddKmsKeyResourceArg)parserparent_groupgroups      &lib/surface/logging/settings/update.pyArgsUpdate.ArgsV   s4    666EL!22?  A 9	  ; D  E  D  E 7))N 5
   ///?E**H#  
@  B    c           
      <   0 n/ n/ SQnUR                  S5      (       aF  UR                  R                  R                  5       R	                  5       US'   UR                  S5        UR                  S5      (       a  SUS'   UR                  S5        UR                  S5      (       a   UR                  US'   UR                  S5        UR                  S5      (       a   UR                  US	'   UR                  S5        UR                  S
5      (       a  UR                  S
5        UR                  S:X  a7  [        R                  " 5       R                  R                  R                  US'   O}UR                  S:X  a7  [        R                  " 5       R                  R                  R                  US'   O6[        R                  " 5       R                  R                  R                  US'   U(       d  [         R"                  " US5      e[        R$                  " U5      n[        R&                  " 5       R(                  R+                  [        R                  " 5       R-                  U[        R                  " 5       R                  " S0 UD6SR/                  U5      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 settings.
)z --kms-key-name | --clear-kms-keyr   r   kms_key_name
kmsKeyNameclear_kms_key storage_locationstorageLocationdisable_default_sinkdisableDefaultSinkanalytics_moder   analyticsModer   z/Please specify at least one property to update.,)r"   settings
updateMask )IsSpecifiedCONCEPTSr1   ParseRelativeNameappendr5   r7   r9   r   GetMessagesSettingsAnalyticsModeValueValuesEnumANALYTICS_REQUIREDANALYTICS_OPTIONALANALYTICS_MODE_UNSPECIFIEDcalliope_exceptionsMinimumArgumentExceptionGetParentFromArgs	GetClientv2UpdateSettingsLoggingUpdateSettingsRequestjoin)selfargsr<   update_maskparameter_namesparent_names         r,   Run
Update.Run   s<    HKO
 ''
--
$
$
*
*
,
9
9
; |(((!h|(*++$($9$9h !+,.//'+'@'@h#$/0()))*			
	*''DDWW 	! *,''DDWW 	!
 ''DD__ 	! 88
LN N ((.K>>--77%%'00<8<xx, 	8 	./ /r/   r>   N)	__name__
__module____qualname____firstlineno____doc__staticmethodr-   rW   __static_attributes__r>   r/   r,   r   r      s$    /b ;B ;Bz:/r/   r   N)r]   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   r	   rJ   googlecloudsdk.command_lib.kmsr
   r'   +googlecloudsdk.command_lib.resource_managerr   UniverseCompatibleReleaseTracksReleaseTrackALPHABETAGACommandr   r>   r/   r,   <module>rl      s     ) '  ' / / ( E M B T..33T5F5F5I5Ik/T\\ k/ k/r/   