google-cloud-org_policy-v2 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,26 +31,29 @@ 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
54
+ # @private
55
+ DEFAULT_ENDPOINT_TEMPLATE = "orgpolicy.$UNIVERSE_DOMAIN$"
56
+
54
57
  include Paths
55
58
 
56
59
  # @private
@@ -120,6 +123,31 @@ module Google
120
123
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
121
124
  }
122
125
 
126
+ default_config.rpcs.create_custom_constraint.timeout = 60.0
127
+ default_config.rpcs.create_custom_constraint.retry_policy = {
128
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
129
+ }
130
+
131
+ default_config.rpcs.update_custom_constraint.timeout = 60.0
132
+ default_config.rpcs.update_custom_constraint.retry_policy = {
133
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
134
+ }
135
+
136
+ default_config.rpcs.get_custom_constraint.timeout = 60.0
137
+ default_config.rpcs.get_custom_constraint.retry_policy = {
138
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
139
+ }
140
+
141
+ default_config.rpcs.list_custom_constraints.timeout = 60.0
142
+ default_config.rpcs.list_custom_constraints.retry_policy = {
143
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
144
+ }
145
+
146
+ default_config.rpcs.delete_custom_constraint.timeout = 60.0
147
+ default_config.rpcs.delete_custom_constraint.retry_policy = {
148
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
149
+ }
150
+
123
151
  default_config
124
152
  end
125
153
  yield @configure if block_given?
@@ -146,6 +174,15 @@ module Google
146
174
  @config
147
175
  end
148
176
 
177
+ ##
178
+ # The effective universe domain
179
+ #
180
+ # @return [String]
181
+ #
182
+ def universe_domain
183
+ @org_policy_stub.universe_domain
184
+ end
185
+
149
186
  ##
150
187
  # Create a new OrgPolicy REST client object.
151
188
  #
@@ -173,8 +210,9 @@ module Google
173
210
  credentials = @config.credentials
174
211
  # Use self-signed JWT if the endpoint is unchanged from default,
175
212
  # but only if the default endpoint does not have a region prefix.
176
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
177
- !@config.endpoint.split(".").first.include?("-")
213
+ enable_self_signed_jwt = @config.endpoint.nil? ||
214
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
215
+ !@config.endpoint.split(".").first.include?("-"))
178
216
  credentials ||= Credentials.default scope: @config.scope,
179
217
  enable_self_signed_jwt: enable_self_signed_jwt
180
218
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -184,13 +222,18 @@ module Google
184
222
  @quota_project_id = @config.quota_project
185
223
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
186
224
 
187
- @org_policy_stub = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
225
+ @org_policy_stub = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::ServiceStub.new(
226
+ endpoint: @config.endpoint,
227
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
228
+ universe_domain: @config.universe_domain,
229
+ credentials: credentials
230
+ )
188
231
  end
189
232
 
190
233
  # Service calls
191
234
 
192
235
  ##
193
- # Lists `Constraints` that could be applied on the specified resource.
236
+ # Lists constraints that could be applied on the specified resource.
194
237
  #
195
238
  # @overload list_constraints(request, options = nil)
196
239
  # Pass arguments to `list_constraints` via a request object, either of type
@@ -208,8 +251,9 @@ module Google
208
251
  # the default parameter values, pass an empty Hash as a request object (see above).
209
252
  #
210
253
  # @param parent [::String]
211
- # Required. The Cloud resource that parents the constraint. Must be in one of
212
- # the following forms:
254
+ # Required. The Google Cloud resource that parents the constraint. Must be in
255
+ # one of the following forms:
256
+ #
213
257
  # * `projects/{project_number}`
214
258
  # * `projects/{project_id}`
215
259
  # * `folders/{folder_id}`
@@ -285,7 +329,7 @@ module Google
285
329
  end
286
330
 
287
331
  ##
288
- # Retrieves all of the `Policies` that exist on a particular resource.
332
+ # Retrieves all of the policies that exist on a particular resource.
289
333
  #
290
334
  # @overload list_policies(request, options = nil)
291
335
  # Pass arguments to `list_policies` via a request object, either of type
@@ -303,9 +347,10 @@ module Google
303
347
  # the default parameter values, pass an empty Hash as a request object (see above).
304
348
  #
305
349
  # @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:
350
+ # Required. The target Google Cloud resource that parents the set of
351
+ # constraints and policies that will be returned from this call. Must be in
352
+ # one of the following forms:
353
+ #
309
354
  # * `projects/{project_number}`
310
355
  # * `projects/{project_id}`
311
356
  # * `folders/{folder_id}`
@@ -381,11 +426,11 @@ module Google
381
426
  end
382
427
 
383
428
  ##
384
- # Gets a `Policy` on a resource.
429
+ # Gets a policy on a resource.
385
430
  #
386
- # If no `Policy` is set on the resource, NOT_FOUND is returned. The
431
+ # If no policy is set on the resource, `NOT_FOUND` is returned. The
387
432
  # `etag` value can be used with `UpdatePolicy()` to update a
388
- # `Policy` during read-modify-write.
433
+ # policy during read-modify-write.
389
434
  #
390
435
  # @overload get_policy(request, options = nil)
391
436
  # Pass arguments to `get_policy` via a request object, either of type
@@ -403,8 +448,8 @@ module Google
403
448
  # the default parameter values, pass an empty Hash as a request object (see above).
404
449
  #
405
450
  # @param name [::String]
406
- # Required. Resource name of the policy. See `Policy` for naming
407
- # requirements.
451
+ # Required. Resource name of the policy. See
452
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
408
453
  # @yield [result, operation] Access the result along with the TransportOperation object
409
454
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
410
455
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -464,10 +509,10 @@ module Google
464
509
  end
465
510
 
466
511
  ##
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.
512
+ # Gets the effective policy on a resource. This is the result of merging
513
+ # policies in the resource hierarchy and evaluating conditions. The
514
+ # returned policy will not have an `etag` or `condition` set because it is
515
+ # an evaluated policy across multiple resources.
471
516
  # Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
472
517
  # not be expanded.
473
518
  #
@@ -487,7 +532,8 @@ module Google
487
532
  # the default parameter values, pass an empty Hash as a request object (see above).
488
533
  #
489
534
  # @param name [::String]
490
- # Required. The effective policy to compute. See `Policy` for naming rules.
535
+ # Required. The effective policy to compute. See
536
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
491
537
  # @yield [result, operation] Access the result along with the TransportOperation object
492
538
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
493
539
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -547,12 +593,12 @@ module Google
547
593
  end
548
594
 
549
595
  ##
550
- # Creates a Policy.
596
+ # Creates a policy.
551
597
  #
552
598
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
553
599
  # constraint does not exist.
554
600
  # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
555
- # policy already exists on the given Cloud resource.
601
+ # policy already exists on the given Google Cloud resource.
556
602
  #
557
603
  # @overload create_policy(request, options = nil)
558
604
  # Pass arguments to `create_policy` via a request object, either of type
@@ -570,14 +616,15 @@ module Google
570
616
  # the default parameter values, pass an empty Hash as a request object (see above).
571
617
  #
572
618
  # @param parent [::String]
573
- # Required. The Cloud resource that will parent the new Policy. Must be in
574
- # one of the following forms:
619
+ # Required. The Google Cloud resource that will parent the new policy. Must
620
+ # be in one of the following forms:
621
+ #
575
622
  # * `projects/{project_number}`
576
623
  # * `projects/{project_id}`
577
624
  # * `folders/{folder_id}`
578
625
  # * `organizations/{organization_id}`
579
626
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
580
- # Required. `Policy` to create.
627
+ # Required. Policy to create.
581
628
  # @yield [result, operation] Access the result along with the TransportOperation object
582
629
  # @yieldparam result [::Google::Cloud::OrgPolicy::V2::Policy]
583
630
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -637,7 +684,7 @@ module Google
637
684
  end
638
685
 
639
686
  ##
640
- # Updates a Policy.
687
+ # Updates a policy.
641
688
  #
642
689
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
643
690
  # constraint or the policy do not exist.
@@ -663,7 +710,7 @@ module Google
663
710
  # the default parameter values, pass an empty Hash as a request object (see above).
664
711
  #
665
712
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
666
- # Required. `Policy` to update.
713
+ # Required. Policy to update.
667
714
  # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
668
715
  # Field mask used to specify the fields to be overwritten in the policy
669
716
  # by the set. The fields specified in the update_mask are relative to the
@@ -727,10 +774,10 @@ module Google
727
774
  end
728
775
 
729
776
  ##
730
- # Deletes a Policy.
777
+ # Deletes a policy.
731
778
  #
732
779
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
733
- # constraint or Org Policy does not exist.
780
+ # constraint or organization policy does not exist.
734
781
  #
735
782
  # @overload delete_policy(request, options = nil)
736
783
  # Pass arguments to `delete_policy` via a request object, either of type
@@ -742,14 +789,18 @@ module Google
742
789
  # @param options [::Gapic::CallOptions, ::Hash]
743
790
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
744
791
  #
745
- # @overload delete_policy(name: nil)
792
+ # @overload delete_policy(name: nil, etag: nil)
746
793
  # Pass arguments to `delete_policy` via keyword arguments. Note that at
747
794
  # least one keyword argument is required. To specify no parameters, or to keep all
748
795
  # the default parameter values, pass an empty Hash as a request object (see above).
749
796
  #
750
797
  # @param name [::String]
751
798
  # Required. Name of the policy to delete.
752
- # See `Policy` for naming rules.
799
+ # See the policy entry for naming rules.
800
+ # @param etag [::String]
801
+ # Optional. The current etag of policy. If an etag is provided and does not
802
+ # match the current etag of the policy, deletion will be blocked and an
803
+ # ABORTED error will be returned.
753
804
  # @yield [result, operation] Access the result along with the TransportOperation object
754
805
  # @yieldparam result [::Google::Protobuf::Empty]
755
806
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -808,6 +859,436 @@ module Google
808
859
  raise ::Google::Cloud::Error.from_error(e)
809
860
  end
810
861
 
862
+ ##
863
+ # Creates a custom constraint.
864
+ #
865
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
866
+ # organization does not exist.
867
+ # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
868
+ # constraint already exists on the given organization.
869
+ #
870
+ # @overload create_custom_constraint(request, options = nil)
871
+ # Pass arguments to `create_custom_constraint` via a request object, either of type
872
+ # {::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest} or an equivalent Hash.
873
+ #
874
+ # @param request [::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest, ::Hash]
875
+ # A request object representing the call parameters. Required. To specify no
876
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
877
+ # @param options [::Gapic::CallOptions, ::Hash]
878
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
879
+ #
880
+ # @overload create_custom_constraint(parent: nil, custom_constraint: nil)
881
+ # Pass arguments to `create_custom_constraint` via keyword arguments. Note that at
882
+ # least one keyword argument is required. To specify no parameters, or to keep all
883
+ # the default parameter values, pass an empty Hash as a request object (see above).
884
+ #
885
+ # @param parent [::String]
886
+ # Required. Must be in the following form:
887
+ #
888
+ # * `organizations/{organization_id}`
889
+ # @param custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
890
+ # Required. Custom constraint to create.
891
+ # @yield [result, operation] Access the result along with the TransportOperation object
892
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
893
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
894
+ #
895
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
896
+ #
897
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
898
+ #
899
+ # @example Basic example
900
+ # require "google/cloud/org_policy/v2"
901
+ #
902
+ # # Create a client object. The client can be reused for multiple calls.
903
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
904
+ #
905
+ # # Create a request. To set request fields, pass in keyword arguments.
906
+ # request = Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest.new
907
+ #
908
+ # # Call the create_custom_constraint method.
909
+ # result = client.create_custom_constraint request
910
+ #
911
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
912
+ # p result
913
+ #
914
+ def create_custom_constraint request, options = nil
915
+ raise ::ArgumentError, "request must be provided" if request.nil?
916
+
917
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest
918
+
919
+ # Converts hash and nil to an options object
920
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
921
+
922
+ # Customize the options with defaults
923
+ call_metadata = @config.rpcs.create_custom_constraint.metadata.to_h
924
+
925
+ # Set x-goog-api-client and x-goog-user-project headers
926
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
927
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
928
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
929
+ transports_version_send: [:rest]
930
+
931
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
932
+
933
+ options.apply_defaults timeout: @config.rpcs.create_custom_constraint.timeout,
934
+ metadata: call_metadata,
935
+ retry_policy: @config.rpcs.create_custom_constraint.retry_policy
936
+
937
+ options.apply_defaults timeout: @config.timeout,
938
+ metadata: @config.metadata,
939
+ retry_policy: @config.retry_policy
940
+
941
+ @org_policy_stub.create_custom_constraint request, options do |result, operation|
942
+ yield result, operation if block_given?
943
+ return result
944
+ end
945
+ rescue ::Gapic::Rest::Error => e
946
+ raise ::Google::Cloud::Error.from_error(e)
947
+ end
948
+
949
+ ##
950
+ # Updates a custom constraint.
951
+ #
952
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
953
+ # constraint does not exist.
954
+ #
955
+ # Note: the supplied policy will perform a full overwrite of all
956
+ # fields.
957
+ #
958
+ # @overload update_custom_constraint(request, options = nil)
959
+ # Pass arguments to `update_custom_constraint` via a request object, either of type
960
+ # {::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest} or an equivalent Hash.
961
+ #
962
+ # @param request [::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest, ::Hash]
963
+ # A request object representing the call parameters. Required. To specify no
964
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
965
+ # @param options [::Gapic::CallOptions, ::Hash]
966
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
967
+ #
968
+ # @overload update_custom_constraint(custom_constraint: nil)
969
+ # Pass arguments to `update_custom_constraint` via keyword arguments. Note that at
970
+ # least one keyword argument is required. To specify no parameters, or to keep all
971
+ # the default parameter values, pass an empty Hash as a request object (see above).
972
+ #
973
+ # @param custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
974
+ # Required. `CustomConstraint` to update.
975
+ # @yield [result, operation] Access the result along with the TransportOperation object
976
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
977
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
978
+ #
979
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
980
+ #
981
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
982
+ #
983
+ # @example Basic example
984
+ # require "google/cloud/org_policy/v2"
985
+ #
986
+ # # Create a client object. The client can be reused for multiple calls.
987
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
988
+ #
989
+ # # Create a request. To set request fields, pass in keyword arguments.
990
+ # request = Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest.new
991
+ #
992
+ # # Call the update_custom_constraint method.
993
+ # result = client.update_custom_constraint request
994
+ #
995
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
996
+ # p result
997
+ #
998
+ def update_custom_constraint request, options = nil
999
+ raise ::ArgumentError, "request must be provided" if request.nil?
1000
+
1001
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest
1002
+
1003
+ # Converts hash and nil to an options object
1004
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1005
+
1006
+ # Customize the options with defaults
1007
+ call_metadata = @config.rpcs.update_custom_constraint.metadata.to_h
1008
+
1009
+ # Set x-goog-api-client and x-goog-user-project headers
1010
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1011
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1012
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1013
+ transports_version_send: [:rest]
1014
+
1015
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1016
+
1017
+ options.apply_defaults timeout: @config.rpcs.update_custom_constraint.timeout,
1018
+ metadata: call_metadata,
1019
+ retry_policy: @config.rpcs.update_custom_constraint.retry_policy
1020
+
1021
+ options.apply_defaults timeout: @config.timeout,
1022
+ metadata: @config.metadata,
1023
+ retry_policy: @config.retry_policy
1024
+
1025
+ @org_policy_stub.update_custom_constraint request, options do |result, operation|
1026
+ yield result, operation if block_given?
1027
+ return result
1028
+ end
1029
+ rescue ::Gapic::Rest::Error => e
1030
+ raise ::Google::Cloud::Error.from_error(e)
1031
+ end
1032
+
1033
+ ##
1034
+ # Gets a custom constraint.
1035
+ #
1036
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1037
+ # custom constraint does not exist.
1038
+ #
1039
+ # @overload get_custom_constraint(request, options = nil)
1040
+ # Pass arguments to `get_custom_constraint` via a request object, either of type
1041
+ # {::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest} or an equivalent Hash.
1042
+ #
1043
+ # @param request [::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest, ::Hash]
1044
+ # A request object representing the call parameters. Required. To specify no
1045
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1046
+ # @param options [::Gapic::CallOptions, ::Hash]
1047
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1048
+ #
1049
+ # @overload get_custom_constraint(name: nil)
1050
+ # Pass arguments to `get_custom_constraint` via keyword arguments. Note that at
1051
+ # least one keyword argument is required. To specify no parameters, or to keep all
1052
+ # the default parameter values, pass an empty Hash as a request object (see above).
1053
+ #
1054
+ # @param name [::String]
1055
+ # Required. Resource name of the custom constraint. See the custom constraint
1056
+ # entry for naming requirements.
1057
+ # @yield [result, operation] Access the result along with the TransportOperation object
1058
+ # @yieldparam result [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1059
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1060
+ #
1061
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1062
+ #
1063
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1064
+ #
1065
+ # @example Basic example
1066
+ # require "google/cloud/org_policy/v2"
1067
+ #
1068
+ # # Create a client object. The client can be reused for multiple calls.
1069
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1070
+ #
1071
+ # # Create a request. To set request fields, pass in keyword arguments.
1072
+ # request = Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest.new
1073
+ #
1074
+ # # Call the get_custom_constraint method.
1075
+ # result = client.get_custom_constraint request
1076
+ #
1077
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
1078
+ # p result
1079
+ #
1080
+ def get_custom_constraint request, options = nil
1081
+ raise ::ArgumentError, "request must be provided" if request.nil?
1082
+
1083
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest
1084
+
1085
+ # Converts hash and nil to an options object
1086
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1087
+
1088
+ # Customize the options with defaults
1089
+ call_metadata = @config.rpcs.get_custom_constraint.metadata.to_h
1090
+
1091
+ # Set x-goog-api-client and x-goog-user-project headers
1092
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1093
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1094
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1095
+ transports_version_send: [:rest]
1096
+
1097
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1098
+
1099
+ options.apply_defaults timeout: @config.rpcs.get_custom_constraint.timeout,
1100
+ metadata: call_metadata,
1101
+ retry_policy: @config.rpcs.get_custom_constraint.retry_policy
1102
+
1103
+ options.apply_defaults timeout: @config.timeout,
1104
+ metadata: @config.metadata,
1105
+ retry_policy: @config.retry_policy
1106
+
1107
+ @org_policy_stub.get_custom_constraint request, options do |result, operation|
1108
+ yield result, operation if block_given?
1109
+ return result
1110
+ end
1111
+ rescue ::Gapic::Rest::Error => e
1112
+ raise ::Google::Cloud::Error.from_error(e)
1113
+ end
1114
+
1115
+ ##
1116
+ # Retrieves all of the custom constraints that exist on a particular
1117
+ # organization resource.
1118
+ #
1119
+ # @overload list_custom_constraints(request, options = nil)
1120
+ # Pass arguments to `list_custom_constraints` via a request object, either of type
1121
+ # {::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest} or an equivalent Hash.
1122
+ #
1123
+ # @param request [::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest, ::Hash]
1124
+ # A request object representing the call parameters. Required. To specify no
1125
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1126
+ # @param options [::Gapic::CallOptions, ::Hash]
1127
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1128
+ #
1129
+ # @overload list_custom_constraints(parent: nil, page_size: nil, page_token: nil)
1130
+ # Pass arguments to `list_custom_constraints` via keyword arguments. Note that at
1131
+ # least one keyword argument is required. To specify no parameters, or to keep all
1132
+ # the default parameter values, pass an empty Hash as a request object (see above).
1133
+ #
1134
+ # @param parent [::String]
1135
+ # Required. The target Google Cloud resource that parents the set of custom
1136
+ # constraints that will be returned from this call. Must be in one of the
1137
+ # following forms:
1138
+ #
1139
+ # * `organizations/{organization_id}`
1140
+ # @param page_size [::Integer]
1141
+ # Size of the pages to be returned. This is currently unsupported and will
1142
+ # be ignored. The server may at any point start using this field to limit
1143
+ # page size.
1144
+ # @param page_token [::String]
1145
+ # Page token used to retrieve the next page. This is currently unsupported
1146
+ # and will be ignored. The server may at any point start using this field.
1147
+ # @yield [result, operation] Access the result along with the TransportOperation object
1148
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1149
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1150
+ #
1151
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1152
+ #
1153
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1154
+ #
1155
+ # @example Basic example
1156
+ # require "google/cloud/org_policy/v2"
1157
+ #
1158
+ # # Create a client object. The client can be reused for multiple calls.
1159
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1160
+ #
1161
+ # # Create a request. To set request fields, pass in keyword arguments.
1162
+ # request = Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest.new
1163
+ #
1164
+ # # Call the list_custom_constraints method.
1165
+ # result = client.list_custom_constraints request
1166
+ #
1167
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1168
+ # # over elements, and API calls will be issued to fetch pages as needed.
1169
+ # result.each do |item|
1170
+ # # Each element is of type ::Google::Cloud::OrgPolicy::V2::CustomConstraint.
1171
+ # p item
1172
+ # end
1173
+ #
1174
+ def list_custom_constraints request, options = nil
1175
+ raise ::ArgumentError, "request must be provided" if request.nil?
1176
+
1177
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest
1178
+
1179
+ # Converts hash and nil to an options object
1180
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1181
+
1182
+ # Customize the options with defaults
1183
+ call_metadata = @config.rpcs.list_custom_constraints.metadata.to_h
1184
+
1185
+ # Set x-goog-api-client and x-goog-user-project headers
1186
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1187
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1188
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1189
+ transports_version_send: [:rest]
1190
+
1191
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1192
+
1193
+ options.apply_defaults timeout: @config.rpcs.list_custom_constraints.timeout,
1194
+ metadata: call_metadata,
1195
+ retry_policy: @config.rpcs.list_custom_constraints.retry_policy
1196
+
1197
+ options.apply_defaults timeout: @config.timeout,
1198
+ metadata: @config.metadata,
1199
+ retry_policy: @config.retry_policy
1200
+
1201
+ @org_policy_stub.list_custom_constraints request, options do |result, operation|
1202
+ result = ::Gapic::Rest::PagedEnumerable.new @org_policy_stub, :list_custom_constraints, "custom_constraints", request, result, options
1203
+ yield result, operation if block_given?
1204
+ return result
1205
+ end
1206
+ rescue ::Gapic::Rest::Error => e
1207
+ raise ::Google::Cloud::Error.from_error(e)
1208
+ end
1209
+
1210
+ ##
1211
+ # Deletes a custom constraint.
1212
+ #
1213
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1214
+ # constraint does not exist.
1215
+ #
1216
+ # @overload delete_custom_constraint(request, options = nil)
1217
+ # Pass arguments to `delete_custom_constraint` via a request object, either of type
1218
+ # {::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest} or an equivalent Hash.
1219
+ #
1220
+ # @param request [::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest, ::Hash]
1221
+ # A request object representing the call parameters. Required. To specify no
1222
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1223
+ # @param options [::Gapic::CallOptions, ::Hash]
1224
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1225
+ #
1226
+ # @overload delete_custom_constraint(name: nil)
1227
+ # Pass arguments to `delete_custom_constraint` via keyword arguments. Note that at
1228
+ # least one keyword argument is required. To specify no parameters, or to keep all
1229
+ # the default parameter values, pass an empty Hash as a request object (see above).
1230
+ #
1231
+ # @param name [::String]
1232
+ # Required. Name of the custom constraint to delete.
1233
+ # See the custom constraint entry for naming rules.
1234
+ # @yield [result, operation] Access the result along with the TransportOperation object
1235
+ # @yieldparam result [::Google::Protobuf::Empty]
1236
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1237
+ #
1238
+ # @return [::Google::Protobuf::Empty]
1239
+ #
1240
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1241
+ #
1242
+ # @example Basic example
1243
+ # require "google/cloud/org_policy/v2"
1244
+ #
1245
+ # # Create a client object. The client can be reused for multiple calls.
1246
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Rest::Client.new
1247
+ #
1248
+ # # Create a request. To set request fields, pass in keyword arguments.
1249
+ # request = Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest.new
1250
+ #
1251
+ # # Call the delete_custom_constraint method.
1252
+ # result = client.delete_custom_constraint request
1253
+ #
1254
+ # # The returned object is of type Google::Protobuf::Empty.
1255
+ # p result
1256
+ #
1257
+ def delete_custom_constraint request, options = nil
1258
+ raise ::ArgumentError, "request must be provided" if request.nil?
1259
+
1260
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest
1261
+
1262
+ # Converts hash and nil to an options object
1263
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1264
+
1265
+ # Customize the options with defaults
1266
+ call_metadata = @config.rpcs.delete_custom_constraint.metadata.to_h
1267
+
1268
+ # Set x-goog-api-client and x-goog-user-project headers
1269
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1270
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1271
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION,
1272
+ transports_version_send: [:rest]
1273
+
1274
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1275
+
1276
+ options.apply_defaults timeout: @config.rpcs.delete_custom_constraint.timeout,
1277
+ metadata: call_metadata,
1278
+ retry_policy: @config.rpcs.delete_custom_constraint.retry_policy
1279
+
1280
+ options.apply_defaults timeout: @config.timeout,
1281
+ metadata: @config.metadata,
1282
+ retry_policy: @config.retry_policy
1283
+
1284
+ @org_policy_stub.delete_custom_constraint request, options do |result, operation|
1285
+ yield result, operation if block_given?
1286
+ return result
1287
+ end
1288
+ rescue ::Gapic::Rest::Error => e
1289
+ raise ::Google::Cloud::Error.from_error(e)
1290
+ end
1291
+
811
1292
  ##
812
1293
  # Configuration class for the OrgPolicy REST API.
813
1294
  #
@@ -838,9 +1319,9 @@ module Google
838
1319
  # end
839
1320
  #
840
1321
  # @!attribute [rw] endpoint
841
- # The hostname or hostname:port of the service endpoint.
842
- # Defaults to `"orgpolicy.googleapis.com"`.
843
- # @return [::String]
1322
+ # A custom service endpoint, as a hostname or hostname:port. The default is
1323
+ # nil, indicating to use the default endpoint in the current universe domain.
1324
+ # @return [::String,nil]
844
1325
  # @!attribute [rw] credentials
845
1326
  # Credentials to send with calls. You may provide any of the following types:
846
1327
  # * (`String`) The path to a service account key file in JSON format
@@ -877,13 +1358,20 @@ module Google
877
1358
  # @!attribute [rw] quota_project
878
1359
  # A separate project against which to charge quota.
879
1360
  # @return [::String]
1361
+ # @!attribute [rw] universe_domain
1362
+ # The universe domain within which to make requests. This determines the
1363
+ # default endpoint URL. The default value of nil uses the environment
1364
+ # universe (usually the default "googleapis.com" universe).
1365
+ # @return [::String,nil]
880
1366
  #
881
1367
  class Configuration
882
1368
  extend ::Gapic::Config
883
1369
 
1370
+ # @private
1371
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
884
1372
  DEFAULT_ENDPOINT = "orgpolicy.googleapis.com"
885
1373
 
886
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
1374
+ config_attr :endpoint, nil, ::String, nil
887
1375
  config_attr :credentials, nil do |value|
888
1376
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
889
1377
  allowed.any? { |klass| klass === value }
@@ -895,6 +1383,7 @@ module Google
895
1383
  config_attr :metadata, nil, ::Hash, nil
896
1384
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
897
1385
  config_attr :quota_project, nil, ::String, nil
1386
+ config_attr :universe_domain, nil, ::String, nil
898
1387
 
899
1388
  # @private
900
1389
  def initialize parent_config = nil
@@ -968,6 +1457,31 @@ module Google
968
1457
  # @return [::Gapic::Config::Method]
969
1458
  #
970
1459
  attr_reader :delete_policy
1460
+ ##
1461
+ # RPC-specific configuration for `create_custom_constraint`
1462
+ # @return [::Gapic::Config::Method]
1463
+ #
1464
+ attr_reader :create_custom_constraint
1465
+ ##
1466
+ # RPC-specific configuration for `update_custom_constraint`
1467
+ # @return [::Gapic::Config::Method]
1468
+ #
1469
+ attr_reader :update_custom_constraint
1470
+ ##
1471
+ # RPC-specific configuration for `get_custom_constraint`
1472
+ # @return [::Gapic::Config::Method]
1473
+ #
1474
+ attr_reader :get_custom_constraint
1475
+ ##
1476
+ # RPC-specific configuration for `list_custom_constraints`
1477
+ # @return [::Gapic::Config::Method]
1478
+ #
1479
+ attr_reader :list_custom_constraints
1480
+ ##
1481
+ # RPC-specific configuration for `delete_custom_constraint`
1482
+ # @return [::Gapic::Config::Method]
1483
+ #
1484
+ attr_reader :delete_custom_constraint
971
1485
 
972
1486
  # @private
973
1487
  def initialize parent_rpcs = nil
@@ -985,6 +1499,16 @@ module Google
985
1499
  @update_policy = ::Gapic::Config::Method.new update_policy_config
986
1500
  delete_policy_config = parent_rpcs.delete_policy if parent_rpcs.respond_to? :delete_policy
987
1501
  @delete_policy = ::Gapic::Config::Method.new delete_policy_config
1502
+ create_custom_constraint_config = parent_rpcs.create_custom_constraint if parent_rpcs.respond_to? :create_custom_constraint
1503
+ @create_custom_constraint = ::Gapic::Config::Method.new create_custom_constraint_config
1504
+ update_custom_constraint_config = parent_rpcs.update_custom_constraint if parent_rpcs.respond_to? :update_custom_constraint
1505
+ @update_custom_constraint = ::Gapic::Config::Method.new update_custom_constraint_config
1506
+ get_custom_constraint_config = parent_rpcs.get_custom_constraint if parent_rpcs.respond_to? :get_custom_constraint
1507
+ @get_custom_constraint = ::Gapic::Config::Method.new get_custom_constraint_config
1508
+ list_custom_constraints_config = parent_rpcs.list_custom_constraints if parent_rpcs.respond_to? :list_custom_constraints
1509
+ @list_custom_constraints = ::Gapic::Config::Method.new list_custom_constraints_config
1510
+ delete_custom_constraint_config = parent_rpcs.delete_custom_constraint if parent_rpcs.respond_to? :delete_custom_constraint
1511
+ @delete_custom_constraint = ::Gapic::Config::Method.new delete_custom_constraint_config
988
1512
 
989
1513
  yield self if block_given?
990
1514
  end