google-cloud-essential_contacts-v1 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,840 @@
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/cloud/essentialcontacts/v1/service_pb"
21
+ require "google/cloud/essential_contacts/v1/essential_contacts_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module EssentialContacts
26
+ module V1
27
+ module EssentialContactsService
28
+ module Rest
29
+ ##
30
+ # REST client for the EssentialContactsService service.
31
+ #
32
+ # Manages contacts for important Google Cloud notifications.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :essential_contacts_service_stub
39
+
40
+ ##
41
+ # Configure the EssentialContactsService Client class.
42
+ #
43
+ # See {::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all EssentialContactsService clients
49
+ # ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::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", "EssentialContacts", "V1"]
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_contact.timeout = 60.0
70
+
71
+ default_config.rpcs.update_contact.timeout = 60.0
72
+
73
+ default_config.rpcs.list_contacts.timeout = 60.0
74
+ default_config.rpcs.list_contacts.retry_policy = {
75
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
76
+ }
77
+
78
+ default_config.rpcs.get_contact.timeout = 60.0
79
+ default_config.rpcs.get_contact.retry_policy = {
80
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
81
+ }
82
+
83
+ default_config.rpcs.delete_contact.timeout = 60.0
84
+
85
+ default_config.rpcs.compute_contacts.timeout = 60.0
86
+
87
+ default_config.rpcs.send_test_message.timeout = 60.0
88
+
89
+ default_config
90
+ end
91
+ yield @configure if block_given?
92
+ @configure
93
+ end
94
+
95
+ ##
96
+ # Configure the EssentialContactsService Client instance.
97
+ #
98
+ # The configuration is set to the derived mode, meaning that values can be changed,
99
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
100
+ # should be made on {Client.configure}.
101
+ #
102
+ # See {::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client::Configuration}
103
+ # for a description of the configuration fields.
104
+ #
105
+ # @yield [config] Configure the Client client.
106
+ # @yieldparam config [Client::Configuration]
107
+ #
108
+ # @return [Client::Configuration]
109
+ #
110
+ def configure
111
+ yield @config if block_given?
112
+ @config
113
+ end
114
+
115
+ ##
116
+ # Create a new EssentialContactsService REST client object.
117
+ #
118
+ # @example
119
+ #
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client.new
122
+ #
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
127
+ #
128
+ # @yield [config] Configure the EssentialContactsService client.
129
+ # @yieldparam config [Client::Configuration]
130
+ #
131
+ def initialize
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
+
150
+ @quota_project_id = @config.quota_project
151
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
152
+
153
+ @essential_contacts_service_stub = ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
154
+ end
155
+
156
+ # Service calls
157
+
158
+ ##
159
+ # Adds a new contact for a resource.
160
+ #
161
+ # @overload create_contact(request, options = nil)
162
+ # Pass arguments to `create_contact` via a request object, either of type
163
+ # {::Google::Cloud::EssentialContacts::V1::CreateContactRequest} or an equivalent Hash.
164
+ #
165
+ # @param request [::Google::Cloud::EssentialContacts::V1::CreateContactRequest, ::Hash]
166
+ # A request object representing the call parameters. Required. To specify no
167
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
168
+ # @param options [::Gapic::CallOptions, ::Hash]
169
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
170
+ #
171
+ # @overload create_contact(parent: nil, contact: nil)
172
+ # Pass arguments to `create_contact` via keyword arguments. Note that at
173
+ # least one keyword argument is required. To specify no parameters, or to keep all
174
+ # the default parameter values, pass an empty Hash as a request object (see above).
175
+ #
176
+ # @param parent [::String]
177
+ # Required. The resource to save this contact for.
178
+ # Format: organizations/\\{organization_id}, folders/\\{folder_id} or
179
+ # projects/\\{project_id}
180
+ # @param contact [::Google::Cloud::EssentialContacts::V1::Contact, ::Hash]
181
+ # Required. The contact to create. Must specify an email address and language
182
+ # tag.
183
+ # @yield [result, operation] Access the result along with the TransportOperation object
184
+ # @yieldparam result [::Google::Cloud::EssentialContacts::V1::Contact]
185
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
186
+ #
187
+ # @return [::Google::Cloud::EssentialContacts::V1::Contact]
188
+ #
189
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
190
+ def create_contact request, options = nil
191
+ raise ::ArgumentError, "request must be provided" if request.nil?
192
+
193
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::CreateContactRequest
194
+
195
+ # Converts hash and nil to an options object
196
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
197
+
198
+ # Customize the options with defaults
199
+ call_metadata = @config.rpcs.create_contact.metadata.to_h
200
+
201
+ # Set x-goog-api-client and x-goog-user-project headers
202
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
203
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
204
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
205
+ transports_version_send: [:rest]
206
+
207
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
208
+
209
+ options.apply_defaults timeout: @config.rpcs.create_contact.timeout,
210
+ metadata: call_metadata,
211
+ retry_policy: @config.rpcs.create_contact.retry_policy
212
+
213
+ options.apply_defaults timeout: @config.timeout,
214
+ metadata: @config.metadata,
215
+ retry_policy: @config.retry_policy
216
+
217
+ @essential_contacts_service_stub.create_contact request, options do |result, operation|
218
+ yield result, operation if block_given?
219
+ return result
220
+ end
221
+ rescue ::Gapic::Rest::Error => e
222
+ raise ::Google::Cloud::Error.from_error(e)
223
+ end
224
+
225
+ ##
226
+ # Updates a contact.
227
+ # Note: A contact's email address cannot be changed.
228
+ #
229
+ # @overload update_contact(request, options = nil)
230
+ # Pass arguments to `update_contact` via a request object, either of type
231
+ # {::Google::Cloud::EssentialContacts::V1::UpdateContactRequest} or an equivalent Hash.
232
+ #
233
+ # @param request [::Google::Cloud::EssentialContacts::V1::UpdateContactRequest, ::Hash]
234
+ # A request object representing the call parameters. Required. To specify no
235
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
236
+ # @param options [::Gapic::CallOptions, ::Hash]
237
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
238
+ #
239
+ # @overload update_contact(contact: nil, update_mask: nil)
240
+ # Pass arguments to `update_contact` via keyword arguments. Note that at
241
+ # least one keyword argument is required. To specify no parameters, or to keep all
242
+ # the default parameter values, pass an empty Hash as a request object (see above).
243
+ #
244
+ # @param contact [::Google::Cloud::EssentialContacts::V1::Contact, ::Hash]
245
+ # Required. The contact resource to replace the existing saved contact. Note:
246
+ # the email address of the contact cannot be modified.
247
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
248
+ # Optional. The update mask applied to the resource. For the `FieldMask`
249
+ # definition, see
250
+ # https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
251
+ # @yield [result, operation] Access the result along with the TransportOperation object
252
+ # @yieldparam result [::Google::Cloud::EssentialContacts::V1::Contact]
253
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
254
+ #
255
+ # @return [::Google::Cloud::EssentialContacts::V1::Contact]
256
+ #
257
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
258
+ def update_contact request, options = nil
259
+ raise ::ArgumentError, "request must be provided" if request.nil?
260
+
261
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::UpdateContactRequest
262
+
263
+ # Converts hash and nil to an options object
264
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
265
+
266
+ # Customize the options with defaults
267
+ call_metadata = @config.rpcs.update_contact.metadata.to_h
268
+
269
+ # Set x-goog-api-client and x-goog-user-project headers
270
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
271
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
272
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
273
+ transports_version_send: [:rest]
274
+
275
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
276
+
277
+ options.apply_defaults timeout: @config.rpcs.update_contact.timeout,
278
+ metadata: call_metadata,
279
+ retry_policy: @config.rpcs.update_contact.retry_policy
280
+
281
+ options.apply_defaults timeout: @config.timeout,
282
+ metadata: @config.metadata,
283
+ retry_policy: @config.retry_policy
284
+
285
+ @essential_contacts_service_stub.update_contact request, options do |result, operation|
286
+ yield result, operation if block_given?
287
+ return result
288
+ end
289
+ rescue ::Gapic::Rest::Error => e
290
+ raise ::Google::Cloud::Error.from_error(e)
291
+ end
292
+
293
+ ##
294
+ # Lists the contacts that have been set on a resource.
295
+ #
296
+ # @overload list_contacts(request, options = nil)
297
+ # Pass arguments to `list_contacts` via a request object, either of type
298
+ # {::Google::Cloud::EssentialContacts::V1::ListContactsRequest} or an equivalent Hash.
299
+ #
300
+ # @param request [::Google::Cloud::EssentialContacts::V1::ListContactsRequest, ::Hash]
301
+ # A request object representing the call parameters. Required. To specify no
302
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
303
+ # @param options [::Gapic::CallOptions, ::Hash]
304
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
305
+ #
306
+ # @overload list_contacts(parent: nil, page_size: nil, page_token: nil)
307
+ # Pass arguments to `list_contacts` via keyword arguments. Note that at
308
+ # least one keyword argument is required. To specify no parameters, or to keep all
309
+ # the default parameter values, pass an empty Hash as a request object (see above).
310
+ #
311
+ # @param parent [::String]
312
+ # Required. The parent resource name.
313
+ # Format: organizations/\\{organization_id}, folders/\\{folder_id} or
314
+ # projects/\\{project_id}
315
+ # @param page_size [::Integer]
316
+ # Optional. The maximum number of results to return from this request.
317
+ # Non-positive values are ignored. The presence of `next_page_token` in the
318
+ # response indicates that more results might be available.
319
+ # If not specified, the default page_size is 100.
320
+ # @param page_token [::String]
321
+ # Optional. If present, retrieves the next batch of results from the
322
+ # preceding call to this method. `page_token` must be the value of
323
+ # `next_page_token` from the previous response. The values of other method
324
+ # parameters should be identical to those in the previous call.
325
+ # @yield [result, operation] Access the result along with the TransportOperation object
326
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::EssentialContacts::V1::Contact>]
327
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
328
+ #
329
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::EssentialContacts::V1::Contact>]
330
+ #
331
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
332
+ def list_contacts request, options = nil
333
+ raise ::ArgumentError, "request must be provided" if request.nil?
334
+
335
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::ListContactsRequest
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
+ call_metadata = @config.rpcs.list_contacts.metadata.to_h
342
+
343
+ # Set x-goog-api-client and x-goog-user-project headers
344
+ call_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::EssentialContacts::V1::VERSION,
347
+ transports_version_send: [:rest]
348
+
349
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
350
+
351
+ options.apply_defaults timeout: @config.rpcs.list_contacts.timeout,
352
+ metadata: call_metadata,
353
+ retry_policy: @config.rpcs.list_contacts.retry_policy
354
+
355
+ options.apply_defaults timeout: @config.timeout,
356
+ metadata: @config.metadata,
357
+ retry_policy: @config.retry_policy
358
+
359
+ @essential_contacts_service_stub.list_contacts request, options do |result, operation|
360
+ result = ::Gapic::Rest::PagedEnumerable.new @essential_contacts_service_stub, :list_contacts, "contacts", request, result, options
361
+ yield result, operation if block_given?
362
+ return result
363
+ end
364
+ rescue ::Gapic::Rest::Error => e
365
+ raise ::Google::Cloud::Error.from_error(e)
366
+ end
367
+
368
+ ##
369
+ # Gets a single contact.
370
+ #
371
+ # @overload get_contact(request, options = nil)
372
+ # Pass arguments to `get_contact` via a request object, either of type
373
+ # {::Google::Cloud::EssentialContacts::V1::GetContactRequest} or an equivalent Hash.
374
+ #
375
+ # @param request [::Google::Cloud::EssentialContacts::V1::GetContactRequest, ::Hash]
376
+ # A request object representing the call parameters. Required. To specify no
377
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
378
+ # @param options [::Gapic::CallOptions, ::Hash]
379
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
380
+ #
381
+ # @overload get_contact(name: nil)
382
+ # Pass arguments to `get_contact` via keyword arguments. Note that at
383
+ # least one keyword argument is required. To specify no parameters, or to keep all
384
+ # the default parameter values, pass an empty Hash as a request object (see above).
385
+ #
386
+ # @param name [::String]
387
+ # Required. The name of the contact to retrieve.
388
+ # Format: organizations/\\{organization_id}/contacts/\\{contact_id},
389
+ # folders/\\{folder_id}/contacts/\\{contact_id} or
390
+ # projects/\\{project_id}/contacts/\\{contact_id}
391
+ # @yield [result, operation] Access the result along with the TransportOperation object
392
+ # @yieldparam result [::Google::Cloud::EssentialContacts::V1::Contact]
393
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
394
+ #
395
+ # @return [::Google::Cloud::EssentialContacts::V1::Contact]
396
+ #
397
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
398
+ def get_contact request, options = nil
399
+ raise ::ArgumentError, "request must be provided" if request.nil?
400
+
401
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::GetContactRequest
402
+
403
+ # Converts hash and nil to an options object
404
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
405
+
406
+ # Customize the options with defaults
407
+ call_metadata = @config.rpcs.get_contact.metadata.to_h
408
+
409
+ # Set x-goog-api-client and x-goog-user-project headers
410
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
411
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
412
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
413
+ transports_version_send: [:rest]
414
+
415
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
416
+
417
+ options.apply_defaults timeout: @config.rpcs.get_contact.timeout,
418
+ metadata: call_metadata,
419
+ retry_policy: @config.rpcs.get_contact.retry_policy
420
+
421
+ options.apply_defaults timeout: @config.timeout,
422
+ metadata: @config.metadata,
423
+ retry_policy: @config.retry_policy
424
+
425
+ @essential_contacts_service_stub.get_contact request, options do |result, operation|
426
+ yield result, operation if block_given?
427
+ return result
428
+ end
429
+ rescue ::Gapic::Rest::Error => e
430
+ raise ::Google::Cloud::Error.from_error(e)
431
+ end
432
+
433
+ ##
434
+ # Deletes a contact.
435
+ #
436
+ # @overload delete_contact(request, options = nil)
437
+ # Pass arguments to `delete_contact` via a request object, either of type
438
+ # {::Google::Cloud::EssentialContacts::V1::DeleteContactRequest} or an equivalent Hash.
439
+ #
440
+ # @param request [::Google::Cloud::EssentialContacts::V1::DeleteContactRequest, ::Hash]
441
+ # A request object representing the call parameters. Required. To specify no
442
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
443
+ # @param options [::Gapic::CallOptions, ::Hash]
444
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
445
+ #
446
+ # @overload delete_contact(name: nil)
447
+ # Pass arguments to `delete_contact` via keyword arguments. Note that at
448
+ # least one keyword argument is required. To specify no parameters, or to keep all
449
+ # the default parameter values, pass an empty Hash as a request object (see above).
450
+ #
451
+ # @param name [::String]
452
+ # Required. The name of the contact to delete.
453
+ # Format: organizations/\\{organization_id}/contacts/\\{contact_id},
454
+ # folders/\\{folder_id}/contacts/\\{contact_id} or
455
+ # projects/\\{project_id}/contacts/\\{contact_id}
456
+ # @yield [result, operation] Access the result along with the TransportOperation object
457
+ # @yieldparam result [::Google::Protobuf::Empty]
458
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
459
+ #
460
+ # @return [::Google::Protobuf::Empty]
461
+ #
462
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
463
+ def delete_contact request, options = nil
464
+ raise ::ArgumentError, "request must be provided" if request.nil?
465
+
466
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::DeleteContactRequest
467
+
468
+ # Converts hash and nil to an options object
469
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
470
+
471
+ # Customize the options with defaults
472
+ call_metadata = @config.rpcs.delete_contact.metadata.to_h
473
+
474
+ # Set x-goog-api-client and x-goog-user-project headers
475
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
476
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
477
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
478
+ transports_version_send: [:rest]
479
+
480
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
481
+
482
+ options.apply_defaults timeout: @config.rpcs.delete_contact.timeout,
483
+ metadata: call_metadata,
484
+ retry_policy: @config.rpcs.delete_contact.retry_policy
485
+
486
+ options.apply_defaults timeout: @config.timeout,
487
+ metadata: @config.metadata,
488
+ retry_policy: @config.retry_policy
489
+
490
+ @essential_contacts_service_stub.delete_contact request, options do |result, operation|
491
+ yield result, operation if block_given?
492
+ return result
493
+ end
494
+ rescue ::Gapic::Rest::Error => e
495
+ raise ::Google::Cloud::Error.from_error(e)
496
+ end
497
+
498
+ ##
499
+ # Lists all contacts for the resource that are subscribed to the
500
+ # specified notification categories, including contacts inherited from
501
+ # any parent resources.
502
+ #
503
+ # @overload compute_contacts(request, options = nil)
504
+ # Pass arguments to `compute_contacts` via a request object, either of type
505
+ # {::Google::Cloud::EssentialContacts::V1::ComputeContactsRequest} or an equivalent Hash.
506
+ #
507
+ # @param request [::Google::Cloud::EssentialContacts::V1::ComputeContactsRequest, ::Hash]
508
+ # A request object representing the call parameters. Required. To specify no
509
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
510
+ # @param options [::Gapic::CallOptions, ::Hash]
511
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
512
+ #
513
+ # @overload compute_contacts(parent: nil, notification_categories: nil, page_size: nil, page_token: nil)
514
+ # Pass arguments to `compute_contacts` via keyword arguments. Note that at
515
+ # least one keyword argument is required. To specify no parameters, or to keep all
516
+ # the default parameter values, pass an empty Hash as a request object (see above).
517
+ #
518
+ # @param parent [::String]
519
+ # Required. The name of the resource to compute contacts for.
520
+ # Format: organizations/\\{organization_id},
521
+ # folders/\\{folder_id} or projects/\\{project_id}
522
+ # @param notification_categories [::Array<::Google::Cloud::EssentialContacts::V1::NotificationCategory>]
523
+ # The categories of notifications to compute contacts for. If ALL is included
524
+ # in this list, contacts subscribed to any notification category will be
525
+ # returned.
526
+ # @param page_size [::Integer]
527
+ # Optional. The maximum number of results to return from this request.
528
+ # Non-positive values are ignored. The presence of `next_page_token` in the
529
+ # response indicates that more results might be available.
530
+ # If not specified, the default page_size is 100.
531
+ # @param page_token [::String]
532
+ # Optional. If present, retrieves the next batch of results from the
533
+ # preceding call to this method. `page_token` must be the value of
534
+ # `next_page_token` from the previous response. The values of other method
535
+ # parameters should be identical to those in the previous call.
536
+ # @yield [result, operation] Access the result along with the TransportOperation object
537
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::EssentialContacts::V1::Contact>]
538
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
539
+ #
540
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::EssentialContacts::V1::Contact>]
541
+ #
542
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
543
+ def compute_contacts request, options = nil
544
+ raise ::ArgumentError, "request must be provided" if request.nil?
545
+
546
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::ComputeContactsRequest
547
+
548
+ # Converts hash and nil to an options object
549
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
550
+
551
+ # Customize the options with defaults
552
+ call_metadata = @config.rpcs.compute_contacts.metadata.to_h
553
+
554
+ # Set x-goog-api-client and x-goog-user-project headers
555
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
556
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
557
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
558
+ transports_version_send: [:rest]
559
+
560
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
561
+
562
+ options.apply_defaults timeout: @config.rpcs.compute_contacts.timeout,
563
+ metadata: call_metadata,
564
+ retry_policy: @config.rpcs.compute_contacts.retry_policy
565
+
566
+ options.apply_defaults timeout: @config.timeout,
567
+ metadata: @config.metadata,
568
+ retry_policy: @config.retry_policy
569
+
570
+ @essential_contacts_service_stub.compute_contacts request, options do |result, operation|
571
+ result = ::Gapic::Rest::PagedEnumerable.new @essential_contacts_service_stub, :compute_contacts, "contacts", request, result, options
572
+ yield result, operation if block_given?
573
+ return result
574
+ end
575
+ rescue ::Gapic::Rest::Error => e
576
+ raise ::Google::Cloud::Error.from_error(e)
577
+ end
578
+
579
+ ##
580
+ # Allows a contact admin to send a test message to contact to verify that it
581
+ # has been configured correctly.
582
+ #
583
+ # @overload send_test_message(request, options = nil)
584
+ # Pass arguments to `send_test_message` via a request object, either of type
585
+ # {::Google::Cloud::EssentialContacts::V1::SendTestMessageRequest} or an equivalent Hash.
586
+ #
587
+ # @param request [::Google::Cloud::EssentialContacts::V1::SendTestMessageRequest, ::Hash]
588
+ # A request object representing the call parameters. Required. To specify no
589
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
590
+ # @param options [::Gapic::CallOptions, ::Hash]
591
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
592
+ #
593
+ # @overload send_test_message(contacts: nil, resource: nil, notification_category: nil)
594
+ # Pass arguments to `send_test_message` via keyword arguments. Note that at
595
+ # least one keyword argument is required. To specify no parameters, or to keep all
596
+ # the default parameter values, pass an empty Hash as a request object (see above).
597
+ #
598
+ # @param contacts [::Array<::String>]
599
+ # Required. The list of names of the contacts to send a test message to.
600
+ # Format: organizations/\\{organization_id}/contacts/\\{contact_id},
601
+ # folders/\\{folder_id}/contacts/\\{contact_id} or
602
+ # projects/\\{project_id}/contacts/\\{contact_id}
603
+ # @param resource [::String]
604
+ # Required. The name of the resource to send the test message for. All
605
+ # contacts must either be set directly on this resource or inherited from
606
+ # another resource that is an ancestor of this one. Format:
607
+ # organizations/\\{organization_id}, folders/\\{folder_id} or
608
+ # projects/\\{project_id}
609
+ # @param notification_category [::Google::Cloud::EssentialContacts::V1::NotificationCategory]
610
+ # Required. The notification category to send the test message for. All
611
+ # contacts must be subscribed to this category.
612
+ # @yield [result, operation] Access the result along with the TransportOperation object
613
+ # @yieldparam result [::Google::Protobuf::Empty]
614
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
615
+ #
616
+ # @return [::Google::Protobuf::Empty]
617
+ #
618
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
619
+ def send_test_message request, options = nil
620
+ raise ::ArgumentError, "request must be provided" if request.nil?
621
+
622
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::EssentialContacts::V1::SendTestMessageRequest
623
+
624
+ # Converts hash and nil to an options object
625
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
626
+
627
+ # Customize the options with defaults
628
+ call_metadata = @config.rpcs.send_test_message.metadata.to_h
629
+
630
+ # Set x-goog-api-client and x-goog-user-project headers
631
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
632
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
633
+ gapic_version: ::Google::Cloud::EssentialContacts::V1::VERSION,
634
+ transports_version_send: [:rest]
635
+
636
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
637
+
638
+ options.apply_defaults timeout: @config.rpcs.send_test_message.timeout,
639
+ metadata: call_metadata,
640
+ retry_policy: @config.rpcs.send_test_message.retry_policy
641
+
642
+ options.apply_defaults timeout: @config.timeout,
643
+ metadata: @config.metadata,
644
+ retry_policy: @config.retry_policy
645
+
646
+ @essential_contacts_service_stub.send_test_message request, options do |result, operation|
647
+ yield result, operation if block_given?
648
+ return result
649
+ end
650
+ rescue ::Gapic::Rest::Error => e
651
+ raise ::Google::Cloud::Error.from_error(e)
652
+ end
653
+
654
+ ##
655
+ # Configuration class for the EssentialContactsService REST API.
656
+ #
657
+ # This class represents the configuration for EssentialContactsService REST,
658
+ # providing control over timeouts, retry behavior, logging, transport
659
+ # parameters, and other low-level controls. Certain parameters can also be
660
+ # applied individually to specific RPCs. See
661
+ # {::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client::Configuration::Rpcs}
662
+ # for a list of RPCs that can be configured independently.
663
+ #
664
+ # Configuration can be applied globally to all clients, or to a single client
665
+ # on construction.
666
+ #
667
+ # @example
668
+ #
669
+ # # Modify the global config, setting the timeout for
670
+ # # create_contact to 20 seconds,
671
+ # # and all remaining timeouts to 10 seconds.
672
+ # ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client.configure do |config|
673
+ # config.timeout = 10.0
674
+ # config.rpcs.create_contact.timeout = 20.0
675
+ # end
676
+ #
677
+ # # Apply the above configuration only to a new client.
678
+ # client = ::Google::Cloud::EssentialContacts::V1::EssentialContactsService::Rest::Client.new do |config|
679
+ # config.timeout = 10.0
680
+ # config.rpcs.create_contact.timeout = 20.0
681
+ # end
682
+ #
683
+ # @!attribute [rw] endpoint
684
+ # The hostname or hostname:port of the service endpoint.
685
+ # Defaults to `"essentialcontacts.googleapis.com"`.
686
+ # @return [::String]
687
+ # @!attribute [rw] credentials
688
+ # Credentials to send with calls. You may provide any of the following types:
689
+ # * (`String`) The path to a service account key file in JSON format
690
+ # * (`Hash`) A service account key as a Hash
691
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
692
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
693
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
694
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
695
+ # * (`nil`) indicating no credentials
696
+ # @return [::Object]
697
+ # @!attribute [rw] scope
698
+ # The OAuth scopes
699
+ # @return [::Array<::String>]
700
+ # @!attribute [rw] lib_name
701
+ # The library name as recorded in instrumentation and logging
702
+ # @return [::String]
703
+ # @!attribute [rw] lib_version
704
+ # The library version as recorded in instrumentation and logging
705
+ # @return [::String]
706
+ # @!attribute [rw] timeout
707
+ # The call timeout in seconds.
708
+ # @return [::Numeric]
709
+ # @!attribute [rw] metadata
710
+ # Additional headers to be sent with the call.
711
+ # @return [::Hash{::Symbol=>::String}]
712
+ # @!attribute [rw] retry_policy
713
+ # The retry policy. The value is a hash with the following keys:
714
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
715
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
716
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
717
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
718
+ # trigger a retry.
719
+ # @return [::Hash]
720
+ # @!attribute [rw] quota_project
721
+ # A separate project against which to charge quota.
722
+ # @return [::String]
723
+ #
724
+ class Configuration
725
+ extend ::Gapic::Config
726
+
727
+ config_attr :endpoint, "essentialcontacts.googleapis.com", ::String
728
+ config_attr :credentials, nil do |value|
729
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
730
+ allowed.any? { |klass| klass === value }
731
+ end
732
+ config_attr :scope, nil, ::String, ::Array, nil
733
+ config_attr :lib_name, nil, ::String, nil
734
+ config_attr :lib_version, nil, ::String, nil
735
+ config_attr :timeout, nil, ::Numeric, nil
736
+ config_attr :metadata, nil, ::Hash, nil
737
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
738
+ config_attr :quota_project, nil, ::String, nil
739
+
740
+ # @private
741
+ def initialize parent_config = nil
742
+ @parent_config = parent_config unless parent_config.nil?
743
+
744
+ yield self if block_given?
745
+ end
746
+
747
+ ##
748
+ # Configurations for individual RPCs
749
+ # @return [Rpcs]
750
+ #
751
+ def rpcs
752
+ @rpcs ||= begin
753
+ parent_rpcs = nil
754
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
755
+ Rpcs.new parent_rpcs
756
+ end
757
+ end
758
+
759
+ ##
760
+ # Configuration RPC class for the EssentialContactsService API.
761
+ #
762
+ # Includes fields providing the configuration for each RPC in this service.
763
+ # Each configuration object is of type `Gapic::Config::Method` and includes
764
+ # the following configuration fields:
765
+ #
766
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
767
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
768
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
769
+ # include the following keys:
770
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
771
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
772
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
773
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
774
+ # trigger a retry.
775
+ #
776
+ class Rpcs
777
+ ##
778
+ # RPC-specific configuration for `create_contact`
779
+ # @return [::Gapic::Config::Method]
780
+ #
781
+ attr_reader :create_contact
782
+ ##
783
+ # RPC-specific configuration for `update_contact`
784
+ # @return [::Gapic::Config::Method]
785
+ #
786
+ attr_reader :update_contact
787
+ ##
788
+ # RPC-specific configuration for `list_contacts`
789
+ # @return [::Gapic::Config::Method]
790
+ #
791
+ attr_reader :list_contacts
792
+ ##
793
+ # RPC-specific configuration for `get_contact`
794
+ # @return [::Gapic::Config::Method]
795
+ #
796
+ attr_reader :get_contact
797
+ ##
798
+ # RPC-specific configuration for `delete_contact`
799
+ # @return [::Gapic::Config::Method]
800
+ #
801
+ attr_reader :delete_contact
802
+ ##
803
+ # RPC-specific configuration for `compute_contacts`
804
+ # @return [::Gapic::Config::Method]
805
+ #
806
+ attr_reader :compute_contacts
807
+ ##
808
+ # RPC-specific configuration for `send_test_message`
809
+ # @return [::Gapic::Config::Method]
810
+ #
811
+ attr_reader :send_test_message
812
+
813
+ # @private
814
+ def initialize parent_rpcs = nil
815
+ create_contact_config = parent_rpcs.create_contact if parent_rpcs.respond_to? :create_contact
816
+ @create_contact = ::Gapic::Config::Method.new create_contact_config
817
+ update_contact_config = parent_rpcs.update_contact if parent_rpcs.respond_to? :update_contact
818
+ @update_contact = ::Gapic::Config::Method.new update_contact_config
819
+ list_contacts_config = parent_rpcs.list_contacts if parent_rpcs.respond_to? :list_contacts
820
+ @list_contacts = ::Gapic::Config::Method.new list_contacts_config
821
+ get_contact_config = parent_rpcs.get_contact if parent_rpcs.respond_to? :get_contact
822
+ @get_contact = ::Gapic::Config::Method.new get_contact_config
823
+ delete_contact_config = parent_rpcs.delete_contact if parent_rpcs.respond_to? :delete_contact
824
+ @delete_contact = ::Gapic::Config::Method.new delete_contact_config
825
+ compute_contacts_config = parent_rpcs.compute_contacts if parent_rpcs.respond_to? :compute_contacts
826
+ @compute_contacts = ::Gapic::Config::Method.new compute_contacts_config
827
+ send_test_message_config = parent_rpcs.send_test_message if parent_rpcs.respond_to? :send_test_message
828
+ @send_test_message = ::Gapic::Config::Method.new send_test_message_config
829
+
830
+ yield self if block_given?
831
+ end
832
+ end
833
+ end
834
+ end
835
+ end
836
+ end
837
+ end
838
+ end
839
+ end
840
+ end