
                         &   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dl	mZ ddlmZ dd	lmZ dd
lmZ  ej"                  ej$                  j&                  ej$                  j(                         G d dej*                               Zy)z,`gcloud monitoring channels create` command.    )absolute_import)division)unicode_literals)channels)base)flags)util)log)
propertiesc                   .    e Zd ZdZddiZed        Zd Zy)Createz"Create a new notification channel.DESCRIPTIONa	            Creates a new notification channel. A channel can be specified as
          JSON/YAML passed in as a string through the `--channel-content` flag
          or as a file through the `--channel-content-from-file` flag.
          A basic channel can also be specified through command line flags. If
          a channel is specified through `--channel-content` or
          `--channel-content-from-file`, and additional flags are supplied, the
          flags will override the given channel's settings.

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

          Additional documentation can for this operation can be found at:
          https://cloud.google.com/monitoring/alerts/using-channels-api

          ## EXAMPLES
          The following commands setup both email and SMS notification channels for the team lead. Note
          that the display name and description focus on the purpose/semantics of the channel rather
          than its destination. This is a best-practice that facilitates swapping/updating notification
          channels in-place (such as when users change teams, projects, roles, companies, etc.) with
          minimal impact to the alerting policies that reference the existing channels. It is also
          a best practice to supply at least two channels of different types for a given person.

            $ {command}               --display-name="Foo Team Lead (Primary)"               --description="Primary contact method for the Foo team lead"               --type=email               --user-labels=team=foo,role=lead,ord=1               --channel-labels=email_address=user@somedomain.tld

            $ {command}               --display-name="Foo Team Lead (Secondary)"               --description="Secondary contact method for the Foo team lead"               --type=sms               --user-labels=team=foo,role=lead,ord=2               --channel-labels=number=123-456-7890
       c                 Z    t        j                  | d       t        j                  |        y )Nzchannel-content)r   AddMessageFlags"AddNotificationChannelSettingFlags)parsers    )lib/surface/monitoring/channels/create.pyArgszCreate.ArgsK   s!    	&"34	,,V4    c                 t   t        j                         }|j                  }t        j                  ||      }|j
                  r9t        j                  |j
                  |j                  j                        |_	        |j                  r9t        j                  |j                  |j                  j                        |_        t        j                  t        j                   j"                  j$                  j'                               }|j)                  ||      }t+        j,                  |j.                  d       |S )Nznotification channel)r   NotificationChannelsClientmessagesr	   GetNotificationChannelFromArgsuser_labelsParseCreateLabelsNotificationChannelUserLabelsValue
userLabelschannel_labelsLabelsValuelabelsprojects_utilParseProjectr   VALUEScoreprojectGetr   r
   CreatedResourcename)selfargsclientr   channelproject_refresults          r   Runz
Create.RunP   s    002FH11$AG11


H88HHJg--


x;;GGIgn 	"":#4#4#9#9#A#A#E#E#GH  ]];0F%;<Mr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r0    r   r   r   r      s0    * $'-R 5 5r   r   N)r4   
__future__r   r   r   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r	   #googlecloudsdk.command_lib.projectsr"   googlecloudsdk.corer
   r   ReleaseTracksReleaseTrackALPHABETACreateCommandr   r7   r   r   <module>rC      st    3 &  ' 6 ( 7 6 E # * D%%++T->->-C-CDCT C ECr   