
    9                         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                   " S	 S
\R                  5      5       rg)z,`gcloud monitoring policies create` command.    )policies)base)flags)resource_args)util)log)
propertiesc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	Create   z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                 `   [         R                  " U S5        [         R                  " U 5        [         R                  " U 5        [        R
                  " SSR                  [        R                  R                  R                  R                  5       S9SSS9n[        R                  " X/5        g )Npolicyz--notification-channelsau              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.{universe_domain}/v3/projects/my-project/notificationChannels/channel-id0
            )universe_domainFT)arg_name
extra_helprequiredplural)r   AddMessageFlagsAddPolicySettingsFlagsAddConditionSettingsFlagsr   $CreateNotificationChannelResourceArgformatr	   VALUEScorer   GetAddResourceArgs)parserchannels_resource_args     )lib/surface/monitoring/policies/create.pyArgsCreate.Args/   s    	&(+	  (	##F+)NN* &--22BBFFH  
 %( !!&*AB    c                    [         R                  " 5       nUR                  n[        R                  " XR                  5      nUR
                  (       a:  [        R                  " UR
                  UR                  R                  5      Ul	        [        R                  " [        R                  R                  R                  R!                  5       5      nUR#                  XT5      n[$        R&                  " UR(                  S5        U$ )Nzalert policy)r   AlertPolicyClientmessagesr   CreateAlertPolicyFromArgsuser_labelsParseCreateLabelsAlertPolicyUserLabelsValue
userLabelsprojects_utilParseProjectr	   r   r   projectr   r   r   CreatedResourcename)selfargsclientr&   r   project_refresults          r    Run
Create.RunJ   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____firstlineno____doc__detailed_helpstaticmethodr!   r7   __static_attributes__r9   r#   r    r   r      s1    %  - C C4r#   r   N)r>   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   r   r   #googlecloudsdk.command_lib.projectsr-   googlecloudsdk.corer   r	   DefaultUniverseOnlyCreateCommandr   r9   r#   r    <module>rI      sK    3 7 ( 7 ? 6 E # * ;T ; ;r#   