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\Group;
21use Google\Service\Monitoring\ListGroupsResponse;
22use Google\Service\Monitoring\MonitoringEmpty;
23
24/**
25 * The "groups" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $monitoringService = new Google\Service\Monitoring(...);
29 *   $groups = $monitoringService->groups;
30 *  </code>
31 */
32class ProjectsGroups extends \Google\Service\Resource
33{
34  /**
35   * Creates a new group. (groups.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 group. The format is: projects/[PROJECT_ID_OR_NUMBER]
40   * @param Group $postBody
41   * @param array $optParams Optional parameters.
42   *
43   * @opt_param bool validateOnly If true, validate this request but do not create
44   * the group.
45   * @return Group
46   */
47  public function create($name, Group $postBody, $optParams = [])
48  {
49    $params = ['name' => $name, 'postBody' => $postBody];
50    $params = array_merge($params, $optParams);
51    return $this->call('create', [$params], Group::class);
52  }
53  /**
54   * Deletes an existing group. (groups.delete)
55   *
56   * @param string $name Required. The group to delete. The format is:
57   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
58   * @param array $optParams Optional parameters.
59   *
60   * @opt_param bool recursive If this field is true, then the request means to
61   * delete a group with all its descendants. Otherwise, the request means to
62   * delete a group only when it has no descendants. The default value is false.
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 group. (groups.get)
73   *
74   * @param string $name Required. The group to retrieve. The format is:
75   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
76   * @param array $optParams Optional parameters.
77   * @return Group
78   */
79  public function get($name, $optParams = [])
80  {
81    $params = ['name' => $name];
82    $params = array_merge($params, $optParams);
83    return $this->call('get', [$params], Group::class);
84  }
85  /**
86   * Lists the existing groups. (groups.listProjectsGroups)
87   *
88   * @param string $name Required. The project
89   * (https://cloud.google.com/monitoring/api/v3#project_name) whose groups are to
90   * be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
91   * @param array $optParams Optional parameters.
92   *
93   * @opt_param string ancestorsOfGroup A group name. The format is:
94   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns groups that are
95   * ancestors of the specified group. The groups are returned in order, starting
96   * with the immediate parent and ending with the most distant ancestor. If the
97   * specified group has no immediate parent, the results are empty.
98   * @opt_param string childrenOfGroup A group name. The format is:
99   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns groups whose
100   * parent_name field contains the group name. If no groups have this parent, the
101   * results are empty.
102   * @opt_param string descendantsOfGroup A group name. The format is:
103   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns the descendants of
104   * the specified group. This is a superset of the results returned by the
105   * children_of_group filter, and includes children-of-children, and so forth.
106   * @opt_param int pageSize A positive number that is the maximum number of
107   * results to return.
108   * @opt_param string pageToken If this field is not empty then it must contain
109   * the next_page_token value returned by a previous call to this method. Using
110   * this field causes the method to return additional results from the previous
111   * method call.
112   * @return ListGroupsResponse
113   */
114  public function listProjectsGroups($name, $optParams = [])
115  {
116    $params = ['name' => $name];
117    $params = array_merge($params, $optParams);
118    return $this->call('list', [$params], ListGroupsResponse::class);
119  }
120  /**
121   * Updates an existing group. You can change any group attributes except name.
122   * (groups.update)
123   *
124   * @param string $name Output only. The name of this group. The format is:
125   * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this
126   * field is ignored and a new name is created consisting of the project
127   * specified in the call to CreateGroup and a unique [GROUP_ID] that is
128   * generated automatically.
129   * @param Group $postBody
130   * @param array $optParams Optional parameters.
131   *
132   * @opt_param bool validateOnly If true, validate this request but do not update
133   * the existing group.
134   * @return Group
135   */
136  public function update($name, Group $postBody, $optParams = [])
137  {
138    $params = ['name' => $name, 'postBody' => $postBody];
139    $params = array_merge($params, $optParams);
140    return $this->call('update', [$params], Group::class);
141  }
142}
143
144// Adding a class alias for backwards compatibility with the previous class name.
145class_alias(ProjectsGroups::class, 'Google_Service_Monitoring_Resource_ProjectsGroups');
146