google-cloud-org_policy-v2 0.6.0 → 0.8.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.
@@ -31,23 +31,23 @@ module Google
31
31
  #
32
32
  # An interface for managing organization policies.
33
33
  #
34
- # The Cloud Org Policy service provides a simple mechanism for organizations to
35
- # restrict the allowed configurations across their entire Cloud Resource
36
- # hierarchy.
34
+ # The Organization Policy Service provides a simple mechanism for
35
+ # organizations to restrict the allowed configurations across their entire
36
+ # resource hierarchy.
37
37
  #
38
- # You can use a `policy` to configure restrictions in Cloud resources. For
39
- # example, you can enforce a `policy` that restricts which Google
40
- # Cloud Platform APIs can be activated in a certain part of your resource
41
- # hierarchy, or prevents serial port access to VM instances in a particular
42
- # folder.
38
+ # You can use a policy to configure restrictions on resources. For
39
+ # example, you can enforce a policy that restricts which Google
40
+ # Cloud APIs can be activated in a certain part of your resource
41
+ # hierarchy, or prevents serial port access to VM instances in a
42
+ # particular folder.
43
43
  #
44
- # `Policies` are inherited down through the resource hierarchy. A `policy`
44
+ # Policies are inherited down through the resource hierarchy. A policy
45
45
  # applied to a parent resource automatically applies to all its child resources
46
- # unless overridden with a `policy` lower in the hierarchy.
46
+ # unless overridden with a policy lower in the hierarchy.
47
47
  #
48
- # A `constraint` defines an aspect of a resource's configuration that can be
49
- # controlled by an organization's policy administrator. `Policies` are a
50
- # collection of `constraints` that defines their allowable configuration on a
48
+ # A constraint defines an aspect of a resource's configuration that can be
49
+ # controlled by an organization's policy administrator. Policies are a
50
+ # collection of constraints that defines their allowable configuration on a
51
51
  # particular resource and its child resources.
52
52
  #
53
53
  class Client
@@ -120,6 +120,31 @@ module Google
120
120
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
121
121
  }
122
122
 
123
+ default_config.rpcs.create_custom_constraint.timeout = 60.0
124
+ default_config.rpcs.create_custom_constraint.retry_policy = {
125
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
126
+ }
127
+
128
+ default_config.rpcs.update_custom_constraint.timeout = 60.0
129
+ default_config.rpcs.update_custom_constraint.retry_policy = {
130
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
131
+ }
132
+
133
+ default_config.rpcs.get_custom_constraint.timeout = 60.0
134
+ default_config.rpcs.get_custom_constraint.retry_policy = {
135
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
136
+ }
137
+
138
+ default_config.rpcs.list_custom_constraints.timeout = 60.0
139
+ default_config.rpcs.list_custom_constraints.retry_policy = {
140
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
141
+ }
142
+
143
+ default_config.rpcs.delete_custom_constraint.timeout = 60.0
144
+ default_config.rpcs.delete_custom_constraint.retry_policy = {
145
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
146
+ }
147
+
123
148
  default_config
124
149
  end
125
150
  yield @configure if block_given?
@@ -190,7 +215,7 @@ module Google
190
215
  # Service calls
191
216
 
192
217
  ##
193
- # Lists `Constraints` that could be applied on the specified resource.
218
+ # Lists constraints that could be applied on the specified resource.
194
219
  #
195
220
  # @overload list_constraints(request, options = nil)
196
221
  # Pass arguments to `list_constraints` via a request object, either of type
@@ -208,8 +233,9 @@ module Google
208
233
  # the default parameter values, pass an empty Hash as a request object (see above).
209
234
  #
210
235
  # @param parent [::String]
211
- # Required. The Cloud resource that parents the constraint. Must be in one of
212
- # the following forms:
236
+ # Required. The Google Cloud resource that parents the constraint. Must be in
237
+ # one of the following forms:
238
+ #
213
239
  # * `projects/{project_number}`
214
240
  # * `projects/{project_id}`
215
241
  # * `folders/{folder_id}`
@@ -228,6 +254,26 @@ module Google
228
254
  # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Constraint>]
229
255
  #
230
256
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
257
+ #
258
+ # @example Basic example
259
+ # require "google/cloud/org_policy/v2"
260
+ #
261
+ # # Create a client object. The client can be reused for multiple calls.
262
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
263
+ #
264
+ # # Create a request. To set request fields, pass in keyword arguments.
265
+ # request = Google::Cloud::OrgPolicy::V2::ListConstraintsRequest.new
266
+ #
267
+ # # Call the list_constraints method.
268
+ # result = client.list_constraints request
269
+ #
270
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
271
+ # # over elements, and API calls will be issued to fetch pages as needed.
272
+ # result.each do |item|
273
+ # # Each element is of type ::Google::Cloud::OrgPolicy::V2::Constraint.
274
+ # p item
275
+ # end
276
+ #
231
277
  def list_constraints request, options = nil
232
278
  raise ::ArgumentError, "request must be provided" if request.nil?
233
279
 
@@ -265,7 +311,7 @@ module Google
265
311
  end
266
312
 
267
313
  ##
268
- # Retrieves all of the `Policies` that exist on a particular resource.
314
+ # Retrieves all of the policies that exist on a particular resource.
269
315
  #
270
316
  # @overload list_policies(request, options = nil)
271
317
  # Pass arguments to `list_policies` via a request object, either of type
@@ -283,9 +329,10 @@ module Google
283
329
  # the default parameter values, pass an empty Hash as a request object (see above).
284
330
  #
285
331
  # @param parent [::String]
286
- # Required. The target Cloud resource that parents the set of constraints and
287
- # policies that will be returned from this call. Must be in one of the
288
- # following forms:
332
+ # Required. The target Google Cloud resource that parents the set of
333
+ # constraints and policies that will be returned from this call. Must be in
334
+ # one of the following forms:
335
+ #
289
336
  # * `projects/{project_number}`
290
337
  # * `projects/{project_id}`
291
338
  # * `folders/{folder_id}`
@@ -304,6 +351,26 @@ module Google
304
351
  # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Policy>]
305
352
  #
306
353
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
354
+ #
355
+ # @example Basic example
356
+ # require "google/cloud/org_policy/v2"
357
+ #
358
+ # # Create a client object. The client can be reused for multiple calls.
359
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
360
+ #
361
+ # # Create a request. To set request fields, pass in keyword arguments.
362
+ # request = Google::Cloud::OrgPolicy::V2::ListPoliciesRequest.new
363
+ #
364
+ # # Call the list_policies method.
365
+ # result = client.list_policies request
366
+ #
367
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
368
+ # # over elements, and API calls will be issued to fetch pages as needed.
369
+ # result.each do |item|
370
+ # # Each element is of type ::Google::Cloud::OrgPolicy::V2::Policy.
371
+ # p item
372
+ # end
373
+ #
307
374
  def list_policies request, options = nil
308
375
  raise ::ArgumentError, "request must be provided" if request.nil?
309
376
 
@@ -341,11 +408,11 @@ module Google
341
408
  end
342
409
 
343
410
  ##
344
- # Gets a `Policy` on a resource.
411
+ # Gets a policy on a resource.
345
412
  #
346
- # If no `Policy` is set on the resource, NOT_FOUND is returned. The
413
+ # If no policy is set on the resource, `NOT_FOUND` is returned. The
347
414
  # `etag` value can be used with `UpdatePolicy()` to update a
348
- # `Policy` during read-modify-write.
415
+ # policy during read-modify-write.
349
416
  #
350
417
  # @overload get_policy(request, options = nil)
351
418
  # Pass arguments to `get_policy` via a request object, either of type
@@ -363,8 +430,8 @@ module Google
363
430
  # the default parameter values, pass an empty Hash as a request object (see above).
364
431
  #
365
432
  # @param name [::String]
366
- # Required. Resource name of the policy. See `Policy` for naming
367
- # requirements.
433
+ # Required. Resource name of the policy. See
434
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
368
435
  # @yield [result, operation] Access the result along with the TransportOperation object
369
436
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
370
437
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -372,6 +439,22 @@ module Google
372
439
  # @return [::Google::Cloud::OrgPolicy::V2::Policy]
373
440
  #
374
441
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
442
+ #
443
+ # @example Basic example
444
+ # require "google/cloud/org_policy/v2"
445
+ #
446
+ # # Create a client object. The client can be reused for multiple calls.
447
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
448
+ #
449
+ # # Create a request. To set request fields, pass in keyword arguments.
450
+ # request = Google::Cloud::OrgPolicy::V2::GetPolicyRequest.new
451
+ #
452
+ # # Call the get_policy method.
453
+ # result = client.get_policy request
454
+ #
455
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::Policy.
456
+ # p result
457
+ #
375
458
  def get_policy request, options = nil
376
459
  raise ::ArgumentError, "request must be provided" if request.nil?
377
460
 
@@ -408,10 +491,10 @@ module Google
408
491
  end
409
492
 
410
493
  ##
411
- # Gets the effective `Policy` on a resource. This is the result of merging
412
- # `Policies` in the resource hierarchy and evaluating conditions. The
413
- # returned `Policy` will not have an `etag` or `condition` set because it is
414
- # a computed `Policy` across multiple resources.
494
+ # Gets the effective policy on a resource. This is the result of merging
495
+ # policies in the resource hierarchy and evaluating conditions. The
496
+ # returned policy will not have an `etag` or `condition` set because it is
497
+ # an evaluated policy across multiple resources.
415
498
  # Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
416
499
  # not be expanded.
417
500
  #
@@ -431,7 +514,8 @@ module Google
431
514
  # the default parameter values, pass an empty Hash as a request object (see above).
432
515
  #
433
516
  # @param name [::String]
434
- # Required. The effective policy to compute. See `Policy` for naming rules.
517
+ # Required. The effective policy to compute. See
518
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
435
519
  # @yield [result, operation] Access the result along with the TransportOperation object
436
520
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
437
521
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -439,6 +523,22 @@ module Google
439
523
  # @return [::Google::Cloud::OrgPolicy::V2::Policy]
440
524
  #
441
525
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
526
+ #
527
+ # @example Basic example
528
+ # require "google/cloud/org_policy/v2"
529
+ #
530
+ # # Create a client object. The client can be reused for multiple calls.
531
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
532
+ #
533
+ # # Create a request. To set request fields, pass in keyword arguments.
534
+ # request = Google::Cloud::OrgPolicy::V2::GetEffectivePolicyRequest.new
535
+ #
536
+ # # Call the get_effective_policy method.
537
+ # result = client.get_effective_policy request
538
+ #
539
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::Policy.
540
+ # p result
541
+ #
442
542
  def get_effective_policy request, options = nil
443
543
  raise ::ArgumentError, "request must be provided" if request.nil?
444
544
 
@@ -475,12 +575,12 @@ module Google
475
575
  end
476
576
 
477
577
  ##
478
- # Creates a Policy.
578
+ # Creates a policy.
479
579
  #
480
580
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
481
581
  # constraint does not exist.
482
582
  # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
483
- # policy already exists on the given Cloud resource.
583
+ # policy already exists on the given Google Cloud resource.
484
584
  #
485
585
  # @overload create_policy(request, options = nil)
486
586
  # Pass arguments to `create_policy` via a request object, either of type
@@ -498,14 +598,15 @@ module Google
498
598
  # the default parameter values, pass an empty Hash as a request object (see above).
499
599
  #
500
600
  # @param parent [::String]
501
- # Required. The Cloud resource that will parent the new Policy. Must be in
502
- # one of the following forms:
601
+ # Required. The Google Cloud resource that will parent the new policy. Must
602
+ # be in one of the following forms:
603
+ #
503
604
  # * `projects/{project_number}`
504
605
  # * `projects/{project_id}`
505
606
  # * `folders/{folder_id}`
506
607
  # * `organizations/{organization_id}`
507
608
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
508
- # Required. `Policy` to create.
609
+ # Required. Policy to create.
509
610
  # @yield [result, operation] Access the result along with the TransportOperation object
510
611
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
511
612
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -513,6 +614,22 @@ module Google
513
614
  # @return [::Google::Cloud::OrgPolicy::V2::Policy]
514
615
  #
515
616
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
617
+ #
618
+ # @example Basic example
619
+ # require "google/cloud/org_policy/v2"
620
+ #
621
+ # # Create a client object. The client can be reused for multiple calls.
622
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
623
+ #
624
+ # # Create a request. To set request fields, pass in keyword arguments.
625
+ # request = Google::Cloud::OrgPolicy::V2::CreatePolicyRequest.new
626
+ #
627
+ # # Call the create_policy method.
628
+ # result = client.create_policy request
629
+ #
630
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::Policy.
631
+ # p result
632
+ #
516
633
  def create_policy request, options = nil
517
634
  raise ::ArgumentError, "request must be provided" if request.nil?
518
635
 
@@ -549,7 +666,7 @@ module Google
549
666
  end
550
667
 
551
668
  ##
552
- # Updates a Policy.
669
+ # Updates a policy.
553
670
  #
554
671
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
555
672
  # constraint or the policy do not exist.
@@ -575,7 +692,7 @@ module Google
575
692
  # the default parameter values, pass an empty Hash as a request object (see above).
576
693
  #
577
694
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
578
- # Required. `Policy` to update.
695
+ # Required. Policy to update.
579
696
  # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
580
697
  # Field mask used to specify the fields to be overwritten in the policy
581
698
  # by the set. The fields specified in the update_mask are relative to the
@@ -587,6 +704,22 @@ module Google
587
704
  # @return [::Google::Cloud::OrgPolicy::V2::Policy]
588
705
  #
589
706
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
707
+ #
708
+ # @example Basic example
709
+ # require "google/cloud/org_policy/v2"
710
+ #
711
+ # # Create a client object. The client can be reused for multiple calls.
712
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
713
+ #
714
+ # # Create a request. To set request fields, pass in keyword arguments.
715
+ # request = Google::Cloud::OrgPolicy::V2::UpdatePolicyRequest.new
716
+ #
717
+ # # Call the update_policy method.
718
+ # result = client.update_policy request
719
+ #
720
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::Policy.
721
+ # p result
722
+ #
590
723
  def update_policy request, options = nil
591
724
  raise ::ArgumentError, "request must be provided" if request.nil?
592
725
 
@@ -623,10 +756,10 @@ module Google
623
756
  end
624
757
 
625
758
  ##
626
- # Deletes a Policy.
759
+ # Deletes a policy.
627
760
  #
628
761
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
629
- # constraint or Org Policy does not exist.
762
+ # constraint or organization policy does not exist.
630
763
  #
631
764
  # @overload delete_policy(request, options = nil)
632
765
  # Pass arguments to `delete_policy` via a request object, either of type
@@ -638,14 +771,18 @@ module Google
638
771
  # @param options [::Gapic::CallOptions, ::Hash]
639
772
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
640
773
  #
641
- # @overload delete_policy(name: nil)
774
+ # @overload delete_policy(name: nil, etag: nil)
642
775
  # Pass arguments to `delete_policy` via keyword arguments. Note that at
643
776
  # least one keyword argument is required. To specify no parameters, or to keep all
644
777
  # the default parameter values, pass an empty Hash as a request object (see above).
645
778
  #
646
779
  # @param name [::String]
647
780
  # Required. Name of the policy to delete.
648
- # See `Policy` for naming rules.
781
+ # See the policy entry for naming rules.
782
+ # @param etag [::String]
783
+ # Optional. The current etag of policy. If an etag is provided and does not
784
+ # match the current etag of the policy, deletion will be blocked and an
785
+ # ABORTED error will be returned.
649
786
  # @yield [result, operation] Access the result along with the TransportOperation object
650
787
  # @yieldparam result [::Google::Protobuf::Empty]
651
788
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -653,6 +790,22 @@ module Google
653
790
  # @return [::Google::Protobuf::Empty]
654
791
  #
655
792
  # @raise [::Google::Cloud::Error] if the REST call is aborted.
793
+ #
794
+ # @example Basic example
795
+ # require "google/cloud/org_policy/v2"
796
+ #
797
+ # # Create a client object. The client can be reused for multiple calls.
798
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
799
+ #
800
+ # # Create a request. To set request fields, pass in keyword arguments.
801
+ # request = Google::Cloud::OrgPolicy::V2::DeletePolicyRequest.new
802
+ #
803
+ # # Call the delete_policy method.
804
+ # result = client.delete_policy request
805
+ #
806
+ # # The returned object is of type Google::Protobuf::Empty.
807
+ # p result
808
+ #
656
809
  def delete_policy request, options = nil
657
810
  raise ::ArgumentError, "request must be provided" if request.nil?
658
811
 
@@ -688,6 +841,436 @@ module Google
688
841
  raise ::Google::Cloud::Error.from_error(e)
689
842
  end
690
843
 
844
+ ##
845
+ # Creates a custom constraint.
846
+ #
847
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
848
+ # organization does not exist.
849
+ # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
850
+ # constraint already exists on the given organization.
851
+ #
852
+ # @overload create_custom_constraint(request, options = nil)
853
+ # Pass arguments to `create_custom_constraint` via a request object, either of type
854
+ # {::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest} or an equivalent Hash.
855
+ #
856
+ # @param request [::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest, ::Hash]
857
+ # A request object representing the call parameters. Required. To specify no
858
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
859
+ # @param options [::Gapic::CallOptions, ::Hash]
860
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
861
+ #
862
+ # @overload create_custom_constraint(parent: nil, custom_constraint: nil)
863
+ # Pass arguments to `create_custom_constraint` via keyword arguments. Note that at
864
+ # least one keyword argument is required. To specify no parameters, or to keep all
865
+ # the default parameter values, pass an empty Hash as a request object (see above).
866
+ #
867
+ # @param parent [::String]
868
+ # Required. Must be in the following form:
869
+ #
870
+ # * `organizations/{organization_id}`
871
+ # @param custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
872
+ # Required. Custom constraint to create.
873
+ # @yield [result, operation] Access the result along with the TransportOperation object
874
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
875
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
876
+ #
877
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
878
+ #
879
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
880
+ #
881
+ # @example Basic example
882
+ # require "google/cloud/org_policy/v2"
883
+ #
884
+ # # Create a client object. The client can be reused for multiple calls.
885
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
886
+ #
887
+ # # Create a request. To set request fields, pass in keyword arguments.
888
+ # request = Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest.new
889
+ #
890
+ # # Call the create_custom_constraint method.
891
+ # result = client.create_custom_constraint request
892
+ #
893
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
894
+ # p result
895
+ #
896
+ def create_custom_constraint request, options = nil
897
+ raise ::ArgumentError, "request must be provided" if request.nil?
898
+
899
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest
900
+
901
+ # Converts hash and nil to an options object
902
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
903
+
904
+ # Customize the options with defaults
905
+ call_metadata = @config.rpcs.create_custom_constraint.metadata.to_h
906
+
907
+ # Set x-goog-api-client and x-goog-user-project headers
908
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
909
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
910
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
911
+ transports_version_send: [:rest]
912
+
913
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
914
+
915
+ options.apply_defaults timeout: @config.rpcs.create_custom_constraint.timeout,
916
+ metadata: call_metadata,
917
+ retry_policy: @config.rpcs.create_custom_constraint.retry_policy
918
+
919
+ options.apply_defaults timeout: @config.timeout,
920
+ metadata: @config.metadata,
921
+ retry_policy: @config.retry_policy
922
+
923
+ @org_policy_stub.create_custom_constraint request, options do |result, operation|
924
+ yield result, operation if block_given?
925
+ return result
926
+ end
927
+ rescue ::Gapic::Rest::Error => e
928
+ raise ::Google::Cloud::Error.from_error(e)
929
+ end
930
+
931
+ ##
932
+ # Updates a custom constraint.
933
+ #
934
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
935
+ # constraint does not exist.
936
+ #
937
+ # Note: the supplied policy will perform a full overwrite of all
938
+ # fields.
939
+ #
940
+ # @overload update_custom_constraint(request, options = nil)
941
+ # Pass arguments to `update_custom_constraint` via a request object, either of type
942
+ # {::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest} or an equivalent Hash.
943
+ #
944
+ # @param request [::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest, ::Hash]
945
+ # A request object representing the call parameters. Required. To specify no
946
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
947
+ # @param options [::Gapic::CallOptions, ::Hash]
948
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
949
+ #
950
+ # @overload update_custom_constraint(custom_constraint: nil)
951
+ # Pass arguments to `update_custom_constraint` via keyword arguments. Note that at
952
+ # least one keyword argument is required. To specify no parameters, or to keep all
953
+ # the default parameter values, pass an empty Hash as a request object (see above).
954
+ #
955
+ # @param custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
956
+ # Required. `CustomConstraint` to update.
957
+ # @yield [result, operation] Access the result along with the TransportOperation object
958
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
959
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
960
+ #
961
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
962
+ #
963
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
964
+ #
965
+ # @example Basic example
966
+ # require "google/cloud/org_policy/v2"
967
+ #
968
+ # # Create a client object. The client can be reused for multiple calls.
969
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
970
+ #
971
+ # # Create a request. To set request fields, pass in keyword arguments.
972
+ # request = Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest.new
973
+ #
974
+ # # Call the update_custom_constraint method.
975
+ # result = client.update_custom_constraint request
976
+ #
977
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
978
+ # p result
979
+ #
980
+ def update_custom_constraint request, options = nil
981
+ raise ::ArgumentError, "request must be provided" if request.nil?
982
+
983
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest
984
+
985
+ # Converts hash and nil to an options object
986
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
987
+
988
+ # Customize the options with defaults
989
+ call_metadata = @config.rpcs.update_custom_constraint.metadata.to_h
990
+
991
+ # Set x-goog-api-client and x-goog-user-project headers
992
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
993
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
994
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
995
+ transports_version_send: [:rest]
996
+
997
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
998
+
999
+ options.apply_defaults timeout: @config.rpcs.update_custom_constraint.timeout,
1000
+ metadata: call_metadata,
1001
+ retry_policy: @config.rpcs.update_custom_constraint.retry_policy
1002
+
1003
+ options.apply_defaults timeout: @config.timeout,
1004
+ metadata: @config.metadata,
1005
+ retry_policy: @config.retry_policy
1006
+
1007
+ @org_policy_stub.update_custom_constraint request, options do |result, operation|
1008
+ yield result, operation if block_given?
1009
+ return result
1010
+ end
1011
+ rescue ::Gapic::Rest::Error => e
1012
+ raise ::Google::Cloud::Error.from_error(e)
1013
+ end
1014
+
1015
+ ##
1016
+ # Gets a custom constraint.
1017
+ #
1018
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1019
+ # custom constraint does not exist.
1020
+ #
1021
+ # @overload get_custom_constraint(request, options = nil)
1022
+ # Pass arguments to `get_custom_constraint` via a request object, either of type
1023
+ # {::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest} or an equivalent Hash.
1024
+ #
1025
+ # @param request [::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest, ::Hash]
1026
+ # A request object representing the call parameters. Required. To specify no
1027
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1028
+ # @param options [::Gapic::CallOptions, ::Hash]
1029
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1030
+ #
1031
+ # @overload get_custom_constraint(name: nil)
1032
+ # Pass arguments to `get_custom_constraint` via keyword arguments. Note that at
1033
+ # least one keyword argument is required. To specify no parameters, or to keep all
1034
+ # the default parameter values, pass an empty Hash as a request object (see above).
1035
+ #
1036
+ # @param name [::String]
1037
+ # Required. Resource name of the custom constraint. See the custom constraint
1038
+ # entry for naming requirements.
1039
+ # @yield [result, operation] Access the result along with the TransportOperation object
1040
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1041
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1042
+ #
1043
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1044
+ #
1045
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1046
+ #
1047
+ # @example Basic example
1048
+ # require "google/cloud/org_policy/v2"
1049
+ #
1050
+ # # Create a client object. The client can be reused for multiple calls.
1051
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1052
+ #
1053
+ # # Create a request. To set request fields, pass in keyword arguments.
1054
+ # request = Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest.new
1055
+ #
1056
+ # # Call the get_custom_constraint method.
1057
+ # result = client.get_custom_constraint request
1058
+ #
1059
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
1060
+ # p result
1061
+ #
1062
+ def get_custom_constraint request, options = nil
1063
+ raise ::ArgumentError, "request must be provided" if request.nil?
1064
+
1065
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest
1066
+
1067
+ # Converts hash and nil to an options object
1068
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1069
+
1070
+ # Customize the options with defaults
1071
+ call_metadata = @config.rpcs.get_custom_constraint.metadata.to_h
1072
+
1073
+ # Set x-goog-api-client and x-goog-user-project headers
1074
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1075
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1076
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1077
+ transports_version_send: [:rest]
1078
+
1079
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1080
+
1081
+ options.apply_defaults timeout: @config.rpcs.get_custom_constraint.timeout,
1082
+ metadata: call_metadata,
1083
+ retry_policy: @config.rpcs.get_custom_constraint.retry_policy
1084
+
1085
+ options.apply_defaults timeout: @config.timeout,
1086
+ metadata: @config.metadata,
1087
+ retry_policy: @config.retry_policy
1088
+
1089
+ @org_policy_stub.get_custom_constraint request, options do |result, operation|
1090
+ yield result, operation if block_given?
1091
+ return result
1092
+ end
1093
+ rescue ::Gapic::Rest::Error => e
1094
+ raise ::Google::Cloud::Error.from_error(e)
1095
+ end
1096
+
1097
+ ##
1098
+ # Retrieves all of the custom constraints that exist on a particular
1099
+ # organization resource.
1100
+ #
1101
+ # @overload list_custom_constraints(request, options = nil)
1102
+ # Pass arguments to `list_custom_constraints` via a request object, either of type
1103
+ # {::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest} or an equivalent Hash.
1104
+ #
1105
+ # @param request [::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest, ::Hash]
1106
+ # A request object representing the call parameters. Required. To specify no
1107
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1108
+ # @param options [::Gapic::CallOptions, ::Hash]
1109
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1110
+ #
1111
+ # @overload list_custom_constraints(parent: nil, page_size: nil, page_token: nil)
1112
+ # Pass arguments to `list_custom_constraints` via keyword arguments. Note that at
1113
+ # least one keyword argument is required. To specify no parameters, or to keep all
1114
+ # the default parameter values, pass an empty Hash as a request object (see above).
1115
+ #
1116
+ # @param parent [::String]
1117
+ # Required. The target Google Cloud resource that parents the set of custom
1118
+ # constraints that will be returned from this call. Must be in one of the
1119
+ # following forms:
1120
+ #
1121
+ # * `organizations/{organization_id}`
1122
+ # @param page_size [::Integer]
1123
+ # Size of the pages to be returned. This is currently unsupported and will
1124
+ # be ignored. The server may at any point start using this field to limit
1125
+ # page size.
1126
+ # @param page_token [::String]
1127
+ # Page token used to retrieve the next page. This is currently unsupported
1128
+ # and will be ignored. The server may at any point start using this field.
1129
+ # @yield [result, operation] Access the result along with the TransportOperation object
1130
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1131
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1132
+ #
1133
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1134
+ #
1135
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1136
+ #
1137
+ # @example Basic example
1138
+ # require "google/cloud/org_policy/v2"
1139
+ #
1140
+ # # Create a client object. The client can be reused for multiple calls.
1141
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1142
+ #
1143
+ # # Create a request. To set request fields, pass in keyword arguments.
1144
+ # request = Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest.new
1145
+ #
1146
+ # # Call the list_custom_constraints method.
1147
+ # result = client.list_custom_constraints request
1148
+ #
1149
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1150
+ # # over elements, and API calls will be issued to fetch pages as needed.
1151
+ # result.each do |item|
1152
+ # # Each element is of type ::Google::Cloud::OrgPolicy::V2::CustomConstraint.
1153
+ # p item
1154
+ # end
1155
+ #
1156
+ def list_custom_constraints request, options = nil
1157
+ raise ::ArgumentError, "request must be provided" if request.nil?
1158
+
1159
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest
1160
+
1161
+ # Converts hash and nil to an options object
1162
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1163
+
1164
+ # Customize the options with defaults
1165
+ call_metadata = @config.rpcs.list_custom_constraints.metadata.to_h
1166
+
1167
+ # Set x-goog-api-client and x-goog-user-project headers
1168
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1169
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1170
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1171
+ transports_version_send: [:rest]
1172
+
1173
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1174
+
1175
+ options.apply_defaults timeout: @config.rpcs.list_custom_constraints.timeout,
1176
+ metadata: call_metadata,
1177
+ retry_policy: @config.rpcs.list_custom_constraints.retry_policy
1178
+
1179
+ options.apply_defaults timeout: @config.timeout,
1180
+ metadata: @config.metadata,
1181
+ retry_policy: @config.retry_policy
1182
+
1183
+ @org_policy_stub.list_custom_constraints request, options do |result, operation|
1184
+ result = ::Gapic::Rest::PagedEnumerable.new @org_policy_stub, :list_custom_constraints, "custom_constraints", request, result, options
1185
+ yield result, operation if block_given?
1186
+ return result
1187
+ end
1188
+ rescue ::Gapic::Rest::Error => e
1189
+ raise ::Google::Cloud::Error.from_error(e)
1190
+ end
1191
+
1192
+ ##
1193
+ # Deletes a custom constraint.
1194
+ #
1195
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1196
+ # constraint does not exist.
1197
+ #
1198
+ # @overload delete_custom_constraint(request, options = nil)
1199
+ # Pass arguments to `delete_custom_constraint` via a request object, either of type
1200
+ # {::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest} or an equivalent Hash.
1201
+ #
1202
+ # @param request [::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest, ::Hash]
1203
+ # A request object representing the call parameters. Required. To specify no
1204
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1205
+ # @param options [::Gapic::CallOptions, ::Hash]
1206
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1207
+ #
1208
+ # @overload delete_custom_constraint(name: nil)
1209
+ # Pass arguments to `delete_custom_constraint` via keyword arguments. Note that at
1210
+ # least one keyword argument is required. To specify no parameters, or to keep all
1211
+ # the default parameter values, pass an empty Hash as a request object (see above).
1212
+ #
1213
+ # @param name [::String]
1214
+ # Required. Name of the custom constraint to delete.
1215
+ # See the custom constraint entry for naming rules.
1216
+ # @yield [result, operation] Access the result along with the TransportOperation object
1217
+ # @yieldparam result [::Google::Protobuf::Empty]
1218
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1219
+ #
1220
+ # @return [::Google::Protobuf::Empty]
1221
+ #
1222
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1223
+ #
1224
+ # @example Basic example
1225
+ # require "google/cloud/org_policy/v2"
1226
+ #
1227
+ # # Create a client object. The client can be reused for multiple calls.
1228
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1229
+ #
1230
+ # # Create a request. To set request fields, pass in keyword arguments.
1231
+ # request = Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest.new
1232
+ #
1233
+ # # Call the delete_custom_constraint method.
1234
+ # result = client.delete_custom_constraint request
1235
+ #
1236
+ # # The returned object is of type Google::Protobuf::Empty.
1237
+ # p result
1238
+ #
1239
+ def delete_custom_constraint request, options = nil
1240
+ raise ::ArgumentError, "request must be provided" if request.nil?
1241
+
1242
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest
1243
+
1244
+ # Converts hash and nil to an options object
1245
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1246
+
1247
+ # Customize the options with defaults
1248
+ call_metadata = @config.rpcs.delete_custom_constraint.metadata.to_h
1249
+
1250
+ # Set x-goog-api-client and x-goog-user-project headers
1251
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1252
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1253
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1254
+ transports_version_send: [:rest]
1255
+
1256
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1257
+
1258
+ options.apply_defaults timeout: @config.rpcs.delete_custom_constraint.timeout,
1259
+ metadata: call_metadata,
1260
+ retry_policy: @config.rpcs.delete_custom_constraint.retry_policy
1261
+
1262
+ options.apply_defaults timeout: @config.timeout,
1263
+ metadata: @config.metadata,
1264
+ retry_policy: @config.retry_policy
1265
+
1266
+ @org_policy_stub.delete_custom_constraint request, options do |result, operation|
1267
+ yield result, operation if block_given?
1268
+ return result
1269
+ end
1270
+ rescue ::Gapic::Rest::Error => e
1271
+ raise ::Google::Cloud::Error.from_error(e)
1272
+ end
1273
+
691
1274
  ##
692
1275
  # Configuration class for the OrgPolicy REST API.
693
1276
  #
@@ -848,6 +1431,31 @@ module Google
848
1431
  # @return [::Gapic::Config::Method]
849
1432
  #
850
1433
  attr_reader :delete_policy
1434
+ ##
1435
+ # RPC-specific configuration for `create_custom_constraint`
1436
+ # @return [::Gapic::Config::Method]
1437
+ #
1438
+ attr_reader :create_custom_constraint
1439
+ ##
1440
+ # RPC-specific configuration for `update_custom_constraint`
1441
+ # @return [::Gapic::Config::Method]
1442
+ #
1443
+ attr_reader :update_custom_constraint
1444
+ ##
1445
+ # RPC-specific configuration for `get_custom_constraint`
1446
+ # @return [::Gapic::Config::Method]
1447
+ #
1448
+ attr_reader :get_custom_constraint
1449
+ ##
1450
+ # RPC-specific configuration for `list_custom_constraints`
1451
+ # @return [::Gapic::Config::Method]
1452
+ #
1453
+ attr_reader :list_custom_constraints
1454
+ ##
1455
+ # RPC-specific configuration for `delete_custom_constraint`
1456
+ # @return [::Gapic::Config::Method]
1457
+ #
1458
+ attr_reader :delete_custom_constraint
851
1459
 
852
1460
  # @private
853
1461
  def initialize parent_rpcs = nil
@@ -865,6 +1473,16 @@ module Google
865
1473
  @update_policy = ::Gapic::Config::Method.new update_policy_config
866
1474
  delete_policy_config = parent_rpcs.delete_policy if parent_rpcs.respond_to? :delete_policy
867
1475
  @delete_policy = ::Gapic::Config::Method.new delete_policy_config
1476
+ create_custom_constraint_config = parent_rpcs.create_custom_constraint if parent_rpcs.respond_to? :create_custom_constraint
1477
+ @create_custom_constraint = ::Gapic::Config::Method.new create_custom_constraint_config
1478
+ update_custom_constraint_config = parent_rpcs.update_custom_constraint if parent_rpcs.respond_to? :update_custom_constraint
1479
+ @update_custom_constraint = ::Gapic::Config::Method.new update_custom_constraint_config
1480
+ get_custom_constraint_config = parent_rpcs.get_custom_constraint if parent_rpcs.respond_to? :get_custom_constraint
1481
+ @get_custom_constraint = ::Gapic::Config::Method.new get_custom_constraint_config
1482
+ list_custom_constraints_config = parent_rpcs.list_custom_constraints if parent_rpcs.respond_to? :list_custom_constraints
1483
+ @list_custom_constraints = ::Gapic::Config::Method.new list_custom_constraints_config
1484
+ delete_custom_constraint_config = parent_rpcs.delete_custom_constraint if parent_rpcs.respond_to? :delete_custom_constraint
1485
+ @delete_custom_constraint = ::Gapic::Config::Method.new delete_custom_constraint_config
868
1486
 
869
1487
  yield self if block_given?
870
1488
  end