
                             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\R                  5      rg)z,`gcloud monitoring policies update` command.    )absolute_import)division)unicode_literals)policies)base)flags)resource_args)util)repeatedc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	Update   zUpdates an alerting policy.DESCRIPTIONa            Updates an alerting policy.

          If `--policy` or `--policy-from-file` are specified:

            * If `--fields` is specified, the only the specified fields will be
              updated.
            * Else, the policy will be replaced with the provided policy. The
              policy can be modified further using the flags from the Policy
              Settings group below.

          Otherwise, the policy will be updated with the values specified in
          the flags from the Policy Settings group.

          For information about the JSON/YAML format of an alerting policy:
          https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies
       c                     [         R                  " S5      /n[         R                  " X5        [        R                  " U S5        [        R
                  " U S[        R                  SS/SS9  g )Nzto be updated.policyzaThe list of fields to update. Must specify `--policy` or `--policy-from-file` if using this flag.disablednotificationChannelsT)fields_helpadd_settings_funcfields_choicesupdate)r	   CreateAlertPolicyResourceArgAddResourceArgsr   AddMessageFlags+AddFieldsFlagsWithMutuallyExclusiveSettingsAddPolicySettingsFlags)parser	resourcess     )lib/surface/monitoring/policies/update.pyArgsUpdate.Args4   se     	223CDFI!!&4	&(+	55@66"$:;    c                 `  ^ [         R                  " U/ SQS5        [        R                  " U5        [        R
                  " 5       nUR                  nSnUR                  R                  R                  5       nUR                  (       d  UR                  (       a#  Sn[         R                  " XR                  5      nOUR                  U5      nUR                  (       Gd"  UR                   m["        R$                  " USU4S j[         R&                  5      nUR)                  S5      (       a  UR*                  OS n/ n	[         R,                  " UUUR.                  UR0                  =(       d    UR2                  UR4                  UUU	S9  [         R6                  " US	UR                  R8                  UR:                  5      n
U
(       a  Xl        U	R=                  S	5        U(       a  S OS
R?                  [A        U	5      5      n	OS
R?                  UR                  5      n	URC                  XVU	5      $ )N)r   policy_from_filedisplay_nameenabledadd_notification_channelsremove_notification_channelsset_notification_channelsclear_notification_channelsdocumentationdocumentation_formatdocumentation_from_filefieldsupdate_user_labelsremove_user_labelsclear_user_labelsr   FTnotification_channelsc                     > T $ )N )channelss   r   <lambda>Update.Run.<locals>.<lambda>]   s    r"   r&   )r%   documentation_contentr,   r&   r5   field_masksuser_labels,)"r
   ValidateUpdateArgsSpecifiedr   ValidateAlertPolicyUpdateArgsr   AlertPolicyClientmessagesCONCEPTSalert_policyParser   r$   GetBasePolicyMessageFromArgsAlertPolicyGetr.   r   r   ParseResourceNameArgsParseNotificationChannelIsSpecifiedr&   ModifyAlertPolicyr%   r+   r-   r,   ProcessUpdateLabelsUserLabelsValue
userLabelsappendjoinsortedr   )selfargsclientr?   passed_yaml_policy
policy_refr   new_channelsr&   r.   
new_labelsr5   s              @r   Run
Update.RunB   s   $$	4 	 
''-'')FH++113J{{d++007K7KLf zz*%f;;;,,h33
')9

'
')l !% 0 0 ; ;gf


((



< < <#88	 ++





.
.


	j
 
&m$ *tsxxv/Gfxx$f==V44r"   r4   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr    rW   __static_attributes__r4   r"   r   r   r      s/    #  -(  ;5r"   r   N)r]   
__future__r   r   r   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r	   r
   $googlecloudsdk.command_lib.util.argsr   CreateCommandr   r4   r"   r   <module>rg      s9    3 &  ' 6 ( 7 ? 6 9`5T `5r"   