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\GetNotificationChannelVerificationCodeRequest;
21use Google\Service\Monitoring\GetNotificationChannelVerificationCodeResponse;
22use Google\Service\Monitoring\ListNotificationChannelsResponse;
23use Google\Service\Monitoring\MonitoringEmpty;
24use Google\Service\Monitoring\NotificationChannel;
25use Google\Service\Monitoring\SendNotificationChannelVerificationCodeRequest;
26use Google\Service\Monitoring\VerifyNotificationChannelRequest;
27
28/**
29 * The "notificationChannels" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $monitoringService = new Google\Service\Monitoring(...);
33 *   $notificationChannels = $monitoringService->notificationChannels;
34 *  </code>
35 */
36class ProjectsNotificationChannels extends \Google\Service\Resource
37{
38  /**
39   * Creates a new notification channel, representing a single notification
40   * endpoint such as an email address, SMS number, or PagerDuty service.
41   * (notificationChannels.create)
42   *
43   * @param string $name Required. The project
44   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
45   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the
46   * container into which the channel will be written, this does not name the
47   * newly created channel. The resulting channel's name will have a normalized
48   * version of this field as a prefix, but will add
49   * /notificationChannels/[CHANNEL_ID] to identify the channel.
50   * @param NotificationChannel $postBody
51   * @param array $optParams Optional parameters.
52   * @return NotificationChannel
53   */
54  public function create($name, NotificationChannel $postBody, $optParams = [])
55  {
56    $params = ['name' => $name, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], NotificationChannel::class);
59  }
60  /**
61   * Deletes a notification channel. (notificationChannels.delete)
62   *
63   * @param string $name Required. The channel for which to execute the request.
64   * The format is:
65   * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
66   * @param array $optParams Optional parameters.
67   *
68   * @opt_param bool force If true, the notification channel will be deleted
69   * regardless of its use in alert policies (the policies will be updated to
70   * remove the channel). If false, channels that are still referenced by an
71   * existing alerting policy will fail to be deleted in a delete operation.
72   * @return MonitoringEmpty
73   */
74  public function delete($name, $optParams = [])
75  {
76    $params = ['name' => $name];
77    $params = array_merge($params, $optParams);
78    return $this->call('delete', [$params], MonitoringEmpty::class);
79  }
80  /**
81   * Gets a single notification channel. The channel includes the relevant
82   * configuration details with which the channel was created. However, the
83   * response may truncate or omit passwords, API keys, or other private key
84   * matter and thus the response may not be 100% identical to the information
85   * that was supplied in the call to the create method.
86   * (notificationChannels.get)
87   *
88   * @param string $name Required. The channel for which to execute the request.
89   * The format is:
90   * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
91   * @param array $optParams Optional parameters.
92   * @return NotificationChannel
93   */
94  public function get($name, $optParams = [])
95  {
96    $params = ['name' => $name];
97    $params = array_merge($params, $optParams);
98    return $this->call('get', [$params], NotificationChannel::class);
99  }
100  /**
101   * Requests a verification code for an already verified channel that can then be
102   * used in a call to VerifyNotificationChannel() on a different channel with an
103   * equivalent identity in the same or in a different project. This makes it
104   * possible to copy a channel between projects without requiring manual
105   * reverification of the channel. If the channel is not in the verified state,
106   * this method will fail (in other words, this may only be used if the
107   * SendNotificationChannelVerificationCode and VerifyNotificationChannel paths
108   * have already been used to put the given channel into the verified
109   * state).There is no guarantee that the verification codes returned by this
110   * method will be of a similar structure or form as the ones that are delivered
111   * to the channel via SendNotificationChannelVerificationCode; while
112   * VerifyNotificationChannel() will recognize both the codes delivered via
113   * SendNotificationChannelVerificationCode() and returned from
114   * GetNotificationChannelVerificationCode(), it is typically the case that the
115   * verification codes delivered via SendNotificationChannelVerificationCode()
116   * will be shorter and also have a shorter expiration (e.g. codes such as
117   * "G-123456") whereas GetVerificationCode() will typically return a much
118   * longer, websafe base 64 encoded string that has a longer expiration time.
119   * (notificationChannels.getVerificationCode)
120   *
121   * @param string $name Required. The notification channel for which a
122   * verification code is to be generated and retrieved. This must name a channel
123   * that is already verified; if the specified channel is not verified, the
124   * request will fail.
125   * @param GetNotificationChannelVerificationCodeRequest $postBody
126   * @param array $optParams Optional parameters.
127   * @return GetNotificationChannelVerificationCodeResponse
128   */
129  public function getVerificationCode($name, GetNotificationChannelVerificationCodeRequest $postBody, $optParams = [])
130  {
131    $params = ['name' => $name, 'postBody' => $postBody];
132    $params = array_merge($params, $optParams);
133    return $this->call('getVerificationCode', [$params], GetNotificationChannelVerificationCodeResponse::class);
134  }
135  /**
136   * Lists the notification channels that have been created for the project.
137   * (notificationChannels.listProjectsNotificationChannels)
138   *
139   * @param string $name Required. The project
140   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
141   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the
142   * container in which to look for the notification channels; it does not name a
143   * specific channel. To query a specific channel by REST resource name, use the
144   * GetNotificationChannel operation.
145   * @param array $optParams Optional parameters.
146   *
147   * @opt_param string filter If provided, this field specifies the criteria that
148   * must be met by notification channels to be included in the response.For more
149   * details, see sorting and filtering
150   * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
151   * @opt_param string orderBy A comma-separated list of fields by which to sort
152   * the result. Supports the same set of fields as in filter. Entries can be
153   * prefixed with a minus sign to sort in descending rather than ascending
154   * order.For more details, see sorting and filtering
155   * (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
156   * @opt_param int pageSize The maximum number of results to return in a single
157   * response. If not set to a positive number, a reasonable value will be chosen
158   * by the service.
159   * @opt_param string pageToken If non-empty, page_token must contain a value
160   * returned as the next_page_token in a previous response to request the next
161   * set of results.
162   * @return ListNotificationChannelsResponse
163   */
164  public function listProjectsNotificationChannels($name, $optParams = [])
165  {
166    $params = ['name' => $name];
167    $params = array_merge($params, $optParams);
168    return $this->call('list', [$params], ListNotificationChannelsResponse::class);
169  }
170  /**
171   * Updates a notification channel. Fields not specified in the field mask remain
172   * unchanged. (notificationChannels.patch)
173   *
174   * @param string $name The full REST resource name for this channel. The format
175   * is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] The
176   * [CHANNEL_ID] is automatically assigned by the server on creation.
177   * @param NotificationChannel $postBody
178   * @param array $optParams Optional parameters.
179   *
180   * @opt_param string updateMask The fields to update.
181   * @return NotificationChannel
182   */
183  public function patch($name, NotificationChannel $postBody, $optParams = [])
184  {
185    $params = ['name' => $name, 'postBody' => $postBody];
186    $params = array_merge($params, $optParams);
187    return $this->call('patch', [$params], NotificationChannel::class);
188  }
189  /**
190   * Causes a verification code to be delivered to the channel. The code can then
191   * be supplied in VerifyNotificationChannel to verify the channel.
192   * (notificationChannels.sendVerificationCode)
193   *
194   * @param string $name Required. The notification channel to which to send a
195   * verification code.
196   * @param SendNotificationChannelVerificationCodeRequest $postBody
197   * @param array $optParams Optional parameters.
198   * @return MonitoringEmpty
199   */
200  public function sendVerificationCode($name, SendNotificationChannelVerificationCodeRequest $postBody, $optParams = [])
201  {
202    $params = ['name' => $name, 'postBody' => $postBody];
203    $params = array_merge($params, $optParams);
204    return $this->call('sendVerificationCode', [$params], MonitoringEmpty::class);
205  }
206  /**
207   * Verifies a NotificationChannel by proving receipt of the code delivered to
208   * the channel as a result of calling SendNotificationChannelVerificationCode.
209   * (notificationChannels.verify)
210   *
211   * @param string $name Required. The notification channel to verify.
212   * @param VerifyNotificationChannelRequest $postBody
213   * @param array $optParams Optional parameters.
214   * @return NotificationChannel
215   */
216  public function verify($name, VerifyNotificationChannelRequest $postBody, $optParams = [])
217  {
218    $params = ['name' => $name, 'postBody' => $postBody];
219    $params = array_merge($params, $optParams);
220    return $this->call('verify', [$params], NotificationChannel::class);
221  }
222}
223
224// Adding a class alias for backwards compatibility with the previous class name.
225class_alias(ProjectsNotificationChannels::class, 'Google_Service_Monitoring_Resource_ProjectsNotificationChannels');
226