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\Logging\Resource;
19
20use Google\Service\Logging\ListLogMetricsResponse;
21use Google\Service\Logging\LogMetric;
22use Google\Service\Logging\LoggingEmpty;
23
24/**
25 * The "metrics" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $loggingService = new Google\Service\Logging(...);
29 *   $metrics = $loggingService->metrics;
30 *  </code>
31 */
32class ProjectsMetrics extends \Google\Service\Resource
33{
34  /**
35   * Creates a logs-based metric. (metrics.create)
36   *
37   * @param string $parent Required. The resource name of the project in which to
38   * create the metric: "projects/[PROJECT_ID]" The new metric must be provided in
39   * the request.
40   * @param LogMetric $postBody
41   * @param array $optParams Optional parameters.
42   * @return LogMetric
43   */
44  public function create($parent, LogMetric $postBody, $optParams = [])
45  {
46    $params = ['parent' => $parent, 'postBody' => $postBody];
47    $params = array_merge($params, $optParams);
48    return $this->call('create', [$params], LogMetric::class);
49  }
50  /**
51   * Deletes a logs-based metric. (metrics.delete)
52   *
53   * @param string $metricName Required. The resource name of the metric to
54   * delete: "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
55   * @param array $optParams Optional parameters.
56   * @return LoggingEmpty
57   */
58  public function delete($metricName, $optParams = [])
59  {
60    $params = ['metricName' => $metricName];
61    $params = array_merge($params, $optParams);
62    return $this->call('delete', [$params], LoggingEmpty::class);
63  }
64  /**
65   * Gets a logs-based metric. (metrics.get)
66   *
67   * @param string $metricName Required. The resource name of the desired metric:
68   * "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
69   * @param array $optParams Optional parameters.
70   * @return LogMetric
71   */
72  public function get($metricName, $optParams = [])
73  {
74    $params = ['metricName' => $metricName];
75    $params = array_merge($params, $optParams);
76    return $this->call('get', [$params], LogMetric::class);
77  }
78  /**
79   * Lists logs-based metrics. (metrics.listProjectsMetrics)
80   *
81   * @param string $parent Required. The name of the project containing the
82   * metrics: "projects/[PROJECT_ID]"
83   * @param array $optParams Optional parameters.
84   *
85   * @opt_param int pageSize Optional. The maximum number of results to return
86   * from this request. Non-positive values are ignored. The presence of
87   * nextPageToken in the response indicates that more results might be available.
88   * @opt_param string pageToken Optional. If present, then retrieve the next
89   * batch of results from the preceding call to this method. pageToken must be
90   * the value of nextPageToken from the previous response. The values of other
91   * method parameters should be identical to those in the previous call.
92   * @return ListLogMetricsResponse
93   */
94  public function listProjectsMetrics($parent, $optParams = [])
95  {
96    $params = ['parent' => $parent];
97    $params = array_merge($params, $optParams);
98    return $this->call('list', [$params], ListLogMetricsResponse::class);
99  }
100  /**
101   * Creates or updates a logs-based metric. (metrics.update)
102   *
103   * @param string $metricName Required. The resource name of the metric to
104   * update: "projects/[PROJECT_ID]/metrics/[METRIC_ID]" The updated metric must
105   * be provided in the request and it's name field must be the same as
106   * [METRIC_ID] If the metric does not exist in [PROJECT_ID], then a new metric
107   * is created.
108   * @param LogMetric $postBody
109   * @param array $optParams Optional parameters.
110   * @return LogMetric
111   */
112  public function update($metricName, LogMetric $postBody, $optParams = [])
113  {
114    $params = ['metricName' => $metricName, 'postBody' => $postBody];
115    $params = array_merge($params, $optParams);
116    return $this->call('update', [$params], LogMetric::class);
117  }
118}
119
120// Adding a class alias for backwards compatibility with the previous class name.
121class_alias(ProjectsMetrics::class, 'Google_Service_Logging_Resource_ProjectsMetrics');
122