google-cloud-metastore-v1beta 0.2.0 → 0.4.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,901 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 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/metastore/v1beta/metastore_federation_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Metastore
25
+ module V1beta
26
+ module DataprocMetastoreFederation
27
+ ##
28
+ # Client for the DataprocMetastoreFederation service.
29
+ #
30
+ # Configures and manages metastore federation services.
31
+ # Dataproc Metastore Federation Service allows federating a collection of
32
+ # backend metastores like BigQuery, Dataplex Lakes, and other Dataproc
33
+ # Metastores. The Federation Service exposes a gRPC URL through which metadata
34
+ # from the backend metastores are served at query time.
35
+ #
36
+ # The Dataproc Metastore Federation API defines the following resource model:
37
+ # * The service works with a collection of Google Cloud projects.
38
+ # * Each project has a collection of available locations.
39
+ # * Each location has a collection of federations.
40
+ # * Dataproc Metastore Federations are resources with names of the
41
+ # form:
42
+ # `projects/{project_number}/locations/{location_id}/federations/{federation_id}`.
43
+ #
44
+ class Client
45
+ include Paths
46
+
47
+ # @private
48
+ attr_reader :dataproc_metastore_federation_stub
49
+
50
+ ##
51
+ # Configure the DataprocMetastoreFederation Client class.
52
+ #
53
+ # See {::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client::Configuration}
54
+ # for a description of the configuration fields.
55
+ #
56
+ # @example
57
+ #
58
+ # # Modify the configuration for all DataprocMetastoreFederation clients
59
+ # ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.configure do |config|
60
+ # config.timeout = 10.0
61
+ # end
62
+ #
63
+ # @yield [config] Configure the Client client.
64
+ # @yieldparam config [Client::Configuration]
65
+ #
66
+ # @return [Client::Configuration]
67
+ #
68
+ def self.configure
69
+ @configure ||= begin
70
+ namespace = ["Google", "Cloud", "Metastore", "V1beta"]
71
+ parent_config = while namespace.any?
72
+ parent_name = namespace.join "::"
73
+ parent_const = const_get parent_name
74
+ break parent_const.configure if parent_const.respond_to? :configure
75
+ namespace.pop
76
+ end
77
+ default_config = Client::Configuration.new parent_config
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the DataprocMetastoreFederation Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # Create a new DataprocMetastoreFederation client object.
107
+ #
108
+ # @example
109
+ #
110
+ # # Create a client using the default configuration
111
+ # client = ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
112
+ #
113
+ # # Create a client using a custom configuration
114
+ # client = ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new do |config|
115
+ # config.timeout = 10.0
116
+ # end
117
+ #
118
+ # @yield [config] Configure the DataprocMetastoreFederation client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ def initialize
122
+ # These require statements are intentionally placed here to initialize
123
+ # the gRPC module only when it's required.
124
+ # See https://github.com/googleapis/toolkit/issues/446
125
+ require "gapic/grpc"
126
+ require "google/cloud/metastore/v1beta/metastore_federation_services_pb"
127
+
128
+ # Create the configuration object
129
+ @config = Configuration.new Client.configure
130
+
131
+ # Yield the configuration if needed
132
+ yield @config if block_given?
133
+
134
+ # Create credentials
135
+ credentials = @config.credentials
136
+ # Use self-signed JWT if the endpoint is unchanged from default,
137
+ # but only if the default endpoint does not have a region prefix.
138
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
139
+ !@config.endpoint.split(".").first.include?("-")
140
+ credentials ||= Credentials.default scope: @config.scope,
141
+ enable_self_signed_jwt: enable_self_signed_jwt
142
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
143
+ credentials = Credentials.new credentials, scope: @config.scope
144
+ end
145
+ @quota_project_id = @config.quota_project
146
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
147
+
148
+ @operations_client = Operations.new do |config|
149
+ config.credentials = credentials
150
+ config.quota_project = @quota_project_id
151
+ config.endpoint = @config.endpoint
152
+ end
153
+
154
+ @dataproc_metastore_federation_stub = ::Gapic::ServiceStub.new(
155
+ ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Stub,
156
+ credentials: credentials,
157
+ endpoint: @config.endpoint,
158
+ channel_args: @config.channel_args,
159
+ interceptors: @config.interceptors
160
+ )
161
+ end
162
+
163
+ ##
164
+ # Get the associated client for long-running operations.
165
+ #
166
+ # @return [::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Operations]
167
+ #
168
+ attr_reader :operations_client
169
+
170
+ # Service calls
171
+
172
+ ##
173
+ # Lists federations in a project and location.
174
+ #
175
+ # @overload list_federations(request, options = nil)
176
+ # Pass arguments to `list_federations` via a request object, either of type
177
+ # {::Google::Cloud::Metastore::V1beta::ListFederationsRequest} or an equivalent Hash.
178
+ #
179
+ # @param request [::Google::Cloud::Metastore::V1beta::ListFederationsRequest, ::Hash]
180
+ # A request object representing the call parameters. Required. To specify no
181
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
182
+ # @param options [::Gapic::CallOptions, ::Hash]
183
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
184
+ #
185
+ # @overload list_federations(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
186
+ # Pass arguments to `list_federations` via keyword arguments. Note that at
187
+ # least one keyword argument is required. To specify no parameters, or to keep all
188
+ # the default parameter values, pass an empty Hash as a request object (see above).
189
+ #
190
+ # @param parent [::String]
191
+ # Required. The relative resource name of the location of metastore
192
+ # federations to list, in the following form:
193
+ # `projects/{project_number}/locations/{location_id}`.
194
+ # @param page_size [::Integer]
195
+ # Optional. The maximum number of federations to return. The response may
196
+ # contain less than the maximum number. If unspecified, no more than 500
197
+ # services are returned. The maximum value is 1000; values above 1000 are
198
+ # changed to 1000.
199
+ # @param page_token [::String]
200
+ # Optional. A page token, received from a previous ListFederationServices
201
+ # call. Provide this token to retrieve the subsequent page.
202
+ #
203
+ # To retrieve the first page, supply an empty page token.
204
+ #
205
+ # When paginating, other parameters provided to
206
+ # ListFederationServices must match the call that provided the
207
+ # page token.
208
+ # @param filter [::String]
209
+ # Optional. The filter to apply to list results.
210
+ # @param order_by [::String]
211
+ # Optional. Specify the ordering of results as described in [Sorting
212
+ # Order](https://cloud.google.com/apis/design/design_patterns#sorting_order).
213
+ # If not specified, the results will be sorted in the default order.
214
+ #
215
+ # @yield [response, operation] Access the result along with the RPC operation
216
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Metastore::V1beta::Federation>]
217
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
218
+ #
219
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Metastore::V1beta::Federation>]
220
+ #
221
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
222
+ #
223
+ # @example Basic example
224
+ # require "google/cloud/metastore/v1beta"
225
+ #
226
+ # # Create a client object. The client can be reused for multiple calls.
227
+ # client = Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
228
+ #
229
+ # # Create a request. To set request fields, pass in keyword arguments.
230
+ # request = Google::Cloud::Metastore::V1beta::ListFederationsRequest.new
231
+ #
232
+ # # Call the list_federations method.
233
+ # result = client.list_federations request
234
+ #
235
+ # # The returned object is of type Gapic::PagedEnumerable. You can
236
+ # # iterate over all elements by calling #each, and the enumerable
237
+ # # will lazily make API calls to fetch subsequent pages. Other
238
+ # # methods are also available for managing paging directly.
239
+ # result.each do |response|
240
+ # # Each element is of type ::Google::Cloud::Metastore::V1beta::Federation.
241
+ # p response
242
+ # end
243
+ #
244
+ def list_federations request, options = nil
245
+ raise ::ArgumentError, "request must be provided" if request.nil?
246
+
247
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Metastore::V1beta::ListFederationsRequest
248
+
249
+ # Converts hash and nil to an options object
250
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
251
+
252
+ # Customize the options with defaults
253
+ metadata = @config.rpcs.list_federations.metadata.to_h
254
+
255
+ # Set x-goog-api-client and x-goog-user-project headers
256
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
257
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
258
+ gapic_version: ::Google::Cloud::Metastore::V1beta::VERSION
259
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
260
+
261
+ header_params = {}
262
+ if request.parent
263
+ header_params["parent"] = request.parent
264
+ end
265
+
266
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
267
+ metadata[:"x-goog-request-params"] ||= request_params_header
268
+
269
+ options.apply_defaults timeout: @config.rpcs.list_federations.timeout,
270
+ metadata: metadata,
271
+ retry_policy: @config.rpcs.list_federations.retry_policy
272
+
273
+ options.apply_defaults timeout: @config.timeout,
274
+ metadata: @config.metadata,
275
+ retry_policy: @config.retry_policy
276
+
277
+ @dataproc_metastore_federation_stub.call_rpc :list_federations, request, options: options do |response, operation|
278
+ response = ::Gapic::PagedEnumerable.new @dataproc_metastore_federation_stub, :list_federations, request, response, operation, options
279
+ yield response, operation if block_given?
280
+ return response
281
+ end
282
+ rescue ::GRPC::BadStatus => e
283
+ raise ::Google::Cloud::Error.from_error(e)
284
+ end
285
+
286
+ ##
287
+ # Gets the details of a single federation.
288
+ #
289
+ # @overload get_federation(request, options = nil)
290
+ # Pass arguments to `get_federation` via a request object, either of type
291
+ # {::Google::Cloud::Metastore::V1beta::GetFederationRequest} or an equivalent Hash.
292
+ #
293
+ # @param request [::Google::Cloud::Metastore::V1beta::GetFederationRequest, ::Hash]
294
+ # A request object representing the call parameters. Required. To specify no
295
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
296
+ # @param options [::Gapic::CallOptions, ::Hash]
297
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
298
+ #
299
+ # @overload get_federation(name: nil)
300
+ # Pass arguments to `get_federation` via keyword arguments. Note that at
301
+ # least one keyword argument is required. To specify no parameters, or to keep all
302
+ # the default parameter values, pass an empty Hash as a request object (see above).
303
+ #
304
+ # @param name [::String]
305
+ # Required. The relative resource name of the metastore federation to
306
+ # retrieve, in the following form:
307
+ #
308
+ # `projects/{project_number}/locations/{location_id}/federations/{federation_id}`.
309
+ #
310
+ # @yield [response, operation] Access the result along with the RPC operation
311
+ # @yieldparam response [::Google::Cloud::Metastore::V1beta::Federation]
312
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
313
+ #
314
+ # @return [::Google::Cloud::Metastore::V1beta::Federation]
315
+ #
316
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
317
+ #
318
+ # @example Basic example
319
+ # require "google/cloud/metastore/v1beta"
320
+ #
321
+ # # Create a client object. The client can be reused for multiple calls.
322
+ # client = Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
323
+ #
324
+ # # Create a request. To set request fields, pass in keyword arguments.
325
+ # request = Google::Cloud::Metastore::V1beta::GetFederationRequest.new
326
+ #
327
+ # # Call the get_federation method.
328
+ # result = client.get_federation request
329
+ #
330
+ # # The returned object is of type Google::Cloud::Metastore::V1beta::Federation.
331
+ # p result
332
+ #
333
+ def get_federation request, options = nil
334
+ raise ::ArgumentError, "request must be provided" if request.nil?
335
+
336
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Metastore::V1beta::GetFederationRequest
337
+
338
+ # Converts hash and nil to an options object
339
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
340
+
341
+ # Customize the options with defaults
342
+ metadata = @config.rpcs.get_federation.metadata.to_h
343
+
344
+ # Set x-goog-api-client and x-goog-user-project headers
345
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
346
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
347
+ gapic_version: ::Google::Cloud::Metastore::V1beta::VERSION
348
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
349
+
350
+ header_params = {}
351
+ if request.name
352
+ header_params["name"] = request.name
353
+ end
354
+
355
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
356
+ metadata[:"x-goog-request-params"] ||= request_params_header
357
+
358
+ options.apply_defaults timeout: @config.rpcs.get_federation.timeout,
359
+ metadata: metadata,
360
+ retry_policy: @config.rpcs.get_federation.retry_policy
361
+
362
+ options.apply_defaults timeout: @config.timeout,
363
+ metadata: @config.metadata,
364
+ retry_policy: @config.retry_policy
365
+
366
+ @dataproc_metastore_federation_stub.call_rpc :get_federation, request, options: options do |response, operation|
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
+ # Creates a metastore federation in a project and location.
376
+ #
377
+ # @overload create_federation(request, options = nil)
378
+ # Pass arguments to `create_federation` via a request object, either of type
379
+ # {::Google::Cloud::Metastore::V1beta::CreateFederationRequest} or an equivalent Hash.
380
+ #
381
+ # @param request [::Google::Cloud::Metastore::V1beta::CreateFederationRequest, ::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 create_federation(parent: nil, federation_id: nil, federation: nil, request_id: nil)
388
+ # Pass arguments to `create_federation` 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 parent [::String]
393
+ # Required. The relative resource name of the location in which to create a
394
+ # federation service, in the following form:
395
+ #
396
+ # `projects/{project_number}/locations/{location_id}`.
397
+ # @param federation_id [::String]
398
+ # Required. The ID of the metastore federation, which is used as the final
399
+ # component of the metastore federation's name.
400
+ #
401
+ # This value must be between 2 and 63 characters long inclusive, begin with a
402
+ # letter, end with a letter or number, and consist of alpha-numeric
403
+ # ASCII characters or hyphens.
404
+ # @param federation [::Google::Cloud::Metastore::V1beta::Federation, ::Hash]
405
+ # Required. The Metastore Federation to create. The `name` field is
406
+ # ignored. The ID of the created metastore federation must be
407
+ # provided in the request's `federation_id` field.
408
+ # @param request_id [::String]
409
+ # Optional. A request ID. Specify a unique request ID to allow the server to
410
+ # ignore the request if it has completed. The server will ignore subsequent
411
+ # requests that provide a duplicate request ID for at least 60 minutes after
412
+ # the first request.
413
+ #
414
+ # For example, if an initial request times out, followed by another request
415
+ # with the same request ID, the server ignores the second request to prevent
416
+ # the creation of duplicate commitments.
417
+ #
418
+ # The request ID must be a valid
419
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format)
420
+ # A zero UUID (00000000-0000-0000-0000-000000000000) is not supported.
421
+ #
422
+ # @yield [response, operation] Access the result along with the RPC operation
423
+ # @yieldparam response [::Gapic::Operation]
424
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
425
+ #
426
+ # @return [::Gapic::Operation]
427
+ #
428
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
429
+ #
430
+ # @example Basic example
431
+ # require "google/cloud/metastore/v1beta"
432
+ #
433
+ # # Create a client object. The client can be reused for multiple calls.
434
+ # client = Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
435
+ #
436
+ # # Create a request. To set request fields, pass in keyword arguments.
437
+ # request = Google::Cloud::Metastore::V1beta::CreateFederationRequest.new
438
+ #
439
+ # # Call the create_federation method.
440
+ # result = client.create_federation request
441
+ #
442
+ # # The returned object is of type Gapic::Operation. You can use this
443
+ # # object to check the status of an operation, cancel it, or wait
444
+ # # for results. Here is how to block until completion:
445
+ # result.wait_until_done! timeout: 60
446
+ # if result.response?
447
+ # p result.response
448
+ # else
449
+ # puts "Error!"
450
+ # end
451
+ #
452
+ def create_federation request, options = nil
453
+ raise ::ArgumentError, "request must be provided" if request.nil?
454
+
455
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Metastore::V1beta::CreateFederationRequest
456
+
457
+ # Converts hash and nil to an options object
458
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
459
+
460
+ # Customize the options with defaults
461
+ metadata = @config.rpcs.create_federation.metadata.to_h
462
+
463
+ # Set x-goog-api-client and x-goog-user-project headers
464
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
465
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
466
+ gapic_version: ::Google::Cloud::Metastore::V1beta::VERSION
467
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
468
+
469
+ header_params = {}
470
+ if request.parent
471
+ header_params["parent"] = request.parent
472
+ end
473
+
474
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
475
+ metadata[:"x-goog-request-params"] ||= request_params_header
476
+
477
+ options.apply_defaults timeout: @config.rpcs.create_federation.timeout,
478
+ metadata: metadata,
479
+ retry_policy: @config.rpcs.create_federation.retry_policy
480
+
481
+ options.apply_defaults timeout: @config.timeout,
482
+ metadata: @config.metadata,
483
+ retry_policy: @config.retry_policy
484
+
485
+ @dataproc_metastore_federation_stub.call_rpc :create_federation, request, options: options do |response, operation|
486
+ response = ::Gapic::Operation.new response, @operations_client, options: options
487
+ yield response, operation if block_given?
488
+ return response
489
+ end
490
+ rescue ::GRPC::BadStatus => e
491
+ raise ::Google::Cloud::Error.from_error(e)
492
+ end
493
+
494
+ ##
495
+ # Updates the fields of a federation.
496
+ #
497
+ # @overload update_federation(request, options = nil)
498
+ # Pass arguments to `update_federation` via a request object, either of type
499
+ # {::Google::Cloud::Metastore::V1beta::UpdateFederationRequest} or an equivalent Hash.
500
+ #
501
+ # @param request [::Google::Cloud::Metastore::V1beta::UpdateFederationRequest, ::Hash]
502
+ # A request object representing the call parameters. Required. To specify no
503
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
504
+ # @param options [::Gapic::CallOptions, ::Hash]
505
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
506
+ #
507
+ # @overload update_federation(update_mask: nil, federation: nil, request_id: nil)
508
+ # Pass arguments to `update_federation` via keyword arguments. Note that at
509
+ # least one keyword argument is required. To specify no parameters, or to keep all
510
+ # the default parameter values, pass an empty Hash as a request object (see above).
511
+ #
512
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
513
+ # Required. A field mask used to specify the fields to be overwritten in the
514
+ # metastore federation resource by the update.
515
+ # Fields specified in the `update_mask` are relative to the resource (not
516
+ # to the full request). A field is overwritten if it is in the mask.
517
+ # @param federation [::Google::Cloud::Metastore::V1beta::Federation, ::Hash]
518
+ # Required. The metastore federation to update. The server only merges fields
519
+ # in the service if they are specified in `update_mask`.
520
+ #
521
+ # The metastore federation's `name` field is used to identify the
522
+ # metastore service to be updated.
523
+ # @param request_id [::String]
524
+ # Optional. A request ID. Specify a unique request ID to allow the server to
525
+ # ignore the request if it has completed. The server will ignore subsequent
526
+ # requests that provide a duplicate request ID for at least 60 minutes after
527
+ # the first request.
528
+ #
529
+ # For example, if an initial request times out, followed by another request
530
+ # with the same request ID, the server ignores the second request to prevent
531
+ # the creation of duplicate commitments.
532
+ #
533
+ # The request ID must be a valid
534
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format)
535
+ # A zero UUID (00000000-0000-0000-0000-000000000000) is not supported.
536
+ #
537
+ # @yield [response, operation] Access the result along with the RPC operation
538
+ # @yieldparam response [::Gapic::Operation]
539
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
540
+ #
541
+ # @return [::Gapic::Operation]
542
+ #
543
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
544
+ #
545
+ # @example Basic example
546
+ # require "google/cloud/metastore/v1beta"
547
+ #
548
+ # # Create a client object. The client can be reused for multiple calls.
549
+ # client = Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
550
+ #
551
+ # # Create a request. To set request fields, pass in keyword arguments.
552
+ # request = Google::Cloud::Metastore::V1beta::UpdateFederationRequest.new
553
+ #
554
+ # # Call the update_federation method.
555
+ # result = client.update_federation request
556
+ #
557
+ # # The returned object is of type Gapic::Operation. You can use this
558
+ # # object to check the status of an operation, cancel it, or wait
559
+ # # for results. Here is how to block until completion:
560
+ # result.wait_until_done! timeout: 60
561
+ # if result.response?
562
+ # p result.response
563
+ # else
564
+ # puts "Error!"
565
+ # end
566
+ #
567
+ def update_federation request, options = nil
568
+ raise ::ArgumentError, "request must be provided" if request.nil?
569
+
570
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Metastore::V1beta::UpdateFederationRequest
571
+
572
+ # Converts hash and nil to an options object
573
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
574
+
575
+ # Customize the options with defaults
576
+ metadata = @config.rpcs.update_federation.metadata.to_h
577
+
578
+ # Set x-goog-api-client and x-goog-user-project headers
579
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
580
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
581
+ gapic_version: ::Google::Cloud::Metastore::V1beta::VERSION
582
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
583
+
584
+ header_params = {}
585
+ if request.federation&.name
586
+ header_params["federation.name"] = request.federation.name
587
+ end
588
+
589
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
590
+ metadata[:"x-goog-request-params"] ||= request_params_header
591
+
592
+ options.apply_defaults timeout: @config.rpcs.update_federation.timeout,
593
+ metadata: metadata,
594
+ retry_policy: @config.rpcs.update_federation.retry_policy
595
+
596
+ options.apply_defaults timeout: @config.timeout,
597
+ metadata: @config.metadata,
598
+ retry_policy: @config.retry_policy
599
+
600
+ @dataproc_metastore_federation_stub.call_rpc :update_federation, request, options: options do |response, operation|
601
+ response = ::Gapic::Operation.new response, @operations_client, options: options
602
+ yield response, operation if block_given?
603
+ return response
604
+ end
605
+ rescue ::GRPC::BadStatus => e
606
+ raise ::Google::Cloud::Error.from_error(e)
607
+ end
608
+
609
+ ##
610
+ # Deletes a single federation.
611
+ #
612
+ # @overload delete_federation(request, options = nil)
613
+ # Pass arguments to `delete_federation` via a request object, either of type
614
+ # {::Google::Cloud::Metastore::V1beta::DeleteFederationRequest} or an equivalent Hash.
615
+ #
616
+ # @param request [::Google::Cloud::Metastore::V1beta::DeleteFederationRequest, ::Hash]
617
+ # A request object representing the call parameters. Required. To specify no
618
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
619
+ # @param options [::Gapic::CallOptions, ::Hash]
620
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
621
+ #
622
+ # @overload delete_federation(name: nil, request_id: nil)
623
+ # Pass arguments to `delete_federation` via keyword arguments. Note that at
624
+ # least one keyword argument is required. To specify no parameters, or to keep all
625
+ # the default parameter values, pass an empty Hash as a request object (see above).
626
+ #
627
+ # @param name [::String]
628
+ # Required. The relative resource name of the metastore federation to delete,
629
+ # in the following form:
630
+ #
631
+ # `projects/{project_number}/locations/{location_id}/federations/{federation_id}`.
632
+ # @param request_id [::String]
633
+ # Optional. A request ID. Specify a unique request ID to allow the server to
634
+ # ignore the request if it has completed. The server will ignore subsequent
635
+ # requests that provide a duplicate request ID for at least 60 minutes after
636
+ # the first request.
637
+ #
638
+ # For example, if an initial request times out, followed by another request
639
+ # with the same request ID, the server ignores the second request to prevent
640
+ # the creation of duplicate commitments.
641
+ #
642
+ # The request ID must be a valid
643
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format)
644
+ # A zero UUID (00000000-0000-0000-0000-000000000000) is not supported.
645
+ #
646
+ # @yield [response, operation] Access the result along with the RPC operation
647
+ # @yieldparam response [::Gapic::Operation]
648
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
649
+ #
650
+ # @return [::Gapic::Operation]
651
+ #
652
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
653
+ #
654
+ # @example Basic example
655
+ # require "google/cloud/metastore/v1beta"
656
+ #
657
+ # # Create a client object. The client can be reused for multiple calls.
658
+ # client = Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new
659
+ #
660
+ # # Create a request. To set request fields, pass in keyword arguments.
661
+ # request = Google::Cloud::Metastore::V1beta::DeleteFederationRequest.new
662
+ #
663
+ # # Call the delete_federation method.
664
+ # result = client.delete_federation request
665
+ #
666
+ # # The returned object is of type Gapic::Operation. You can use this
667
+ # # object to check the status of an operation, cancel it, or wait
668
+ # # for results. Here is how to block until completion:
669
+ # result.wait_until_done! timeout: 60
670
+ # if result.response?
671
+ # p result.response
672
+ # else
673
+ # puts "Error!"
674
+ # end
675
+ #
676
+ def delete_federation request, options = nil
677
+ raise ::ArgumentError, "request must be provided" if request.nil?
678
+
679
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Metastore::V1beta::DeleteFederationRequest
680
+
681
+ # Converts hash and nil to an options object
682
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
683
+
684
+ # Customize the options with defaults
685
+ metadata = @config.rpcs.delete_federation.metadata.to_h
686
+
687
+ # Set x-goog-api-client and x-goog-user-project headers
688
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
689
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
690
+ gapic_version: ::Google::Cloud::Metastore::V1beta::VERSION
691
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
692
+
693
+ header_params = {}
694
+ if request.name
695
+ header_params["name"] = request.name
696
+ end
697
+
698
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
699
+ metadata[:"x-goog-request-params"] ||= request_params_header
700
+
701
+ options.apply_defaults timeout: @config.rpcs.delete_federation.timeout,
702
+ metadata: metadata,
703
+ retry_policy: @config.rpcs.delete_federation.retry_policy
704
+
705
+ options.apply_defaults timeout: @config.timeout,
706
+ metadata: @config.metadata,
707
+ retry_policy: @config.retry_policy
708
+
709
+ @dataproc_metastore_federation_stub.call_rpc :delete_federation, request, options: options do |response, operation|
710
+ response = ::Gapic::Operation.new response, @operations_client, options: options
711
+ yield response, operation if block_given?
712
+ return response
713
+ end
714
+ rescue ::GRPC::BadStatus => e
715
+ raise ::Google::Cloud::Error.from_error(e)
716
+ end
717
+
718
+ ##
719
+ # Configuration class for the DataprocMetastoreFederation API.
720
+ #
721
+ # This class represents the configuration for DataprocMetastoreFederation,
722
+ # providing control over timeouts, retry behavior, logging, transport
723
+ # parameters, and other low-level controls. Certain parameters can also be
724
+ # applied individually to specific RPCs. See
725
+ # {::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client::Configuration::Rpcs}
726
+ # for a list of RPCs that can be configured independently.
727
+ #
728
+ # Configuration can be applied globally to all clients, or to a single client
729
+ # on construction.
730
+ #
731
+ # @example
732
+ #
733
+ # # Modify the global config, setting the timeout for
734
+ # # list_federations to 20 seconds,
735
+ # # and all remaining timeouts to 10 seconds.
736
+ # ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.configure do |config|
737
+ # config.timeout = 10.0
738
+ # config.rpcs.list_federations.timeout = 20.0
739
+ # end
740
+ #
741
+ # # Apply the above configuration only to a new client.
742
+ # client = ::Google::Cloud::Metastore::V1beta::DataprocMetastoreFederation::Client.new do |config|
743
+ # config.timeout = 10.0
744
+ # config.rpcs.list_federations.timeout = 20.0
745
+ # end
746
+ #
747
+ # @!attribute [rw] endpoint
748
+ # The hostname or hostname:port of the service endpoint.
749
+ # Defaults to `"metastore.googleapis.com"`.
750
+ # @return [::String]
751
+ # @!attribute [rw] credentials
752
+ # Credentials to send with calls. You may provide any of the following types:
753
+ # * (`String`) The path to a service account key file in JSON format
754
+ # * (`Hash`) A service account key as a Hash
755
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
756
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
757
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
758
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
759
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
760
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
761
+ # * (`nil`) indicating no credentials
762
+ # @return [::Object]
763
+ # @!attribute [rw] scope
764
+ # The OAuth scopes
765
+ # @return [::Array<::String>]
766
+ # @!attribute [rw] lib_name
767
+ # The library name as recorded in instrumentation and logging
768
+ # @return [::String]
769
+ # @!attribute [rw] lib_version
770
+ # The library version as recorded in instrumentation and logging
771
+ # @return [::String]
772
+ # @!attribute [rw] channel_args
773
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
774
+ # `GRPC::Core::Channel` object is provided as the credential.
775
+ # @return [::Hash]
776
+ # @!attribute [rw] interceptors
777
+ # An array of interceptors that are run before calls are executed.
778
+ # @return [::Array<::GRPC::ClientInterceptor>]
779
+ # @!attribute [rw] timeout
780
+ # The call timeout in seconds.
781
+ # @return [::Numeric]
782
+ # @!attribute [rw] metadata
783
+ # Additional gRPC headers to be sent with the call.
784
+ # @return [::Hash{::Symbol=>::String}]
785
+ # @!attribute [rw] retry_policy
786
+ # The retry policy. The value is a hash with the following keys:
787
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
788
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
789
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
790
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
791
+ # trigger a retry.
792
+ # @return [::Hash]
793
+ # @!attribute [rw] quota_project
794
+ # A separate project against which to charge quota.
795
+ # @return [::String]
796
+ #
797
+ class Configuration
798
+ extend ::Gapic::Config
799
+
800
+ config_attr :endpoint, "metastore.googleapis.com", ::String
801
+ config_attr :credentials, nil do |value|
802
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
803
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
804
+ allowed.any? { |klass| klass === value }
805
+ end
806
+ config_attr :scope, nil, ::String, ::Array, nil
807
+ config_attr :lib_name, nil, ::String, nil
808
+ config_attr :lib_version, nil, ::String, nil
809
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
810
+ config_attr :interceptors, nil, ::Array, nil
811
+ config_attr :timeout, nil, ::Numeric, nil
812
+ config_attr :metadata, nil, ::Hash, nil
813
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
814
+ config_attr :quota_project, nil, ::String, nil
815
+
816
+ # @private
817
+ def initialize parent_config = nil
818
+ @parent_config = parent_config unless parent_config.nil?
819
+
820
+ yield self if block_given?
821
+ end
822
+
823
+ ##
824
+ # Configurations for individual RPCs
825
+ # @return [Rpcs]
826
+ #
827
+ def rpcs
828
+ @rpcs ||= begin
829
+ parent_rpcs = nil
830
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
831
+ Rpcs.new parent_rpcs
832
+ end
833
+ end
834
+
835
+ ##
836
+ # Configuration RPC class for the DataprocMetastoreFederation API.
837
+ #
838
+ # Includes fields providing the configuration for each RPC in this service.
839
+ # Each configuration object is of type `Gapic::Config::Method` and includes
840
+ # the following configuration fields:
841
+ #
842
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
843
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
844
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
845
+ # include the following keys:
846
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
847
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
848
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
849
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
850
+ # trigger a retry.
851
+ #
852
+ class Rpcs
853
+ ##
854
+ # RPC-specific configuration for `list_federations`
855
+ # @return [::Gapic::Config::Method]
856
+ #
857
+ attr_reader :list_federations
858
+ ##
859
+ # RPC-specific configuration for `get_federation`
860
+ # @return [::Gapic::Config::Method]
861
+ #
862
+ attr_reader :get_federation
863
+ ##
864
+ # RPC-specific configuration for `create_federation`
865
+ # @return [::Gapic::Config::Method]
866
+ #
867
+ attr_reader :create_federation
868
+ ##
869
+ # RPC-specific configuration for `update_federation`
870
+ # @return [::Gapic::Config::Method]
871
+ #
872
+ attr_reader :update_federation
873
+ ##
874
+ # RPC-specific configuration for `delete_federation`
875
+ # @return [::Gapic::Config::Method]
876
+ #
877
+ attr_reader :delete_federation
878
+
879
+ # @private
880
+ def initialize parent_rpcs = nil
881
+ list_federations_config = parent_rpcs.list_federations if parent_rpcs.respond_to? :list_federations
882
+ @list_federations = ::Gapic::Config::Method.new list_federations_config
883
+ get_federation_config = parent_rpcs.get_federation if parent_rpcs.respond_to? :get_federation
884
+ @get_federation = ::Gapic::Config::Method.new get_federation_config
885
+ create_federation_config = parent_rpcs.create_federation if parent_rpcs.respond_to? :create_federation
886
+ @create_federation = ::Gapic::Config::Method.new create_federation_config
887
+ update_federation_config = parent_rpcs.update_federation if parent_rpcs.respond_to? :update_federation
888
+ @update_federation = ::Gapic::Config::Method.new update_federation_config
889
+ delete_federation_config = parent_rpcs.delete_federation if parent_rpcs.respond_to? :delete_federation
890
+ @delete_federation = ::Gapic::Config::Method.new delete_federation_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