google-cloud-bigquery-connection-v1 0.11.0 → 0.13.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,906 @@
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/bigquery/connection/v1/connection_pb"
21
+ require "google/cloud/bigquery/connection/v1/connection_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Bigquery
26
+ module Connection
27
+ module V1
28
+ module ConnectionService
29
+ module Rest
30
+ ##
31
+ # REST client for the ConnectionService service.
32
+ #
33
+ # Manages external data source connections and credentials.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :connection_service_stub
40
+
41
+ ##
42
+ # Configure the ConnectionService Client class.
43
+ #
44
+ # See {::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all ConnectionService clients
50
+ # ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Bigquery", "Connection", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.create_connection.timeout = 60.0
71
+
72
+ default_config.rpcs.get_connection.timeout = 60.0
73
+ default_config.rpcs.get_connection.retry_policy = {
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
75
+ }
76
+
77
+ default_config.rpcs.list_connections.timeout = 60.0
78
+ default_config.rpcs.list_connections.retry_policy = {
79
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
80
+ }
81
+
82
+ default_config.rpcs.update_connection.timeout = 60.0
83
+
84
+ default_config.rpcs.delete_connection.timeout = 60.0
85
+ default_config.rpcs.delete_connection.retry_policy = {
86
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
87
+ }
88
+
89
+ default_config.rpcs.get_iam_policy.timeout = 60.0
90
+
91
+ default_config.rpcs.set_iam_policy.timeout = 60.0
92
+
93
+ default_config.rpcs.test_iam_permissions.timeout = 60.0
94
+
95
+ default_config
96
+ end
97
+ yield @configure if block_given?
98
+ @configure
99
+ end
100
+
101
+ ##
102
+ # Configure the ConnectionService Client instance.
103
+ #
104
+ # The configuration is set to the derived mode, meaning that values can be changed,
105
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
106
+ # should be made on {Client.configure}.
107
+ #
108
+ # See {::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client::Configuration}
109
+ # for a description of the configuration fields.
110
+ #
111
+ # @yield [config] Configure the Client client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ # @return [Client::Configuration]
115
+ #
116
+ def configure
117
+ yield @config if block_given?
118
+ @config
119
+ end
120
+
121
+ ##
122
+ # Create a new ConnectionService REST client object.
123
+ #
124
+ # @example
125
+ #
126
+ # # Create a client using the default configuration
127
+ # client = ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client.new
128
+ #
129
+ # # Create a client using a custom configuration
130
+ # client = ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client.new do |config|
131
+ # config.timeout = 10.0
132
+ # end
133
+ #
134
+ # @yield [config] Configure the ConnectionService client.
135
+ # @yieldparam config [Client::Configuration]
136
+ #
137
+ def initialize
138
+ # Create the configuration object
139
+ @config = Configuration.new Client.configure
140
+
141
+ # Yield the configuration if needed
142
+ yield @config if block_given?
143
+
144
+ # Create credentials
145
+ credentials = @config.credentials
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
147
+ # but only if the default endpoint does not have a region prefix.
148
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
149
+ !@config.endpoint.split(".").first.include?("-")
150
+ credentials ||= Credentials.default scope: @config.scope,
151
+ enable_self_signed_jwt: enable_self_signed_jwt
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
153
+ credentials = Credentials.new credentials, scope: @config.scope
154
+ end
155
+
156
+ @quota_project_id = @config.quota_project
157
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
158
+
159
+ @connection_service_stub = ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
160
+ end
161
+
162
+ # Service calls
163
+
164
+ ##
165
+ # Creates a new connection.
166
+ #
167
+ # @overload create_connection(request, options = nil)
168
+ # Pass arguments to `create_connection` via a request object, either of type
169
+ # {::Google::Cloud::Bigquery::Connection::V1::CreateConnectionRequest} or an equivalent Hash.
170
+ #
171
+ # @param request [::Google::Cloud::Bigquery::Connection::V1::CreateConnectionRequest, ::Hash]
172
+ # A request object representing the call parameters. Required. To specify no
173
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
174
+ # @param options [::Gapic::CallOptions, ::Hash]
175
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
176
+ #
177
+ # @overload create_connection(parent: nil, connection_id: nil, connection: nil)
178
+ # Pass arguments to `create_connection` via keyword arguments. Note that at
179
+ # least one keyword argument is required. To specify no parameters, or to keep all
180
+ # the default parameter values, pass an empty Hash as a request object (see above).
181
+ #
182
+ # @param parent [::String]
183
+ # Required. Parent resource name.
184
+ # Must be in the format `projects/{project_id}/locations/{location_id}`
185
+ # @param connection_id [::String]
186
+ # Optional. Connection id that should be assigned to the created connection.
187
+ # @param connection [::Google::Cloud::Bigquery::Connection::V1::Connection, ::Hash]
188
+ # Required. Connection to create.
189
+ # @yield [result, operation] Access the result along with the TransportOperation object
190
+ # @yieldparam result [::Google::Cloud::Bigquery::Connection::V1::Connection]
191
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
192
+ #
193
+ # @return [::Google::Cloud::Bigquery::Connection::V1::Connection]
194
+ #
195
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
196
+ def create_connection request, options = nil
197
+ raise ::ArgumentError, "request must be provided" if request.nil?
198
+
199
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Connection::V1::CreateConnectionRequest
200
+
201
+ # Converts hash and nil to an options object
202
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
203
+
204
+ # Customize the options with defaults
205
+ call_metadata = @config.rpcs.create_connection.metadata.to_h
206
+
207
+ # Set x-goog-api-client and x-goog-user-project headers
208
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
209
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
210
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
211
+ transports_version_send: [:rest]
212
+
213
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
214
+
215
+ options.apply_defaults timeout: @config.rpcs.create_connection.timeout,
216
+ metadata: call_metadata,
217
+ retry_policy: @config.rpcs.create_connection.retry_policy
218
+
219
+ options.apply_defaults timeout: @config.timeout,
220
+ metadata: @config.metadata,
221
+ retry_policy: @config.retry_policy
222
+
223
+ @connection_service_stub.create_connection request, options do |result, operation|
224
+ yield result, operation if block_given?
225
+ return result
226
+ end
227
+ rescue ::Gapic::Rest::Error => e
228
+ raise ::Google::Cloud::Error.from_error(e)
229
+ end
230
+
231
+ ##
232
+ # Returns specified connection.
233
+ #
234
+ # @overload get_connection(request, options = nil)
235
+ # Pass arguments to `get_connection` via a request object, either of type
236
+ # {::Google::Cloud::Bigquery::Connection::V1::GetConnectionRequest} or an equivalent Hash.
237
+ #
238
+ # @param request [::Google::Cloud::Bigquery::Connection::V1::GetConnectionRequest, ::Hash]
239
+ # A request object representing the call parameters. Required. To specify no
240
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
241
+ # @param options [::Gapic::CallOptions, ::Hash]
242
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
243
+ #
244
+ # @overload get_connection(name: nil)
245
+ # Pass arguments to `get_connection` via keyword arguments. Note that at
246
+ # least one keyword argument is required. To specify no parameters, or to keep all
247
+ # the default parameter values, pass an empty Hash as a request object (see above).
248
+ #
249
+ # @param name [::String]
250
+ # Required. Name of the requested connection, for example:
251
+ # `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
252
+ # @yield [result, operation] Access the result along with the TransportOperation object
253
+ # @yieldparam result [::Google::Cloud::Bigquery::Connection::V1::Connection]
254
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
255
+ #
256
+ # @return [::Google::Cloud::Bigquery::Connection::V1::Connection]
257
+ #
258
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
259
+ def get_connection request, options = nil
260
+ raise ::ArgumentError, "request must be provided" if request.nil?
261
+
262
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Connection::V1::GetConnectionRequest
263
+
264
+ # Converts hash and nil to an options object
265
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
266
+
267
+ # Customize the options with defaults
268
+ call_metadata = @config.rpcs.get_connection.metadata.to_h
269
+
270
+ # Set x-goog-api-client and x-goog-user-project headers
271
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
272
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
273
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
274
+ transports_version_send: [:rest]
275
+
276
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
277
+
278
+ options.apply_defaults timeout: @config.rpcs.get_connection.timeout,
279
+ metadata: call_metadata,
280
+ retry_policy: @config.rpcs.get_connection.retry_policy
281
+
282
+ options.apply_defaults timeout: @config.timeout,
283
+ metadata: @config.metadata,
284
+ retry_policy: @config.retry_policy
285
+
286
+ @connection_service_stub.get_connection request, options do |result, operation|
287
+ yield result, operation if block_given?
288
+ return result
289
+ end
290
+ rescue ::Gapic::Rest::Error => e
291
+ raise ::Google::Cloud::Error.from_error(e)
292
+ end
293
+
294
+ ##
295
+ # Returns a list of connections in the given project.
296
+ #
297
+ # @overload list_connections(request, options = nil)
298
+ # Pass arguments to `list_connections` via a request object, either of type
299
+ # {::Google::Cloud::Bigquery::Connection::V1::ListConnectionsRequest} or an equivalent Hash.
300
+ #
301
+ # @param request [::Google::Cloud::Bigquery::Connection::V1::ListConnectionsRequest, ::Hash]
302
+ # A request object representing the call parameters. Required. To specify no
303
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
304
+ # @param options [::Gapic::CallOptions, ::Hash]
305
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
306
+ #
307
+ # @overload list_connections(parent: nil, page_size: nil, page_token: nil)
308
+ # Pass arguments to `list_connections` via keyword arguments. Note that at
309
+ # least one keyword argument is required. To specify no parameters, or to keep all
310
+ # the default parameter values, pass an empty Hash as a request object (see above).
311
+ #
312
+ # @param parent [::String]
313
+ # Required. Parent resource name.
314
+ # Must be in the form: `projects/{project_id}/locations/{location_id}`
315
+ # @param page_size [::Integer]
316
+ # Required. Page size.
317
+ # @param page_token [::String]
318
+ # Page token.
319
+ # @yield [result, operation] Access the result along with the TransportOperation object
320
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Bigquery::Connection::V1::Connection>]
321
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
322
+ #
323
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Bigquery::Connection::V1::Connection>]
324
+ #
325
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
326
+ def list_connections request, options = nil
327
+ raise ::ArgumentError, "request must be provided" if request.nil?
328
+
329
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Connection::V1::ListConnectionsRequest
330
+
331
+ # Converts hash and nil to an options object
332
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
333
+
334
+ # Customize the options with defaults
335
+ call_metadata = @config.rpcs.list_connections.metadata.to_h
336
+
337
+ # Set x-goog-api-client and x-goog-user-project headers
338
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
339
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
340
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
341
+ transports_version_send: [:rest]
342
+
343
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
344
+
345
+ options.apply_defaults timeout: @config.rpcs.list_connections.timeout,
346
+ metadata: call_metadata,
347
+ retry_policy: @config.rpcs.list_connections.retry_policy
348
+
349
+ options.apply_defaults timeout: @config.timeout,
350
+ metadata: @config.metadata,
351
+ retry_policy: @config.retry_policy
352
+
353
+ @connection_service_stub.list_connections request, options do |result, operation|
354
+ result = ::Gapic::Rest::PagedEnumerable.new @connection_service_stub, :list_connections, "connections", request, result, options
355
+ yield result, operation if block_given?
356
+ return result
357
+ end
358
+ rescue ::Gapic::Rest::Error => e
359
+ raise ::Google::Cloud::Error.from_error(e)
360
+ end
361
+
362
+ ##
363
+ # Updates the specified connection. For security reasons, also resets
364
+ # credential if connection properties are in the update field mask.
365
+ #
366
+ # @overload update_connection(request, options = nil)
367
+ # Pass arguments to `update_connection` via a request object, either of type
368
+ # {::Google::Cloud::Bigquery::Connection::V1::UpdateConnectionRequest} or an equivalent Hash.
369
+ #
370
+ # @param request [::Google::Cloud::Bigquery::Connection::V1::UpdateConnectionRequest, ::Hash]
371
+ # A request object representing the call parameters. Required. To specify no
372
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
373
+ # @param options [::Gapic::CallOptions, ::Hash]
374
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
375
+ #
376
+ # @overload update_connection(name: nil, connection: nil, update_mask: nil)
377
+ # Pass arguments to `update_connection` via keyword arguments. Note that at
378
+ # least one keyword argument is required. To specify no parameters, or to keep all
379
+ # the default parameter values, pass an empty Hash as a request object (see above).
380
+ #
381
+ # @param name [::String]
382
+ # Required. Name of the connection to update, for example:
383
+ # `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
384
+ # @param connection [::Google::Cloud::Bigquery::Connection::V1::Connection, ::Hash]
385
+ # Required. Connection containing the updated fields.
386
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
387
+ # Required. Update mask for the connection fields to be updated.
388
+ # @yield [result, operation] Access the result along with the TransportOperation object
389
+ # @yieldparam result [::Google::Cloud::Bigquery::Connection::V1::Connection]
390
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
391
+ #
392
+ # @return [::Google::Cloud::Bigquery::Connection::V1::Connection]
393
+ #
394
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
395
+ def update_connection request, options = nil
396
+ raise ::ArgumentError, "request must be provided" if request.nil?
397
+
398
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Connection::V1::UpdateConnectionRequest
399
+
400
+ # Converts hash and nil to an options object
401
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
402
+
403
+ # Customize the options with defaults
404
+ call_metadata = @config.rpcs.update_connection.metadata.to_h
405
+
406
+ # Set x-goog-api-client and x-goog-user-project headers
407
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
408
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
409
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
410
+ transports_version_send: [:rest]
411
+
412
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
413
+
414
+ options.apply_defaults timeout: @config.rpcs.update_connection.timeout,
415
+ metadata: call_metadata,
416
+ retry_policy: @config.rpcs.update_connection.retry_policy
417
+
418
+ options.apply_defaults timeout: @config.timeout,
419
+ metadata: @config.metadata,
420
+ retry_policy: @config.retry_policy
421
+
422
+ @connection_service_stub.update_connection request, options do |result, operation|
423
+ yield result, operation if block_given?
424
+ return result
425
+ end
426
+ rescue ::Gapic::Rest::Error => e
427
+ raise ::Google::Cloud::Error.from_error(e)
428
+ end
429
+
430
+ ##
431
+ # Deletes connection and associated credential.
432
+ #
433
+ # @overload delete_connection(request, options = nil)
434
+ # Pass arguments to `delete_connection` via a request object, either of type
435
+ # {::Google::Cloud::Bigquery::Connection::V1::DeleteConnectionRequest} or an equivalent Hash.
436
+ #
437
+ # @param request [::Google::Cloud::Bigquery::Connection::V1::DeleteConnectionRequest, ::Hash]
438
+ # A request object representing the call parameters. Required. To specify no
439
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
440
+ # @param options [::Gapic::CallOptions, ::Hash]
441
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
442
+ #
443
+ # @overload delete_connection(name: nil)
444
+ # Pass arguments to `delete_connection` via keyword arguments. Note that at
445
+ # least one keyword argument is required. To specify no parameters, or to keep all
446
+ # the default parameter values, pass an empty Hash as a request object (see above).
447
+ #
448
+ # @param name [::String]
449
+ # Required. Name of the deleted connection, for example:
450
+ # `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
451
+ # @yield [result, operation] Access the result along with the TransportOperation object
452
+ # @yieldparam result [::Google::Protobuf::Empty]
453
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
454
+ #
455
+ # @return [::Google::Protobuf::Empty]
456
+ #
457
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
458
+ def delete_connection request, options = nil
459
+ raise ::ArgumentError, "request must be provided" if request.nil?
460
+
461
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Connection::V1::DeleteConnectionRequest
462
+
463
+ # Converts hash and nil to an options object
464
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
465
+
466
+ # Customize the options with defaults
467
+ call_metadata = @config.rpcs.delete_connection.metadata.to_h
468
+
469
+ # Set x-goog-api-client and x-goog-user-project headers
470
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
471
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
472
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
473
+ transports_version_send: [:rest]
474
+
475
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
476
+
477
+ options.apply_defaults timeout: @config.rpcs.delete_connection.timeout,
478
+ metadata: call_metadata,
479
+ retry_policy: @config.rpcs.delete_connection.retry_policy
480
+
481
+ options.apply_defaults timeout: @config.timeout,
482
+ metadata: @config.metadata,
483
+ retry_policy: @config.retry_policy
484
+
485
+ @connection_service_stub.delete_connection request, options do |result, operation|
486
+ yield result, operation if block_given?
487
+ return result
488
+ end
489
+ rescue ::Gapic::Rest::Error => e
490
+ raise ::Google::Cloud::Error.from_error(e)
491
+ end
492
+
493
+ ##
494
+ # Gets the access control policy for a resource.
495
+ # Returns an empty policy if the resource exists and does not have a policy
496
+ # set.
497
+ #
498
+ # @overload get_iam_policy(request, options = nil)
499
+ # Pass arguments to `get_iam_policy` via a request object, either of type
500
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
501
+ #
502
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
503
+ # A request object representing the call parameters. Required. To specify no
504
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
505
+ # @param options [::Gapic::CallOptions, ::Hash]
506
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
507
+ #
508
+ # @overload get_iam_policy(resource: nil, options: nil)
509
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
510
+ # least one keyword argument is required. To specify no parameters, or to keep all
511
+ # the default parameter values, pass an empty Hash as a request object (see above).
512
+ #
513
+ # @param resource [::String]
514
+ # REQUIRED: The resource for which the policy is being requested.
515
+ # See the operation documentation for the appropriate value for this field.
516
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
517
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
518
+ # `GetIamPolicy`.
519
+ # @yield [result, operation] Access the result along with the TransportOperation object
520
+ # @yieldparam result [::Google::Iam::V1::Policy]
521
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
522
+ #
523
+ # @return [::Google::Iam::V1::Policy]
524
+ #
525
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
526
+ def get_iam_policy request, options = nil
527
+ raise ::ArgumentError, "request must be provided" if request.nil?
528
+
529
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
530
+
531
+ # Converts hash and nil to an options object
532
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
533
+
534
+ # Customize the options with defaults
535
+ call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
536
+
537
+ # Set x-goog-api-client and x-goog-user-project headers
538
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
539
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
540
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
541
+ transports_version_send: [:rest]
542
+
543
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
544
+
545
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
546
+ metadata: call_metadata,
547
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
548
+
549
+ options.apply_defaults timeout: @config.timeout,
550
+ metadata: @config.metadata,
551
+ retry_policy: @config.retry_policy
552
+
553
+ @connection_service_stub.get_iam_policy request, options do |result, operation|
554
+ yield result, operation if block_given?
555
+ return result
556
+ end
557
+ rescue ::Gapic::Rest::Error => e
558
+ raise ::Google::Cloud::Error.from_error(e)
559
+ end
560
+
561
+ ##
562
+ # Sets the access control policy on the specified resource. Replaces any
563
+ # existing policy.
564
+ #
565
+ # Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
566
+ #
567
+ # @overload set_iam_policy(request, options = nil)
568
+ # Pass arguments to `set_iam_policy` via a request object, either of type
569
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
570
+ #
571
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
572
+ # A request object representing the call parameters. Required. To specify no
573
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
574
+ # @param options [::Gapic::CallOptions, ::Hash]
575
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
576
+ #
577
+ # @overload set_iam_policy(resource: nil, policy: nil, update_mask: nil)
578
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
579
+ # least one keyword argument is required. To specify no parameters, or to keep all
580
+ # the default parameter values, pass an empty Hash as a request object (see above).
581
+ #
582
+ # @param resource [::String]
583
+ # REQUIRED: The resource for which the policy is being specified.
584
+ # See the operation documentation for the appropriate value for this field.
585
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
586
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
587
+ # the policy is limited to a few 10s of KB. An empty policy is a
588
+ # valid policy but certain Cloud Platform services (such as Projects)
589
+ # might reject them.
590
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
591
+ # OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
592
+ # the fields in the mask will be modified. If no mask is provided, the
593
+ # following default mask is used:
594
+ #
595
+ # `paths: "bindings, etag"`
596
+ # @yield [result, operation] Access the result along with the TransportOperation object
597
+ # @yieldparam result [::Google::Iam::V1::Policy]
598
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
599
+ #
600
+ # @return [::Google::Iam::V1::Policy]
601
+ #
602
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
603
+ def set_iam_policy request, options = nil
604
+ raise ::ArgumentError, "request must be provided" if request.nil?
605
+
606
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
607
+
608
+ # Converts hash and nil to an options object
609
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
610
+
611
+ # Customize the options with defaults
612
+ call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
613
+
614
+ # Set x-goog-api-client and x-goog-user-project headers
615
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
616
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
617
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
618
+ transports_version_send: [:rest]
619
+
620
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
621
+
622
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
623
+ metadata: call_metadata,
624
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
625
+
626
+ options.apply_defaults timeout: @config.timeout,
627
+ metadata: @config.metadata,
628
+ retry_policy: @config.retry_policy
629
+
630
+ @connection_service_stub.set_iam_policy request, options do |result, operation|
631
+ yield result, operation if block_given?
632
+ return result
633
+ end
634
+ rescue ::Gapic::Rest::Error => e
635
+ raise ::Google::Cloud::Error.from_error(e)
636
+ end
637
+
638
+ ##
639
+ # Returns permissions that a caller has on the specified resource.
640
+ # If the resource does not exist, this will return an empty set of
641
+ # permissions, not a `NOT_FOUND` error.
642
+ #
643
+ # Note: This operation is designed to be used for building permission-aware
644
+ # UIs and command-line tools, not for authorization checking. This operation
645
+ # may "fail open" without warning.
646
+ #
647
+ # @overload test_iam_permissions(request, options = nil)
648
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
649
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
650
+ #
651
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
652
+ # A request object representing the call parameters. Required. To specify no
653
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
654
+ # @param options [::Gapic::CallOptions, ::Hash]
655
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
656
+ #
657
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
658
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
659
+ # least one keyword argument is required. To specify no parameters, or to keep all
660
+ # the default parameter values, pass an empty Hash as a request object (see above).
661
+ #
662
+ # @param resource [::String]
663
+ # REQUIRED: The resource for which the policy detail is being requested.
664
+ # See the operation documentation for the appropriate value for this field.
665
+ # @param permissions [::Array<::String>]
666
+ # The set of permissions to check for the `resource`. Permissions with
667
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
668
+ # information see
669
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
670
+ # @yield [result, operation] Access the result along with the TransportOperation object
671
+ # @yieldparam result [::Google::Iam::V1::TestIamPermissionsResponse]
672
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
673
+ #
674
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
675
+ #
676
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
677
+ def test_iam_permissions request, options = nil
678
+ raise ::ArgumentError, "request must be provided" if request.nil?
679
+
680
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
681
+
682
+ # Converts hash and nil to an options object
683
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
684
+
685
+ # Customize the options with defaults
686
+ call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
687
+
688
+ # Set x-goog-api-client and x-goog-user-project headers
689
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
690
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
691
+ gapic_version: ::Google::Cloud::Bigquery::Connection::V1::VERSION,
692
+ transports_version_send: [:rest]
693
+
694
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
695
+
696
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
697
+ metadata: call_metadata,
698
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
699
+
700
+ options.apply_defaults timeout: @config.timeout,
701
+ metadata: @config.metadata,
702
+ retry_policy: @config.retry_policy
703
+
704
+ @connection_service_stub.test_iam_permissions request, options do |result, operation|
705
+ yield result, operation if block_given?
706
+ return result
707
+ end
708
+ rescue ::Gapic::Rest::Error => e
709
+ raise ::Google::Cloud::Error.from_error(e)
710
+ end
711
+
712
+ ##
713
+ # Configuration class for the ConnectionService REST API.
714
+ #
715
+ # This class represents the configuration for ConnectionService REST,
716
+ # providing control over timeouts, retry behavior, logging, transport
717
+ # parameters, and other low-level controls. Certain parameters can also be
718
+ # applied individually to specific RPCs. See
719
+ # {::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client::Configuration::Rpcs}
720
+ # for a list of RPCs that can be configured independently.
721
+ #
722
+ # Configuration can be applied globally to all clients, or to a single client
723
+ # on construction.
724
+ #
725
+ # @example
726
+ #
727
+ # # Modify the global config, setting the timeout for
728
+ # # create_connection to 20 seconds,
729
+ # # and all remaining timeouts to 10 seconds.
730
+ # ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client.configure do |config|
731
+ # config.timeout = 10.0
732
+ # config.rpcs.create_connection.timeout = 20.0
733
+ # end
734
+ #
735
+ # # Apply the above configuration only to a new client.
736
+ # client = ::Google::Cloud::Bigquery::Connection::V1::ConnectionService::Rest::Client.new do |config|
737
+ # config.timeout = 10.0
738
+ # config.rpcs.create_connection.timeout = 20.0
739
+ # end
740
+ #
741
+ # @!attribute [rw] endpoint
742
+ # The hostname or hostname:port of the service endpoint.
743
+ # Defaults to `"bigqueryconnection.googleapis.com"`.
744
+ # @return [::String]
745
+ # @!attribute [rw] credentials
746
+ # Credentials to send with calls. You may provide any of the following types:
747
+ # * (`String`) The path to a service account key file in JSON format
748
+ # * (`Hash`) A service account key as a Hash
749
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
750
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
751
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
752
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
753
+ # * (`nil`) indicating no credentials
754
+ # @return [::Object]
755
+ # @!attribute [rw] scope
756
+ # The OAuth scopes
757
+ # @return [::Array<::String>]
758
+ # @!attribute [rw] lib_name
759
+ # The library name as recorded in instrumentation and logging
760
+ # @return [::String]
761
+ # @!attribute [rw] lib_version
762
+ # The library version as recorded in instrumentation and logging
763
+ # @return [::String]
764
+ # @!attribute [rw] timeout
765
+ # The call timeout in seconds.
766
+ # @return [::Numeric]
767
+ # @!attribute [rw] metadata
768
+ # Additional headers to be sent with the call.
769
+ # @return [::Hash{::Symbol=>::String}]
770
+ # @!attribute [rw] retry_policy
771
+ # The retry policy. The value is a hash with the following keys:
772
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
773
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
774
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
775
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
776
+ # trigger a retry.
777
+ # @return [::Hash]
778
+ # @!attribute [rw] quota_project
779
+ # A separate project against which to charge quota.
780
+ # @return [::String]
781
+ #
782
+ class Configuration
783
+ extend ::Gapic::Config
784
+
785
+ config_attr :endpoint, "bigqueryconnection.googleapis.com", ::String
786
+ config_attr :credentials, nil do |value|
787
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
788
+ allowed.any? { |klass| klass === value }
789
+ end
790
+ config_attr :scope, nil, ::String, ::Array, nil
791
+ config_attr :lib_name, nil, ::String, nil
792
+ config_attr :lib_version, nil, ::String, nil
793
+ config_attr :timeout, nil, ::Numeric, nil
794
+ config_attr :metadata, nil, ::Hash, nil
795
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
796
+ config_attr :quota_project, nil, ::String, nil
797
+
798
+ # @private
799
+ def initialize parent_config = nil
800
+ @parent_config = parent_config unless parent_config.nil?
801
+
802
+ yield self if block_given?
803
+ end
804
+
805
+ ##
806
+ # Configurations for individual RPCs
807
+ # @return [Rpcs]
808
+ #
809
+ def rpcs
810
+ @rpcs ||= begin
811
+ parent_rpcs = nil
812
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
813
+ Rpcs.new parent_rpcs
814
+ end
815
+ end
816
+
817
+ ##
818
+ # Configuration RPC class for the ConnectionService API.
819
+ #
820
+ # Includes fields providing the configuration for each RPC in this service.
821
+ # Each configuration object is of type `Gapic::Config::Method` and includes
822
+ # the following configuration fields:
823
+ #
824
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
825
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
826
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
827
+ # include the following keys:
828
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
829
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
830
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
831
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
832
+ # trigger a retry.
833
+ #
834
+ class Rpcs
835
+ ##
836
+ # RPC-specific configuration for `create_connection`
837
+ # @return [::Gapic::Config::Method]
838
+ #
839
+ attr_reader :create_connection
840
+ ##
841
+ # RPC-specific configuration for `get_connection`
842
+ # @return [::Gapic::Config::Method]
843
+ #
844
+ attr_reader :get_connection
845
+ ##
846
+ # RPC-specific configuration for `list_connections`
847
+ # @return [::Gapic::Config::Method]
848
+ #
849
+ attr_reader :list_connections
850
+ ##
851
+ # RPC-specific configuration for `update_connection`
852
+ # @return [::Gapic::Config::Method]
853
+ #
854
+ attr_reader :update_connection
855
+ ##
856
+ # RPC-specific configuration for `delete_connection`
857
+ # @return [::Gapic::Config::Method]
858
+ #
859
+ attr_reader :delete_connection
860
+ ##
861
+ # RPC-specific configuration for `get_iam_policy`
862
+ # @return [::Gapic::Config::Method]
863
+ #
864
+ attr_reader :get_iam_policy
865
+ ##
866
+ # RPC-specific configuration for `set_iam_policy`
867
+ # @return [::Gapic::Config::Method]
868
+ #
869
+ attr_reader :set_iam_policy
870
+ ##
871
+ # RPC-specific configuration for `test_iam_permissions`
872
+ # @return [::Gapic::Config::Method]
873
+ #
874
+ attr_reader :test_iam_permissions
875
+
876
+ # @private
877
+ def initialize parent_rpcs = nil
878
+ create_connection_config = parent_rpcs.create_connection if parent_rpcs.respond_to? :create_connection
879
+ @create_connection = ::Gapic::Config::Method.new create_connection_config
880
+ get_connection_config = parent_rpcs.get_connection if parent_rpcs.respond_to? :get_connection
881
+ @get_connection = ::Gapic::Config::Method.new get_connection_config
882
+ list_connections_config = parent_rpcs.list_connections if parent_rpcs.respond_to? :list_connections
883
+ @list_connections = ::Gapic::Config::Method.new list_connections_config
884
+ update_connection_config = parent_rpcs.update_connection if parent_rpcs.respond_to? :update_connection
885
+ @update_connection = ::Gapic::Config::Method.new update_connection_config
886
+ delete_connection_config = parent_rpcs.delete_connection if parent_rpcs.respond_to? :delete_connection
887
+ @delete_connection = ::Gapic::Config::Method.new delete_connection_config
888
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
889
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
890
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
891
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
892
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
893
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
894
+
895
+ yield self if block_given?
896
+ end
897
+ end
898
+ end
899
+ end
900
+ end
901
+ end
902
+ end
903
+ end
904
+ end
905
+ end
906
+ end