google-cloud-policy_troubleshooter-iam-v3 0.a → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/README.md +144 -8
  5. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter/client.rb +400 -0
  6. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter/credentials.rb +49 -0
  7. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter/rest/client.rb +372 -0
  8. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter/rest/service_stub.rb +108 -0
  9. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter/rest.rb +55 -0
  10. data/lib/google/cloud/policy_troubleshooter/iam/v3/policy_troubleshooter.rb +58 -0
  11. data/lib/google/cloud/policy_troubleshooter/iam/v3/rest.rb +39 -0
  12. data/lib/google/cloud/policy_troubleshooter/iam/v3/version.rb +7 -2
  13. data/lib/google/cloud/policy_troubleshooter/iam/v3.rb +47 -0
  14. data/lib/google/cloud/policytroubleshooter/iam/v3/troubleshooter_pb.rb +86 -0
  15. data/lib/google/cloud/policytroubleshooter/iam/v3/troubleshooter_services_pb.rb +51 -0
  16. data/lib/google-cloud-policy_troubleshooter-iam-v3.rb +21 -0
  17. data/proto_docs/README.md +4 -0
  18. data/proto_docs/google/api/client.rb +381 -0
  19. data/proto_docs/google/api/field_behavior.rb +85 -0
  20. data/proto_docs/google/api/launch_stage.rb +71 -0
  21. data/proto_docs/google/api/resource.rb +222 -0
  22. data/proto_docs/google/cloud/policytroubleshooter/iam/v3/troubleshooter.rb +826 -0
  23. data/proto_docs/google/iam/v1/policy.rb +426 -0
  24. data/proto_docs/google/iam/v2/deny.rb +110 -0
  25. data/proto_docs/google/iam/v2/policy.rb +241 -0
  26. data/proto_docs/google/longrunning/operations.rb +164 -0
  27. data/proto_docs/google/protobuf/any.rb +144 -0
  28. data/proto_docs/google/protobuf/duration.rb +98 -0
  29. data/proto_docs/google/protobuf/empty.rb +34 -0
  30. data/proto_docs/google/protobuf/struct.rb +96 -0
  31. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  32. data/proto_docs/google/rpc/status.rb +48 -0
  33. data/proto_docs/google/type/expr.rb +75 -0
  34. metadata +229 -13
@@ -0,0 +1,400 @@
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/policytroubleshooter/iam/v3/troubleshooter_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PolicyTroubleshooter
25
+ module Iam
26
+ module V3
27
+ module PolicyTroubleshooter
28
+ ##
29
+ # Client for the PolicyTroubleshooter service.
30
+ #
31
+ # IAM Policy Troubleshooter service.
32
+ #
33
+ # This service helps you troubleshoot access issues for Google Cloud resources.
34
+ #
35
+ class Client
36
+ # @private
37
+ attr_reader :policy_troubleshooter_stub
38
+
39
+ ##
40
+ # Configure the PolicyTroubleshooter Client class.
41
+ #
42
+ # See {::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # @example
46
+ #
47
+ # # Modify the configuration for all PolicyTroubleshooter clients
48
+ # ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "PolicyTroubleshooter", "Iam", "V3"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.rpcs.troubleshoot_iam_policy.timeout = 60.0
69
+ default_config.rpcs.troubleshoot_iam_policy.retry_policy = {
70
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
71
+ }
72
+
73
+ default_config
74
+ end
75
+ yield @configure if block_given?
76
+ @configure
77
+ end
78
+
79
+ ##
80
+ # Configure the PolicyTroubleshooter Client instance.
81
+ #
82
+ # The configuration is set to the derived mode, meaning that values can be changed,
83
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
84
+ # should be made on {Client.configure}.
85
+ #
86
+ # See {::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client::Configuration}
87
+ # for a description of the configuration fields.
88
+ #
89
+ # @yield [config] Configure the Client client.
90
+ # @yieldparam config [Client::Configuration]
91
+ #
92
+ # @return [Client::Configuration]
93
+ #
94
+ def configure
95
+ yield @config if block_given?
96
+ @config
97
+ end
98
+
99
+ ##
100
+ # Create a new PolicyTroubleshooter client object.
101
+ #
102
+ # @example
103
+ #
104
+ # # Create a client using the default configuration
105
+ # client = ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new
106
+ #
107
+ # # Create a client using a custom configuration
108
+ # client = ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new do |config|
109
+ # config.timeout = 10.0
110
+ # end
111
+ #
112
+ # @yield [config] Configure the PolicyTroubleshooter client.
113
+ # @yieldparam config [Client::Configuration]
114
+ #
115
+ def initialize
116
+ # These require statements are intentionally placed here to initialize
117
+ # the gRPC module only when it's required.
118
+ # See https://github.com/googleapis/toolkit/issues/446
119
+ require "gapic/grpc"
120
+ require "google/cloud/policytroubleshooter/iam/v3/troubleshooter_services_pb"
121
+
122
+ # Create the configuration object
123
+ @config = Configuration.new Client.configure
124
+
125
+ # Yield the configuration if needed
126
+ yield @config if block_given?
127
+
128
+ # Create credentials
129
+ credentials = @config.credentials
130
+ # Use self-signed JWT if the endpoint is unchanged from default,
131
+ # but only if the default endpoint does not have a region prefix.
132
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
133
+ !@config.endpoint.split(".").first.include?("-")
134
+ credentials ||= Credentials.default scope: @config.scope,
135
+ enable_self_signed_jwt: enable_self_signed_jwt
136
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
137
+ credentials = Credentials.new credentials, scope: @config.scope
138
+ end
139
+ @quota_project_id = @config.quota_project
140
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
141
+
142
+ @policy_troubleshooter_stub = ::Gapic::ServiceStub.new(
143
+ ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Stub,
144
+ credentials: credentials,
145
+ endpoint: @config.endpoint,
146
+ channel_args: @config.channel_args,
147
+ interceptors: @config.interceptors,
148
+ channel_pool_config: @config.channel_pool
149
+ )
150
+ end
151
+
152
+ # Service calls
153
+
154
+ ##
155
+ # Checks whether a principal has a specific permission for a specific
156
+ # resource, and explains why the principal does or doesn't have that
157
+ # permission.
158
+ #
159
+ # @overload troubleshoot_iam_policy(request, options = nil)
160
+ # Pass arguments to `troubleshoot_iam_policy` via a request object, either of type
161
+ # {::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest} or an equivalent Hash.
162
+ #
163
+ # @param request [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest, ::Hash]
164
+ # A request object representing the call parameters. Required. To specify no
165
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
166
+ # @param options [::Gapic::CallOptions, ::Hash]
167
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
168
+ #
169
+ # @overload troubleshoot_iam_policy(access_tuple: nil)
170
+ # Pass arguments to `troubleshoot_iam_policy` via keyword arguments. Note that at
171
+ # least one keyword argument is required. To specify no parameters, or to keep all
172
+ # the default parameter values, pass an empty Hash as a request object (see above).
173
+ #
174
+ # @param access_tuple [::Google::Cloud::PolicyTroubleshooter::Iam::V3::AccessTuple, ::Hash]
175
+ # The information to use for checking whether a principal has a permission
176
+ # for a resource.
177
+ #
178
+ # @yield [response, operation] Access the result along with the RPC operation
179
+ # @yieldparam response [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse]
180
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
181
+ #
182
+ # @return [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse]
183
+ #
184
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
185
+ #
186
+ # @example Basic example
187
+ # require "google/cloud/policy_troubleshooter/iam/v3"
188
+ #
189
+ # # Create a client object. The client can be reused for multiple calls.
190
+ # client = Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new
191
+ #
192
+ # # Create a request. To set request fields, pass in keyword arguments.
193
+ # request = Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest.new
194
+ #
195
+ # # Call the troubleshoot_iam_policy method.
196
+ # result = client.troubleshoot_iam_policy request
197
+ #
198
+ # # The returned object is of type Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse.
199
+ # p result
200
+ #
201
+ def troubleshoot_iam_policy request, options = nil
202
+ raise ::ArgumentError, "request must be provided" if request.nil?
203
+
204
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest
205
+
206
+ # Converts hash and nil to an options object
207
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
208
+
209
+ # Customize the options with defaults
210
+ metadata = @config.rpcs.troubleshoot_iam_policy.metadata.to_h
211
+
212
+ # Set x-goog-api-client and x-goog-user-project headers
213
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
214
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
215
+ gapic_version: ::Google::Cloud::PolicyTroubleshooter::Iam::V3::VERSION
216
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
217
+
218
+ options.apply_defaults timeout: @config.rpcs.troubleshoot_iam_policy.timeout,
219
+ metadata: metadata,
220
+ retry_policy: @config.rpcs.troubleshoot_iam_policy.retry_policy
221
+
222
+ options.apply_defaults timeout: @config.timeout,
223
+ metadata: @config.metadata,
224
+ retry_policy: @config.retry_policy
225
+
226
+ @policy_troubleshooter_stub.call_rpc :troubleshoot_iam_policy, request, options: options do |response, operation|
227
+ yield response, operation if block_given?
228
+ return response
229
+ end
230
+ rescue ::GRPC::BadStatus => e
231
+ raise ::Google::Cloud::Error.from_error(e)
232
+ end
233
+
234
+ ##
235
+ # Configuration class for the PolicyTroubleshooter API.
236
+ #
237
+ # This class represents the configuration for PolicyTroubleshooter,
238
+ # providing control over timeouts, retry behavior, logging, transport
239
+ # parameters, and other low-level controls. Certain parameters can also be
240
+ # applied individually to specific RPCs. See
241
+ # {::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client::Configuration::Rpcs}
242
+ # for a list of RPCs that can be configured independently.
243
+ #
244
+ # Configuration can be applied globally to all clients, or to a single client
245
+ # on construction.
246
+ #
247
+ # @example
248
+ #
249
+ # # Modify the global config, setting the timeout for
250
+ # # troubleshoot_iam_policy to 20 seconds,
251
+ # # and all remaining timeouts to 10 seconds.
252
+ # ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.configure do |config|
253
+ # config.timeout = 10.0
254
+ # config.rpcs.troubleshoot_iam_policy.timeout = 20.0
255
+ # end
256
+ #
257
+ # # Apply the above configuration only to a new client.
258
+ # client = ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new do |config|
259
+ # config.timeout = 10.0
260
+ # config.rpcs.troubleshoot_iam_policy.timeout = 20.0
261
+ # end
262
+ #
263
+ # @!attribute [rw] endpoint
264
+ # The hostname or hostname:port of the service endpoint.
265
+ # Defaults to `"policytroubleshooter.googleapis.com"`.
266
+ # @return [::String]
267
+ # @!attribute [rw] credentials
268
+ # Credentials to send with calls. You may provide any of the following types:
269
+ # * (`String`) The path to a service account key file in JSON format
270
+ # * (`Hash`) A service account key as a Hash
271
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
272
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
273
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
274
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
275
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
276
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
277
+ # * (`nil`) indicating no credentials
278
+ # @return [::Object]
279
+ # @!attribute [rw] scope
280
+ # The OAuth scopes
281
+ # @return [::Array<::String>]
282
+ # @!attribute [rw] lib_name
283
+ # The library name as recorded in instrumentation and logging
284
+ # @return [::String]
285
+ # @!attribute [rw] lib_version
286
+ # The library version as recorded in instrumentation and logging
287
+ # @return [::String]
288
+ # @!attribute [rw] channel_args
289
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
290
+ # `GRPC::Core::Channel` object is provided as the credential.
291
+ # @return [::Hash]
292
+ # @!attribute [rw] interceptors
293
+ # An array of interceptors that are run before calls are executed.
294
+ # @return [::Array<::GRPC::ClientInterceptor>]
295
+ # @!attribute [rw] timeout
296
+ # The call timeout in seconds.
297
+ # @return [::Numeric]
298
+ # @!attribute [rw] metadata
299
+ # Additional gRPC headers to be sent with the call.
300
+ # @return [::Hash{::Symbol=>::String}]
301
+ # @!attribute [rw] retry_policy
302
+ # The retry policy. The value is a hash with the following keys:
303
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
304
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
305
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
306
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
307
+ # trigger a retry.
308
+ # @return [::Hash]
309
+ # @!attribute [rw] quota_project
310
+ # A separate project against which to charge quota.
311
+ # @return [::String]
312
+ #
313
+ class Configuration
314
+ extend ::Gapic::Config
315
+
316
+ DEFAULT_ENDPOINT = "policytroubleshooter.googleapis.com"
317
+
318
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
319
+ config_attr :credentials, nil do |value|
320
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
321
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
322
+ allowed.any? { |klass| klass === value }
323
+ end
324
+ config_attr :scope, nil, ::String, ::Array, nil
325
+ config_attr :lib_name, nil, ::String, nil
326
+ config_attr :lib_version, nil, ::String, nil
327
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
328
+ config_attr :interceptors, nil, ::Array, nil
329
+ config_attr :timeout, nil, ::Numeric, nil
330
+ config_attr :metadata, nil, ::Hash, nil
331
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
332
+ config_attr :quota_project, nil, ::String, nil
333
+
334
+ # @private
335
+ def initialize parent_config = nil
336
+ @parent_config = parent_config unless parent_config.nil?
337
+
338
+ yield self if block_given?
339
+ end
340
+
341
+ ##
342
+ # Configurations for individual RPCs
343
+ # @return [Rpcs]
344
+ #
345
+ def rpcs
346
+ @rpcs ||= begin
347
+ parent_rpcs = nil
348
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
349
+ Rpcs.new parent_rpcs
350
+ end
351
+ end
352
+
353
+ ##
354
+ # Configuration for the channel pool
355
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
356
+ #
357
+ def channel_pool
358
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
359
+ end
360
+
361
+ ##
362
+ # Configuration RPC class for the PolicyTroubleshooter API.
363
+ #
364
+ # Includes fields providing the configuration for each RPC in this service.
365
+ # Each configuration object is of type `Gapic::Config::Method` and includes
366
+ # the following configuration fields:
367
+ #
368
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
369
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
370
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
371
+ # include the following keys:
372
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
373
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
374
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
375
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
376
+ # trigger a retry.
377
+ #
378
+ class Rpcs
379
+ ##
380
+ # RPC-specific configuration for `troubleshoot_iam_policy`
381
+ # @return [::Gapic::Config::Method]
382
+ #
383
+ attr_reader :troubleshoot_iam_policy
384
+
385
+ # @private
386
+ def initialize parent_rpcs = nil
387
+ troubleshoot_iam_policy_config = parent_rpcs.troubleshoot_iam_policy if parent_rpcs.respond_to? :troubleshoot_iam_policy
388
+ @troubleshoot_iam_policy = ::Gapic::Config::Method.new troubleshoot_iam_policy_config
389
+
390
+ yield self if block_given?
391
+ end
392
+ end
393
+ end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ end
399
+ end
400
+ end
@@ -0,0 +1,49 @@
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 "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module PolicyTroubleshooter
24
+ module Iam
25
+ module V3
26
+ module PolicyTroubleshooter
27
+ # Credentials for the PolicyTroubleshooter API.
28
+ class Credentials < ::Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/cloud-platform"
31
+ ]
32
+ self.env_vars = [
33
+ "GOOGLE_CLOUD_CREDENTIALS",
34
+ "GOOGLE_CLOUD_KEYFILE",
35
+ "GCLOUD_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
37
+ "GOOGLE_CLOUD_KEYFILE_JSON",
38
+ "GCLOUD_KEYFILE_JSON"
39
+ ]
40
+ self.paths = [
41
+ "~/.config/google_cloud/application_default_credentials.json"
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end