google-cloud-monitoring-v3 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/README.md +1 -1
- data/lib/google/cloud/monitoring/v3/alert_policy_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/group_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/metric_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/notification_channel_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/query_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/service_monitoring_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/snooze_service/client.rb +748 -0
- data/lib/google/cloud/monitoring/v3/snooze_service/credentials.rb +53 -0
- data/lib/google/cloud/monitoring/v3/snooze_service/paths.rb +149 -0
- data/lib/google/cloud/monitoring/v3/snooze_service.rb +51 -0
- data/lib/google/cloud/monitoring/v3/uptime_check_service.rb +1 -1
- data/lib/google/cloud/monitoring/v3/version.rb +1 -1
- data/lib/google/cloud/monitoring/v3.rb +3 -2
- data/lib/google/monitoring/v3/snooze_pb.rb +33 -0
- data/lib/google/monitoring/v3/snooze_service_pb.rb +51 -0
- data/lib/google/monitoring/v3/snooze_service_services_pb.rb +57 -0
- data/proto_docs/google/api/client.rb +318 -0
- data/proto_docs/google/api/launch_stage.rb +3 -3
- data/proto_docs/google/api/monitored_resource.rb +9 -2
- data/proto_docs/google/monitoring/v3/snooze.rb +74 -0
- data/proto_docs/google/monitoring/v3/snooze_service.rb +154 -0
- data/proto_docs/google/rpc/status.rb +4 -2
- metadata +15 -5
@@ -0,0 +1,748 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://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,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/monitoring/v3/snooze_service_pb"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Monitoring
|
25
|
+
module V3
|
26
|
+
module SnoozeService
|
27
|
+
##
|
28
|
+
# Client for the SnoozeService service.
|
29
|
+
#
|
30
|
+
# The SnoozeService API is used to temporarily prevent an alert policy from
|
31
|
+
# generating alerts. A Snooze is a description of the criteria under which one
|
32
|
+
# or more alert policies should not fire alerts for the specified duration.
|
33
|
+
#
|
34
|
+
class Client
|
35
|
+
include Paths
|
36
|
+
|
37
|
+
# @private
|
38
|
+
attr_reader :snooze_service_stub
|
39
|
+
|
40
|
+
##
|
41
|
+
# Configure the SnoozeService Client class.
|
42
|
+
#
|
43
|
+
# See {::Google::Cloud::Monitoring::V3::SnoozeService::Client::Configuration}
|
44
|
+
# for a description of the configuration fields.
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
#
|
48
|
+
# # Modify the configuration for all SnoozeService clients
|
49
|
+
# ::Google::Cloud::Monitoring::V3::SnoozeService::Client.configure do |config|
|
50
|
+
# config.timeout = 10.0
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @yield [config] Configure the Client client.
|
54
|
+
# @yieldparam config [Client::Configuration]
|
55
|
+
#
|
56
|
+
# @return [Client::Configuration]
|
57
|
+
#
|
58
|
+
def self.configure
|
59
|
+
@configure ||= begin
|
60
|
+
namespace = ["Google", "Cloud", "Monitoring", "V3"]
|
61
|
+
parent_config = while namespace.any?
|
62
|
+
parent_name = namespace.join "::"
|
63
|
+
parent_const = const_get parent_name
|
64
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
65
|
+
namespace.pop
|
66
|
+
end
|
67
|
+
default_config = Client::Configuration.new parent_config
|
68
|
+
|
69
|
+
default_config.rpcs.create_snooze.timeout = 30.0
|
70
|
+
|
71
|
+
default_config.rpcs.list_snoozes.timeout = 30.0
|
72
|
+
default_config.rpcs.list_snoozes.retry_policy = {
|
73
|
+
initial_delay: 0.1, max_delay: 30.0, multiplier: 1.3, retry_codes: [14]
|
74
|
+
}
|
75
|
+
|
76
|
+
default_config.rpcs.get_snooze.timeout = 30.0
|
77
|
+
default_config.rpcs.get_snooze.retry_policy = {
|
78
|
+
initial_delay: 0.1, max_delay: 30.0, multiplier: 1.3, retry_codes: [14]
|
79
|
+
}
|
80
|
+
|
81
|
+
default_config.rpcs.update_snooze.timeout = 30.0
|
82
|
+
|
83
|
+
default_config
|
84
|
+
end
|
85
|
+
yield @configure if block_given?
|
86
|
+
@configure
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Configure the SnoozeService Client instance.
|
91
|
+
#
|
92
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
93
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
94
|
+
# should be made on {Client.configure}.
|
95
|
+
#
|
96
|
+
# See {::Google::Cloud::Monitoring::V3::SnoozeService::Client::Configuration}
|
97
|
+
# for a description of the configuration fields.
|
98
|
+
#
|
99
|
+
# @yield [config] Configure the Client client.
|
100
|
+
# @yieldparam config [Client::Configuration]
|
101
|
+
#
|
102
|
+
# @return [Client::Configuration]
|
103
|
+
#
|
104
|
+
def configure
|
105
|
+
yield @config if block_given?
|
106
|
+
@config
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Create a new SnoozeService client object.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
#
|
114
|
+
# # Create a client using the default configuration
|
115
|
+
# client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new
|
116
|
+
#
|
117
|
+
# # Create a client using a custom configuration
|
118
|
+
# client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new do |config|
|
119
|
+
# config.timeout = 10.0
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# @yield [config] Configure the SnoozeService client.
|
123
|
+
# @yieldparam config [Client::Configuration]
|
124
|
+
#
|
125
|
+
def initialize
|
126
|
+
# These require statements are intentionally placed here to initialize
|
127
|
+
# the gRPC module only when it's required.
|
128
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
129
|
+
require "gapic/grpc"
|
130
|
+
require "google/monitoring/v3/snooze_service_services_pb"
|
131
|
+
|
132
|
+
# Create the configuration object
|
133
|
+
@config = Configuration.new Client.configure
|
134
|
+
|
135
|
+
# Yield the configuration if needed
|
136
|
+
yield @config if block_given?
|
137
|
+
|
138
|
+
# Create credentials
|
139
|
+
credentials = @config.credentials
|
140
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
141
|
+
# but only if the default endpoint does not have a region prefix.
|
142
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
143
|
+
!@config.endpoint.split(".").first.include?("-")
|
144
|
+
credentials ||= Credentials.default scope: @config.scope,
|
145
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
146
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
147
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
148
|
+
end
|
149
|
+
@quota_project_id = @config.quota_project
|
150
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
151
|
+
|
152
|
+
@snooze_service_stub = ::Gapic::ServiceStub.new(
|
153
|
+
::Google::Cloud::Monitoring::V3::SnoozeService::Stub,
|
154
|
+
credentials: credentials,
|
155
|
+
endpoint: @config.endpoint,
|
156
|
+
channel_args: @config.channel_args,
|
157
|
+
interceptors: @config.interceptors
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Service calls
|
162
|
+
|
163
|
+
##
|
164
|
+
# Creates a `Snooze` that will prevent alerts, which match the provided
|
165
|
+
# criteria, from being opened. The `Snooze` applies for a specific time
|
166
|
+
# interval.
|
167
|
+
#
|
168
|
+
# @overload create_snooze(request, options = nil)
|
169
|
+
# Pass arguments to `create_snooze` via a request object, either of type
|
170
|
+
# {::Google::Cloud::Monitoring::V3::CreateSnoozeRequest} or an equivalent Hash.
|
171
|
+
#
|
172
|
+
# @param request [::Google::Cloud::Monitoring::V3::CreateSnoozeRequest, ::Hash]
|
173
|
+
# A request object representing the call parameters. Required. To specify no
|
174
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
175
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
176
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
177
|
+
#
|
178
|
+
# @overload create_snooze(parent: nil, snooze: nil)
|
179
|
+
# Pass arguments to `create_snooze` via keyword arguments. Note that at
|
180
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
181
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
182
|
+
#
|
183
|
+
# @param parent [::String]
|
184
|
+
# Required. The
|
185
|
+
# [project](https://cloud.google.com/monitoring/api/v3#project_name) in which
|
186
|
+
# a `Snooze` should be created. The format is:
|
187
|
+
#
|
188
|
+
# projects/[PROJECT_ID_OR_NUMBER]
|
189
|
+
# @param snooze [::Google::Cloud::Monitoring::V3::Snooze, ::Hash]
|
190
|
+
# Required. The `Snooze` to create. Omit the `name` field, as it will be
|
191
|
+
# filled in by the API.
|
192
|
+
#
|
193
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
194
|
+
# @yieldparam response [::Google::Cloud::Monitoring::V3::Snooze]
|
195
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
196
|
+
#
|
197
|
+
# @return [::Google::Cloud::Monitoring::V3::Snooze]
|
198
|
+
#
|
199
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
200
|
+
#
|
201
|
+
# @example Basic example
|
202
|
+
# require "google/cloud/monitoring/v3"
|
203
|
+
#
|
204
|
+
# # Create a client object. The client can be reused for multiple calls.
|
205
|
+
# client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
|
206
|
+
#
|
207
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
208
|
+
# request = Google::Cloud::Monitoring::V3::CreateSnoozeRequest.new
|
209
|
+
#
|
210
|
+
# # Call the create_snooze method.
|
211
|
+
# result = client.create_snooze request
|
212
|
+
#
|
213
|
+
# # The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
|
214
|
+
# p result
|
215
|
+
#
|
216
|
+
def create_snooze request, options = nil
|
217
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
218
|
+
|
219
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::CreateSnoozeRequest
|
220
|
+
|
221
|
+
# Converts hash and nil to an options object
|
222
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
223
|
+
|
224
|
+
# Customize the options with defaults
|
225
|
+
metadata = @config.rpcs.create_snooze.metadata.to_h
|
226
|
+
|
227
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
228
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
229
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
230
|
+
gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
|
231
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
232
|
+
|
233
|
+
header_params = {}
|
234
|
+
if request.parent
|
235
|
+
header_params["parent"] = request.parent
|
236
|
+
end
|
237
|
+
|
238
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
239
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
240
|
+
|
241
|
+
options.apply_defaults timeout: @config.rpcs.create_snooze.timeout,
|
242
|
+
metadata: metadata,
|
243
|
+
retry_policy: @config.rpcs.create_snooze.retry_policy
|
244
|
+
|
245
|
+
options.apply_defaults timeout: @config.timeout,
|
246
|
+
metadata: @config.metadata,
|
247
|
+
retry_policy: @config.retry_policy
|
248
|
+
|
249
|
+
@snooze_service_stub.call_rpc :create_snooze, request, options: options do |response, operation|
|
250
|
+
yield response, operation if block_given?
|
251
|
+
return response
|
252
|
+
end
|
253
|
+
rescue ::GRPC::BadStatus => e
|
254
|
+
raise ::Google::Cloud::Error.from_error(e)
|
255
|
+
end
|
256
|
+
|
257
|
+
##
|
258
|
+
# Lists the `Snooze`s associated with a project. Can optionally pass in
|
259
|
+
# `filter`, which specifies predicates to match `Snooze`s.
|
260
|
+
#
|
261
|
+
# @overload list_snoozes(request, options = nil)
|
262
|
+
# Pass arguments to `list_snoozes` via a request object, either of type
|
263
|
+
# {::Google::Cloud::Monitoring::V3::ListSnoozesRequest} or an equivalent Hash.
|
264
|
+
#
|
265
|
+
# @param request [::Google::Cloud::Monitoring::V3::ListSnoozesRequest, ::Hash]
|
266
|
+
# A request object representing the call parameters. Required. To specify no
|
267
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
268
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
269
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
270
|
+
#
|
271
|
+
# @overload list_snoozes(parent: nil, filter: nil, page_size: nil, page_token: nil)
|
272
|
+
# Pass arguments to `list_snoozes` via keyword arguments. Note that at
|
273
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
274
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
275
|
+
#
|
276
|
+
# @param parent [::String]
|
277
|
+
# Required. The
|
278
|
+
# [project](https://cloud.google.com/monitoring/api/v3#project_name) whose
|
279
|
+
# `Snooze`s should be listed. The format is:
|
280
|
+
#
|
281
|
+
# projects/[PROJECT_ID_OR_NUMBER]
|
282
|
+
# @param filter [::String]
|
283
|
+
# Optional. Optional filter to restrict results to the given criteria. The
|
284
|
+
# following fields are supported.
|
285
|
+
#
|
286
|
+
# * `interval.start_time`
|
287
|
+
# * `interval.end_time`
|
288
|
+
#
|
289
|
+
# For example:
|
290
|
+
#
|
291
|
+
# ```
|
292
|
+
# interval.start_time > "2022-03-11T00:00:00-08:00" AND
|
293
|
+
# interval.end_time < "2022-03-12T00:00:00-08:00"
|
294
|
+
# ```
|
295
|
+
# @param page_size [::Integer]
|
296
|
+
# Optional. The maximum number of results to return for a single query. The
|
297
|
+
# server may further constrain the maximum number of results returned in a
|
298
|
+
# single page. The value should be in the range [1, 1000]. If the value given
|
299
|
+
# is outside this range, the server will decide the number of results to be
|
300
|
+
# returned.
|
301
|
+
# @param page_token [::String]
|
302
|
+
# Optional. The `next_page_token` from a previous call to
|
303
|
+
# `ListSnoozesRequest` to get the next page of results.
|
304
|
+
#
|
305
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
306
|
+
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>]
|
307
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
308
|
+
#
|
309
|
+
# @return [::Gapic::PagedEnumerable<::Google::Cloud::Monitoring::V3::Snooze>]
|
310
|
+
#
|
311
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
312
|
+
#
|
313
|
+
# @example Basic example
|
314
|
+
# require "google/cloud/monitoring/v3"
|
315
|
+
#
|
316
|
+
# # Create a client object. The client can be reused for multiple calls.
|
317
|
+
# client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
|
318
|
+
#
|
319
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
320
|
+
# request = Google::Cloud::Monitoring::V3::ListSnoozesRequest.new
|
321
|
+
#
|
322
|
+
# # Call the list_snoozes method.
|
323
|
+
# result = client.list_snoozes request
|
324
|
+
#
|
325
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can
|
326
|
+
# # iterate over all elements by calling #each, and the enumerable
|
327
|
+
# # will lazily make API calls to fetch subsequent pages. Other
|
328
|
+
# # methods are also available for managing paging directly.
|
329
|
+
# result.each do |response|
|
330
|
+
# # Each element is of type ::Google::Cloud::Monitoring::V3::Snooze.
|
331
|
+
# p response
|
332
|
+
# end
|
333
|
+
#
|
334
|
+
def list_snoozes request, options = nil
|
335
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
336
|
+
|
337
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::ListSnoozesRequest
|
338
|
+
|
339
|
+
# Converts hash and nil to an options object
|
340
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
341
|
+
|
342
|
+
# Customize the options with defaults
|
343
|
+
metadata = @config.rpcs.list_snoozes.metadata.to_h
|
344
|
+
|
345
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
346
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
347
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
348
|
+
gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
|
349
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
350
|
+
|
351
|
+
header_params = {}
|
352
|
+
if request.parent
|
353
|
+
header_params["parent"] = request.parent
|
354
|
+
end
|
355
|
+
|
356
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
357
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
358
|
+
|
359
|
+
options.apply_defaults timeout: @config.rpcs.list_snoozes.timeout,
|
360
|
+
metadata: metadata,
|
361
|
+
retry_policy: @config.rpcs.list_snoozes.retry_policy
|
362
|
+
|
363
|
+
options.apply_defaults timeout: @config.timeout,
|
364
|
+
metadata: @config.metadata,
|
365
|
+
retry_policy: @config.retry_policy
|
366
|
+
|
367
|
+
@snooze_service_stub.call_rpc :list_snoozes, request, options: options do |response, operation|
|
368
|
+
response = ::Gapic::PagedEnumerable.new @snooze_service_stub, :list_snoozes, request, response, operation, options
|
369
|
+
yield response, operation if block_given?
|
370
|
+
return response
|
371
|
+
end
|
372
|
+
rescue ::GRPC::BadStatus => e
|
373
|
+
raise ::Google::Cloud::Error.from_error(e)
|
374
|
+
end
|
375
|
+
|
376
|
+
##
|
377
|
+
# Retrieves a `Snooze` by `name`.
|
378
|
+
#
|
379
|
+
# @overload get_snooze(request, options = nil)
|
380
|
+
# Pass arguments to `get_snooze` via a request object, either of type
|
381
|
+
# {::Google::Cloud::Monitoring::V3::GetSnoozeRequest} or an equivalent Hash.
|
382
|
+
#
|
383
|
+
# @param request [::Google::Cloud::Monitoring::V3::GetSnoozeRequest, ::Hash]
|
384
|
+
# A request object representing the call parameters. Required. To specify no
|
385
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
386
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
387
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
388
|
+
#
|
389
|
+
# @overload get_snooze(name: nil)
|
390
|
+
# Pass arguments to `get_snooze` via keyword arguments. Note that at
|
391
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
392
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
393
|
+
#
|
394
|
+
# @param name [::String]
|
395
|
+
# Required. The ID of the `Snooze` to retrieve. The format is:
|
396
|
+
#
|
397
|
+
# projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
|
398
|
+
#
|
399
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
400
|
+
# @yieldparam response [::Google::Cloud::Monitoring::V3::Snooze]
|
401
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
402
|
+
#
|
403
|
+
# @return [::Google::Cloud::Monitoring::V3::Snooze]
|
404
|
+
#
|
405
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
406
|
+
#
|
407
|
+
# @example Basic example
|
408
|
+
# require "google/cloud/monitoring/v3"
|
409
|
+
#
|
410
|
+
# # Create a client object. The client can be reused for multiple calls.
|
411
|
+
# client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
|
412
|
+
#
|
413
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
414
|
+
# request = Google::Cloud::Monitoring::V3::GetSnoozeRequest.new
|
415
|
+
#
|
416
|
+
# # Call the get_snooze method.
|
417
|
+
# result = client.get_snooze request
|
418
|
+
#
|
419
|
+
# # The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
|
420
|
+
# p result
|
421
|
+
#
|
422
|
+
def get_snooze request, options = nil
|
423
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
424
|
+
|
425
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::GetSnoozeRequest
|
426
|
+
|
427
|
+
# Converts hash and nil to an options object
|
428
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
429
|
+
|
430
|
+
# Customize the options with defaults
|
431
|
+
metadata = @config.rpcs.get_snooze.metadata.to_h
|
432
|
+
|
433
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
434
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
435
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
436
|
+
gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
|
437
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
438
|
+
|
439
|
+
header_params = {}
|
440
|
+
if request.name
|
441
|
+
header_params["name"] = request.name
|
442
|
+
end
|
443
|
+
|
444
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
445
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
446
|
+
|
447
|
+
options.apply_defaults timeout: @config.rpcs.get_snooze.timeout,
|
448
|
+
metadata: metadata,
|
449
|
+
retry_policy: @config.rpcs.get_snooze.retry_policy
|
450
|
+
|
451
|
+
options.apply_defaults timeout: @config.timeout,
|
452
|
+
metadata: @config.metadata,
|
453
|
+
retry_policy: @config.retry_policy
|
454
|
+
|
455
|
+
@snooze_service_stub.call_rpc :get_snooze, request, options: options do |response, operation|
|
456
|
+
yield response, operation if block_given?
|
457
|
+
return response
|
458
|
+
end
|
459
|
+
rescue ::GRPC::BadStatus => e
|
460
|
+
raise ::Google::Cloud::Error.from_error(e)
|
461
|
+
end
|
462
|
+
|
463
|
+
##
|
464
|
+
# Updates a `Snooze`, identified by its `name`, with the parameters in the
|
465
|
+
# given `Snooze` object.
|
466
|
+
#
|
467
|
+
# @overload update_snooze(request, options = nil)
|
468
|
+
# Pass arguments to `update_snooze` via a request object, either of type
|
469
|
+
# {::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest} or an equivalent Hash.
|
470
|
+
#
|
471
|
+
# @param request [::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest, ::Hash]
|
472
|
+
# A request object representing the call parameters. Required. To specify no
|
473
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
474
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
475
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
476
|
+
#
|
477
|
+
# @overload update_snooze(snooze: nil, update_mask: nil)
|
478
|
+
# Pass arguments to `update_snooze` via keyword arguments. Note that at
|
479
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
480
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
481
|
+
#
|
482
|
+
# @param snooze [::Google::Cloud::Monitoring::V3::Snooze, ::Hash]
|
483
|
+
# Required. The `Snooze` to update. Must have the name field present.
|
484
|
+
# @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
|
485
|
+
# Required. The fields to update.
|
486
|
+
#
|
487
|
+
# For each field listed in `update_mask`:
|
488
|
+
#
|
489
|
+
# * If the `Snooze` object supplied in the `UpdateSnoozeRequest` has a
|
490
|
+
# value for that field, the value of the field in the existing `Snooze`
|
491
|
+
# will be set to the value of the field in the supplied `Snooze`.
|
492
|
+
# * If the field does not have a value in the supplied `Snooze`, the field
|
493
|
+
# in the existing `Snooze` is set to its default value.
|
494
|
+
#
|
495
|
+
# Fields not listed retain their existing value.
|
496
|
+
#
|
497
|
+
# The following are the field names that are accepted in `update_mask`:
|
498
|
+
#
|
499
|
+
# * `display_name`
|
500
|
+
# * `interval.start_time`
|
501
|
+
# * `interval.end_time`
|
502
|
+
#
|
503
|
+
# That said, the start time and end time of the `Snooze` determines which
|
504
|
+
# fields can legally be updated. Before attempting an update, users should
|
505
|
+
# consult the documentation for `UpdateSnoozeRequest`, which talks about
|
506
|
+
# which fields can be updated.
|
507
|
+
#
|
508
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
509
|
+
# @yieldparam response [::Google::Cloud::Monitoring::V3::Snooze]
|
510
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
511
|
+
#
|
512
|
+
# @return [::Google::Cloud::Monitoring::V3::Snooze]
|
513
|
+
#
|
514
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
515
|
+
#
|
516
|
+
# @example Basic example
|
517
|
+
# require "google/cloud/monitoring/v3"
|
518
|
+
#
|
519
|
+
# # Create a client object. The client can be reused for multiple calls.
|
520
|
+
# client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
|
521
|
+
#
|
522
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
523
|
+
# request = Google::Cloud::Monitoring::V3::UpdateSnoozeRequest.new
|
524
|
+
#
|
525
|
+
# # Call the update_snooze method.
|
526
|
+
# result = client.update_snooze request
|
527
|
+
#
|
528
|
+
# # The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
|
529
|
+
# p result
|
530
|
+
#
|
531
|
+
def update_snooze request, options = nil
|
532
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
533
|
+
|
534
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest
|
535
|
+
|
536
|
+
# Converts hash and nil to an options object
|
537
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
538
|
+
|
539
|
+
# Customize the options with defaults
|
540
|
+
metadata = @config.rpcs.update_snooze.metadata.to_h
|
541
|
+
|
542
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
543
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
544
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
545
|
+
gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
|
546
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
547
|
+
|
548
|
+
header_params = {}
|
549
|
+
if request.snooze&.name
|
550
|
+
header_params["snooze.name"] = request.snooze.name
|
551
|
+
end
|
552
|
+
|
553
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
554
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
555
|
+
|
556
|
+
options.apply_defaults timeout: @config.rpcs.update_snooze.timeout,
|
557
|
+
metadata: metadata,
|
558
|
+
retry_policy: @config.rpcs.update_snooze.retry_policy
|
559
|
+
|
560
|
+
options.apply_defaults timeout: @config.timeout,
|
561
|
+
metadata: @config.metadata,
|
562
|
+
retry_policy: @config.retry_policy
|
563
|
+
|
564
|
+
@snooze_service_stub.call_rpc :update_snooze, request, options: options do |response, operation|
|
565
|
+
yield response, operation if block_given?
|
566
|
+
return response
|
567
|
+
end
|
568
|
+
rescue ::GRPC::BadStatus => e
|
569
|
+
raise ::Google::Cloud::Error.from_error(e)
|
570
|
+
end
|
571
|
+
|
572
|
+
##
|
573
|
+
# Configuration class for the SnoozeService API.
|
574
|
+
#
|
575
|
+
# This class represents the configuration for SnoozeService,
|
576
|
+
# providing control over timeouts, retry behavior, logging, transport
|
577
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
578
|
+
# applied individually to specific RPCs. See
|
579
|
+
# {::Google::Cloud::Monitoring::V3::SnoozeService::Client::Configuration::Rpcs}
|
580
|
+
# for a list of RPCs that can be configured independently.
|
581
|
+
#
|
582
|
+
# Configuration can be applied globally to all clients, or to a single client
|
583
|
+
# on construction.
|
584
|
+
#
|
585
|
+
# @example
|
586
|
+
#
|
587
|
+
# # Modify the global config, setting the timeout for
|
588
|
+
# # create_snooze to 20 seconds,
|
589
|
+
# # and all remaining timeouts to 10 seconds.
|
590
|
+
# ::Google::Cloud::Monitoring::V3::SnoozeService::Client.configure do |config|
|
591
|
+
# config.timeout = 10.0
|
592
|
+
# config.rpcs.create_snooze.timeout = 20.0
|
593
|
+
# end
|
594
|
+
#
|
595
|
+
# # Apply the above configuration only to a new client.
|
596
|
+
# client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new do |config|
|
597
|
+
# config.timeout = 10.0
|
598
|
+
# config.rpcs.create_snooze.timeout = 20.0
|
599
|
+
# end
|
600
|
+
#
|
601
|
+
# @!attribute [rw] endpoint
|
602
|
+
# The hostname or hostname:port of the service endpoint.
|
603
|
+
# Defaults to `"monitoring.googleapis.com"`.
|
604
|
+
# @return [::String]
|
605
|
+
# @!attribute [rw] credentials
|
606
|
+
# Credentials to send with calls. You may provide any of the following types:
|
607
|
+
# * (`String`) The path to a service account key file in JSON format
|
608
|
+
# * (`Hash`) A service account key as a Hash
|
609
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
610
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
611
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
612
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
613
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
614
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
615
|
+
# * (`nil`) indicating no credentials
|
616
|
+
# @return [::Object]
|
617
|
+
# @!attribute [rw] scope
|
618
|
+
# The OAuth scopes
|
619
|
+
# @return [::Array<::String>]
|
620
|
+
# @!attribute [rw] lib_name
|
621
|
+
# The library name as recorded in instrumentation and logging
|
622
|
+
# @return [::String]
|
623
|
+
# @!attribute [rw] lib_version
|
624
|
+
# The library version as recorded in instrumentation and logging
|
625
|
+
# @return [::String]
|
626
|
+
# @!attribute [rw] channel_args
|
627
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
628
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
629
|
+
# @return [::Hash]
|
630
|
+
# @!attribute [rw] interceptors
|
631
|
+
# An array of interceptors that are run before calls are executed.
|
632
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
633
|
+
# @!attribute [rw] timeout
|
634
|
+
# The call timeout in seconds.
|
635
|
+
# @return [::Numeric]
|
636
|
+
# @!attribute [rw] metadata
|
637
|
+
# Additional gRPC headers to be sent with the call.
|
638
|
+
# @return [::Hash{::Symbol=>::String}]
|
639
|
+
# @!attribute [rw] retry_policy
|
640
|
+
# The retry policy. The value is a hash with the following keys:
|
641
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
642
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
643
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
644
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
645
|
+
# trigger a retry.
|
646
|
+
# @return [::Hash]
|
647
|
+
# @!attribute [rw] quota_project
|
648
|
+
# A separate project against which to charge quota.
|
649
|
+
# @return [::String]
|
650
|
+
#
|
651
|
+
class Configuration
|
652
|
+
extend ::Gapic::Config
|
653
|
+
|
654
|
+
config_attr :endpoint, "monitoring.googleapis.com", ::String
|
655
|
+
config_attr :credentials, nil do |value|
|
656
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
657
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
658
|
+
allowed.any? { |klass| klass === value }
|
659
|
+
end
|
660
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
661
|
+
config_attr :lib_name, nil, ::String, nil
|
662
|
+
config_attr :lib_version, nil, ::String, nil
|
663
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
|
664
|
+
config_attr :interceptors, nil, ::Array, nil
|
665
|
+
config_attr :timeout, nil, ::Numeric, nil
|
666
|
+
config_attr :metadata, nil, ::Hash, nil
|
667
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
668
|
+
config_attr :quota_project, nil, ::String, nil
|
669
|
+
|
670
|
+
# @private
|
671
|
+
def initialize parent_config = nil
|
672
|
+
@parent_config = parent_config unless parent_config.nil?
|
673
|
+
|
674
|
+
yield self if block_given?
|
675
|
+
end
|
676
|
+
|
677
|
+
##
|
678
|
+
# Configurations for individual RPCs
|
679
|
+
# @return [Rpcs]
|
680
|
+
#
|
681
|
+
def rpcs
|
682
|
+
@rpcs ||= begin
|
683
|
+
parent_rpcs = nil
|
684
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
685
|
+
Rpcs.new parent_rpcs
|
686
|
+
end
|
687
|
+
end
|
688
|
+
|
689
|
+
##
|
690
|
+
# Configuration RPC class for the SnoozeService API.
|
691
|
+
#
|
692
|
+
# Includes fields providing the configuration for each RPC in this service.
|
693
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
694
|
+
# the following configuration fields:
|
695
|
+
#
|
696
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
697
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
698
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
699
|
+
# include the following keys:
|
700
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
701
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
702
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
703
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
704
|
+
# trigger a retry.
|
705
|
+
#
|
706
|
+
class Rpcs
|
707
|
+
##
|
708
|
+
# RPC-specific configuration for `create_snooze`
|
709
|
+
# @return [::Gapic::Config::Method]
|
710
|
+
#
|
711
|
+
attr_reader :create_snooze
|
712
|
+
##
|
713
|
+
# RPC-specific configuration for `list_snoozes`
|
714
|
+
# @return [::Gapic::Config::Method]
|
715
|
+
#
|
716
|
+
attr_reader :list_snoozes
|
717
|
+
##
|
718
|
+
# RPC-specific configuration for `get_snooze`
|
719
|
+
# @return [::Gapic::Config::Method]
|
720
|
+
#
|
721
|
+
attr_reader :get_snooze
|
722
|
+
##
|
723
|
+
# RPC-specific configuration for `update_snooze`
|
724
|
+
# @return [::Gapic::Config::Method]
|
725
|
+
#
|
726
|
+
attr_reader :update_snooze
|
727
|
+
|
728
|
+
# @private
|
729
|
+
def initialize parent_rpcs = nil
|
730
|
+
create_snooze_config = parent_rpcs.create_snooze if parent_rpcs.respond_to? :create_snooze
|
731
|
+
@create_snooze = ::Gapic::Config::Method.new create_snooze_config
|
732
|
+
list_snoozes_config = parent_rpcs.list_snoozes if parent_rpcs.respond_to? :list_snoozes
|
733
|
+
@list_snoozes = ::Gapic::Config::Method.new list_snoozes_config
|
734
|
+
get_snooze_config = parent_rpcs.get_snooze if parent_rpcs.respond_to? :get_snooze
|
735
|
+
@get_snooze = ::Gapic::Config::Method.new get_snooze_config
|
736
|
+
update_snooze_config = parent_rpcs.update_snooze if parent_rpcs.respond_to? :update_snooze
|
737
|
+
@update_snooze = ::Gapic::Config::Method.new update_snooze_config
|
738
|
+
|
739
|
+
yield self if block_given?
|
740
|
+
end
|
741
|
+
end
|
742
|
+
end
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
746
|
+
end
|
747
|
+
end
|
748
|
+
end
|