google-cloud-monitoring-v3 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/README.md +3 -3
  4. data/lib/google/cloud/monitoring/v3/alert_policy_service/client.rb +6 -8
  5. data/lib/google/cloud/monitoring/v3/alert_policy_service.rb +1 -1
  6. data/lib/google/cloud/monitoring/v3/group_service/client.rb +10 -14
  7. data/lib/google/cloud/monitoring/v3/group_service.rb +1 -1
  8. data/lib/google/cloud/monitoring/v3/metric_service/client.rb +14 -20
  9. data/lib/google/cloud/monitoring/v3/metric_service.rb +1 -1
  10. data/lib/google/cloud/monitoring/v3/notification_channel_service/client.rb +10 -14
  11. data/lib/google/cloud/monitoring/v3/notification_channel_service.rb +1 -1
  12. data/lib/google/cloud/monitoring/v3/query_service/client.rb +6 -8
  13. data/lib/google/cloud/monitoring/v3/query_service.rb +1 -1
  14. data/lib/google/cloud/monitoring/v3/service_monitoring_service/client.rb +10 -14
  15. data/lib/google/cloud/monitoring/v3/service_monitoring_service.rb +1 -1
  16. data/lib/google/cloud/monitoring/v3/snooze_service/client.rb +746 -0
  17. data/lib/google/cloud/monitoring/v3/snooze_service/credentials.rb +53 -0
  18. data/lib/google/cloud/monitoring/v3/snooze_service/paths.rb +149 -0
  19. data/lib/google/cloud/monitoring/v3/snooze_service.rb +51 -0
  20. data/lib/google/cloud/monitoring/v3/uptime_check_service/client.rb +23 -21
  21. data/lib/google/cloud/monitoring/v3/uptime_check_service.rb +6 -6
  22. data/lib/google/cloud/monitoring/v3/version.rb +1 -1
  23. data/lib/google/cloud/monitoring/v3.rb +3 -2
  24. data/lib/google/monitoring/v3/snooze_pb.rb +33 -0
  25. data/lib/google/monitoring/v3/snooze_service_pb.rb +51 -0
  26. data/lib/google/monitoring/v3/snooze_service_services_pb.rb +57 -0
  27. data/lib/google/monitoring/v3/uptime_pb.rb +54 -0
  28. data/lib/google/monitoring/v3/uptime_service_pb.rb +1 -0
  29. data/lib/google/monitoring/v3/uptime_service_services_pb.rb +5 -5
  30. data/proto_docs/google/api/client.rb +381 -0
  31. data/proto_docs/google/api/distribution.rb +2 -0
  32. data/proto_docs/google/api/launch_stage.rb +3 -3
  33. data/proto_docs/google/api/metric.rb +10 -6
  34. data/proto_docs/google/api/monitored_resource.rb +30 -18
  35. data/proto_docs/google/monitoring/v3/snooze.rb +74 -0
  36. data/proto_docs/google/monitoring/v3/snooze_service.rb +154 -0
  37. data/proto_docs/google/monitoring/v3/uptime.rb +184 -14
  38. data/proto_docs/google/monitoring/v3/uptime_service.rb +8 -1
  39. data/proto_docs/google/rpc/status.rb +4 -2
  40. metadata +18 -8
@@ -0,0 +1,746 @@
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 iterate
326
+ # # over elements, and API calls will be issued to fetch pages as needed.
327
+ # result.each do |item|
328
+ # # Each element is of type ::Google::Cloud::Monitoring::V3::Snooze.
329
+ # p item
330
+ # end
331
+ #
332
+ def list_snoozes request, options = nil
333
+ raise ::ArgumentError, "request must be provided" if request.nil?
334
+
335
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::ListSnoozesRequest
336
+
337
+ # Converts hash and nil to an options object
338
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
339
+
340
+ # Customize the options with defaults
341
+ metadata = @config.rpcs.list_snoozes.metadata.to_h
342
+
343
+ # Set x-goog-api-client and x-goog-user-project headers
344
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
345
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
346
+ gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
347
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
348
+
349
+ header_params = {}
350
+ if request.parent
351
+ header_params["parent"] = request.parent
352
+ end
353
+
354
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
355
+ metadata[:"x-goog-request-params"] ||= request_params_header
356
+
357
+ options.apply_defaults timeout: @config.rpcs.list_snoozes.timeout,
358
+ metadata: metadata,
359
+ retry_policy: @config.rpcs.list_snoozes.retry_policy
360
+
361
+ options.apply_defaults timeout: @config.timeout,
362
+ metadata: @config.metadata,
363
+ retry_policy: @config.retry_policy
364
+
365
+ @snooze_service_stub.call_rpc :list_snoozes, request, options: options do |response, operation|
366
+ response = ::Gapic::PagedEnumerable.new @snooze_service_stub, :list_snoozes, request, response, operation, options
367
+ yield response, operation if block_given?
368
+ return response
369
+ end
370
+ rescue ::GRPC::BadStatus => e
371
+ raise ::Google::Cloud::Error.from_error(e)
372
+ end
373
+
374
+ ##
375
+ # Retrieves a `Snooze` by `name`.
376
+ #
377
+ # @overload get_snooze(request, options = nil)
378
+ # Pass arguments to `get_snooze` via a request object, either of type
379
+ # {::Google::Cloud::Monitoring::V3::GetSnoozeRequest} or an equivalent Hash.
380
+ #
381
+ # @param request [::Google::Cloud::Monitoring::V3::GetSnoozeRequest, ::Hash]
382
+ # A request object representing the call parameters. Required. To specify no
383
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
384
+ # @param options [::Gapic::CallOptions, ::Hash]
385
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
386
+ #
387
+ # @overload get_snooze(name: nil)
388
+ # Pass arguments to `get_snooze` via keyword arguments. Note that at
389
+ # least one keyword argument is required. To specify no parameters, or to keep all
390
+ # the default parameter values, pass an empty Hash as a request object (see above).
391
+ #
392
+ # @param name [::String]
393
+ # Required. The ID of the `Snooze` to retrieve. The format is:
394
+ #
395
+ # projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
396
+ #
397
+ # @yield [response, operation] Access the result along with the RPC operation
398
+ # @yieldparam response [::Google::Cloud::Monitoring::V3::Snooze]
399
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
400
+ #
401
+ # @return [::Google::Cloud::Monitoring::V3::Snooze]
402
+ #
403
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
404
+ #
405
+ # @example Basic example
406
+ # require "google/cloud/monitoring/v3"
407
+ #
408
+ # # Create a client object. The client can be reused for multiple calls.
409
+ # client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
410
+ #
411
+ # # Create a request. To set request fields, pass in keyword arguments.
412
+ # request = Google::Cloud::Monitoring::V3::GetSnoozeRequest.new
413
+ #
414
+ # # Call the get_snooze method.
415
+ # result = client.get_snooze request
416
+ #
417
+ # # The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
418
+ # p result
419
+ #
420
+ def get_snooze request, options = nil
421
+ raise ::ArgumentError, "request must be provided" if request.nil?
422
+
423
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::GetSnoozeRequest
424
+
425
+ # Converts hash and nil to an options object
426
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
427
+
428
+ # Customize the options with defaults
429
+ metadata = @config.rpcs.get_snooze.metadata.to_h
430
+
431
+ # Set x-goog-api-client and x-goog-user-project headers
432
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
433
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
434
+ gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
435
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
436
+
437
+ header_params = {}
438
+ if request.name
439
+ header_params["name"] = request.name
440
+ end
441
+
442
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
443
+ metadata[:"x-goog-request-params"] ||= request_params_header
444
+
445
+ options.apply_defaults timeout: @config.rpcs.get_snooze.timeout,
446
+ metadata: metadata,
447
+ retry_policy: @config.rpcs.get_snooze.retry_policy
448
+
449
+ options.apply_defaults timeout: @config.timeout,
450
+ metadata: @config.metadata,
451
+ retry_policy: @config.retry_policy
452
+
453
+ @snooze_service_stub.call_rpc :get_snooze, request, options: options do |response, operation|
454
+ yield response, operation if block_given?
455
+ return response
456
+ end
457
+ rescue ::GRPC::BadStatus => e
458
+ raise ::Google::Cloud::Error.from_error(e)
459
+ end
460
+
461
+ ##
462
+ # Updates a `Snooze`, identified by its `name`, with the parameters in the
463
+ # given `Snooze` object.
464
+ #
465
+ # @overload update_snooze(request, options = nil)
466
+ # Pass arguments to `update_snooze` via a request object, either of type
467
+ # {::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest} or an equivalent Hash.
468
+ #
469
+ # @param request [::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest, ::Hash]
470
+ # A request object representing the call parameters. Required. To specify no
471
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
472
+ # @param options [::Gapic::CallOptions, ::Hash]
473
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
474
+ #
475
+ # @overload update_snooze(snooze: nil, update_mask: nil)
476
+ # Pass arguments to `update_snooze` via keyword arguments. Note that at
477
+ # least one keyword argument is required. To specify no parameters, or to keep all
478
+ # the default parameter values, pass an empty Hash as a request object (see above).
479
+ #
480
+ # @param snooze [::Google::Cloud::Monitoring::V3::Snooze, ::Hash]
481
+ # Required. The `Snooze` to update. Must have the name field present.
482
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
483
+ # Required. The fields to update.
484
+ #
485
+ # For each field listed in `update_mask`:
486
+ #
487
+ # * If the `Snooze` object supplied in the `UpdateSnoozeRequest` has a
488
+ # value for that field, the value of the field in the existing `Snooze`
489
+ # will be set to the value of the field in the supplied `Snooze`.
490
+ # * If the field does not have a value in the supplied `Snooze`, the field
491
+ # in the existing `Snooze` is set to its default value.
492
+ #
493
+ # Fields not listed retain their existing value.
494
+ #
495
+ # The following are the field names that are accepted in `update_mask`:
496
+ #
497
+ # * `display_name`
498
+ # * `interval.start_time`
499
+ # * `interval.end_time`
500
+ #
501
+ # That said, the start time and end time of the `Snooze` determines which
502
+ # fields can legally be updated. Before attempting an update, users should
503
+ # consult the documentation for `UpdateSnoozeRequest`, which talks about
504
+ # which fields can be updated.
505
+ #
506
+ # @yield [response, operation] Access the result along with the RPC operation
507
+ # @yieldparam response [::Google::Cloud::Monitoring::V3::Snooze]
508
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
509
+ #
510
+ # @return [::Google::Cloud::Monitoring::V3::Snooze]
511
+ #
512
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
513
+ #
514
+ # @example Basic example
515
+ # require "google/cloud/monitoring/v3"
516
+ #
517
+ # # Create a client object. The client can be reused for multiple calls.
518
+ # client = Google::Cloud::Monitoring::V3::SnoozeService::Client.new
519
+ #
520
+ # # Create a request. To set request fields, pass in keyword arguments.
521
+ # request = Google::Cloud::Monitoring::V3::UpdateSnoozeRequest.new
522
+ #
523
+ # # Call the update_snooze method.
524
+ # result = client.update_snooze request
525
+ #
526
+ # # The returned object is of type Google::Cloud::Monitoring::V3::Snooze.
527
+ # p result
528
+ #
529
+ def update_snooze request, options = nil
530
+ raise ::ArgumentError, "request must be provided" if request.nil?
531
+
532
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Monitoring::V3::UpdateSnoozeRequest
533
+
534
+ # Converts hash and nil to an options object
535
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
536
+
537
+ # Customize the options with defaults
538
+ metadata = @config.rpcs.update_snooze.metadata.to_h
539
+
540
+ # Set x-goog-api-client and x-goog-user-project headers
541
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
542
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
543
+ gapic_version: ::Google::Cloud::Monitoring::V3::VERSION
544
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
545
+
546
+ header_params = {}
547
+ if request.snooze&.name
548
+ header_params["snooze.name"] = request.snooze.name
549
+ end
550
+
551
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
552
+ metadata[:"x-goog-request-params"] ||= request_params_header
553
+
554
+ options.apply_defaults timeout: @config.rpcs.update_snooze.timeout,
555
+ metadata: metadata,
556
+ retry_policy: @config.rpcs.update_snooze.retry_policy
557
+
558
+ options.apply_defaults timeout: @config.timeout,
559
+ metadata: @config.metadata,
560
+ retry_policy: @config.retry_policy
561
+
562
+ @snooze_service_stub.call_rpc :update_snooze, request, options: options do |response, operation|
563
+ yield response, operation if block_given?
564
+ return response
565
+ end
566
+ rescue ::GRPC::BadStatus => e
567
+ raise ::Google::Cloud::Error.from_error(e)
568
+ end
569
+
570
+ ##
571
+ # Configuration class for the SnoozeService API.
572
+ #
573
+ # This class represents the configuration for SnoozeService,
574
+ # providing control over timeouts, retry behavior, logging, transport
575
+ # parameters, and other low-level controls. Certain parameters can also be
576
+ # applied individually to specific RPCs. See
577
+ # {::Google::Cloud::Monitoring::V3::SnoozeService::Client::Configuration::Rpcs}
578
+ # for a list of RPCs that can be configured independently.
579
+ #
580
+ # Configuration can be applied globally to all clients, or to a single client
581
+ # on construction.
582
+ #
583
+ # @example
584
+ #
585
+ # # Modify the global config, setting the timeout for
586
+ # # create_snooze to 20 seconds,
587
+ # # and all remaining timeouts to 10 seconds.
588
+ # ::Google::Cloud::Monitoring::V3::SnoozeService::Client.configure do |config|
589
+ # config.timeout = 10.0
590
+ # config.rpcs.create_snooze.timeout = 20.0
591
+ # end
592
+ #
593
+ # # Apply the above configuration only to a new client.
594
+ # client = ::Google::Cloud::Monitoring::V3::SnoozeService::Client.new do |config|
595
+ # config.timeout = 10.0
596
+ # config.rpcs.create_snooze.timeout = 20.0
597
+ # end
598
+ #
599
+ # @!attribute [rw] endpoint
600
+ # The hostname or hostname:port of the service endpoint.
601
+ # Defaults to `"monitoring.googleapis.com"`.
602
+ # @return [::String]
603
+ # @!attribute [rw] credentials
604
+ # Credentials to send with calls. You may provide any of the following types:
605
+ # * (`String`) The path to a service account key file in JSON format
606
+ # * (`Hash`) A service account key as a Hash
607
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
608
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
609
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
610
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
611
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
612
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
613
+ # * (`nil`) indicating no credentials
614
+ # @return [::Object]
615
+ # @!attribute [rw] scope
616
+ # The OAuth scopes
617
+ # @return [::Array<::String>]
618
+ # @!attribute [rw] lib_name
619
+ # The library name as recorded in instrumentation and logging
620
+ # @return [::String]
621
+ # @!attribute [rw] lib_version
622
+ # The library version as recorded in instrumentation and logging
623
+ # @return [::String]
624
+ # @!attribute [rw] channel_args
625
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
626
+ # `GRPC::Core::Channel` object is provided as the credential.
627
+ # @return [::Hash]
628
+ # @!attribute [rw] interceptors
629
+ # An array of interceptors that are run before calls are executed.
630
+ # @return [::Array<::GRPC::ClientInterceptor>]
631
+ # @!attribute [rw] timeout
632
+ # The call timeout in seconds.
633
+ # @return [::Numeric]
634
+ # @!attribute [rw] metadata
635
+ # Additional gRPC headers to be sent with the call.
636
+ # @return [::Hash{::Symbol=>::String}]
637
+ # @!attribute [rw] retry_policy
638
+ # The retry policy. The value is a hash with the following keys:
639
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
640
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
641
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
642
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
643
+ # trigger a retry.
644
+ # @return [::Hash]
645
+ # @!attribute [rw] quota_project
646
+ # A separate project against which to charge quota.
647
+ # @return [::String]
648
+ #
649
+ class Configuration
650
+ extend ::Gapic::Config
651
+
652
+ config_attr :endpoint, "monitoring.googleapis.com", ::String
653
+ config_attr :credentials, nil do |value|
654
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
655
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
656
+ allowed.any? { |klass| klass === value }
657
+ end
658
+ config_attr :scope, nil, ::String, ::Array, nil
659
+ config_attr :lib_name, nil, ::String, nil
660
+ config_attr :lib_version, nil, ::String, nil
661
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
662
+ config_attr :interceptors, nil, ::Array, nil
663
+ config_attr :timeout, nil, ::Numeric, nil
664
+ config_attr :metadata, nil, ::Hash, nil
665
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
666
+ config_attr :quota_project, nil, ::String, nil
667
+
668
+ # @private
669
+ def initialize parent_config = nil
670
+ @parent_config = parent_config unless parent_config.nil?
671
+
672
+ yield self if block_given?
673
+ end
674
+
675
+ ##
676
+ # Configurations for individual RPCs
677
+ # @return [Rpcs]
678
+ #
679
+ def rpcs
680
+ @rpcs ||= begin
681
+ parent_rpcs = nil
682
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
683
+ Rpcs.new parent_rpcs
684
+ end
685
+ end
686
+
687
+ ##
688
+ # Configuration RPC class for the SnoozeService API.
689
+ #
690
+ # Includes fields providing the configuration for each RPC in this service.
691
+ # Each configuration object is of type `Gapic::Config::Method` and includes
692
+ # the following configuration fields:
693
+ #
694
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
695
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
696
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
697
+ # include the following keys:
698
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
699
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
700
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
701
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
702
+ # trigger a retry.
703
+ #
704
+ class Rpcs
705
+ ##
706
+ # RPC-specific configuration for `create_snooze`
707
+ # @return [::Gapic::Config::Method]
708
+ #
709
+ attr_reader :create_snooze
710
+ ##
711
+ # RPC-specific configuration for `list_snoozes`
712
+ # @return [::Gapic::Config::Method]
713
+ #
714
+ attr_reader :list_snoozes
715
+ ##
716
+ # RPC-specific configuration for `get_snooze`
717
+ # @return [::Gapic::Config::Method]
718
+ #
719
+ attr_reader :get_snooze
720
+ ##
721
+ # RPC-specific configuration for `update_snooze`
722
+ # @return [::Gapic::Config::Method]
723
+ #
724
+ attr_reader :update_snooze
725
+
726
+ # @private
727
+ def initialize parent_rpcs = nil
728
+ create_snooze_config = parent_rpcs.create_snooze if parent_rpcs.respond_to? :create_snooze
729
+ @create_snooze = ::Gapic::Config::Method.new create_snooze_config
730
+ list_snoozes_config = parent_rpcs.list_snoozes if parent_rpcs.respond_to? :list_snoozes
731
+ @list_snoozes = ::Gapic::Config::Method.new list_snoozes_config
732
+ get_snooze_config = parent_rpcs.get_snooze if parent_rpcs.respond_to? :get_snooze
733
+ @get_snooze = ::Gapic::Config::Method.new get_snooze_config
734
+ update_snooze_config = parent_rpcs.update_snooze if parent_rpcs.respond_to? :update_snooze
735
+ @update_snooze = ::Gapic::Config::Method.new update_snooze_config
736
+
737
+ yield self if block_given?
738
+ end
739
+ end
740
+ end
741
+ end
742
+ end
743
+ end
744
+ end
745
+ end
746
+ end