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