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\CreateTimeSeriesRequest;
21use Google\Service\Monitoring\ListTimeSeriesResponse;
22use Google\Service\Monitoring\MonitoringEmpty;
23use Google\Service\Monitoring\QueryTimeSeriesRequest;
24use Google\Service\Monitoring\QueryTimeSeriesResponse;
25
26/**
27 * The "timeSeries" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $monitoringService = new Google\Service\Monitoring(...);
31 *   $timeSeries = $monitoringService->timeSeries;
32 *  </code>
33 */
34class ProjectsTimeSeries extends \Google\Service\Resource
35{
36  /**
37   * Creates or adds data to one or more time series. The response is empty if all
38   * time series in the request were written. If any time series could not be
39   * written, a corresponding failure message is included in the error response.
40   * (timeSeries.create)
41   *
42   * @param string $name Required. The project
43   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
44   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
45   * @param CreateTimeSeriesRequest $postBody
46   * @param array $optParams Optional parameters.
47   * @return MonitoringEmpty
48   */
49  public function create($name, CreateTimeSeriesRequest $postBody, $optParams = [])
50  {
51    $params = ['name' => $name, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('create', [$params], MonitoringEmpty::class);
54  }
55  /**
56   * Creates or adds data to one or more service time series. A service time
57   * series is a time series for a metric from a Google Cloud service. The
58   * response is empty if all time series in the request were written. If any time
59   * series could not be written, a corresponding failure message is included in
60   * the error response. This endpoint rejects writes to user-defined metrics.
61   * This method is only for use by Google Cloud services. Use
62   * projects.timeSeries.create instead. (timeSeries.createService)
63   *
64   * @param string $name Required. The project
65   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
66   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
67   * @param CreateTimeSeriesRequest $postBody
68   * @param array $optParams Optional parameters.
69   * @return MonitoringEmpty
70   */
71  public function createService($name, CreateTimeSeriesRequest $postBody, $optParams = [])
72  {
73    $params = ['name' => $name, 'postBody' => $postBody];
74    $params = array_merge($params, $optParams);
75    return $this->call('createService', [$params], MonitoringEmpty::class);
76  }
77  /**
78   * Lists time series that match a filter. (timeSeries.listProjectsTimeSeries)
79   *
80   * @param string $name Required. The project
81   * (https://cloud.google.com/monitoring/api/v3#project_name), organization or
82   * folder on which to execute the request. The format is:
83   * projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID]
84   * folders/[FOLDER_ID]
85   * @param array $optParams Optional parameters.
86   *
87   * @opt_param string aggregation.alignmentPeriod The alignment_period specifies
88   * a time interval, in seconds, that is used to divide the data in all the time
89   * series into consistent blocks of time. This will be done before the per-
90   * series aligner can be applied to the data.The value must be at least 60
91   * seconds. If a per-series aligner other than ALIGN_NONE is specified, this
92   * field is required or an error is returned. If no per-series aligner is
93   * specified, or the aligner ALIGN_NONE is specified, then this field is
94   * ignored.The maximum value of the alignment_period is 104 weeks (2 years) for
95   * charts, and 90,000 seconds (25 hours) for alerting policies.
96   * @opt_param string aggregation.crossSeriesReducer The reduction operation to
97   * be used to combine time series into a single time series, where the value of
98   * each data point in the resulting series is a function of all the already
99   * aligned values in the input time series.Not all reducer operations can be
100   * applied to all time series. The valid choices depend on the metric_kind and
101   * the value_type of the original time series. Reduction can yield a time series
102   * with a different metric_kind or value_type than the input time series.Time
103   * series data must first be aligned (see per_series_aligner) in order to
104   * perform cross-time series reduction. If cross_series_reducer is specified,
105   * then per_series_aligner must be specified, and must not be ALIGN_NONE. An
106   * alignment_period must also be specified; otherwise, an error is returned.
107   * @opt_param string aggregation.groupByFields The set of fields to preserve
108   * when cross_series_reducer is specified. The group_by_fields determine how the
109   * time series are partitioned into subsets prior to applying the aggregation
110   * operation. Each subset contains time series that have the same value for each
111   * of the grouping fields. Each individual time series is a member of exactly
112   * one subset. The cross_series_reducer is applied to each subset of time
113   * series. It is not possible to reduce across different resource types, so this
114   * field implicitly contains resource.type. Fields not specified in
115   * group_by_fields are aggregated away. If group_by_fields is not specified and
116   * all the time series have the same resource type, then the time series are
117   * aggregated into a single output time series. If cross_series_reducer is not
118   * defined, this field is ignored.
119   * @opt_param string aggregation.perSeriesAligner An Aligner describes how to
120   * bring the data points in a single time series into temporal alignment. Except
121   * for ALIGN_NONE, all alignments cause all the data points in an
122   * alignment_period to be mathematically grouped together, resulting in a single
123   * data point for each alignment_period with end timestamp at the end of the
124   * period.Not all alignment operations may be applied to all time series. The
125   * valid choices depend on the metric_kind and value_type of the original time
126   * series. Alignment can change the metric_kind or the value_type of the time
127   * series.Time series data must be aligned in order to perform cross-time series
128   * reduction. If cross_series_reducer is specified, then per_series_aligner must
129   * be specified and not equal to ALIGN_NONE and alignment_period must be
130   * specified; otherwise, an error is returned.
131   * @opt_param string filter Required. A monitoring filter
132   * (https://cloud.google.com/monitoring/api/v3/filters) that specifies which
133   * time series should be returned. The filter must specify a single metric type,
134   * and can additionally specify metric labels and other information. For
135   * example: metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
136   * metric.labels.instance_name = "my-instance-name"
137   * @opt_param string interval.endTime Required. The end of the time interval.
138   * @opt_param string interval.startTime Optional. The beginning of the time
139   * interval. The default value for the start time is the end time. The start
140   * time must not be later than the end time.
141   * @opt_param string orderBy Unsupported: must be left blank. The points in each
142   * time series are currently returned in reverse time order (most recent to
143   * oldest).
144   * @opt_param int pageSize A positive number that is the maximum number of
145   * results to return. If page_size is empty or more than 100,000 results, the
146   * effective page_size is 100,000 results. If view is set to FULL, this is the
147   * maximum number of Points returned. If view is set to HEADERS, this is the
148   * maximum number of TimeSeries returned.
149   * @opt_param string pageToken If this field is not empty then it must contain
150   * the nextPageToken value returned by a previous call to this method. Using
151   * this field causes the method to return additional results from the previous
152   * method call.
153   * @opt_param string secondaryAggregation.alignmentPeriod The alignment_period
154   * specifies a time interval, in seconds, that is used to divide the data in all
155   * the time series into consistent blocks of time. This will be done before the
156   * per-series aligner can be applied to the data.The value must be at least 60
157   * seconds. If a per-series aligner other than ALIGN_NONE is specified, this
158   * field is required or an error is returned. If no per-series aligner is
159   * specified, or the aligner ALIGN_NONE is specified, then this field is
160   * ignored.The maximum value of the alignment_period is 104 weeks (2 years) for
161   * charts, and 90,000 seconds (25 hours) for alerting policies.
162   * @opt_param string secondaryAggregation.crossSeriesReducer The reduction
163   * operation to be used to combine time series into a single time series, where
164   * the value of each data point in the resulting series is a function of all the
165   * already aligned values in the input time series.Not all reducer operations
166   * can be applied to all time series. The valid choices depend on the
167   * metric_kind and the value_type of the original time series. Reduction can
168   * yield a time series with a different metric_kind or value_type than the input
169   * time series.Time series data must first be aligned (see per_series_aligner)
170   * in order to perform cross-time series reduction. If cross_series_reducer is
171   * specified, then per_series_aligner must be specified, and must not be
172   * ALIGN_NONE. An alignment_period must also be specified; otherwise, an error
173   * is returned.
174   * @opt_param string secondaryAggregation.groupByFields The set of fields to
175   * preserve when cross_series_reducer is specified. The group_by_fields
176   * determine how the time series are partitioned into subsets prior to applying
177   * the aggregation operation. Each subset contains time series that have the
178   * same value for each of the grouping fields. Each individual time series is a
179   * member of exactly one subset. The cross_series_reducer is applied to each
180   * subset of time series. It is not possible to reduce across different resource
181   * types, so this field implicitly contains resource.type. Fields not specified
182   * in group_by_fields are aggregated away. If group_by_fields is not specified
183   * and all the time series have the same resource type, then the time series are
184   * aggregated into a single output time series. If cross_series_reducer is not
185   * defined, this field is ignored.
186   * @opt_param string secondaryAggregation.perSeriesAligner An Aligner describes
187   * how to bring the data points in a single time series into temporal alignment.
188   * Except for ALIGN_NONE, all alignments cause all the data points in an
189   * alignment_period to be mathematically grouped together, resulting in a single
190   * data point for each alignment_period with end timestamp at the end of the
191   * period.Not all alignment operations may be applied to all time series. The
192   * valid choices depend on the metric_kind and value_type of the original time
193   * series. Alignment can change the metric_kind or the value_type of the time
194   * series.Time series data must be aligned in order to perform cross-time series
195   * reduction. If cross_series_reducer is specified, then per_series_aligner must
196   * be specified and not equal to ALIGN_NONE and alignment_period must be
197   * specified; otherwise, an error is returned.
198   * @opt_param string view Required. Specifies which information is returned
199   * about the time series.
200   * @return ListTimeSeriesResponse
201   */
202  public function listProjectsTimeSeries($name, $optParams = [])
203  {
204    $params = ['name' => $name];
205    $params = array_merge($params, $optParams);
206    return $this->call('list', [$params], ListTimeSeriesResponse::class);
207  }
208  /**
209   * Queries time series using Monitoring Query Language. (timeSeries.query)
210   *
211   * @param string $name Required. The project
212   * (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute
213   * the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
214   * @param QueryTimeSeriesRequest $postBody
215   * @param array $optParams Optional parameters.
216   * @return QueryTimeSeriesResponse
217   */
218  public function query($name, QueryTimeSeriesRequest $postBody, $optParams = [])
219  {
220    $params = ['name' => $name, 'postBody' => $postBody];
221    $params = array_merge($params, $optParams);
222    return $this->call('query', [$params], QueryTimeSeriesResponse::class);
223  }
224}
225
226// Adding a class alias for backwards compatibility with the previous class name.
227class_alias(ProjectsTimeSeries::class, 'Google_Service_Monitoring_Resource_ProjectsTimeSeries');
228