
    *                         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 ddlmZ  G d dej$                        Zy)z,`gcloud monitoring policies create` command.    )absolute_import)division)unicode_literals)policies)base)flags)resource_args)util)log)
propertiesc                   .    e Zd ZdZddiZed        Zd Zy)CreatezCreate a new alerting policy.DESCRIPTIONa            Creates a new alerting policy. An alert policy can be specified as a
          JSON/YAML value passed in as a string through the `--policy` flag or
          as a file through the `--policy-from-file` flag. A basic policy can
          also be specified through command line flags. If a policy is specified
          through `--policy` or `--policy-from-file`, and additional flags are
          supplied, the flags will override the policy's settings and a
          specified condition will be appended to the list of conditions.

          For information about the JSON/YAML format of an alerting policy:
          https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies
       c                     t        j                  | d       t        j                  |        t        j                  |        t	        j
                  dddd      }t	        j                  | |g       y )Npolicyz--notification-channelsar              to be added to the policy. These should be the resource names (not
            the display name) of the channels. Acceptable formats are:

            * Channel Name: `my-channel`
              * The project specified through `--project` or the default
                project defined by the `core/project` property will be used,
                in that order.
            * Channel Relative Name:
                `projects/my-project/notificationChannels/channel-id0`
            * Channel URI:
                https://monitoring.googleapis.com/v3/projects/my-project/notificationChannels/channel-id0
            FT)arg_name
extra_helprequiredplural)r   AddMessageFlagsAddPolicySettingsFlagsAddConditionSettingsFlagsr	   $CreateNotificationChannelResourceArgAddResourceArgs)parserchannels_resource_args     )lib/surface/monitoring/policies/create.pyArgszCreate.Args1   se    	&(+	  (	##F+)NN* !" !!&+@*AB    c                    t        j                         }|j                  }t        j                  ||j                        }|j
                  r9t        j                  |j
                  |j                  j                        |_	        t        j                  t        j                  j                  j                  j!                               }|j#                  ||      }t%        j&                  |j(                  d       |S )Nzalert policy)r   AlertPolicyClientmessagesr
   CreateAlertPolicyFromArgsuser_labelsParseCreateLabelsAlertPolicyUserLabelsValue
userLabelsprojects_utilParseProjectr   VALUEScoreprojectGetr   r   CreatedResourcename)selfargsclientr"   r   project_refresults          r   Runz
Create.RunI   s    '')FH++D&//BF00


H00@@Bf 	"":#4#4#9#9#A#A#E#E#GH  ]];/F^4Mr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r6    r   r   r   r      s1    %  - C C.r   r   N)r:   
__future__r   r   r   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r	   r
   #googlecloudsdk.command_lib.projectsr)   googlecloudsdk.corer   r   CreateCommandr   r=   r   r   <module>rE      s=    3 &  ' 6 ( 7 ? 6 E # *8T 8r   