google-iam-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,625 @@
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/iam/v1/iam_policy_pb"
21
+
22
+ module Google
23
+ module Iam
24
+ module V1
25
+ module IAMPolicy
26
+ ##
27
+ # Client for the IAMPolicy service.
28
+ #
29
+ # API Overview
30
+ #
31
+ #
32
+ # Manages Identity and Access Management (IAM) policies.
33
+ #
34
+ # Any implementation of an API that offers access control features
35
+ # implements the google.iam.v1.IAMPolicy interface.
36
+ #
37
+ # ## Data model
38
+ #
39
+ # Access control is applied when a principal (user or service account), takes
40
+ # some action on a resource exposed by a service. Resources, identified by
41
+ # URI-like names, are the unit of access control specification. Service
42
+ # implementations can choose the granularity of access control and the
43
+ # supported permissions for their resources.
44
+ # For example one database service may allow access control to be
45
+ # specified only at the Table level, whereas another might allow access control
46
+ # to also be specified at the Column level.
47
+ #
48
+ # ## Policy Structure
49
+ #
50
+ # See google.iam.v1.Policy
51
+ #
52
+ # This is intentionally not a CRUD style API because access control policies
53
+ # are created and deleted implicitly with the resources to which they are
54
+ # attached.
55
+ #
56
+ class Client
57
+ # @private
58
+ attr_reader :iam_policy_stub
59
+
60
+ ##
61
+ # Configure the IAMPolicy Client class.
62
+ #
63
+ # See {::Google::Iam::V1::IAMPolicy::Client::Configuration}
64
+ # for a description of the configuration fields.
65
+ #
66
+ # @example
67
+ #
68
+ # # Modify the configuration for all IAMPolicy clients
69
+ # ::Google::Iam::V1::IAMPolicy::Client.configure do |config|
70
+ # config.timeout = 10.0
71
+ # end
72
+ #
73
+ # @yield [config] Configure the Client client.
74
+ # @yieldparam config [Client::Configuration]
75
+ #
76
+ # @return [Client::Configuration]
77
+ #
78
+ def self.configure
79
+ @configure ||= begin
80
+ namespace = ["Google", "Iam", "V1"]
81
+ parent_config = while namespace.any?
82
+ parent_name = namespace.join "::"
83
+ parent_const = const_get parent_name
84
+ break parent_const.configure if parent_const.respond_to? :configure
85
+ namespace.pop
86
+ end
87
+ default_config = Client::Configuration.new parent_config
88
+
89
+ default_config
90
+ end
91
+ yield @configure if block_given?
92
+ @configure
93
+ end
94
+
95
+ ##
96
+ # Configure the IAMPolicy Client instance.
97
+ #
98
+ # The configuration is set to the derived mode, meaning that values can be changed,
99
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
100
+ # should be made on {Client.configure}.
101
+ #
102
+ # See {::Google::Iam::V1::IAMPolicy::Client::Configuration}
103
+ # for a description of the configuration fields.
104
+ #
105
+ # @yield [config] Configure the Client client.
106
+ # @yieldparam config [Client::Configuration]
107
+ #
108
+ # @return [Client::Configuration]
109
+ #
110
+ def configure
111
+ yield @config if block_given?
112
+ @config
113
+ end
114
+
115
+ ##
116
+ # Create a new IAMPolicy client object.
117
+ #
118
+ # @example
119
+ #
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Iam::V1::IAMPolicy::Client.new
122
+ #
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Iam::V1::IAMPolicy::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
127
+ #
128
+ # @yield [config] Configure the IAMPolicy client.
129
+ # @yieldparam config [Client::Configuration]
130
+ #
131
+ def initialize
132
+ # These require statements are intentionally placed here to initialize
133
+ # the gRPC module only when it's required.
134
+ # See https://github.com/googleapis/toolkit/issues/446
135
+ require "gapic/grpc"
136
+ require "google/iam/v1/iam_policy_services_pb"
137
+
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
+ @quota_project_id = @config.quota_project
156
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
157
+
158
+ @iam_policy_stub = ::Gapic::ServiceStub.new(
159
+ ::Google::Iam::V1::IAMPolicy::Stub,
160
+ credentials: credentials,
161
+ endpoint: @config.endpoint,
162
+ channel_args: @config.channel_args,
163
+ interceptors: @config.interceptors
164
+ )
165
+ end
166
+
167
+ # Service calls
168
+
169
+ ##
170
+ # Sets the access control policy on the specified resource. Replaces any
171
+ # existing policy.
172
+ #
173
+ # Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
174
+ #
175
+ # @overload set_iam_policy(request, options = nil)
176
+ # Pass arguments to `set_iam_policy` via a request object, either of type
177
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
178
+ #
179
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::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 set_iam_policy(resource: nil, policy: nil, update_mask: nil)
186
+ # Pass arguments to `set_iam_policy` 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 resource [::String]
191
+ # REQUIRED: The resource for which the policy is being specified.
192
+ # See the operation documentation for the appropriate value for this field.
193
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
194
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
195
+ # the policy is limited to a few 10s of KB. An empty policy is a
196
+ # valid policy but certain Cloud Platform services (such as Projects)
197
+ # might reject them.
198
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
199
+ # OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
200
+ # the fields in the mask will be modified. If no mask is provided, the
201
+ # following default mask is used:
202
+ #
203
+ # `paths: "bindings, etag"`
204
+ #
205
+ # @yield [response, operation] Access the result along with the RPC operation
206
+ # @yieldparam response [::Google::Iam::V1::Policy]
207
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
208
+ #
209
+ # @return [::Google::Iam::V1::Policy]
210
+ #
211
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
212
+ #
213
+ # @example Basic example
214
+ # require "google/iam/v1"
215
+ #
216
+ # # Create a client object. The client can be reused for multiple calls.
217
+ # client = Google::Iam::V1::IAMPolicy::Client.new
218
+ #
219
+ # # Create a request. To set request fields, pass in keyword arguments.
220
+ # request = Google::Iam::V1::SetIamPolicyRequest.new
221
+ #
222
+ # # Call the set_iam_policy method.
223
+ # result = client.set_iam_policy request
224
+ #
225
+ # # The returned object is of type Google::Iam::V1::Policy.
226
+ # p result
227
+ #
228
+ def set_iam_policy request, options = nil
229
+ raise ::ArgumentError, "request must be provided" if request.nil?
230
+
231
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
232
+
233
+ # Converts hash and nil to an options object
234
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
235
+
236
+ # Customize the options with defaults
237
+ metadata = @config.rpcs.set_iam_policy.metadata.to_h
238
+
239
+ # Set x-goog-api-client and x-goog-user-project headers
240
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
241
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
242
+ gapic_version: ::Google::Iam::V1::VERSION
243
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
244
+
245
+ header_params = {}
246
+ if request.resource
247
+ header_params["resource"] = request.resource
248
+ end
249
+
250
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
+ metadata[:"x-goog-request-params"] ||= request_params_header
252
+
253
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
254
+ metadata: metadata,
255
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
256
+
257
+ options.apply_defaults timeout: @config.timeout,
258
+ metadata: @config.metadata,
259
+ retry_policy: @config.retry_policy
260
+
261
+ @iam_policy_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
262
+ yield response, operation if block_given?
263
+ return response
264
+ end
265
+ rescue ::GRPC::BadStatus => e
266
+ raise ::Google::Cloud::Error.from_error(e)
267
+ end
268
+
269
+ ##
270
+ # Gets the access control policy for a resource.
271
+ # Returns an empty policy if the resource exists and does not have a policy
272
+ # set.
273
+ #
274
+ # @overload get_iam_policy(request, options = nil)
275
+ # Pass arguments to `get_iam_policy` via a request object, either of type
276
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
277
+ #
278
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
279
+ # A request object representing the call parameters. Required. To specify no
280
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
281
+ # @param options [::Gapic::CallOptions, ::Hash]
282
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
283
+ #
284
+ # @overload get_iam_policy(resource: nil, options: nil)
285
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
286
+ # least one keyword argument is required. To specify no parameters, or to keep all
287
+ # the default parameter values, pass an empty Hash as a request object (see above).
288
+ #
289
+ # @param resource [::String]
290
+ # REQUIRED: The resource for which the policy is being requested.
291
+ # See the operation documentation for the appropriate value for this field.
292
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
293
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
294
+ # `GetIamPolicy`.
295
+ #
296
+ # @yield [response, operation] Access the result along with the RPC operation
297
+ # @yieldparam response [::Google::Iam::V1::Policy]
298
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
299
+ #
300
+ # @return [::Google::Iam::V1::Policy]
301
+ #
302
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
303
+ #
304
+ # @example Basic example
305
+ # require "google/iam/v1"
306
+ #
307
+ # # Create a client object. The client can be reused for multiple calls.
308
+ # client = Google::Iam::V1::IAMPolicy::Client.new
309
+ #
310
+ # # Create a request. To set request fields, pass in keyword arguments.
311
+ # request = Google::Iam::V1::GetIamPolicyRequest.new
312
+ #
313
+ # # Call the get_iam_policy method.
314
+ # result = client.get_iam_policy request
315
+ #
316
+ # # The returned object is of type Google::Iam::V1::Policy.
317
+ # p result
318
+ #
319
+ def get_iam_policy request, options = nil
320
+ raise ::ArgumentError, "request must be provided" if request.nil?
321
+
322
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
323
+
324
+ # Converts hash and nil to an options object
325
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
326
+
327
+ # Customize the options with defaults
328
+ metadata = @config.rpcs.get_iam_policy.metadata.to_h
329
+
330
+ # Set x-goog-api-client and x-goog-user-project headers
331
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
332
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
333
+ gapic_version: ::Google::Iam::V1::VERSION
334
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
335
+
336
+ header_params = {}
337
+ if request.resource
338
+ header_params["resource"] = request.resource
339
+ end
340
+
341
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
342
+ metadata[:"x-goog-request-params"] ||= request_params_header
343
+
344
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
345
+ metadata: metadata,
346
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
347
+
348
+ options.apply_defaults timeout: @config.timeout,
349
+ metadata: @config.metadata,
350
+ retry_policy: @config.retry_policy
351
+
352
+ @iam_policy_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
353
+ yield response, operation if block_given?
354
+ return response
355
+ end
356
+ rescue ::GRPC::BadStatus => e
357
+ raise ::Google::Cloud::Error.from_error(e)
358
+ end
359
+
360
+ ##
361
+ # Returns permissions that a caller has on the specified resource.
362
+ # If the resource does not exist, this will return an empty set of
363
+ # permissions, not a `NOT_FOUND` error.
364
+ #
365
+ # Note: This operation is designed to be used for building permission-aware
366
+ # UIs and command-line tools, not for authorization checking. This operation
367
+ # may "fail open" without warning.
368
+ #
369
+ # @overload test_iam_permissions(request, options = nil)
370
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
371
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
372
+ #
373
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
374
+ # A request object representing the call parameters. Required. To specify no
375
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
376
+ # @param options [::Gapic::CallOptions, ::Hash]
377
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
378
+ #
379
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
380
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
381
+ # least one keyword argument is required. To specify no parameters, or to keep all
382
+ # the default parameter values, pass an empty Hash as a request object (see above).
383
+ #
384
+ # @param resource [::String]
385
+ # REQUIRED: The resource for which the policy detail is being requested.
386
+ # See the operation documentation for the appropriate value for this field.
387
+ # @param permissions [::Array<::String>]
388
+ # The set of permissions to check for the `resource`. Permissions with
389
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
390
+ # information see
391
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
392
+ #
393
+ # @yield [response, operation] Access the result along with the RPC operation
394
+ # @yieldparam response [::Google::Iam::V1::TestIamPermissionsResponse]
395
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
396
+ #
397
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
398
+ #
399
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
400
+ #
401
+ # @example Basic example
402
+ # require "google/iam/v1"
403
+ #
404
+ # # Create a client object. The client can be reused for multiple calls.
405
+ # client = Google::Iam::V1::IAMPolicy::Client.new
406
+ #
407
+ # # Create a request. To set request fields, pass in keyword arguments.
408
+ # request = Google::Iam::V1::TestIamPermissionsRequest.new
409
+ #
410
+ # # Call the test_iam_permissions method.
411
+ # result = client.test_iam_permissions request
412
+ #
413
+ # # The returned object is of type Google::Iam::V1::TestIamPermissionsResponse.
414
+ # p result
415
+ #
416
+ def test_iam_permissions request, options = nil
417
+ raise ::ArgumentError, "request must be provided" if request.nil?
418
+
419
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
420
+
421
+ # Converts hash and nil to an options object
422
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
423
+
424
+ # Customize the options with defaults
425
+ metadata = @config.rpcs.test_iam_permissions.metadata.to_h
426
+
427
+ # Set x-goog-api-client and x-goog-user-project headers
428
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
429
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
430
+ gapic_version: ::Google::Iam::V1::VERSION
431
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
432
+
433
+ header_params = {}
434
+ if request.resource
435
+ header_params["resource"] = request.resource
436
+ end
437
+
438
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
439
+ metadata[:"x-goog-request-params"] ||= request_params_header
440
+
441
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
442
+ metadata: metadata,
443
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
444
+
445
+ options.apply_defaults timeout: @config.timeout,
446
+ metadata: @config.metadata,
447
+ retry_policy: @config.retry_policy
448
+
449
+ @iam_policy_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
450
+ yield response, operation if block_given?
451
+ return response
452
+ end
453
+ rescue ::GRPC::BadStatus => e
454
+ raise ::Google::Cloud::Error.from_error(e)
455
+ end
456
+
457
+ ##
458
+ # Configuration class for the IAMPolicy API.
459
+ #
460
+ # This class represents the configuration for IAMPolicy,
461
+ # providing control over timeouts, retry behavior, logging, transport
462
+ # parameters, and other low-level controls. Certain parameters can also be
463
+ # applied individually to specific RPCs. See
464
+ # {::Google::Iam::V1::IAMPolicy::Client::Configuration::Rpcs}
465
+ # for a list of RPCs that can be configured independently.
466
+ #
467
+ # Configuration can be applied globally to all clients, or to a single client
468
+ # on construction.
469
+ #
470
+ # @example
471
+ #
472
+ # # Modify the global config, setting the timeout for
473
+ # # set_iam_policy to 20 seconds,
474
+ # # and all remaining timeouts to 10 seconds.
475
+ # ::Google::Iam::V1::IAMPolicy::Client.configure do |config|
476
+ # config.timeout = 10.0
477
+ # config.rpcs.set_iam_policy.timeout = 20.0
478
+ # end
479
+ #
480
+ # # Apply the above configuration only to a new client.
481
+ # client = ::Google::Iam::V1::IAMPolicy::Client.new do |config|
482
+ # config.timeout = 10.0
483
+ # config.rpcs.set_iam_policy.timeout = 20.0
484
+ # end
485
+ #
486
+ # @!attribute [rw] endpoint
487
+ # The hostname or hostname:port of the service endpoint.
488
+ # Defaults to `"iam-meta-api.googleapis.com"`.
489
+ # @return [::String]
490
+ # @!attribute [rw] credentials
491
+ # Credentials to send with calls. You may provide any of the following types:
492
+ # * (`String`) The path to a service account key file in JSON format
493
+ # * (`Hash`) A service account key as a Hash
494
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
495
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
496
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
497
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
498
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
499
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
500
+ # * (`nil`) indicating no credentials
501
+ # @return [::Object]
502
+ # @!attribute [rw] scope
503
+ # The OAuth scopes
504
+ # @return [::Array<::String>]
505
+ # @!attribute [rw] lib_name
506
+ # The library name as recorded in instrumentation and logging
507
+ # @return [::String]
508
+ # @!attribute [rw] lib_version
509
+ # The library version as recorded in instrumentation and logging
510
+ # @return [::String]
511
+ # @!attribute [rw] channel_args
512
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
513
+ # `GRPC::Core::Channel` object is provided as the credential.
514
+ # @return [::Hash]
515
+ # @!attribute [rw] interceptors
516
+ # An array of interceptors that are run before calls are executed.
517
+ # @return [::Array<::GRPC::ClientInterceptor>]
518
+ # @!attribute [rw] timeout
519
+ # The call timeout in seconds.
520
+ # @return [::Numeric]
521
+ # @!attribute [rw] metadata
522
+ # Additional gRPC headers to be sent with the call.
523
+ # @return [::Hash{::Symbol=>::String}]
524
+ # @!attribute [rw] retry_policy
525
+ # The retry policy. The value is a hash with the following keys:
526
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
527
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
528
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
529
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
530
+ # trigger a retry.
531
+ # @return [::Hash]
532
+ # @!attribute [rw] quota_project
533
+ # A separate project against which to charge quota.
534
+ # @return [::String]
535
+ #
536
+ class Configuration
537
+ extend ::Gapic::Config
538
+
539
+ config_attr :endpoint, "iam-meta-api.googleapis.com", ::String
540
+ config_attr :credentials, nil do |value|
541
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
542
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
543
+ allowed.any? { |klass| klass === value }
544
+ end
545
+ config_attr :scope, nil, ::String, ::Array, nil
546
+ config_attr :lib_name, nil, ::String, nil
547
+ config_attr :lib_version, nil, ::String, nil
548
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
549
+ config_attr :interceptors, nil, ::Array, nil
550
+ config_attr :timeout, nil, ::Numeric, nil
551
+ config_attr :metadata, nil, ::Hash, nil
552
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
553
+ config_attr :quota_project, nil, ::String, nil
554
+
555
+ # @private
556
+ def initialize parent_config = nil
557
+ @parent_config = parent_config unless parent_config.nil?
558
+
559
+ yield self if block_given?
560
+ end
561
+
562
+ ##
563
+ # Configurations for individual RPCs
564
+ # @return [Rpcs]
565
+ #
566
+ def rpcs
567
+ @rpcs ||= begin
568
+ parent_rpcs = nil
569
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
570
+ Rpcs.new parent_rpcs
571
+ end
572
+ end
573
+
574
+ ##
575
+ # Configuration RPC class for the IAMPolicy API.
576
+ #
577
+ # Includes fields providing the configuration for each RPC in this service.
578
+ # Each configuration object is of type `Gapic::Config::Method` and includes
579
+ # the following configuration fields:
580
+ #
581
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
582
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
583
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
584
+ # include the following keys:
585
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
586
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
587
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
588
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
589
+ # trigger a retry.
590
+ #
591
+ class Rpcs
592
+ ##
593
+ # RPC-specific configuration for `set_iam_policy`
594
+ # @return [::Gapic::Config::Method]
595
+ #
596
+ attr_reader :set_iam_policy
597
+ ##
598
+ # RPC-specific configuration for `get_iam_policy`
599
+ # @return [::Gapic::Config::Method]
600
+ #
601
+ attr_reader :get_iam_policy
602
+ ##
603
+ # RPC-specific configuration for `test_iam_permissions`
604
+ # @return [::Gapic::Config::Method]
605
+ #
606
+ attr_reader :test_iam_permissions
607
+
608
+ # @private
609
+ def initialize parent_rpcs = nil
610
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
611
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
612
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
613
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
614
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
615
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
616
+
617
+ yield self if block_given?
618
+ end
619
+ end
620
+ end
621
+ end
622
+ end
623
+ end
624
+ end
625
+ end
@@ -0,0 +1,42 @@
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 "googleauth"
20
+
21
+ module Google
22
+ module Iam
23
+ module V1
24
+ module IAMPolicy
25
+ # Credentials for the IAMPolicy API.
26
+ class Credentials < ::Google::Auth::Credentials
27
+ self.env_vars = [
28
+ "GOOGLE_CLOUD_CREDENTIALS",
29
+ "GOOGLE_CLOUD_KEYFILE",
30
+ "GCLOUD_KEYFILE",
31
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
32
+ "GOOGLE_CLOUD_KEYFILE_JSON",
33
+ "GCLOUD_KEYFILE_JSON"
34
+ ]
35
+ self.paths = [
36
+ "~/.config/google_cloud/application_default_credentials.json"
37
+ ]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end