google-cloud-policy_simulator-v1 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/client.rb +848 -0
  5. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/credentials.rb +47 -0
  6. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/operations.rb +813 -0
  7. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/paths.rb +138 -0
  8. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/rest/client.rb +794 -0
  9. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/rest/operations.rb +998 -0
  10. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/rest/service_stub.rb +326 -0
  11. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service/rest.rb +63 -0
  12. data/lib/google/cloud/policy_simulator/v1/org_policy_violations_preview_service.rb +66 -0
  13. data/lib/google/cloud/policy_simulator/v1/rest.rb +2 -1
  14. data/lib/google/cloud/policy_simulator/v1/simulator/rest/operations.rb +42 -0
  15. data/lib/google/cloud/policy_simulator/v1/version.rb +1 -1
  16. data/lib/google/cloud/policy_simulator/v1.rb +3 -2
  17. data/lib/google/cloud/policysimulator/v1/explanations_pb.rb +1 -1
  18. data/lib/google/cloud/policysimulator/v1/orgpolicy_pb.rb +70 -0
  19. data/lib/google/cloud/policysimulator/v1/orgpolicy_services_pb.rb +76 -0
  20. data/lib/google/cloud/policysimulator/v1/simulator_pb.rb +1 -1
  21. data/proto_docs/google/cloud/orgpolicy/v2/constraint.rb +370 -0
  22. data/proto_docs/google/cloud/orgpolicy/v2/orgpolicy.rb +454 -0
  23. data/proto_docs/google/cloud/policysimulator/v1/explanations.rb +3 -3
  24. data/proto_docs/google/cloud/policysimulator/v1/orgpolicy.rb +380 -0
  25. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  26. data/proto_docs/google/protobuf/struct.rb +108 -0
  27. metadata +32 -2
@@ -0,0 +1,794 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/orgpolicy_pb"
21
+ require "google/cloud/policy_simulator/v1/org_policy_violations_preview_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module PolicySimulator
26
+ module V1
27
+ module OrgPolicyViolationsPreviewService
28
+ module Rest
29
+ ##
30
+ # REST client for the OrgPolicyViolationsPreviewService service.
31
+ #
32
+ # Violations Preview API service for OrgPolicy.
33
+ #
34
+ # An
35
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
36
+ # is a preview of the violations that will exist as soon as a proposed
37
+ # OrgPolicy change is submitted. To create an
38
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview},
39
+ # the API user specifies the changes they wish to make and requests the
40
+ # generation of a preview via [GenerateViolationsPreview][]. the OrgPolicy
41
+ # Simulator service then scans the API user's currently existing resources to
42
+ # determine these resources violate the newly set OrgPolicy.
43
+ #
44
+ class Client
45
+ # @private
46
+ API_VERSION = ""
47
+
48
+ # @private
49
+ DEFAULT_ENDPOINT_TEMPLATE = "policysimulator.$UNIVERSE_DOMAIN$"
50
+
51
+ include Paths
52
+
53
+ # @private
54
+ attr_reader :org_policy_violations_preview_service_stub
55
+
56
+ ##
57
+ # Configure the OrgPolicyViolationsPreviewService Client class.
58
+ #
59
+ # See {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client::Configuration}
60
+ # for a description of the configuration fields.
61
+ #
62
+ # @example
63
+ #
64
+ # # Modify the configuration for all OrgPolicyViolationsPreviewService clients
65
+ # ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.configure do |config|
66
+ # config.timeout = 10.0
67
+ # end
68
+ #
69
+ # @yield [config] Configure the Client client.
70
+ # @yieldparam config [Client::Configuration]
71
+ #
72
+ # @return [Client::Configuration]
73
+ #
74
+ def self.configure
75
+ @configure ||= begin
76
+ namespace = ["Google", "Cloud", "PolicySimulator", "V1"]
77
+ parent_config = while namespace.any?
78
+ parent_name = namespace.join "::"
79
+ parent_const = const_get parent_name
80
+ break parent_const.configure if parent_const.respond_to? :configure
81
+ namespace.pop
82
+ end
83
+ default_config = Client::Configuration.new parent_config
84
+
85
+ default_config.rpcs.list_org_policy_violations_previews.timeout = 60.0
86
+ default_config.rpcs.list_org_policy_violations_previews.retry_policy = {
87
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
88
+ }
89
+
90
+ default_config.rpcs.get_org_policy_violations_preview.timeout = 60.0
91
+ default_config.rpcs.get_org_policy_violations_preview.retry_policy = {
92
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
93
+ }
94
+
95
+ default_config.rpcs.create_org_policy_violations_preview.timeout = 60.0
96
+
97
+ default_config.rpcs.list_org_policy_violations.timeout = 60.0
98
+ default_config.rpcs.list_org_policy_violations.retry_policy = {
99
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
100
+ }
101
+
102
+ default_config
103
+ end
104
+ yield @configure if block_given?
105
+ @configure
106
+ end
107
+
108
+ ##
109
+ # Configure the OrgPolicyViolationsPreviewService Client instance.
110
+ #
111
+ # The configuration is set to the derived mode, meaning that values can be changed,
112
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
113
+ # should be made on {Client.configure}.
114
+ #
115
+ # See {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client::Configuration}
116
+ # for a description of the configuration fields.
117
+ #
118
+ # @yield [config] Configure the Client client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ # @return [Client::Configuration]
122
+ #
123
+ def configure
124
+ yield @config if block_given?
125
+ @config
126
+ end
127
+
128
+ ##
129
+ # The effective universe domain
130
+ #
131
+ # @return [String]
132
+ #
133
+ def universe_domain
134
+ @org_policy_violations_preview_service_stub.universe_domain
135
+ end
136
+
137
+ ##
138
+ # Create a new OrgPolicyViolationsPreviewService REST client object.
139
+ #
140
+ # @example
141
+ #
142
+ # # Create a client using the default configuration
143
+ # client = ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new
144
+ #
145
+ # # Create a client using a custom configuration
146
+ # client = ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new do |config|
147
+ # config.timeout = 10.0
148
+ # end
149
+ #
150
+ # @yield [config] Configure the OrgPolicyViolationsPreviewService client.
151
+ # @yieldparam config [Client::Configuration]
152
+ #
153
+ def initialize
154
+ # Create the configuration object
155
+ @config = Configuration.new Client.configure
156
+
157
+ # Yield the configuration if needed
158
+ yield @config if block_given?
159
+
160
+ # Create credentials
161
+ credentials = @config.credentials
162
+ # Use self-signed JWT if the endpoint is unchanged from default,
163
+ # but only if the default endpoint does not have a region prefix.
164
+ enable_self_signed_jwt = @config.endpoint.nil? ||
165
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
166
+ !@config.endpoint.split(".").first.include?("-"))
167
+ credentials ||= Credentials.default scope: @config.scope,
168
+ enable_self_signed_jwt: enable_self_signed_jwt
169
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
170
+ credentials = Credentials.new credentials, scope: @config.scope
171
+ end
172
+
173
+ @quota_project_id = @config.quota_project
174
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
175
+
176
+ @operations_client = ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Operations.new do |config|
177
+ config.credentials = credentials
178
+ config.quota_project = @quota_project_id
179
+ config.endpoint = @config.endpoint
180
+ config.universe_domain = @config.universe_domain
181
+ end
182
+
183
+ @org_policy_violations_preview_service_stub = ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::ServiceStub.new(
184
+ endpoint: @config.endpoint,
185
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
186
+ universe_domain: @config.universe_domain,
187
+ credentials: credentials,
188
+ logger: @config.logger
189
+ )
190
+
191
+ @org_policy_violations_preview_service_stub.logger(stub: true)&.info do |entry|
192
+ entry.set_system_name
193
+ entry.set_service
194
+ entry.message = "Created client for #{entry.service}"
195
+ entry.set_credentials_fields credentials
196
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
197
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
198
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
199
+ end
200
+ end
201
+
202
+ ##
203
+ # Get the associated client for long-running operations.
204
+ #
205
+ # @return [::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Operations]
206
+ #
207
+ attr_reader :operations_client
208
+
209
+ ##
210
+ # The logger used for request/response debug logging.
211
+ #
212
+ # @return [Logger]
213
+ #
214
+ def logger
215
+ @org_policy_violations_preview_service_stub.logger
216
+ end
217
+
218
+ # Service calls
219
+
220
+ ##
221
+ # ListOrgPolicyViolationsPreviews lists each
222
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
223
+ # in an organization. Each
224
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
225
+ # is available for at least 7 days.
226
+ #
227
+ # @overload list_org_policy_violations_previews(request, options = nil)
228
+ # Pass arguments to `list_org_policy_violations_previews` via a request object, either of type
229
+ # {::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsPreviewsRequest} or an equivalent Hash.
230
+ #
231
+ # @param request [::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsPreviewsRequest, ::Hash]
232
+ # A request object representing the call parameters. Required. To specify no
233
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
234
+ # @param options [::Gapic::CallOptions, ::Hash]
235
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
236
+ #
237
+ # @overload list_org_policy_violations_previews(parent: nil, page_size: nil, page_token: nil)
238
+ # Pass arguments to `list_org_policy_violations_previews` via keyword arguments. Note that at
239
+ # least one keyword argument is required. To specify no parameters, or to keep all
240
+ # the default parameter values, pass an empty Hash as a request object (see above).
241
+ #
242
+ # @param parent [::String]
243
+ # Required. The parent the violations are scoped to.
244
+ # Format:
245
+ # `organizations/{organization}/locations/{location}`
246
+ #
247
+ # Example: `organizations/my-example-org/locations/global`
248
+ # @param page_size [::Integer]
249
+ # Optional. The maximum number of items to return. The service may return
250
+ # fewer than this value. If unspecified, at most 5 items will be returned.
251
+ # The maximum value is 10; values above 10 will be coerced to 10.
252
+ # @param page_token [::String]
253
+ # Optional. A page token, received from a previous call. Provide this to
254
+ # retrieve the subsequent page.
255
+ #
256
+ # When paginating, all other parameters must match the call that provided the
257
+ # page token.
258
+ # @yield [result, operation] Access the result along with the TransportOperation object
259
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview>]
260
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
261
+ #
262
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview>]
263
+ #
264
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
265
+ #
266
+ # @example Basic example
267
+ # require "google/cloud/policy_simulator/v1"
268
+ #
269
+ # # Create a client object. The client can be reused for multiple calls.
270
+ # client = Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new
271
+ #
272
+ # # Create a request. To set request fields, pass in keyword arguments.
273
+ # request = Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsPreviewsRequest.new
274
+ #
275
+ # # Call the list_org_policy_violations_previews method.
276
+ # result = client.list_org_policy_violations_previews request
277
+ #
278
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
279
+ # # over elements, and API calls will be issued to fetch pages as needed.
280
+ # result.each do |item|
281
+ # # Each element is of type ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview.
282
+ # p item
283
+ # end
284
+ #
285
+ def list_org_policy_violations_previews request, options = nil
286
+ raise ::ArgumentError, "request must be provided" if request.nil?
287
+
288
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsPreviewsRequest
289
+
290
+ # Converts hash and nil to an options object
291
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
292
+
293
+ # Customize the options with defaults
294
+ call_metadata = @config.rpcs.list_org_policy_violations_previews.metadata.to_h
295
+
296
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
297
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
298
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
299
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION,
300
+ transports_version_send: [:rest]
301
+
302
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
303
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
304
+
305
+ options.apply_defaults timeout: @config.rpcs.list_org_policy_violations_previews.timeout,
306
+ metadata: call_metadata,
307
+ retry_policy: @config.rpcs.list_org_policy_violations_previews.retry_policy
308
+
309
+ options.apply_defaults timeout: @config.timeout,
310
+ metadata: @config.metadata,
311
+ retry_policy: @config.retry_policy
312
+
313
+ @org_policy_violations_preview_service_stub.list_org_policy_violations_previews request, options do |result, operation|
314
+ result = ::Gapic::Rest::PagedEnumerable.new @org_policy_violations_preview_service_stub, :list_org_policy_violations_previews, "org_policy_violations_previews", request, result, options
315
+ yield result, operation if block_given?
316
+ throw :response, result
317
+ end
318
+ rescue ::Gapic::Rest::Error => e
319
+ raise ::Google::Cloud::Error.from_error(e)
320
+ end
321
+
322
+ ##
323
+ # GetOrgPolicyViolationsPreview gets the specified
324
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}.
325
+ # Each
326
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
327
+ # is available for at least 7 days.
328
+ #
329
+ # @overload get_org_policy_violations_preview(request, options = nil)
330
+ # Pass arguments to `get_org_policy_violations_preview` via a request object, either of type
331
+ # {::Google::Cloud::PolicySimulator::V1::GetOrgPolicyViolationsPreviewRequest} or an equivalent Hash.
332
+ #
333
+ # @param request [::Google::Cloud::PolicySimulator::V1::GetOrgPolicyViolationsPreviewRequest, ::Hash]
334
+ # A request object representing the call parameters. Required. To specify no
335
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
336
+ # @param options [::Gapic::CallOptions, ::Hash]
337
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
338
+ #
339
+ # @overload get_org_policy_violations_preview(name: nil)
340
+ # Pass arguments to `get_org_policy_violations_preview` via keyword arguments. Note that at
341
+ # least one keyword argument is required. To specify no parameters, or to keep all
342
+ # the default parameter values, pass an empty Hash as a request object (see above).
343
+ #
344
+ # @param name [::String]
345
+ # Required. The name of the OrgPolicyViolationsPreview to get.
346
+ # @yield [result, operation] Access the result along with the TransportOperation object
347
+ # @yieldparam result [::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview]
348
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
349
+ #
350
+ # @return [::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview]
351
+ #
352
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
353
+ #
354
+ # @example Basic example
355
+ # require "google/cloud/policy_simulator/v1"
356
+ #
357
+ # # Create a client object. The client can be reused for multiple calls.
358
+ # client = Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new
359
+ #
360
+ # # Create a request. To set request fields, pass in keyword arguments.
361
+ # request = Google::Cloud::PolicySimulator::V1::GetOrgPolicyViolationsPreviewRequest.new
362
+ #
363
+ # # Call the get_org_policy_violations_preview method.
364
+ # result = client.get_org_policy_violations_preview request
365
+ #
366
+ # # The returned object is of type Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview.
367
+ # p result
368
+ #
369
+ def get_org_policy_violations_preview request, options = nil
370
+ raise ::ArgumentError, "request must be provided" if request.nil?
371
+
372
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::GetOrgPolicyViolationsPreviewRequest
373
+
374
+ # Converts hash and nil to an options object
375
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
376
+
377
+ # Customize the options with defaults
378
+ call_metadata = @config.rpcs.get_org_policy_violations_preview.metadata.to_h
379
+
380
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
381
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
382
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
383
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION,
384
+ transports_version_send: [:rest]
385
+
386
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
387
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
388
+
389
+ options.apply_defaults timeout: @config.rpcs.get_org_policy_violations_preview.timeout,
390
+ metadata: call_metadata,
391
+ retry_policy: @config.rpcs.get_org_policy_violations_preview.retry_policy
392
+
393
+ options.apply_defaults timeout: @config.timeout,
394
+ metadata: @config.metadata,
395
+ retry_policy: @config.retry_policy
396
+
397
+ @org_policy_violations_preview_service_stub.get_org_policy_violations_preview request, options do |result, operation|
398
+ yield result, operation if block_given?
399
+ end
400
+ rescue ::Gapic::Rest::Error => e
401
+ raise ::Google::Cloud::Error.from_error(e)
402
+ end
403
+
404
+ ##
405
+ # CreateOrgPolicyViolationsPreview creates an
406
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
407
+ # for the proposed changes in the provided
408
+ # [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy
409
+ # are specified by this `OrgPolicyOverlay`. The resources to scan are
410
+ # inferred from these specified changes.
411
+ #
412
+ # @overload create_org_policy_violations_preview(request, options = nil)
413
+ # Pass arguments to `create_org_policy_violations_preview` via a request object, either of type
414
+ # {::Google::Cloud::PolicySimulator::V1::CreateOrgPolicyViolationsPreviewRequest} or an equivalent Hash.
415
+ #
416
+ # @param request [::Google::Cloud::PolicySimulator::V1::CreateOrgPolicyViolationsPreviewRequest, ::Hash]
417
+ # A request object representing the call parameters. Required. To specify no
418
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
419
+ # @param options [::Gapic::CallOptions, ::Hash]
420
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
421
+ #
422
+ # @overload create_org_policy_violations_preview(parent: nil, org_policy_violations_preview: nil, org_policy_violations_preview_id: nil)
423
+ # Pass arguments to `create_org_policy_violations_preview` via keyword arguments. Note that at
424
+ # least one keyword argument is required. To specify no parameters, or to keep all
425
+ # the default parameter values, pass an empty Hash as a request object (see above).
426
+ #
427
+ # @param parent [::String]
428
+ # Required. The organization under which this
429
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
430
+ # will be created.
431
+ #
432
+ # Example: `organizations/my-example-org/locations/global`
433
+ # @param org_policy_violations_preview [::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview, ::Hash]
434
+ # Required. The
435
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}
436
+ # to generate.
437
+ # @param org_policy_violations_preview_id [::String]
438
+ # Optional. An optional user-specified ID for the
439
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}.
440
+ # If not provided, a random ID will be generated.
441
+ # @yield [result, operation] Access the result along with the TransportOperation object
442
+ # @yieldparam result [::Gapic::Operation]
443
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
444
+ #
445
+ # @return [::Gapic::Operation]
446
+ #
447
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
448
+ #
449
+ # @example Basic example
450
+ # require "google/cloud/policy_simulator/v1"
451
+ #
452
+ # # Create a client object. The client can be reused for multiple calls.
453
+ # client = Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new
454
+ #
455
+ # # Create a request. To set request fields, pass in keyword arguments.
456
+ # request = Google::Cloud::PolicySimulator::V1::CreateOrgPolicyViolationsPreviewRequest.new
457
+ #
458
+ # # Call the create_org_policy_violations_preview method.
459
+ # result = client.create_org_policy_violations_preview request
460
+ #
461
+ # # The returned object is of type Gapic::Operation. You can use it to
462
+ # # check the status of an operation, cancel it, or wait for results.
463
+ # # Here is how to wait for a response.
464
+ # result.wait_until_done! timeout: 60
465
+ # if result.response?
466
+ # p result.response
467
+ # else
468
+ # puts "No response received."
469
+ # end
470
+ #
471
+ def create_org_policy_violations_preview request, options = nil
472
+ raise ::ArgumentError, "request must be provided" if request.nil?
473
+
474
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::CreateOrgPolicyViolationsPreviewRequest
475
+
476
+ # Converts hash and nil to an options object
477
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
478
+
479
+ # Customize the options with defaults
480
+ call_metadata = @config.rpcs.create_org_policy_violations_preview.metadata.to_h
481
+
482
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
483
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
484
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
485
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION,
486
+ transports_version_send: [:rest]
487
+
488
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
489
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
490
+
491
+ options.apply_defaults timeout: @config.rpcs.create_org_policy_violations_preview.timeout,
492
+ metadata: call_metadata,
493
+ retry_policy: @config.rpcs.create_org_policy_violations_preview.retry_policy
494
+
495
+ options.apply_defaults timeout: @config.timeout,
496
+ metadata: @config.metadata,
497
+ retry_policy: @config.retry_policy
498
+
499
+ @org_policy_violations_preview_service_stub.create_org_policy_violations_preview request, options do |result, operation|
500
+ result = ::Gapic::Operation.new result, @operations_client, options: options
501
+ yield result, operation if block_given?
502
+ throw :response, result
503
+ end
504
+ rescue ::Gapic::Rest::Error => e
505
+ raise ::Google::Cloud::Error.from_error(e)
506
+ end
507
+
508
+ ##
509
+ # ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present
510
+ # in an
511
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview OrgPolicyViolationsPreview}.
512
+ #
513
+ # @overload list_org_policy_violations(request, options = nil)
514
+ # Pass arguments to `list_org_policy_violations` via a request object, either of type
515
+ # {::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsRequest} or an equivalent Hash.
516
+ #
517
+ # @param request [::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsRequest, ::Hash]
518
+ # A request object representing the call parameters. Required. To specify no
519
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
520
+ # @param options [::Gapic::CallOptions, ::Hash]
521
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
522
+ #
523
+ # @overload list_org_policy_violations(parent: nil, page_size: nil, page_token: nil)
524
+ # Pass arguments to `list_org_policy_violations` via keyword arguments. Note that at
525
+ # least one keyword argument is required. To specify no parameters, or to keep all
526
+ # the default parameter values, pass an empty Hash as a request object (see above).
527
+ #
528
+ # @param parent [::String]
529
+ # Required. The OrgPolicyViolationsPreview to get OrgPolicyViolations from.
530
+ # Format:
531
+ # organizations/\\{organization}/locations/\\{location}/orgPolicyViolationsPreviews/\\{orgPolicyViolationsPreview}
532
+ # @param page_size [::Integer]
533
+ # Optional. The maximum number of items to return. The service may return
534
+ # fewer than this value. If unspecified, at most 1000 items will be returned.
535
+ # The maximum value is 1000; values above 1000 will be coerced to 1000.
536
+ # @param page_token [::String]
537
+ # Optional. A page token, received from a previous call. Provide this to
538
+ # retrieve the subsequent page.
539
+ #
540
+ # When paginating, all other parameters must match the call that provided the
541
+ # page token.
542
+ # @yield [result, operation] Access the result along with the TransportOperation object
543
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::OrgPolicyViolation>]
544
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
545
+ #
546
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::OrgPolicyViolation>]
547
+ #
548
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
549
+ #
550
+ # @example Basic example
551
+ # require "google/cloud/policy_simulator/v1"
552
+ #
553
+ # # Create a client object. The client can be reused for multiple calls.
554
+ # client = Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new
555
+ #
556
+ # # Create a request. To set request fields, pass in keyword arguments.
557
+ # request = Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsRequest.new
558
+ #
559
+ # # Call the list_org_policy_violations method.
560
+ # result = client.list_org_policy_violations request
561
+ #
562
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
563
+ # # over elements, and API calls will be issued to fetch pages as needed.
564
+ # result.each do |item|
565
+ # # Each element is of type ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolation.
566
+ # p item
567
+ # end
568
+ #
569
+ def list_org_policy_violations request, options = nil
570
+ raise ::ArgumentError, "request must be provided" if request.nil?
571
+
572
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PolicySimulator::V1::ListOrgPolicyViolationsRequest
573
+
574
+ # Converts hash and nil to an options object
575
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
576
+
577
+ # Customize the options with defaults
578
+ call_metadata = @config.rpcs.list_org_policy_violations.metadata.to_h
579
+
580
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
581
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
582
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
583
+ gapic_version: ::Google::Cloud::PolicySimulator::V1::VERSION,
584
+ transports_version_send: [:rest]
585
+
586
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
587
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
588
+
589
+ options.apply_defaults timeout: @config.rpcs.list_org_policy_violations.timeout,
590
+ metadata: call_metadata,
591
+ retry_policy: @config.rpcs.list_org_policy_violations.retry_policy
592
+
593
+ options.apply_defaults timeout: @config.timeout,
594
+ metadata: @config.metadata,
595
+ retry_policy: @config.retry_policy
596
+
597
+ @org_policy_violations_preview_service_stub.list_org_policy_violations request, options do |result, operation|
598
+ result = ::Gapic::Rest::PagedEnumerable.new @org_policy_violations_preview_service_stub, :list_org_policy_violations, "org_policy_violations", request, result, options
599
+ yield result, operation if block_given?
600
+ throw :response, result
601
+ end
602
+ rescue ::Gapic::Rest::Error => e
603
+ raise ::Google::Cloud::Error.from_error(e)
604
+ end
605
+
606
+ ##
607
+ # Configuration class for the OrgPolicyViolationsPreviewService REST API.
608
+ #
609
+ # This class represents the configuration for OrgPolicyViolationsPreviewService REST,
610
+ # providing control over timeouts, retry behavior, logging, transport
611
+ # parameters, and other low-level controls. Certain parameters can also be
612
+ # applied individually to specific RPCs. See
613
+ # {::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client::Configuration::Rpcs}
614
+ # for a list of RPCs that can be configured independently.
615
+ #
616
+ # Configuration can be applied globally to all clients, or to a single client
617
+ # on construction.
618
+ #
619
+ # @example
620
+ #
621
+ # # Modify the global config, setting the timeout for
622
+ # # list_org_policy_violations_previews to 20 seconds,
623
+ # # and all remaining timeouts to 10 seconds.
624
+ # ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.configure do |config|
625
+ # config.timeout = 10.0
626
+ # config.rpcs.list_org_policy_violations_previews.timeout = 20.0
627
+ # end
628
+ #
629
+ # # Apply the above configuration only to a new client.
630
+ # client = ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreviewService::Rest::Client.new do |config|
631
+ # config.timeout = 10.0
632
+ # config.rpcs.list_org_policy_violations_previews.timeout = 20.0
633
+ # end
634
+ #
635
+ # @!attribute [rw] endpoint
636
+ # A custom service endpoint, as a hostname or hostname:port. The default is
637
+ # nil, indicating to use the default endpoint in the current universe domain.
638
+ # @return [::String,nil]
639
+ # @!attribute [rw] credentials
640
+ # Credentials to send with calls. You may provide any of the following types:
641
+ # * (`String`) The path to a service account key file in JSON format
642
+ # * (`Hash`) A service account key as a Hash
643
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
644
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
645
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
646
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
647
+ # * (`nil`) indicating no credentials
648
+ #
649
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
650
+ # external source for authentication to Google Cloud, you must validate it before
651
+ # providing it to a Google API client library. Providing an unvalidated credential
652
+ # configuration to Google APIs can compromise the security of your systems and data.
653
+ # For more information, refer to [Validate credential configurations from external
654
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
655
+ # @return [::Object]
656
+ # @!attribute [rw] scope
657
+ # The OAuth scopes
658
+ # @return [::Array<::String>]
659
+ # @!attribute [rw] lib_name
660
+ # The library name as recorded in instrumentation and logging
661
+ # @return [::String]
662
+ # @!attribute [rw] lib_version
663
+ # The library version as recorded in instrumentation and logging
664
+ # @return [::String]
665
+ # @!attribute [rw] timeout
666
+ # The call timeout in seconds.
667
+ # @return [::Numeric]
668
+ # @!attribute [rw] metadata
669
+ # Additional headers to be sent with the call.
670
+ # @return [::Hash{::Symbol=>::String}]
671
+ # @!attribute [rw] retry_policy
672
+ # The retry policy. The value is a hash with the following keys:
673
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
674
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
675
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
676
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
677
+ # trigger a retry.
678
+ # @return [::Hash]
679
+ # @!attribute [rw] quota_project
680
+ # A separate project against which to charge quota.
681
+ # @return [::String]
682
+ # @!attribute [rw] universe_domain
683
+ # The universe domain within which to make requests. This determines the
684
+ # default endpoint URL. The default value of nil uses the environment
685
+ # universe (usually the default "googleapis.com" universe).
686
+ # @return [::String,nil]
687
+ # @!attribute [rw] logger
688
+ # A custom logger to use for request/response debug logging, or the value
689
+ # `:default` (the default) to construct a default logger, or `nil` to
690
+ # explicitly disable logging.
691
+ # @return [::Logger,:default,nil]
692
+ #
693
+ class Configuration
694
+ extend ::Gapic::Config
695
+
696
+ # @private
697
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
698
+ DEFAULT_ENDPOINT = "policysimulator.googleapis.com"
699
+
700
+ config_attr :endpoint, nil, ::String, nil
701
+ config_attr :credentials, nil do |value|
702
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
703
+ allowed.any? { |klass| klass === value }
704
+ end
705
+ config_attr :scope, nil, ::String, ::Array, nil
706
+ config_attr :lib_name, nil, ::String, nil
707
+ config_attr :lib_version, nil, ::String, nil
708
+ config_attr :timeout, nil, ::Numeric, nil
709
+ config_attr :metadata, nil, ::Hash, nil
710
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
711
+ config_attr :quota_project, nil, ::String, nil
712
+ config_attr :universe_domain, nil, ::String, nil
713
+ config_attr :logger, :default, ::Logger, nil, :default
714
+
715
+ # @private
716
+ def initialize parent_config = nil
717
+ @parent_config = parent_config unless parent_config.nil?
718
+
719
+ yield self if block_given?
720
+ end
721
+
722
+ ##
723
+ # Configurations for individual RPCs
724
+ # @return [Rpcs]
725
+ #
726
+ def rpcs
727
+ @rpcs ||= begin
728
+ parent_rpcs = nil
729
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
730
+ Rpcs.new parent_rpcs
731
+ end
732
+ end
733
+
734
+ ##
735
+ # Configuration RPC class for the OrgPolicyViolationsPreviewService API.
736
+ #
737
+ # Includes fields providing the configuration for each RPC in this service.
738
+ # Each configuration object is of type `Gapic::Config::Method` and includes
739
+ # the following configuration fields:
740
+ #
741
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
742
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
743
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
744
+ # include the following keys:
745
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
746
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
747
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
748
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
749
+ # trigger a retry.
750
+ #
751
+ class Rpcs
752
+ ##
753
+ # RPC-specific configuration for `list_org_policy_violations_previews`
754
+ # @return [::Gapic::Config::Method]
755
+ #
756
+ attr_reader :list_org_policy_violations_previews
757
+ ##
758
+ # RPC-specific configuration for `get_org_policy_violations_preview`
759
+ # @return [::Gapic::Config::Method]
760
+ #
761
+ attr_reader :get_org_policy_violations_preview
762
+ ##
763
+ # RPC-specific configuration for `create_org_policy_violations_preview`
764
+ # @return [::Gapic::Config::Method]
765
+ #
766
+ attr_reader :create_org_policy_violations_preview
767
+ ##
768
+ # RPC-specific configuration for `list_org_policy_violations`
769
+ # @return [::Gapic::Config::Method]
770
+ #
771
+ attr_reader :list_org_policy_violations
772
+
773
+ # @private
774
+ def initialize parent_rpcs = nil
775
+ list_org_policy_violations_previews_config = parent_rpcs.list_org_policy_violations_previews if parent_rpcs.respond_to? :list_org_policy_violations_previews
776
+ @list_org_policy_violations_previews = ::Gapic::Config::Method.new list_org_policy_violations_previews_config
777
+ get_org_policy_violations_preview_config = parent_rpcs.get_org_policy_violations_preview if parent_rpcs.respond_to? :get_org_policy_violations_preview
778
+ @get_org_policy_violations_preview = ::Gapic::Config::Method.new get_org_policy_violations_preview_config
779
+ create_org_policy_violations_preview_config = parent_rpcs.create_org_policy_violations_preview if parent_rpcs.respond_to? :create_org_policy_violations_preview
780
+ @create_org_policy_violations_preview = ::Gapic::Config::Method.new create_org_policy_violations_preview_config
781
+ list_org_policy_violations_config = parent_rpcs.list_org_policy_violations if parent_rpcs.respond_to? :list_org_policy_violations
782
+ @list_org_policy_violations = ::Gapic::Config::Method.new list_org_policy_violations_config
783
+
784
+ yield self if block_given?
785
+ end
786
+ end
787
+ end
788
+ end
789
+ end
790
+ end
791
+ end
792
+ end
793
+ end
794
+ end