1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Monitoring\Resource;
19
20use Google\Service\Monitoring\AlertPolicy;
21use Google\Service\Monitoring\ListAlertPoliciesResponse;
22use Google\Service\Monitoring\MonitoringEmpty;
23
24/**
25 * The "alertPolicies" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $monitoringService = new Google\Service\Monitoring(...);
29 *   $alertPolicies = $monitoringService->alertPolicies;
30 *  </code>
31 */
32class ProjectsAlertPolicies extends \Google\Service\Resource
33{
34  /**
35   * Creates a new alerting policy. (alertPolicies.create)
36   *
37   * @param string $name Required. The project
38   * (https://cloud.google.com/monitoring/api/v3#project_name) in which to create
39   * the alerting policy. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that
40   * this field names the parent container in which the alerting policy will be
41   * written, not the name of the created policy. |name| must be a host project of
42   * a workspace, otherwise INVALID_ARGUMENT error will return. The alerting
43   * policy that is returned will have a name that contains a normalized
44   * representation of this name as a prefix but adds a suffix of the form
45   * /alertPolicies/[ALERT_POLICY_ID], identifying the policy in the container.
46   * @param AlertPolicy $postBody
47   * @param array $optParams Optional parameters.
48   * @return AlertPolicy
49   */
50  public function create($name, AlertPolicy $postBody, $optParams = [])
51  {
52    $params = ['name' => $name, 'postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('create', [$params], AlertPolicy::class);
55  }
56  /**
57   * Deletes an alerting policy. (alertPolicies.delete)
58   *
59   * @param string $name Required. The alerting policy to delete. The format is:
60   * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] For more
61   * information, see AlertPolicy.
62   * @param array $optParams Optional parameters.
63   * @return MonitoringEmpty
64   */
65  public function delete($name, $optParams = [])
66  {
67    $params = ['name' => $name];
68    $params = array_merge($params, $optParams);
69    return $this->call('delete', [$params], MonitoringEmpty::class);
70  }
71  /**
72   * Gets a single alerting policy. (alertPolicies.get)
73   *
74   * @param string $name Required. The alerting policy to retrieve. The format is:
75   * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
76   * @param array $optParams Optional parameters.
77   * @return AlertPolicy
78   */
79  public function get($name, $optParams = [])
80  {
81    $params = ['name' => $name];
82    $params = array_merge($params, $optParams);
83    return $this->call('get', [$params], AlertPolicy::class);
84  }
85  /**
86   * Lists the existing alerting policies for the workspace.
87   * (alertPolicies.listProjectsAlertPolicies)
88   *
89   * @param string $name Required. The project
90   * (https://cloud.google.com/monitoring/api/v3#project_name) whose alert
91   * policies are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
92   * Note that this field names the parent container in which the alerting
93   * policies to be listed are stored. To retrieve a single alerting policy by
94   * name, use the GetAlertPolicy operation, instead.
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param string filter If provided, this field specifies the criteria that
98   * must be met by alert policies to be included in the response.For more
99   * details, see sorting and filtering
100   * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
101   * @opt_param string orderBy A comma-separated list of fields by which to sort
102   * the result. Supports the same set of field references as the filter field.
103   * Entries can be prefixed with a minus sign to sort by the field in descending
104   * order.For more details, see sorting and filtering
105   * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
106   * @opt_param int pageSize The maximum number of results to return in a single
107   * response.
108   * @opt_param string pageToken If this field is not empty then it must contain
109   * the nextPageToken value returned by a previous call to this method. Using
110   * this field causes the method to return more results from the previous method
111   * call.
112   * @return ListAlertPoliciesResponse
113   */
114  public function listProjectsAlertPolicies($name, $optParams = [])
115  {
116    $params = ['name' => $name];
117    $params = array_merge($params, $optParams);
118    return $this->call('list', [$params], ListAlertPoliciesResponse::class);
119  }
120  /**
121   * Updates an alerting policy. You can either replace the entire policy with a
122   * new one or replace only certain fields in the current alerting policy by
123   * specifying the fields to be updated via updateMask. Returns the updated
124   * alerting policy. (alertPolicies.patch)
125   *
126   * @param string $name Required if the policy exists. The resource name for this
127   * policy. The format is:
128   * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
129   * [ALERT_POLICY_ID] is assigned by Stackdriver Monitoring when the policy is
130   * created. When calling the alertPolicies.create method, do not include the
131   * name field in the alerting policy passed as part of the request.
132   * @param AlertPolicy $postBody
133   * @param array $optParams Optional parameters.
134   *
135   * @opt_param string updateMask Optional. A list of alerting policy field names.
136   * If this field is not empty, each listed field in the existing alerting policy
137   * is set to the value of the corresponding field in the supplied policy
138   * (alert_policy), or to the field's default value if the field is not in the
139   * supplied alerting policy. Fields not listed retain their previous
140   * value.Examples of valid field masks include display_name, documentation,
141   * documentation.content, documentation.mime_type, user_labels,
142   * user_label.nameofkey, enabled, conditions, combiner, etc.If this field is
143   * empty, then the supplied alerting policy replaces the existing policy. It is
144   * the same as deleting the existing policy and adding the supplied policy,
145   * except for the following: The new policy will have the same [ALERT_POLICY_ID]
146   * as the former policy. This gives you continuity with the former policy in
147   * your notifications and incidents. Conditions in the new policy will keep
148   * their former [CONDITION_ID] if the supplied condition includes the name field
149   * with that [CONDITION_ID]. If the supplied condition omits the name field,
150   * then a new [CONDITION_ID] is created.
151   * @return AlertPolicy
152   */
153  public function patch($name, AlertPolicy $postBody, $optParams = [])
154  {
155    $params = ['name' => $name, 'postBody' => $postBody];
156    $params = array_merge($params, $optParams);
157    return $this->call('patch', [$params], AlertPolicy::class);
158  }
159}
160
161// Adding a class alias for backwards compatibility with the previous class name.
162class_alias(ProjectsAlertPolicies::class, 'Google_Service_Monitoring_Resource_ProjectsAlertPolicies');
163