google-cloud-monitoring 0.25.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ module Google
41
41
  # The sum of squared deviations from the mean of the values in the
42
42
  # population. For values x_i this is:
43
43
  #
44
- # Sum{i=1..n}[https://cloud.google.com(x_i - mean]^2)
44
+ # Sum[i=1..n](https://cloud.google.com(x_i - mean)^2)
45
45
  #
46
46
  # Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
47
47
  # describes Welford's method for accumulating this sum in one pass.
@@ -24,13 +24,13 @@ module Google
24
24
  # that defines the scope of the metric type or of its data; and (2) the
25
25
  # metric's URL-encoded type, which also appears in the +type+ field of this
26
26
  # descriptor. For example, following is the resource name of a custom
27
- # metric within the GCP project 123456789:
27
+ # metric within the GCP project +my-project-id+:
28
28
  #
29
- # "projects/123456789/metricDescriptors/custom.googleapis.com%2Finvoice%2Fpaid%2Famount"
29
+ # "projects/my-project-id/metricDescriptors/custom.googleapis.com%2Finvoice%2Fpaid%2Famount"
30
30
  # @!attribute [rw] type
31
31
  # @return [String]
32
32
  # The metric type, including its DNS name prefix. The type is not
33
- # URL-encoded. All user-defined metric types have the DNS name
33
+ # URL-encoded. All user-defined custom metric types have the DNS name
34
34
  # +custom.googleapis.com+. Metric types should use a natural hierarchical
35
35
  # grouping. For example:
36
36
  #
@@ -56,8 +56,8 @@ module Google
56
56
  # @return [String]
57
57
  # The unit in which the metric value is reported. It is only applicable
58
58
  # if the +value_type+ is +INT64+, +DOUBLE+, or +DISTRIBUTION+. The
59
- # supported units are a subset of {The Unified Code for Units of
60
- # Measure}[http://unitsofmeasure.org/ucum.html] standard:
59
+ # supported units are a subset of [The Unified Code for Units of
60
+ # Measure](http://unitsofmeasure.org/ucum.html) standard:
61
61
  #
62
62
  # **Basic units (UNIT)**
63
63
  #
@@ -114,10 +114,10 @@ module Google
114
114
  # Notes:
115
115
  #
116
116
  # * +Annotation+ is just a comment if it follows a +UNIT+ and is
117
- # equivalent to +1+ if it is used alone. For examples,
118
- # +{requests}/s == 1/s+, +By{transmitted}/s == By/s+.
117
+ # equivalent to +1+ if it is used alone. For examples,
118
+ # +{requests}/s == 1/s+, +By{transmitted}/s == By/s+.
119
119
  # * +NAME+ is a sequence of non-blank printable ASCII characters not
120
- # containing '{' or '}'.
120
+ # containing '{' or '}'.
121
121
  # @!attribute [rw] description
122
122
  # @return [String]
123
123
  # A detailed description of the metric, which can be used in documentation.
@@ -164,7 +164,7 @@ module Google
164
164
  # This value type can be used only if the metric kind is +GAUGE+.
165
165
  STRING = 4
166
166
 
167
- # The value is a +Distribution+.
167
+ # The value is a {Google::Api::Distribution +Distribution+}.
168
168
  DISTRIBUTION = 5
169
169
 
170
170
  # The value is money.
@@ -173,10 +173,10 @@ module Google
173
173
  end
174
174
 
175
175
  # A specific metric, identified by specifying values for all of the
176
- # labels of a +MetricDescriptor+.
176
+ # labels of a {Google::Api::MetricDescriptor +MetricDescriptor+}.
177
177
  # @!attribute [rw] type
178
178
  # @return [String]
179
- # An existing metric type, see Google::Api::MetricDescriptor.
179
+ # An existing metric type, see {Google::Api::MetricDescriptor}.
180
180
  # For example, +custom.googleapis.com/invoice/paid/amount+.
181
181
  # @!attribute [rw] labels
182
182
  # @return [Hash{String => String}]
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Google
16
16
  module Api
17
- # An object that describes the schema of a MonitoredResource object using a
17
+ # An object that describes the schema of a {Google::Api::MonitoredResource MonitoredResource} object using a
18
18
  # type name and a set of labels. For example, the monitored resource
19
19
  # descriptor for Google Compute Engine VM instances has a type of
20
20
  # +"gce_instance"+ and specifies the use of the labels +"instance_id"+ and
@@ -56,11 +56,11 @@ module Google
56
56
  # An object representing a resource that can be used for monitoring, logging,
57
57
  # billing, or other purposes. Examples include virtual machine instances,
58
58
  # databases, and storage devices such as disks. The +type+ field identifies a
59
- # MonitoredResourceDescriptor object that describes the resource's
59
+ # {Google::Api::MonitoredResourceDescriptor MonitoredResourceDescriptor} object that describes the resource's
60
60
  # schema. Information in the +labels+ field identifies the actual resource and
61
61
  # its attributes according to the schema. For example, a particular Compute
62
62
  # Engine VM instance could be represented by the following object, because the
63
- # MonitoredResourceDescriptor for +"gce_instance"+ has labels
63
+ # {Google::Api::MonitoredResourceDescriptor MonitoredResourceDescriptor} for +"gce_instance"+ has labels
64
64
  # +"instance_id"+ and +"zone"+:
65
65
  #
66
66
  # { "type": "gce_instance",
@@ -69,7 +69,7 @@ module Google
69
69
  # @!attribute [rw] type
70
70
  # @return [String]
71
71
  # Required. The monitored resource type. This field must match
72
- # the +type+ field of a MonitoredResourceDescriptor object. For
72
+ # the +type+ field of a {Google::Api::MonitoredResourceDescriptor MonitoredResourceDescriptor} object. For
73
73
  # example, the type of a Cloud SQL database is +"cloudsql_database"+.
74
74
  # @!attribute [rw] labels
75
75
  # @return [Hash{String => String}]
@@ -52,10 +52,10 @@ module Google
52
52
  # the data. Aggregation consists of an alignment step on individual time
53
53
  # series (+per_series_aligner+) followed by an optional reduction of the data
54
54
  # across different time series (+cross_series_reducer+). For more details, see
55
- # {Aggregation}[https://cloud.google.com/monitoring/api/learn_more#aggregation].
55
+ # [Aggregation](https://cloud.google.com/monitoring/api/learn_more#aggregation).
56
56
  # @!attribute [rw] alignment_period
57
57
  # @return [Google::Protobuf::Duration]
58
- # The alignment period for per-Time series
58
+ # The alignment period for per-{Google::Monitoring::V3::TimeSeries time series}
59
59
  # alignment. If present, +alignmentPeriod+ must be at least 60
60
60
  # seconds. After per-time series alignment, each time series will
61
61
  # contain data points only on the period boundaries. If
@@ -124,7 +124,7 @@ module Google
124
124
  # Align and convert to a rate. This alignment is valid for
125
125
  # cumulative metrics and delta metrics with numeric values. The output is a
126
126
  # gauge metric with value type
127
- # DOUBLE.
127
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
128
128
  ALIGN_RATE = 2
129
129
 
130
130
  # Align by interpolating between adjacent points around the
@@ -157,14 +157,14 @@ module Google
157
157
  # the alignment period is the average or arithmetic mean of all
158
158
  # data points in the period. This alignment is valid for gauge and delta
159
159
  # metrics with numeric values. The value type of the output is
160
- # DOUBLE.
160
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
161
161
  ALIGN_MEAN = 12
162
162
 
163
163
  # Align time series via aggregation. The resulting data point in
164
164
  # the alignment period is the count of all data points in the
165
165
  # period. This alignment is valid for gauge and delta metrics with numeric
166
166
  # or Boolean values. The value type of the output is
167
- # INT64.
167
+ # {Google::Api::MetricDescriptor::ValueType::INT64 INT64}.
168
168
  ALIGN_COUNT = 13
169
169
 
170
170
  # Align time series via aggregation. The resulting data point in
@@ -178,49 +178,49 @@ module Google
178
178
  # the alignment period is the standard deviation of all data
179
179
  # points in the period. This alignment is valid for gauge and delta metrics
180
180
  # with numeric values. The value type of the output is
181
- # DOUBLE.
181
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
182
182
  ALIGN_STDDEV = 15
183
183
 
184
184
  # Align time series via aggregation. The resulting data point in
185
185
  # the alignment period is the count of True-valued data points in the
186
186
  # period. This alignment is valid for gauge metrics with
187
187
  # Boolean values. The value type of the output is
188
- # INT64.
188
+ # {Google::Api::MetricDescriptor::ValueType::INT64 INT64}.
189
189
  ALIGN_COUNT_TRUE = 16
190
190
 
191
191
  # Align time series via aggregation. The resulting data point in
192
192
  # the alignment period is the fraction of True-valued data points in the
193
193
  # period. This alignment is valid for gauge metrics with Boolean values.
194
194
  # The output value is in the range [0, 1] and has value type
195
- # DOUBLE.
195
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
196
196
  ALIGN_FRACTION_TRUE = 17
197
197
 
198
198
  # Align time series via aggregation. The resulting data point in
199
199
  # the alignment period is the 99th percentile of all data
200
200
  # points in the period. This alignment is valid for gauge and delta metrics
201
201
  # with distribution values. The output is a gauge metric with value type
202
- # DOUBLE.
202
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
203
203
  ALIGN_PERCENTILE_99 = 18
204
204
 
205
205
  # Align time series via aggregation. The resulting data point in
206
206
  # the alignment period is the 95th percentile of all data
207
207
  # points in the period. This alignment is valid for gauge and delta metrics
208
208
  # with distribution values. The output is a gauge metric with value type
209
- # DOUBLE.
209
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
210
210
  ALIGN_PERCENTILE_95 = 19
211
211
 
212
212
  # Align time series via aggregation. The resulting data point in
213
213
  # the alignment period is the 50th percentile of all data
214
214
  # points in the period. This alignment is valid for gauge and delta metrics
215
215
  # with distribution values. The output is a gauge metric with value type
216
- # DOUBLE.
216
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
217
217
  ALIGN_PERCENTILE_50 = 20
218
218
 
219
219
  # Align time series via aggregation. The resulting data point in
220
220
  # the alignment period is the 5th percentile of all data
221
221
  # points in the period. This alignment is valid for gauge and delta metrics
222
222
  # with distribution values. The output is a gauge metric with value type
223
- # DOUBLE.
223
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
224
224
  ALIGN_PERCENTILE_05 = 21
225
225
  end
226
226
 
@@ -234,7 +234,7 @@ module Google
234
234
  # Reduce by computing the mean across time series for each
235
235
  # alignment period. This reducer is valid for delta and
236
236
  # gauge metrics with numeric or distribution values. The value type of the
237
- # output is DOUBLE.
237
+ # output is {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
238
238
  REDUCE_MEAN = 1
239
239
 
240
240
  # Reduce by computing the minimum across time series for each
@@ -258,51 +258,51 @@ module Google
258
258
  # Reduce by computing the standard deviation across time series
259
259
  # for each alignment period. This reducer is valid for delta
260
260
  # and gauge metrics with numeric or distribution values. The value type of
261
- # the output is DOUBLE.
261
+ # the output is {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
262
262
  REDUCE_STDDEV = 5
263
263
 
264
264
  # Reduce by computing the count of data points across time series
265
265
  # for each alignment period. This reducer is valid for delta
266
266
  # and gauge metrics of numeric, Boolean, distribution, and string value
267
267
  # type. The value type of the output is
268
- # INT64.
268
+ # {Google::Api::MetricDescriptor::ValueType::INT64 INT64}.
269
269
  REDUCE_COUNT = 6
270
270
 
271
271
  # Reduce by computing the count of True-valued data points across time
272
272
  # series for each alignment period. This reducer is valid for delta
273
273
  # and gauge metrics of Boolean value type. The value type of
274
- # the output is INT64.
274
+ # the output is {Google::Api::MetricDescriptor::ValueType::INT64 INT64}.
275
275
  REDUCE_COUNT_TRUE = 7
276
276
 
277
277
  # Reduce by computing the fraction of True-valued data points across time
278
278
  # series for each alignment period. This reducer is valid for delta
279
279
  # and gauge metrics of Boolean value type. The output value is in the
280
280
  # range [0, 1] and has value type
281
- # DOUBLE.
281
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}.
282
282
  REDUCE_FRACTION_TRUE = 8
283
283
 
284
284
  # Reduce by computing 99th percentile of data points across time series
285
285
  # for each alignment period. This reducer is valid for gauge and delta
286
286
  # metrics of numeric and distribution type. The value of the output is
287
- # DOUBLE
287
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}
288
288
  REDUCE_PERCENTILE_99 = 9
289
289
 
290
290
  # Reduce by computing 95th percentile of data points across time series
291
291
  # for each alignment period. This reducer is valid for gauge and delta
292
292
  # metrics of numeric and distribution type. The value of the output is
293
- # DOUBLE
293
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}
294
294
  REDUCE_PERCENTILE_95 = 10
295
295
 
296
296
  # Reduce by computing 50th percentile of data points across time series
297
297
  # for each alignment period. This reducer is valid for gauge and delta
298
298
  # metrics of numeric and distribution type. The value of the output is
299
- # DOUBLE
299
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}
300
300
  REDUCE_PERCENTILE_50 = 11
301
301
 
302
302
  # Reduce by computing 5th percentile of data points across time series
303
303
  # for each alignment period. This reducer is valid for gauge and delta
304
304
  # metrics of numeric and distribution type. The value of the output is
305
- # DOUBLE
305
+ # {Google::Api::MetricDescriptor::ValueType::DOUBLE DOUBLE}
306
306
  REDUCE_PERCENTILE_05 = 12
307
307
  end
308
308
  end
@@ -21,6 +21,8 @@ module Google
21
21
  # two Timestamp values is a Duration and it can be added or subtracted
22
22
  # from a Timestamp. Range is approximately +-10,000 years.
23
23
  #
24
+ # = Examples
25
+ #
24
26
  # Example 1: Compute Duration from two Timestamps in pseudo code.
25
27
  #
26
28
  # Timestamp start = ...;
@@ -60,10 +62,21 @@ module Google
60
62
  # td = datetime.timedelta(days=3, minutes=10)
61
63
  # duration = Duration()
62
64
  # duration.FromTimedelta(td)
65
+ #
66
+ # = JSON Mapping
67
+ #
68
+ # In JSON format, the Duration type is encoded as a string rather than an
69
+ # object, where the string ends in the suffix "s" (indicating seconds) and
70
+ # is preceded by the number of seconds, with nanoseconds expressed as
71
+ # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
72
+ # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
73
+ # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
74
+ # microsecond should be expressed in JSON format as "3.000001s".
63
75
  # @!attribute [rw] seconds
64
76
  # @return [Integer]
65
77
  # Signed seconds of the span of time. Must be from -315,576,000,000
66
- # to +315,576,000,000 inclusive.
78
+ # to +315,576,000,000 inclusive. Note: these bounds are computed from:
79
+ # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
67
80
  # @!attribute [rw] nanos
68
81
  # @return [Integer]
69
82
  # Signed fractions of a second at nanosecond resolution of the span
@@ -24,7 +24,9 @@ module Google
24
24
  # 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
25
25
  # By restricting to that range, we ensure that we can convert to
26
26
  # and from RFC 3339 date strings.
27
- # See {https://www.ietf.org/rfc/rfc3339.txt}[https://www.ietf.org/rfc/rfc3339.txt].
27
+ # See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
28
+ #
29
+ # = Examples
28
30
  #
29
31
  # Example 1: Compute Timestamp from POSIX +time()+.
30
32
  #
@@ -65,6 +67,29 @@ module Google
65
67
  #
66
68
  # timestamp = Timestamp()
67
69
  # timestamp.GetCurrentTime()
70
+ #
71
+ # = JSON Mapping
72
+ #
73
+ # In JSON format, the Timestamp type is encoded as a string in the
74
+ # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
75
+ # format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
76
+ # where {year} is always expressed using four digits while {month}, {day},
77
+ # {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
78
+ # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
79
+ # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
80
+ # is required, though only UTC (as indicated by "Z") is presently supported.
81
+ #
82
+ # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
83
+ # 01:30 UTC on January 15, 2017.
84
+ #
85
+ # In JavaScript, one can convert a Date object to this format using the
86
+ # standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
87
+ # method. In Python, a standard +datetime.datetime+ object can be converted
88
+ # to this format using [+strftime+](https://docs.python.org/2/library/time.html#time.strftime)
89
+ # with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
90
+ # can use the Joda Time's [+ISODateTimeFormat.dateTime()+](
91
+ # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
92
+ # to obtain a formatter capable of generating timestamps in this format.
68
93
  # @!attribute [rw] seconds
69
94
  # @return [Integer]
70
95
  # Represents seconds of UTC time since Unix epoch
@@ -0,0 +1,77 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Stackdriver Monitoring API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Stackdriver Monitoring API][Product Documentation]:
23
+ # Manages your Stackdriver Monitoring data and configurations. Most projects must
24
+ # be associated with a Stackdriver account, with a few exceptions as noted on the
25
+ # individual method pages.
26
+ # - [Product Documentation][]
27
+ #
28
+ # ## Quick Start
29
+ # In order to use this library, you first need to go through the following
30
+ # steps:
31
+ #
32
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
33
+ # 2. [Enable the Stackdriver Monitoring API.](https://console.cloud.google.com/apis/api/monitoring)
34
+ # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
35
+ #
36
+ # ### Installation
37
+ # ```
38
+ # $ gem install google-cloud-monitoring
39
+ # ```
40
+ #
41
+ # ### Preview
42
+ # #### MetricServiceClient
43
+ # ```rb
44
+ # require "google/cloud/monitoring"
45
+ #
46
+ # metric_service_client = Google::Cloud::Monitoring::Metric.new
47
+ # formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path(project_id)
48
+ #
49
+ # # Iterate over all results.
50
+ # metric_service_client.list_monitored_resource_descriptors(formatted_name).each do |element|
51
+ # # Process element.
52
+ # end
53
+ #
54
+ # # Or iterate over results one page at a time.
55
+ # metric_service_client.list_monitored_resource_descriptors(formatted_name).each_page do |page|
56
+ # # Process each page at a time.
57
+ # page.each do |element|
58
+ # # Process element.
59
+ # end
60
+ # end
61
+ # ```
62
+ #
63
+ # ### Next Steps
64
+ # - Read the [Stackdriver Monitoring API Product documentation][Product Documentation]
65
+ # to learn more about the product and see How-to Guides.
66
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
67
+ # to see the full list of Cloud APIs that we cover.
68
+ #
69
+ # [Product Documentation]: https://cloud.google.com/monitoring
70
+ #
71
+ #
72
+ module Monitoring
73
+ module V3
74
+ end
75
+ end
76
+ end
77
+ end
@@ -28,13 +28,14 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/monitoring/v3/group_service_pb"
31
+ require "google/cloud/monitoring/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
34
35
  module Monitoring
35
36
  module V3
36
37
  # The Group API lets you inspect and manage your
37
- # {groups}[https://cloud.google.comgoogle.monitoring.v3.Group].
38
+ # [groups](https://cloud.google.comgoogle.monitoring.v3.Group).
38
39
  #
39
40
  # A group is a named filter that is used to identify
40
41
  # a collection of monitored resources. Groups are typically used to
@@ -113,36 +114,24 @@ module Google
113
114
  )
114
115
  end
115
116
 
116
- # Parses the project from a project resource.
117
- # @param project_name [String]
118
- # @return [String]
119
- def self.match_project_from_project_name project_name
120
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
121
- end
122
-
123
- # Parses the project from a group resource.
124
- # @param group_name [String]
125
- # @return [String]
126
- def self.match_project_from_group_name group_name
127
- GROUP_PATH_TEMPLATE.match(group_name)["project"]
128
- end
129
-
130
- # Parses the group from a group resource.
131
- # @param group_name [String]
132
- # @return [String]
133
- def self.match_group_from_group_name group_name
134
- GROUP_PATH_TEMPLATE.match(group_name)["group"]
135
- end
136
-
137
- # @param service_path [String]
138
- # The domain name of the API remote host.
139
- # @param port [Integer]
140
- # The port on which to connect to the remote host.
141
- # @param channel [Channel]
142
- # A Channel object through which to make calls.
143
- # @param chan_creds [Grpc::ChannelCredentials]
144
- # A ChannelCredentials for the setting up the RPC client.
145
- # @param client_config[Hash]
117
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
118
+ # Provides the means for authenticating requests made by the client. This parameter can
119
+ # be many types.
120
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
121
+ # authenticating requests made by this client.
122
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
123
+ # credentials for this client.
124
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
125
+ # credentials for this client.
126
+ # A `GRPC::Core::Channel` will be used to make calls through.
127
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
128
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
129
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
130
+ # metadata for requests, generally, to give OAuth credentials.
131
+ # @param scopes [Array<String>]
132
+ # The OAuth scopes for this service. This parameter is ignored if
133
+ # an updater_proc is supplied.
134
+ # @param client_config [Hash]
146
135
  # A Hash for call options for each method. See
147
136
  # Google::Gax#construct_settings for the structure of
148
137
  # this data. Falls back to the default config if not specified
@@ -154,11 +143,11 @@ module Google
154
143
  port: DEFAULT_SERVICE_PORT,
155
144
  channel: nil,
156
145
  chan_creds: nil,
146
+ updater_proc: nil,
147
+ credentials: nil,
157
148
  scopes: ALL_SCOPES,
158
149
  client_config: {},
159
150
  timeout: DEFAULT_TIMEOUT,
160
- app_name: nil,
161
- app_version: nil,
162
151
  lib_name: nil,
163
152
  lib_version: ""
164
153
  # These require statements are intentionally placed here to initialize
@@ -167,14 +156,38 @@ module Google
167
156
  require "google/gax/grpc"
168
157
  require "google/monitoring/v3/group_service_services_pb"
169
158
 
159
+ if channel || chan_creds || updater_proc
160
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
161
+ "on 2017/09/08"
162
+ credentials ||= channel
163
+ credentials ||= chan_creds
164
+ credentials ||= updater_proc
165
+ end
166
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
167
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
168
+ end
169
+
170
+ credentials ||= Google::Cloud::Monitoring::Credentials.default
170
171
 
171
- if app_name || app_version
172
- warn "`app_name` and `app_version` are no longer being used in the request headers."
172
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
173
+ updater_proc = Google::Cloud::Monitoring::Credentials.new(credentials).updater_proc
174
+ end
175
+ if credentials.is_a?(GRPC::Core::Channel)
176
+ channel = credentials
177
+ end
178
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
179
+ chan_creds = credentials
180
+ end
181
+ if credentials.is_a?(Proc)
182
+ updater_proc = credentials
183
+ end
184
+ if credentials.is_a?(Google::Auth::Credentials)
185
+ updater_proc = credentials.updater_proc
173
186
  end
174
187
 
175
188
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
176
189
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
177
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
190
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
178
191
  google_api_client << " grpc/#{GRPC::VERSION}"
179
192
  google_api_client.freeze
180
193
 
@@ -199,6 +212,7 @@ module Google
199
212
  port,
200
213
  chan_creds: chan_creds,
201
214
  channel: channel,
215
+ updater_proc: updater_proc,
202
216
  scopes: scopes,
203
217
  &Google::Monitoring::V3::GroupService::Stub.method(:new)
204
218
  )
@@ -267,12 +281,10 @@ module Google
267
281
  # object.
268
282
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
269
283
  # @example
270
- # require "google/cloud/monitoring/v3/group_service_client"
271
- #
272
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
284
+ # require "google/cloud/monitoring/v3"
273
285
  #
274
- # group_service_client = GroupServiceClient.new
275
- # formatted_name = GroupServiceClient.project_path("[PROJECT]")
286
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
287
+ # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.project_path("[PROJECT]")
276
288
  #
277
289
  # # Iterate over all results.
278
290
  # group_service_client.list_groups(formatted_name).each do |element|
@@ -294,13 +306,14 @@ module Google
294
306
  descendants_of_group: nil,
295
307
  page_size: nil,
296
308
  options: nil
297
- req = Google::Monitoring::V3::ListGroupsRequest.new({
309
+ req = {
298
310
  name: name,
299
311
  children_of_group: children_of_group,
300
312
  ancestors_of_group: ancestors_of_group,
301
313
  descendants_of_group: descendants_of_group,
302
314
  page_size: page_size
303
- }.delete_if { |_, v| v.nil? })
315
+ }.delete_if { |_, v| v.nil? }
316
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListGroupsRequest)
304
317
  @list_groups.call(req, options)
305
318
  end
306
319
 
@@ -315,20 +328,19 @@ module Google
315
328
  # @return [Google::Monitoring::V3::Group]
316
329
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
317
330
  # @example
318
- # require "google/cloud/monitoring/v3/group_service_client"
331
+ # require "google/cloud/monitoring/v3"
319
332
  #
320
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
321
- #
322
- # group_service_client = GroupServiceClient.new
323
- # formatted_name = GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
333
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
334
+ # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
324
335
  # response = group_service_client.get_group(formatted_name)
325
336
 
326
337
  def get_group \
327
338
  name,
328
339
  options: nil
329
- req = Google::Monitoring::V3::GetGroupRequest.new({
340
+ req = {
330
341
  name: name
331
- }.delete_if { |_, v| v.nil? })
342
+ }.delete_if { |_, v| v.nil? }
343
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetGroupRequest)
332
344
  @get_group.call(req, options)
333
345
  end
334
346
 
@@ -337,9 +349,11 @@ module Google
337
349
  # @param name [String]
338
350
  # The project in which to create the group. The format is
339
351
  # +"projects/{project_id_or_number}"+.
340
- # @param group [Google::Monitoring::V3::Group]
352
+ # @param group [Google::Monitoring::V3::Group | Hash]
341
353
  # A group definition. It is an error to define the +name+ field because
342
354
  # the system assigns the name.
355
+ # A hash of the same form as `Google::Monitoring::V3::Group`
356
+ # can also be provided.
343
357
  # @param validate_only [true, false]
344
358
  # If true, validate this request but do not create the group.
345
359
  # @param options [Google::Gax::CallOptions]
@@ -348,14 +362,11 @@ module Google
348
362
  # @return [Google::Monitoring::V3::Group]
349
363
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
350
364
  # @example
351
- # require "google/cloud/monitoring/v3/group_service_client"
352
- #
353
- # Group = Google::Monitoring::V3::Group
354
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
365
+ # require "google/cloud/monitoring/v3"
355
366
  #
356
- # group_service_client = GroupServiceClient.new
357
- # formatted_name = GroupServiceClient.project_path("[PROJECT]")
358
- # group = Group.new
367
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
368
+ # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.project_path("[PROJECT]")
369
+ # group = {}
359
370
  # response = group_service_client.create_group(formatted_name, group)
360
371
 
361
372
  def create_group \
@@ -363,20 +374,23 @@ module Google
363
374
  group,
364
375
  validate_only: nil,
365
376
  options: nil
366
- req = Google::Monitoring::V3::CreateGroupRequest.new({
377
+ req = {
367
378
  name: name,
368
379
  group: group,
369
380
  validate_only: validate_only
370
- }.delete_if { |_, v| v.nil? })
381
+ }.delete_if { |_, v| v.nil? }
382
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateGroupRequest)
371
383
  @create_group.call(req, options)
372
384
  end
373
385
 
374
386
  # Updates an existing group.
375
387
  # You can change any group attributes except +name+.
376
388
  #
377
- # @param group [Google::Monitoring::V3::Group]
389
+ # @param group [Google::Monitoring::V3::Group | Hash]
378
390
  # The new definition of the group. All fields of the existing group,
379
391
  # excepting +name+, are replaced with the corresponding fields of this group.
392
+ # A hash of the same form as `Google::Monitoring::V3::Group`
393
+ # can also be provided.
380
394
  # @param validate_only [true, false]
381
395
  # If true, validate this request but do not update the existing group.
382
396
  # @param options [Google::Gax::CallOptions]
@@ -385,23 +399,21 @@ module Google
385
399
  # @return [Google::Monitoring::V3::Group]
386
400
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
387
401
  # @example
388
- # require "google/cloud/monitoring/v3/group_service_client"
389
- #
390
- # Group = Google::Monitoring::V3::Group
391
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
402
+ # require "google/cloud/monitoring/v3"
392
403
  #
393
- # group_service_client = GroupServiceClient.new
394
- # group = Group.new
404
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
405
+ # group = {}
395
406
  # response = group_service_client.update_group(group)
396
407
 
397
408
  def update_group \
398
409
  group,
399
410
  validate_only: nil,
400
411
  options: nil
401
- req = Google::Monitoring::V3::UpdateGroupRequest.new({
412
+ req = {
402
413
  group: group,
403
414
  validate_only: validate_only
404
- }.delete_if { |_, v| v.nil? })
415
+ }.delete_if { |_, v| v.nil? }
416
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::UpdateGroupRequest)
405
417
  @update_group.call(req, options)
406
418
  end
407
419
 
@@ -415,20 +427,19 @@ module Google
415
427
  # retries, etc.
416
428
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
417
429
  # @example
418
- # require "google/cloud/monitoring/v3/group_service_client"
430
+ # require "google/cloud/monitoring/v3"
419
431
  #
420
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
421
- #
422
- # group_service_client = GroupServiceClient.new
423
- # formatted_name = GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
432
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
433
+ # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
424
434
  # group_service_client.delete_group(formatted_name)
425
435
 
426
436
  def delete_group \
427
437
  name,
428
438
  options: nil
429
- req = Google::Monitoring::V3::DeleteGroupRequest.new({
439
+ req = {
430
440
  name: name
431
- }.delete_if { |_, v| v.nil? })
441
+ }.delete_if { |_, v| v.nil? }
442
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteGroupRequest)
432
443
  @delete_group.call(req, options)
433
444
  nil
434
445
  end
@@ -445,18 +456,20 @@ module Google
445
456
  # performed per-page, this determines the maximum number of
446
457
  # resources in a page.
447
458
  # @param filter [String]
448
- # An optional {list filter}[https://cloud.google.com/monitoring/api/learn_more#filtering] describing
459
+ # An optional [list filter](https://cloud.google.com/monitoring/api/learn_more#filtering) describing
449
460
  # the members to be returned. The filter may reference the type, labels, and
450
461
  # metadata of monitored resources that comprise the group.
451
462
  # For example, to return only resources representing Compute Engine VM
452
463
  # instances, use this filter:
453
464
  #
454
465
  # resource.type = "gce_instance"
455
- # @param interval [Google::Monitoring::V3::TimeInterval]
466
+ # @param interval [Google::Monitoring::V3::TimeInterval | Hash]
456
467
  # An optional time interval for which results should be returned. Only
457
468
  # members that were part of the group during the specified interval are
458
469
  # included in the response. If no interval is provided then the group
459
470
  # membership over the last minute is returned.
471
+ # A hash of the same form as `Google::Monitoring::V3::TimeInterval`
472
+ # can also be provided.
460
473
  # @param options [Google::Gax::CallOptions]
461
474
  # Overrides the default settings for this call, e.g, timeout,
462
475
  # retries, etc.
@@ -467,12 +480,10 @@ module Google
467
480
  # object.
468
481
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
469
482
  # @example
470
- # require "google/cloud/monitoring/v3/group_service_client"
471
- #
472
- # GroupServiceClient = Google::Cloud::Monitoring::V3::GroupServiceClient
483
+ # require "google/cloud/monitoring/v3"
473
484
  #
474
- # group_service_client = GroupServiceClient.new
475
- # formatted_name = GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
485
+ # group_service_client = Google::Cloud::Monitoring::V3::Group.new
486
+ # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.group_path("[PROJECT]", "[GROUP]")
476
487
  #
477
488
  # # Iterate over all results.
478
489
  # group_service_client.list_group_members(formatted_name).each do |element|
@@ -493,12 +504,13 @@ module Google
493
504
  filter: nil,
494
505
  interval: nil,
495
506
  options: nil
496
- req = Google::Monitoring::V3::ListGroupMembersRequest.new({
507
+ req = {
497
508
  name: name,
498
509
  page_size: page_size,
499
510
  filter: filter,
500
511
  interval: interval
501
- }.delete_if { |_, v| v.nil? })
512
+ }.delete_if { |_, v| v.nil? }
513
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListGroupMembersRequest)
502
514
  @list_group_members.call(req, options)
503
515
  end
504
516
  end