
    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  \R                  " \R                  R                  \R                  R                   5       " S
 S\R"                  5      5       rg)z,`gcloud monitoring channels update` command.    )absolute_import)division)unicode_literals)channels)base)flags)resource_args)utilc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	Create   zUpdate a notification channel.DESCRIPTIONa            Updates a notification channel.

          If `--channel-content` or `--channel-content-from-file` are specified:

            * --fields can be specified; only the specified fields will be
              updated.
            * Alternatively, the channel will be replaced with the provided
              channel. The channel can be modified further using the flags
              from the notification channel settings group below.

          Otherwise, the channel will be updated with the values specified in
          the flags from the notification channel settings group.

          For information about the JSON/YAML format of a notification channel:
          https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannels

          *Note:* When specifying the Channel as a YAML/JSON, the use of
          `channelLabels` as an alternative name for `labels` is supported.

          ## EXAMPLES
          The following command updates an existing email notification channel to point from
          its original email address to "newaddress@newdomain.tld":

            $ {command} "projects/12345/notificationChannels/67890"               --update-channel-labels=email_address=newaddress@newdomain.tld
       c                     [         R                  " SS5      n[         R                  " X/5        [        R                  " U S5        [        R
                  " U S[        R                  SS9  g )Nchannelz	to updatezchannel-contentzsThe list of fields to update. Must specify `--channel-content` or `--channel-content-from-file` if using this flag.T)fields_helpadd_settings_funcupdate)r	   $CreateNotificationChannelResourceArgAddResourceArgsr   AddMessageFlags+AddFieldsFlagsWithMutuallyExclusiveSettings"AddNotificationChannelSettingFlags)parserchannel_args     )lib/surface/monitoring/channels/update.pyArgsCreate.Args?   s\    DD; K!!&-8	&"34	55*  BB    c           	         [         R                  " U/ SQS5        [        R                  " U5        [        R
                  " 5       nUR                  nUR                  R                  R                  5       nSnUR                  =(       d    UR                  nU(       a1  Sn[         R                  " XcR                  S[         R                  S9nOUR                  U5      nUR                   (       Gd+  UR#                  S5      (       a  UR$                  OS n/ n	[         R&                  " UUR(                  UR*                  UR,                  UU	S9  [         R.                  " US	UR                  R0                  UR2                  5      n
[         R.                  " US
UR                  R4                  UR6                  5      nU
(       a  Xl        U	R9                  S	5        U(       a  Xl        U	R9                  S5        U(       a  S OSR;                  [=        U	5      5      n	OSR;                  UR                   5      n	UR?                  XGU	5      $ )N)channel_contentchannel_content_from_filedisplay_nameenabledtypedescriptionfieldsupdate_user_labelsremove_user_labelsclear_user_labelsupdate_channel_labelsremove_channel_labelsclear_channel_labelsr   FTNotificationChannel)field_remappingsr#   )channel_typer"   r%   r#   field_masksuser_labelschannel_labelslabels,) r
   ValidateUpdateArgsSpecifiedr   %ValidateNotificationChannelUpdateArgsr   NotificationChannelsClientmessagesCONCEPTSr   Parser    r!   MessageFromStringr-   CHANNELS_FIELD_REMAPPINGSGetr&   IsSpecifiedr#   ModifyNotificationChannelr$   r"   r%   ProcessUpdateLabelsUserLabelsValue
userLabelsLabelsValuer3   appendjoinsortedUpdate)selfargsclientr8   channel_refpassed_yaml_channelchannel_strr   r#   r&   new_user_labelsnew_channel_labelss               r   Run
Create.RunM   s   $$	: 	 
//5002FH--''--/K&&H$*H*HK &&
335J99;g 

;'g;;; $ 0 0 ; ;gf
$$W26))262C2C151A1A-4179 00
x;;KK


o  33
 (">">"J"J
.. 
,m$	+h
 +t0Hfxx$f==v66r    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rP   __static_attributes__rR   r   r   r   r      s/    & ->  97r   r   N)rW   
__future__r   r   r   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r	   r
   ReleaseTracksReleaseTrackALPHABETACreateCommandr   rR   r   r   <module>rd      sl    3 &  ' 6 ( 7 ? 6 D%%++T->->-C-CDi7T i7 Ei7r   