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