google-cloud-policy_troubleshooter-iam-v3 0.a → 0.1.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 +391 -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 +356 -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,391 @@
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
+ )
149
+ end
150
+
151
+ # Service calls
152
+
153
+ ##
154
+ # Checks whether a principal has a specific permission for a specific
155
+ # resource, and explains why the principal does or doesn't have that
156
+ # permission.
157
+ #
158
+ # @overload troubleshoot_iam_policy(request, options = nil)
159
+ # Pass arguments to `troubleshoot_iam_policy` via a request object, either of type
160
+ # {::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest} or an equivalent Hash.
161
+ #
162
+ # @param request [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest, ::Hash]
163
+ # A request object representing the call parameters. Required. To specify no
164
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
165
+ # @param options [::Gapic::CallOptions, ::Hash]
166
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
167
+ #
168
+ # @overload troubleshoot_iam_policy(access_tuple: nil)
169
+ # Pass arguments to `troubleshoot_iam_policy` via keyword arguments. Note that at
170
+ # least one keyword argument is required. To specify no parameters, or to keep all
171
+ # the default parameter values, pass an empty Hash as a request object (see above).
172
+ #
173
+ # @param access_tuple [::Google::Cloud::PolicyTroubleshooter::Iam::V3::AccessTuple, ::Hash]
174
+ # The information to use for checking whether a principal has a permission
175
+ # for a resource.
176
+ #
177
+ # @yield [response, operation] Access the result along with the RPC operation
178
+ # @yieldparam response [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse]
179
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
180
+ #
181
+ # @return [::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse]
182
+ #
183
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
184
+ #
185
+ # @example Basic example
186
+ # require "google/cloud/policy_troubleshooter/iam/v3"
187
+ #
188
+ # # Create a client object. The client can be reused for multiple calls.
189
+ # client = Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new
190
+ #
191
+ # # Create a request. To set request fields, pass in keyword arguments.
192
+ # request = Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest.new
193
+ #
194
+ # # Call the troubleshoot_iam_policy method.
195
+ # result = client.troubleshoot_iam_policy request
196
+ #
197
+ # # The returned object is of type Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyResponse.
198
+ # p result
199
+ #
200
+ def troubleshoot_iam_policy request, options = nil
201
+ raise ::ArgumentError, "request must be provided" if request.nil?
202
+
203
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicyTroubleshooter::Iam::V3::TroubleshootIamPolicyRequest
204
+
205
+ # Converts hash and nil to an options object
206
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
207
+
208
+ # Customize the options with defaults
209
+ metadata = @config.rpcs.troubleshoot_iam_policy.metadata.to_h
210
+
211
+ # Set x-goog-api-client and x-goog-user-project headers
212
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
213
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
214
+ gapic_version: ::Google::Cloud::PolicyTroubleshooter::Iam::V3::VERSION
215
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
216
+
217
+ options.apply_defaults timeout: @config.rpcs.troubleshoot_iam_policy.timeout,
218
+ metadata: metadata,
219
+ retry_policy: @config.rpcs.troubleshoot_iam_policy.retry_policy
220
+
221
+ options.apply_defaults timeout: @config.timeout,
222
+ metadata: @config.metadata,
223
+ retry_policy: @config.retry_policy
224
+
225
+ @policy_troubleshooter_stub.call_rpc :troubleshoot_iam_policy, request, options: options do |response, operation|
226
+ yield response, operation if block_given?
227
+ return response
228
+ end
229
+ rescue ::GRPC::BadStatus => e
230
+ raise ::Google::Cloud::Error.from_error(e)
231
+ end
232
+
233
+ ##
234
+ # Configuration class for the PolicyTroubleshooter API.
235
+ #
236
+ # This class represents the configuration for PolicyTroubleshooter,
237
+ # providing control over timeouts, retry behavior, logging, transport
238
+ # parameters, and other low-level controls. Certain parameters can also be
239
+ # applied individually to specific RPCs. See
240
+ # {::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client::Configuration::Rpcs}
241
+ # for a list of RPCs that can be configured independently.
242
+ #
243
+ # Configuration can be applied globally to all clients, or to a single client
244
+ # on construction.
245
+ #
246
+ # @example
247
+ #
248
+ # # Modify the global config, setting the timeout for
249
+ # # troubleshoot_iam_policy to 20 seconds,
250
+ # # and all remaining timeouts to 10 seconds.
251
+ # ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.configure do |config|
252
+ # config.timeout = 10.0
253
+ # config.rpcs.troubleshoot_iam_policy.timeout = 20.0
254
+ # end
255
+ #
256
+ # # Apply the above configuration only to a new client.
257
+ # client = ::Google::Cloud::PolicyTroubleshooter::Iam::V3::PolicyTroubleshooter::Client.new do |config|
258
+ # config.timeout = 10.0
259
+ # config.rpcs.troubleshoot_iam_policy.timeout = 20.0
260
+ # end
261
+ #
262
+ # @!attribute [rw] endpoint
263
+ # The hostname or hostname:port of the service endpoint.
264
+ # Defaults to `"policytroubleshooter.googleapis.com"`.
265
+ # @return [::String]
266
+ # @!attribute [rw] credentials
267
+ # Credentials to send with calls. You may provide any of the following types:
268
+ # * (`String`) The path to a service account key file in JSON format
269
+ # * (`Hash`) A service account key as a Hash
270
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
271
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
272
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
273
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
274
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
275
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
276
+ # * (`nil`) indicating no credentials
277
+ # @return [::Object]
278
+ # @!attribute [rw] scope
279
+ # The OAuth scopes
280
+ # @return [::Array<::String>]
281
+ # @!attribute [rw] lib_name
282
+ # The library name as recorded in instrumentation and logging
283
+ # @return [::String]
284
+ # @!attribute [rw] lib_version
285
+ # The library version as recorded in instrumentation and logging
286
+ # @return [::String]
287
+ # @!attribute [rw] channel_args
288
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
289
+ # `GRPC::Core::Channel` object is provided as the credential.
290
+ # @return [::Hash]
291
+ # @!attribute [rw] interceptors
292
+ # An array of interceptors that are run before calls are executed.
293
+ # @return [::Array<::GRPC::ClientInterceptor>]
294
+ # @!attribute [rw] timeout
295
+ # The call timeout in seconds.
296
+ # @return [::Numeric]
297
+ # @!attribute [rw] metadata
298
+ # Additional gRPC headers to be sent with the call.
299
+ # @return [::Hash{::Symbol=>::String}]
300
+ # @!attribute [rw] retry_policy
301
+ # The retry policy. The value is a hash with the following keys:
302
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
303
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
304
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
305
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
306
+ # trigger a retry.
307
+ # @return [::Hash]
308
+ # @!attribute [rw] quota_project
309
+ # A separate project against which to charge quota.
310
+ # @return [::String]
311
+ #
312
+ class Configuration
313
+ extend ::Gapic::Config
314
+
315
+ DEFAULT_ENDPOINT = "policytroubleshooter.googleapis.com"
316
+
317
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
318
+ config_attr :credentials, nil do |value|
319
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
320
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
321
+ allowed.any? { |klass| klass === value }
322
+ end
323
+ config_attr :scope, nil, ::String, ::Array, nil
324
+ config_attr :lib_name, nil, ::String, nil
325
+ config_attr :lib_version, nil, ::String, nil
326
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
327
+ config_attr :interceptors, nil, ::Array, nil
328
+ config_attr :timeout, nil, ::Numeric, nil
329
+ config_attr :metadata, nil, ::Hash, nil
330
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
331
+ config_attr :quota_project, nil, ::String, nil
332
+
333
+ # @private
334
+ def initialize parent_config = nil
335
+ @parent_config = parent_config unless parent_config.nil?
336
+
337
+ yield self if block_given?
338
+ end
339
+
340
+ ##
341
+ # Configurations for individual RPCs
342
+ # @return [Rpcs]
343
+ #
344
+ def rpcs
345
+ @rpcs ||= begin
346
+ parent_rpcs = nil
347
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
348
+ Rpcs.new parent_rpcs
349
+ end
350
+ end
351
+
352
+ ##
353
+ # Configuration RPC class for the PolicyTroubleshooter API.
354
+ #
355
+ # Includes fields providing the configuration for each RPC in this service.
356
+ # Each configuration object is of type `Gapic::Config::Method` and includes
357
+ # the following configuration fields:
358
+ #
359
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
360
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
361
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
362
+ # include the following keys:
363
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
364
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
365
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
366
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
367
+ # trigger a retry.
368
+ #
369
+ class Rpcs
370
+ ##
371
+ # RPC-specific configuration for `troubleshoot_iam_policy`
372
+ # @return [::Gapic::Config::Method]
373
+ #
374
+ attr_reader :troubleshoot_iam_policy
375
+
376
+ # @private
377
+ def initialize parent_rpcs = nil
378
+ troubleshoot_iam_policy_config = parent_rpcs.troubleshoot_iam_policy if parent_rpcs.respond_to? :troubleshoot_iam_policy
379
+ @troubleshoot_iam_policy = ::Gapic::Config::Method.new troubleshoot_iam_policy_config
380
+
381
+ yield self if block_given?
382
+ end
383
+ end
384
+ end
385
+ end
386
+ end
387
+ end
388
+ end
389
+ end
390
+ end
391
+ 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