google-cloud-policy_simulator-v1 0.a → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) 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_simulator/v1/rest.rb +37 -0
  6. data/lib/google/cloud/policy_simulator/v1/simulator/client.rb +660 -0
  7. data/lib/google/cloud/policy_simulator/v1/simulator/credentials.rb +47 -0
  8. data/lib/google/cloud/policy_simulator/v1/simulator/operations.rb +770 -0
  9. data/lib/google/cloud/policy_simulator/v1/simulator/paths.rb +91 -0
  10. data/lib/google/cloud/policy_simulator/v1/simulator/rest/client.rb +560 -0
  11. data/lib/google/cloud/policy_simulator/v1/simulator/rest/operations.rb +837 -0
  12. data/lib/google/cloud/policy_simulator/v1/simulator/rest/service_stub.rb +270 -0
  13. data/lib/google/cloud/policy_simulator/v1/simulator/rest.rb +64 -0
  14. data/lib/google/cloud/policy_simulator/v1/simulator.rb +67 -0
  15. data/lib/google/cloud/policy_simulator/v1/version.rb +7 -2
  16. data/lib/google/cloud/policy_simulator/v1.rb +45 -0
  17. data/lib/google/cloud/policysimulator/v1/explanations_pb.rb +55 -0
  18. data/lib/google/cloud/policysimulator/v1/simulator_pb.rb +72 -0
  19. data/lib/google/cloud/policysimulator/v1/simulator_services_pb.rb +63 -0
  20. data/lib/google-cloud-policy_simulator-v1.rb +21 -0
  21. data/proto_docs/README.md +4 -0
  22. data/proto_docs/google/api/client.rb +381 -0
  23. data/proto_docs/google/api/field_behavior.rb +71 -0
  24. data/proto_docs/google/api/launch_stage.rb +71 -0
  25. data/proto_docs/google/api/resource.rb +222 -0
  26. data/proto_docs/google/cloud/policysimulator/v1/explanations.rb +277 -0
  27. data/proto_docs/google/cloud/policysimulator/v1/simulator.rb +396 -0
  28. data/proto_docs/google/iam/v1/policy.rb +422 -0
  29. data/proto_docs/google/longrunning/operations.rb +164 -0
  30. data/proto_docs/google/protobuf/any.rb +144 -0
  31. data/proto_docs/google/protobuf/duration.rb +98 -0
  32. data/proto_docs/google/protobuf/empty.rb +34 -0
  33. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  34. data/proto_docs/google/rpc/status.rb +48 -0
  35. data/proto_docs/google/type/date.rb +53 -0
  36. data/proto_docs/google/type/expr.rb +75 -0
  37. metadata +215 -12
@@ -0,0 +1,660 @@
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/policysimulator/v1/simulator_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PolicySimulator
25
+ module V1
26
+ module Simulator
27
+ ##
28
+ # Client for the Simulator service.
29
+ #
30
+ # Policy Simulator API service.
31
+ #
32
+ # Policy Simulator is a collection of endpoints for creating, running, and
33
+ # viewing a {::Google::Cloud::PolicySimulator::V1::Replay Replay}. A
34
+ # {::Google::Cloud::PolicySimulator::V1::Replay Replay} is a type of simulation that
35
+ # lets you see how your principals' access to resources might change if you
36
+ # changed your IAM policy.
37
+ #
38
+ # During a {::Google::Cloud::PolicySimulator::V1::Replay Replay}, Policy Simulator
39
+ # re-evaluates, or replays, past access attempts under both the current policy
40
+ # and your proposed policy, and compares those results to determine how your
41
+ # principals' access might change under the proposed policy.
42
+ #
43
+ class Client
44
+ include Paths
45
+
46
+ # @private
47
+ attr_reader :simulator_stub
48
+
49
+ ##
50
+ # Configure the Simulator Client class.
51
+ #
52
+ # See {::Google::Cloud::PolicySimulator::V1::Simulator::Client::Configuration}
53
+ # for a description of the configuration fields.
54
+ #
55
+ # @example
56
+ #
57
+ # # Modify the configuration for all Simulator clients
58
+ # ::Google::Cloud::PolicySimulator::V1::Simulator::Client.configure do |config|
59
+ # config.timeout = 10.0
60
+ # end
61
+ #
62
+ # @yield [config] Configure the Client client.
63
+ # @yieldparam config [Client::Configuration]
64
+ #
65
+ # @return [Client::Configuration]
66
+ #
67
+ def self.configure
68
+ @configure ||= begin
69
+ namespace = ["Google", "Cloud", "PolicySimulator", "V1"]
70
+ parent_config = while namespace.any?
71
+ parent_name = namespace.join "::"
72
+ parent_const = const_get parent_name
73
+ break parent_const.configure if parent_const.respond_to? :configure
74
+ namespace.pop
75
+ end
76
+ default_config = Client::Configuration.new parent_config
77
+
78
+ default_config.rpcs.get_replay.timeout = 60.0
79
+ default_config.rpcs.get_replay.retry_policy = {
80
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
81
+ }
82
+
83
+ default_config.rpcs.create_replay.timeout = 60.0
84
+
85
+ default_config.rpcs.list_replay_results.timeout = 60.0
86
+ default_config.rpcs.list_replay_results.retry_policy = {
87
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
88
+ }
89
+
90
+ default_config
91
+ end
92
+ yield @configure if block_given?
93
+ @configure
94
+ end
95
+
96
+ ##
97
+ # Configure the Simulator Client instance.
98
+ #
99
+ # The configuration is set to the derived mode, meaning that values can be changed,
100
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
101
+ # should be made on {Client.configure}.
102
+ #
103
+ # See {::Google::Cloud::PolicySimulator::V1::Simulator::Client::Configuration}
104
+ # for a description of the configuration fields.
105
+ #
106
+ # @yield [config] Configure the Client client.
107
+ # @yieldparam config [Client::Configuration]
108
+ #
109
+ # @return [Client::Configuration]
110
+ #
111
+ def configure
112
+ yield @config if block_given?
113
+ @config
114
+ end
115
+
116
+ ##
117
+ # Create a new Simulator client object.
118
+ #
119
+ # @example
120
+ #
121
+ # # Create a client using the default configuration
122
+ # client = ::Google::Cloud::PolicySimulator::V1::Simulator::Client.new
123
+ #
124
+ # # Create a client using a custom configuration
125
+ # client = ::Google::Cloud::PolicySimulator::V1::Simulator::Client.new do |config|
126
+ # config.timeout = 10.0
127
+ # end
128
+ #
129
+ # @yield [config] Configure the Simulator client.
130
+ # @yieldparam config [Client::Configuration]
131
+ #
132
+ def initialize
133
+ # These require statements are intentionally placed here to initialize
134
+ # the gRPC module only when it's required.
135
+ # See https://github.com/googleapis/toolkit/issues/446
136
+ require "gapic/grpc"
137
+ require "google/cloud/policysimulator/v1/simulator_services_pb"
138
+
139
+ # Create the configuration object
140
+ @config = Configuration.new Client.configure
141
+
142
+ # Yield the configuration if needed
143
+ yield @config if block_given?
144
+
145
+ # Create credentials
146
+ credentials = @config.credentials
147
+ # Use self-signed JWT if the endpoint is unchanged from default,
148
+ # but only if the default endpoint does not have a region prefix.
149
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
150
+ !@config.endpoint.split(".").first.include?("-")
151
+ credentials ||= Credentials.default scope: @config.scope,
152
+ enable_self_signed_jwt: enable_self_signed_jwt
153
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
154
+ credentials = Credentials.new credentials, scope: @config.scope
155
+ end
156
+ @quota_project_id = @config.quota_project
157
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
158
+
159
+ @operations_client = Operations.new do |config|
160
+ config.credentials = credentials
161
+ config.quota_project = @quota_project_id
162
+ config.endpoint = @config.endpoint
163
+ end
164
+
165
+ @simulator_stub = ::Gapic::ServiceStub.new(
166
+ ::Google::Cloud::PolicySimulator::V1::Simulator::Stub,
167
+ credentials: credentials,
168
+ endpoint: @config.endpoint,
169
+ channel_args: @config.channel_args,
170
+ interceptors: @config.interceptors
171
+ )
172
+ end
173
+
174
+ ##
175
+ # Get the associated client for long-running operations.
176
+ #
177
+ # @return [::Google::Cloud::PolicySimulator::V1::Simulator::Operations]
178
+ #
179
+ attr_reader :operations_client
180
+
181
+ # Service calls
182
+
183
+ ##
184
+ # Gets the specified {::Google::Cloud::PolicySimulator::V1::Replay Replay}. Each
185
+ # `Replay` is available for at least 7 days.
186
+ #
187
+ # @overload get_replay(request, options = nil)
188
+ # Pass arguments to `get_replay` via a request object, either of type
189
+ # {::Google::Cloud::PolicySimulator::V1::GetReplayRequest} or an equivalent Hash.
190
+ #
191
+ # @param request [::Google::Cloud::PolicySimulator::V1::GetReplayRequest, ::Hash]
192
+ # A request object representing the call parameters. Required. To specify no
193
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
194
+ # @param options [::Gapic::CallOptions, ::Hash]
195
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
196
+ #
197
+ # @overload get_replay(name: nil)
198
+ # Pass arguments to `get_replay` via keyword arguments. Note that at
199
+ # least one keyword argument is required. To specify no parameters, or to keep all
200
+ # the default parameter values, pass an empty Hash as a request object (see above).
201
+ #
202
+ # @param name [::String]
203
+ # Required. The name of the {::Google::Cloud::PolicySimulator::V1::Replay Replay}
204
+ # to retrieve, in the following format:
205
+ #
206
+ # `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`,
207
+ # where `{resource-id}` is the ID of the project, folder, or organization
208
+ # that owns the `Replay`.
209
+ #
210
+ # Example:
211
+ # `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
212
+ #
213
+ # @yield [response, operation] Access the result along with the RPC operation
214
+ # @yieldparam response [::Google::Cloud::PolicySimulator::V1::Replay]
215
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
216
+ #
217
+ # @return [::Google::Cloud::PolicySimulator::V1::Replay]
218
+ #
219
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
220
+ #
221
+ # @example Basic example
222
+ # require "google/cloud/policy_simulator/v1"
223
+ #
224
+ # # Create a client object. The client can be reused for multiple calls.
225
+ # client = Google::Cloud::PolicySimulator::V1::Simulator::Client.new
226
+ #
227
+ # # Create a request. To set request fields, pass in keyword arguments.
228
+ # request = Google::Cloud::PolicySimulator::V1::GetReplayRequest.new
229
+ #
230
+ # # Call the get_replay method.
231
+ # result = client.get_replay request
232
+ #
233
+ # # The returned object is of type Google::Cloud::PolicySimulator::V1::Replay.
234
+ # p result
235
+ #
236
+ def get_replay request, options = nil
237
+ raise ::ArgumentError, "request must be provided" if request.nil?
238
+
239
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::GetReplayRequest
240
+
241
+ # Converts hash and nil to an options object
242
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
243
+
244
+ # Customize the options with defaults
245
+ metadata = @config.rpcs.get_replay.metadata.to_h
246
+
247
+ # Set x-goog-api-client and x-goog-user-project headers
248
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
249
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
250
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION
251
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
252
+
253
+ header_params = {}
254
+ if request.name
255
+ header_params["name"] = request.name
256
+ end
257
+
258
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
259
+ metadata[:"x-goog-request-params"] ||= request_params_header
260
+
261
+ options.apply_defaults timeout: @config.rpcs.get_replay.timeout,
262
+ metadata: metadata,
263
+ retry_policy: @config.rpcs.get_replay.retry_policy
264
+
265
+ options.apply_defaults timeout: @config.timeout,
266
+ metadata: @config.metadata,
267
+ retry_policy: @config.retry_policy
268
+
269
+ @simulator_stub.call_rpc :get_replay, request, options: options do |response, operation|
270
+ yield response, operation if block_given?
271
+ return response
272
+ end
273
+ rescue ::GRPC::BadStatus => e
274
+ raise ::Google::Cloud::Error.from_error(e)
275
+ end
276
+
277
+ ##
278
+ # Creates and starts a {::Google::Cloud::PolicySimulator::V1::Replay Replay} using
279
+ # the given {::Google::Cloud::PolicySimulator::V1::ReplayConfig ReplayConfig}.
280
+ #
281
+ # @overload create_replay(request, options = nil)
282
+ # Pass arguments to `create_replay` via a request object, either of type
283
+ # {::Google::Cloud::PolicySimulator::V1::CreateReplayRequest} or an equivalent Hash.
284
+ #
285
+ # @param request [::Google::Cloud::PolicySimulator::V1::CreateReplayRequest, ::Hash]
286
+ # A request object representing the call parameters. Required. To specify no
287
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
288
+ # @param options [::Gapic::CallOptions, ::Hash]
289
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
290
+ #
291
+ # @overload create_replay(parent: nil, replay: nil)
292
+ # Pass arguments to `create_replay` via keyword arguments. Note that at
293
+ # least one keyword argument is required. To specify no parameters, or to keep all
294
+ # the default parameter values, pass an empty Hash as a request object (see above).
295
+ #
296
+ # @param parent [::String]
297
+ # Required. The parent resource where this
298
+ # {::Google::Cloud::PolicySimulator::V1::Replay Replay} will be created. This
299
+ # resource must be a project, folder, or organization with a location.
300
+ #
301
+ # Example: `projects/my-example-project/locations/global`
302
+ # @param replay [::Google::Cloud::PolicySimulator::V1::Replay, ::Hash]
303
+ # Required. The {::Google::Cloud::PolicySimulator::V1::Replay Replay} to create.
304
+ # Set `Replay.ReplayConfig` to configure the replay.
305
+ #
306
+ # @yield [response, operation] Access the result along with the RPC operation
307
+ # @yieldparam response [::Gapic::Operation]
308
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
309
+ #
310
+ # @return [::Gapic::Operation]
311
+ #
312
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
313
+ #
314
+ # @example Basic example
315
+ # require "google/cloud/policy_simulator/v1"
316
+ #
317
+ # # Create a client object. The client can be reused for multiple calls.
318
+ # client = Google::Cloud::PolicySimulator::V1::Simulator::Client.new
319
+ #
320
+ # # Create a request. To set request fields, pass in keyword arguments.
321
+ # request = Google::Cloud::PolicySimulator::V1::CreateReplayRequest.new
322
+ #
323
+ # # Call the create_replay method.
324
+ # result = client.create_replay request
325
+ #
326
+ # # The returned object is of type Gapic::Operation. You can use it to
327
+ # # check the status of an operation, cancel it, or wait for results.
328
+ # # Here is how to wait for a response.
329
+ # result.wait_until_done! timeout: 60
330
+ # if result.response?
331
+ # p result.response
332
+ # else
333
+ # puts "No response received."
334
+ # end
335
+ #
336
+ def create_replay request, options = nil
337
+ raise ::ArgumentError, "request must be provided" if request.nil?
338
+
339
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::CreateReplayRequest
340
+
341
+ # Converts hash and nil to an options object
342
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
343
+
344
+ # Customize the options with defaults
345
+ metadata = @config.rpcs.create_replay.metadata.to_h
346
+
347
+ # Set x-goog-api-client and x-goog-user-project headers
348
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
349
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
350
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION
351
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
352
+
353
+ header_params = {}
354
+ if request.parent
355
+ header_params["parent"] = request.parent
356
+ end
357
+
358
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
359
+ metadata[:"x-goog-request-params"] ||= request_params_header
360
+
361
+ options.apply_defaults timeout: @config.rpcs.create_replay.timeout,
362
+ metadata: metadata,
363
+ retry_policy: @config.rpcs.create_replay.retry_policy
364
+
365
+ options.apply_defaults timeout: @config.timeout,
366
+ metadata: @config.metadata,
367
+ retry_policy: @config.retry_policy
368
+
369
+ @simulator_stub.call_rpc :create_replay, request, options: options do |response, operation|
370
+ response = ::Gapic::Operation.new response, @operations_client, options: options
371
+ yield response, operation if block_given?
372
+ return response
373
+ end
374
+ rescue ::GRPC::BadStatus => e
375
+ raise ::Google::Cloud::Error.from_error(e)
376
+ end
377
+
378
+ ##
379
+ # Lists the results of running a
380
+ # {::Google::Cloud::PolicySimulator::V1::Replay Replay}.
381
+ #
382
+ # @overload list_replay_results(request, options = nil)
383
+ # Pass arguments to `list_replay_results` via a request object, either of type
384
+ # {::Google::Cloud::PolicySimulator::V1::ListReplayResultsRequest} or an equivalent Hash.
385
+ #
386
+ # @param request [::Google::Cloud::PolicySimulator::V1::ListReplayResultsRequest, ::Hash]
387
+ # A request object representing the call parameters. Required. To specify no
388
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
389
+ # @param options [::Gapic::CallOptions, ::Hash]
390
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
391
+ #
392
+ # @overload list_replay_results(parent: nil, page_size: nil, page_token: nil)
393
+ # Pass arguments to `list_replay_results` via keyword arguments. Note that at
394
+ # least one keyword argument is required. To specify no parameters, or to keep all
395
+ # the default parameter values, pass an empty Hash as a request object (see above).
396
+ #
397
+ # @param parent [::String]
398
+ # Required. The {::Google::Cloud::PolicySimulator::V1::Replay Replay} whose
399
+ # results are listed, in the following format:
400
+ #
401
+ # `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`
402
+ #
403
+ # Example:
404
+ # `projects/my-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
405
+ # @param page_size [::Integer]
406
+ # The maximum number of
407
+ # {::Google::Cloud::PolicySimulator::V1::ReplayResult ReplayResult} objects to
408
+ # return. Defaults to 5000.
409
+ #
410
+ # The maximum value is 5000; values above 5000 are rounded down to 5000.
411
+ # @param page_token [::String]
412
+ # A page token, received from a previous
413
+ # {::Google::Cloud::PolicySimulator::V1::Simulator::Client#list_replay_results Simulator.ListReplayResults}
414
+ # call. Provide this token to retrieve the next page of results.
415
+ #
416
+ # When paginating, all other parameters provided to
417
+ # [Simulator.ListReplayResults[] must match the call that provided the page
418
+ # token.
419
+ #
420
+ # @yield [response, operation] Access the result along with the RPC operation
421
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>]
422
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
423
+ #
424
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>]
425
+ #
426
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
427
+ #
428
+ # @example Basic example
429
+ # require "google/cloud/policy_simulator/v1"
430
+ #
431
+ # # Create a client object. The client can be reused for multiple calls.
432
+ # client = Google::Cloud::PolicySimulator::V1::Simulator::Client.new
433
+ #
434
+ # # Create a request. To set request fields, pass in keyword arguments.
435
+ # request = Google::Cloud::PolicySimulator::V1::ListReplayResultsRequest.new
436
+ #
437
+ # # Call the list_replay_results method.
438
+ # result = client.list_replay_results request
439
+ #
440
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
441
+ # # over elements, and API calls will be issued to fetch pages as needed.
442
+ # result.each do |item|
443
+ # # Each element is of type ::Google::Cloud::PolicySimulator::V1::ReplayResult.
444
+ # p item
445
+ # end
446
+ #
447
+ def list_replay_results request, options = nil
448
+ raise ::ArgumentError, "request must be provided" if request.nil?
449
+
450
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::ListReplayResultsRequest
451
+
452
+ # Converts hash and nil to an options object
453
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
454
+
455
+ # Customize the options with defaults
456
+ metadata = @config.rpcs.list_replay_results.metadata.to_h
457
+
458
+ # Set x-goog-api-client and x-goog-user-project headers
459
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
460
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
461
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION
462
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
463
+
464
+ header_params = {}
465
+ if request.parent
466
+ header_params["parent"] = request.parent
467
+ end
468
+
469
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
470
+ metadata[:"x-goog-request-params"] ||= request_params_header
471
+
472
+ options.apply_defaults timeout: @config.rpcs.list_replay_results.timeout,
473
+ metadata: metadata,
474
+ retry_policy: @config.rpcs.list_replay_results.retry_policy
475
+
476
+ options.apply_defaults timeout: @config.timeout,
477
+ metadata: @config.metadata,
478
+ retry_policy: @config.retry_policy
479
+
480
+ @simulator_stub.call_rpc :list_replay_results, request, options: options do |response, operation|
481
+ response = ::Gapic::PagedEnumerable.new @simulator_stub, :list_replay_results, request, response, operation, options
482
+ yield response, operation if block_given?
483
+ return response
484
+ end
485
+ rescue ::GRPC::BadStatus => e
486
+ raise ::Google::Cloud::Error.from_error(e)
487
+ end
488
+
489
+ ##
490
+ # Configuration class for the Simulator API.
491
+ #
492
+ # This class represents the configuration for Simulator,
493
+ # providing control over timeouts, retry behavior, logging, transport
494
+ # parameters, and other low-level controls. Certain parameters can also be
495
+ # applied individually to specific RPCs. See
496
+ # {::Google::Cloud::PolicySimulator::V1::Simulator::Client::Configuration::Rpcs}
497
+ # for a list of RPCs that can be configured independently.
498
+ #
499
+ # Configuration can be applied globally to all clients, or to a single client
500
+ # on construction.
501
+ #
502
+ # @example
503
+ #
504
+ # # Modify the global config, setting the timeout for
505
+ # # get_replay to 20 seconds,
506
+ # # and all remaining timeouts to 10 seconds.
507
+ # ::Google::Cloud::PolicySimulator::V1::Simulator::Client.configure do |config|
508
+ # config.timeout = 10.0
509
+ # config.rpcs.get_replay.timeout = 20.0
510
+ # end
511
+ #
512
+ # # Apply the above configuration only to a new client.
513
+ # client = ::Google::Cloud::PolicySimulator::V1::Simulator::Client.new do |config|
514
+ # config.timeout = 10.0
515
+ # config.rpcs.get_replay.timeout = 20.0
516
+ # end
517
+ #
518
+ # @!attribute [rw] endpoint
519
+ # The hostname or hostname:port of the service endpoint.
520
+ # Defaults to `"policysimulator.googleapis.com"`.
521
+ # @return [::String]
522
+ # @!attribute [rw] credentials
523
+ # Credentials to send with calls. You may provide any of the following types:
524
+ # * (`String`) The path to a service account key file in JSON format
525
+ # * (`Hash`) A service account key as a Hash
526
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
527
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
528
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
529
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
530
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
531
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
532
+ # * (`nil`) indicating no credentials
533
+ # @return [::Object]
534
+ # @!attribute [rw] scope
535
+ # The OAuth scopes
536
+ # @return [::Array<::String>]
537
+ # @!attribute [rw] lib_name
538
+ # The library name as recorded in instrumentation and logging
539
+ # @return [::String]
540
+ # @!attribute [rw] lib_version
541
+ # The library version as recorded in instrumentation and logging
542
+ # @return [::String]
543
+ # @!attribute [rw] channel_args
544
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
545
+ # `GRPC::Core::Channel` object is provided as the credential.
546
+ # @return [::Hash]
547
+ # @!attribute [rw] interceptors
548
+ # An array of interceptors that are run before calls are executed.
549
+ # @return [::Array<::GRPC::ClientInterceptor>]
550
+ # @!attribute [rw] timeout
551
+ # The call timeout in seconds.
552
+ # @return [::Numeric]
553
+ # @!attribute [rw] metadata
554
+ # Additional gRPC headers to be sent with the call.
555
+ # @return [::Hash{::Symbol=>::String}]
556
+ # @!attribute [rw] retry_policy
557
+ # The retry policy. The value is a hash with the following keys:
558
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
559
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
560
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
561
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
562
+ # trigger a retry.
563
+ # @return [::Hash]
564
+ # @!attribute [rw] quota_project
565
+ # A separate project against which to charge quota.
566
+ # @return [::String]
567
+ #
568
+ class Configuration
569
+ extend ::Gapic::Config
570
+
571
+ DEFAULT_ENDPOINT = "policysimulator.googleapis.com"
572
+
573
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
574
+ config_attr :credentials, nil do |value|
575
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
576
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
577
+ allowed.any? { |klass| klass === value }
578
+ end
579
+ config_attr :scope, nil, ::String, ::Array, nil
580
+ config_attr :lib_name, nil, ::String, nil
581
+ config_attr :lib_version, nil, ::String, nil
582
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
583
+ config_attr :interceptors, nil, ::Array, nil
584
+ config_attr :timeout, nil, ::Numeric, nil
585
+ config_attr :metadata, nil, ::Hash, nil
586
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
587
+ config_attr :quota_project, nil, ::String, nil
588
+
589
+ # @private
590
+ def initialize parent_config = nil
591
+ @parent_config = parent_config unless parent_config.nil?
592
+
593
+ yield self if block_given?
594
+ end
595
+
596
+ ##
597
+ # Configurations for individual RPCs
598
+ # @return [Rpcs]
599
+ #
600
+ def rpcs
601
+ @rpcs ||= begin
602
+ parent_rpcs = nil
603
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
604
+ Rpcs.new parent_rpcs
605
+ end
606
+ end
607
+
608
+ ##
609
+ # Configuration RPC class for the Simulator API.
610
+ #
611
+ # Includes fields providing the configuration for each RPC in this service.
612
+ # Each configuration object is of type `Gapic::Config::Method` and includes
613
+ # the following configuration fields:
614
+ #
615
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
616
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
617
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
618
+ # include the following keys:
619
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
620
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
621
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
622
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
623
+ # trigger a retry.
624
+ #
625
+ class Rpcs
626
+ ##
627
+ # RPC-specific configuration for `get_replay`
628
+ # @return [::Gapic::Config::Method]
629
+ #
630
+ attr_reader :get_replay
631
+ ##
632
+ # RPC-specific configuration for `create_replay`
633
+ # @return [::Gapic::Config::Method]
634
+ #
635
+ attr_reader :create_replay
636
+ ##
637
+ # RPC-specific configuration for `list_replay_results`
638
+ # @return [::Gapic::Config::Method]
639
+ #
640
+ attr_reader :list_replay_results
641
+
642
+ # @private
643
+ def initialize parent_rpcs = nil
644
+ get_replay_config = parent_rpcs.get_replay if parent_rpcs.respond_to? :get_replay
645
+ @get_replay = ::Gapic::Config::Method.new get_replay_config
646
+ create_replay_config = parent_rpcs.create_replay if parent_rpcs.respond_to? :create_replay
647
+ @create_replay = ::Gapic::Config::Method.new create_replay_config
648
+ list_replay_results_config = parent_rpcs.list_replay_results if parent_rpcs.respond_to? :list_replay_results
649
+ @list_replay_results = ::Gapic::Config::Method.new list_replay_results_config
650
+
651
+ yield self if block_given?
652
+ end
653
+ end
654
+ end
655
+ end
656
+ end
657
+ end
658
+ end
659
+ end
660
+ end