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