google-cloud-org_policy-v2 0.7.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}`
@@ -285,7 +311,7 @@ module Google
285
311
  end
286
312
 
287
313
  ##
288
- # Retrieves all of the `Policies` that exist on a particular resource.
314
+ # Retrieves all of the policies that exist on a particular resource.
289
315
  #
290
316
  # @overload list_policies(request, options = nil)
291
317
  # Pass arguments to `list_policies` via a request object, either of type
@@ -303,9 +329,10 @@ module Google
303
329
  # the default parameter values, pass an empty Hash as a request object (see above).
304
330
  #
305
331
  # @param parent [::String]
306
- # Required. The target Cloud resource that parents the set of constraints and
307
- # policies that will be returned from this call. Must be in one of the
308
- # 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
+ #
309
336
  # * `projects/{project_number}`
310
337
  # * `projects/{project_id}`
311
338
  # * `folders/{folder_id}`
@@ -381,11 +408,11 @@ module Google
381
408
  end
382
409
 
383
410
  ##
384
- # Gets a `Policy` on a resource.
411
+ # Gets a policy on a resource.
385
412
  #
386
- # 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
387
414
  # `etag` value can be used with `UpdatePolicy()` to update a
388
- # `Policy` during read-modify-write.
415
+ # policy during read-modify-write.
389
416
  #
390
417
  # @overload get_policy(request, options = nil)
391
418
  # Pass arguments to `get_policy` via a request object, either of type
@@ -403,8 +430,8 @@ module Google
403
430
  # the default parameter values, pass an empty Hash as a request object (see above).
404
431
  #
405
432
  # @param name [::String]
406
- # Required. Resource name of the policy. See `Policy` for naming
407
- # requirements.
433
+ # Required. Resource name of the policy. See
434
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
408
435
  # @yield [result, operation] Access the result along with the TransportOperation object
409
436
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
410
437
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -464,10 +491,10 @@ module Google
464
491
  end
465
492
 
466
493
  ##
467
- # Gets the effective `Policy` on a resource. This is the result of merging
468
- # `Policies` in the resource hierarchy and evaluating conditions. The
469
- # returned `Policy` will not have an `etag` or `condition` set because it is
470
- # 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.
471
498
  # Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
472
499
  # not be expanded.
473
500
  #
@@ -487,7 +514,8 @@ module Google
487
514
  # the default parameter values, pass an empty Hash as a request object (see above).
488
515
  #
489
516
  # @param name [::String]
490
- # 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.
491
519
  # @yield [result, operation] Access the result along with the TransportOperation object
492
520
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
493
521
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -547,12 +575,12 @@ module Google
547
575
  end
548
576
 
549
577
  ##
550
- # Creates a Policy.
578
+ # Creates a policy.
551
579
  #
552
580
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
553
581
  # constraint does not exist.
554
582
  # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
555
- # policy already exists on the given Cloud resource.
583
+ # policy already exists on the given Google Cloud resource.
556
584
  #
557
585
  # @overload create_policy(request, options = nil)
558
586
  # Pass arguments to `create_policy` via a request object, either of type
@@ -570,14 +598,15 @@ module Google
570
598
  # the default parameter values, pass an empty Hash as a request object (see above).
571
599
  #
572
600
  # @param parent [::String]
573
- # Required. The Cloud resource that will parent the new Policy. Must be in
574
- # 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
+ #
575
604
  # * `projects/{project_number}`
576
605
  # * `projects/{project_id}`
577
606
  # * `folders/{folder_id}`
578
607
  # * `organizations/{organization_id}`
579
608
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
580
- # Required. `Policy` to create.
609
+ # Required. Policy to create.
581
610
  # @yield [result, operation] Access the result along with the TransportOperation object
582
611
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
583
612
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -637,7 +666,7 @@ module Google
637
666
  end
638
667
 
639
668
  ##
640
- # Updates a Policy.
669
+ # Updates a policy.
641
670
  #
642
671
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
643
672
  # constraint or the policy do not exist.
@@ -663,7 +692,7 @@ module Google
663
692
  # the default parameter values, pass an empty Hash as a request object (see above).
664
693
  #
665
694
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
666
- # Required. `Policy` to update.
695
+ # Required. Policy to update.
667
696
  # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
668
697
  # Field mask used to specify the fields to be overwritten in the policy
669
698
  # by the set. The fields specified in the update_mask are relative to the
@@ -727,10 +756,10 @@ module Google
727
756
  end
728
757
 
729
758
  ##
730
- # Deletes a Policy.
759
+ # Deletes a policy.
731
760
  #
732
761
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
733
- # constraint or Org Policy does not exist.
762
+ # constraint or organization policy does not exist.
734
763
  #
735
764
  # @overload delete_policy(request, options = nil)
736
765
  # Pass arguments to `delete_policy` via a request object, either of type
@@ -742,14 +771,18 @@ module Google
742
771
  # @param options [::Gapic::CallOptions, ::Hash]
743
772
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
744
773
  #
745
- # @overload delete_policy(name: nil)
774
+ # @overload delete_policy(name: nil, etag: nil)
746
775
  # Pass arguments to `delete_policy` via keyword arguments. Note that at
747
776
  # least one keyword argument is required. To specify no parameters, or to keep all
748
777
  # the default parameter values, pass an empty Hash as a request object (see above).
749
778
  #
750
779
  # @param name [::String]
751
780
  # Required. Name of the policy to delete.
752
- # 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.
753
786
  # @yield [result, operation] Access the result along with the TransportOperation object
754
787
  # @yieldparam result [::Google::Protobuf::Empty]
755
788
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -808,6 +841,436 @@ module Google
808
841
  raise ::Google::Cloud::Error.from_error(e)
809
842
  end
810
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
+
811
1274
  ##
812
1275
  # Configuration class for the OrgPolicy REST API.
813
1276
  #
@@ -968,6 +1431,31 @@ module Google
968
1431
  # @return [::Gapic::Config::Method]
969
1432
  #
970
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
971
1459
 
972
1460
  # @private
973
1461
  def initialize parent_rpcs = nil
@@ -985,6 +1473,16 @@ module Google
985
1473
  @update_policy = ::Gapic::Config::Method.new update_policy_config
986
1474
  delete_policy_config = parent_rpcs.delete_policy if parent_rpcs.respond_to? :delete_policy
987
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
988
1486
 
989
1487
  yield self if block_given?
990
1488
  end