
    6                     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 jrSS jr " S	 S
\	5      r
g)z,Utilities for Cloud Monitoring Policies API.    )absolute_import)division)unicode_literals)apisc                 .    [         R                  " SSU S9$ )N
monitoringv3no_http)r   GetClientInstancer
   s    1lib/googlecloudsdk/api_lib/monitoring/policies.pyr   r      s    			dG	DD    Nc                 @    U =(       d
    [        5       n U R                  $ N)r   MESSAGES_MODULE)clients    r   GetMessagesModuler      s    (&(&			r   c                   B    \ rS rSrSrS
S jrS rS rSS jrSS jr	S	r
g)AlertPolicyClient!   zFClient for the Alert Policy service in the Stackdriver Monitoring API.Nc                     U=(       d
    [        5       U l        U=(       d    [        U5      U l        U R                  R                  U l        g r   )r   r   r   messagesprojects_alertPolicies_service)selfr   r   s      r   __init__AlertPolicyClient.__init__$   s5    /-/DK9 1& 9DMKK66DMr   c                     U R                   R                  UR                  5       US9nU R                  R	                  U5      $ )z&Creates a Stackdriver alerting policy.)namealertPolicy)r   ,MonitoringProjectsAlertPoliciesCreateRequestRelativeNamer   Create)r   project_refpolicyreqs       r   r#   AlertPolicyClient.Create)   sB    
--
D
D%%' E C ==$$r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )z Gets an Monitoring Alert Policy.)r   )r   )MonitoringProjectsAlertPoliciesGetRequestr"   r   Get)r   
policy_refrequests      r   r*   AlertPolicyClient.Get0   s=    mmEE$$& F (G==W%%r   c                     U R                   R                  UR                  5       U=(       d    SS9nU R                  R	                  U5      $ )a  List Monitoring Alert Policies.

"list_filter" must be a valid filter expression or an empty value. For more
information, see
https://cloud.google.com/monitoring/api/v3/sorting-and-filtering

Args:
  project_ref: resources.Resource, Resource reference to the policy to be
    updated.
  list_filter: str, filter to be included in the ListAlertPOliciesRequest.

Returns:
  Alert policies that match the given filter. If no filter is given, fetches
  all policies from the target project.
 )r   filter)r   *MonitoringProjectsAlertPoliciesListRequestr"   r   List)r   r$   list_filterr,   s       r   r2   AlertPolicyClient.List6   sH      mmFF%%'0Ar G G ==g&&r   c                     U R                   R                  UR                  5       UUS9nU R                  R	                  U5      $ )a  Updates a Monitoring Alert Policy.

If fields is not specified, then the policy is replaced entirely. If
fields are specified, then only the fields are replaced.

Args:
  policy_ref: resources.Resource, Resource reference to the policy to be
      updated.
  policy: AlertPolicy, The policy message to be sent with the request.
  fields: str, Comma separated list of field masks.
Returns:
  AlertPolicy, The updated AlertPolicy.
)r   r    
updateMask)r   +MonitoringProjectsAlertPoliciesPatchRequestr"   r   Patch)r   r+   r%   fieldsr,   s        r   UpdateAlertPolicyClient.UpdateK   sG     mmGG$$& H G ==w''r   )r   r   r   )NNr   )__name__
__module____qualname____firstlineno____doc__r   r#   r*   r2   r:   __static_attributes__ r   r   r   r   !   s    N7
%&'*(r   r   )Fr   )r@   
__future__r   r   r   googlecloudsdk.api_lib.utilr   r   r   objectr   rB   r   r   <module>rF      s-    3 &  ' ,E 
<( <(r   