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\ListMetricDescriptorsResponse;
21use Google\Service\Monitoring\MetricDescriptor;
22use Google\Service\Monitoring\MonitoringEmpty;
23
24/**
25 * The "metricDescriptors" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $monitoringService = new Google\Service\Monitoring(...);
29 *   $metricDescriptors = $monitoringService->metricDescriptors;
30 *  </code>
31 */
32class ProjectsMetricDescriptors extends \Google\Service\Resource
33{
34  /**
35   * Creates a new metric descriptor. The creation is executed asynchronously and
36   * callers may check the returned operation to track its progress. User-created
37   * metric descriptors define custom metrics (https://cloud.google.com/monitoring
38   * /custom-metrics). (metricDescriptors.create)
39   *
40   * @param string $name Required. The project
41   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
42   * the request. The format is: 4 projects/PROJECT_ID_OR_NUMBER
43   * @param MetricDescriptor $postBody
44   * @param array $optParams Optional parameters.
45   * @return MetricDescriptor
46   */
47  public function create($name, MetricDescriptor $postBody, $optParams = [])
48  {
49    $params = ['name' => $name, 'postBody' => $postBody];
50    $params = array_merge($params, $optParams);
51    return $this->call('create', [$params], MetricDescriptor::class);
52  }
53  /**
54   * Deletes a metric descriptor. Only user-created custom metrics
55   * (https://cloud.google.com/monitoring/custom-metrics) can be deleted.
56   * (metricDescriptors.delete)
57   *
58   * @param string $name Required. The metric descriptor on which to execute the
59   * request. The format is:
60   * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example of
61   * [METRIC_ID] is: "custom.googleapis.com/my_test_metric".
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 metric descriptor. (metricDescriptors.get)
73   *
74   * @param string $name Required. The metric descriptor on which to execute the
75   * request. The format is:
76   * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example
77   * value of [METRIC_ID] is
78   * "compute.googleapis.com/instance/disk/read_bytes_count".
79   * @param array $optParams Optional parameters.
80   * @return MetricDescriptor
81   */
82  public function get($name, $optParams = [])
83  {
84    $params = ['name' => $name];
85    $params = array_merge($params, $optParams);
86    return $this->call('get', [$params], MetricDescriptor::class);
87  }
88  /**
89   * Lists metric descriptors that match a filter.
90   * (metricDescriptors.listProjectsMetricDescriptors)
91   *
92   * @param string $name Required. The project
93   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
94   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param string filter If this field is empty, all custom and system-
98   * defined metric descriptors are returned. Otherwise, the filter
99   * (https://cloud.google.com/monitoring/api/v3/filters) specifies which metric
100   * descriptors are to be returned. For example, the following filter matches all
101   * custom metrics (https://cloud.google.com/monitoring/custom-metrics):
102   * metric.type = starts_with("custom.googleapis.com/")
103   * @opt_param int pageSize A positive number that is the maximum number of
104   * results to return.
105   * @opt_param string pageToken If this field is not empty then it must contain
106   * the nextPageToken value returned by a previous call to this method. Using
107   * this field causes the method to return additional results from the previous
108   * method call.
109   * @return ListMetricDescriptorsResponse
110   */
111  public function listProjectsMetricDescriptors($name, $optParams = [])
112  {
113    $params = ['name' => $name];
114    $params = array_merge($params, $optParams);
115    return $this->call('list', [$params], ListMetricDescriptorsResponse::class);
116  }
117}
118
119// Adding a class alias for backwards compatibility with the previous class name.
120class_alias(ProjectsMetricDescriptors::class, 'Google_Service_Monitoring_Resource_ProjectsMetricDescriptors');
121