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.
@@ -29,26 +29,29 @@ module Google
29
29
  #
30
30
  # An interface for managing organization policies.
31
31
  #
32
- # The Cloud Org Policy service provides a simple mechanism for organizations to
33
- # restrict the allowed configurations across their entire Cloud Resource
34
- # hierarchy.
32
+ # The Organization Policy Service provides a simple mechanism for
33
+ # organizations to restrict the allowed configurations across their entire
34
+ # resource hierarchy.
35
35
  #
36
- # You can use a `policy` to configure restrictions in Cloud resources. For
37
- # example, you can enforce a `policy` that restricts which Google
38
- # Cloud Platform APIs can be activated in a certain part of your resource
39
- # hierarchy, or prevents serial port access to VM instances in a particular
40
- # folder.
36
+ # You can use a policy to configure restrictions on resources. For
37
+ # example, you can enforce a policy that restricts which Google
38
+ # Cloud APIs can be activated in a certain part of your resource
39
+ # hierarchy, or prevents serial port access to VM instances in a
40
+ # particular folder.
41
41
  #
42
- # `Policies` are inherited down through the resource hierarchy. A `policy`
42
+ # Policies are inherited down through the resource hierarchy. A policy
43
43
  # applied to a parent resource automatically applies to all its child resources
44
- # unless overridden with a `policy` lower in the hierarchy.
44
+ # unless overridden with a policy lower in the hierarchy.
45
45
  #
46
- # A `constraint` defines an aspect of a resource's configuration that can be
47
- # controlled by an organization's policy administrator. `Policies` are a
48
- # collection of `constraints` that defines their allowable configuration on a
46
+ # A constraint defines an aspect of a resource's configuration that can be
47
+ # controlled by an organization's policy administrator. Policies are a
48
+ # collection of constraints that defines their allowable configuration on a
49
49
  # particular resource and its child resources.
50
50
  #
51
51
  class Client
52
+ # @private
53
+ DEFAULT_ENDPOINT_TEMPLATE = "orgpolicy.$UNIVERSE_DOMAIN$"
54
+
52
55
  include Paths
53
56
 
54
57
  # @private
@@ -118,6 +121,31 @@ module Google
118
121
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
119
122
  }
120
123
 
124
+ default_config.rpcs.create_custom_constraint.timeout = 60.0
125
+ default_config.rpcs.create_custom_constraint.retry_policy = {
126
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
127
+ }
128
+
129
+ default_config.rpcs.update_custom_constraint.timeout = 60.0
130
+ default_config.rpcs.update_custom_constraint.retry_policy = {
131
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
132
+ }
133
+
134
+ default_config.rpcs.get_custom_constraint.timeout = 60.0
135
+ default_config.rpcs.get_custom_constraint.retry_policy = {
136
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
137
+ }
138
+
139
+ default_config.rpcs.list_custom_constraints.timeout = 60.0
140
+ default_config.rpcs.list_custom_constraints.retry_policy = {
141
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
142
+ }
143
+
144
+ default_config.rpcs.delete_custom_constraint.timeout = 60.0
145
+ default_config.rpcs.delete_custom_constraint.retry_policy = {
146
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
147
+ }
148
+
121
149
  default_config
122
150
  end
123
151
  yield @configure if block_given?
@@ -144,6 +172,15 @@ module Google
144
172
  @config
145
173
  end
146
174
 
175
+ ##
176
+ # The effective universe domain
177
+ #
178
+ # @return [String]
179
+ #
180
+ def universe_domain
181
+ @org_policy_stub.universe_domain
182
+ end
183
+
147
184
  ##
148
185
  # Create a new OrgPolicy client object.
149
186
  #
@@ -177,8 +214,9 @@ module Google
177
214
  credentials = @config.credentials
178
215
  # Use self-signed JWT if the endpoint is unchanged from default,
179
216
  # but only if the default endpoint does not have a region prefix.
180
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
181
- !@config.endpoint.split(".").first.include?("-")
217
+ enable_self_signed_jwt = @config.endpoint.nil? ||
218
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
219
+ !@config.endpoint.split(".").first.include?("-"))
182
220
  credentials ||= Credentials.default scope: @config.scope,
183
221
  enable_self_signed_jwt: enable_self_signed_jwt
184
222
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -189,8 +227,10 @@ module Google
189
227
 
190
228
  @org_policy_stub = ::Gapic::ServiceStub.new(
191
229
  ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Stub,
192
- credentials: credentials,
193
- endpoint: @config.endpoint,
230
+ credentials: credentials,
231
+ endpoint: @config.endpoint,
232
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
233
+ universe_domain: @config.universe_domain,
194
234
  channel_args: @config.channel_args,
195
235
  interceptors: @config.interceptors,
196
236
  channel_pool_config: @config.channel_pool
@@ -200,7 +240,7 @@ module Google
200
240
  # Service calls
201
241
 
202
242
  ##
203
- # Lists `Constraints` that could be applied on the specified resource.
243
+ # Lists constraints that could be applied on the specified resource.
204
244
  #
205
245
  # @overload list_constraints(request, options = nil)
206
246
  # Pass arguments to `list_constraints` via a request object, either of type
@@ -218,8 +258,9 @@ module Google
218
258
  # the default parameter values, pass an empty Hash as a request object (see above).
219
259
  #
220
260
  # @param parent [::String]
221
- # Required. The Cloud resource that parents the constraint. Must be in one of
222
- # the following forms:
261
+ # Required. The Google Cloud resource that parents the constraint. Must be in
262
+ # one of the following forms:
263
+ #
223
264
  # * `projects/{project_number}`
224
265
  # * `projects/{project_id}`
225
266
  # * `folders/{folder_id}`
@@ -302,7 +343,7 @@ module Google
302
343
  end
303
344
 
304
345
  ##
305
- # Retrieves all of the `Policies` that exist on a particular resource.
346
+ # Retrieves all of the policies that exist on a particular resource.
306
347
  #
307
348
  # @overload list_policies(request, options = nil)
308
349
  # Pass arguments to `list_policies` via a request object, either of type
@@ -320,9 +361,10 @@ module Google
320
361
  # the default parameter values, pass an empty Hash as a request object (see above).
321
362
  #
322
363
  # @param parent [::String]
323
- # Required. The target Cloud resource that parents the set of constraints and
324
- # policies that will be returned from this call. Must be in one of the
325
- # following forms:
364
+ # Required. The target Google Cloud resource that parents the set of
365
+ # constraints and policies that will be returned from this call. Must be in
366
+ # one of the following forms:
367
+ #
326
368
  # * `projects/{project_number}`
327
369
  # * `projects/{project_id}`
328
370
  # * `folders/{folder_id}`
@@ -405,11 +447,11 @@ module Google
405
447
  end
406
448
 
407
449
  ##
408
- # Gets a `Policy` on a resource.
450
+ # Gets a policy on a resource.
409
451
  #
410
- # If no `Policy` is set on the resource, NOT_FOUND is returned. The
452
+ # If no policy is set on the resource, `NOT_FOUND` is returned. The
411
453
  # `etag` value can be used with `UpdatePolicy()` to update a
412
- # `Policy` during read-modify-write.
454
+ # policy during read-modify-write.
413
455
  #
414
456
  # @overload get_policy(request, options = nil)
415
457
  # Pass arguments to `get_policy` via a request object, either of type
@@ -427,8 +469,8 @@ module Google
427
469
  # the default parameter values, pass an empty Hash as a request object (see above).
428
470
  #
429
471
  # @param name [::String]
430
- # Required. Resource name of the policy. See `Policy` for naming
431
- # requirements.
472
+ # Required. Resource name of the policy. See
473
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
432
474
  #
433
475
  # @yield [response, operation] Access the result along with the RPC operation
434
476
  # @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
@@ -495,10 +537,10 @@ module Google
495
537
  end
496
538
 
497
539
  ##
498
- # Gets the effective `Policy` on a resource. This is the result of merging
499
- # `Policies` in the resource hierarchy and evaluating conditions. The
500
- # returned `Policy` will not have an `etag` or `condition` set because it is
501
- # a computed `Policy` across multiple resources.
540
+ # Gets the effective policy on a resource. This is the result of merging
541
+ # policies in the resource hierarchy and evaluating conditions. The
542
+ # returned policy will not have an `etag` or `condition` set because it is
543
+ # an evaluated policy across multiple resources.
502
544
  # Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
503
545
  # not be expanded.
504
546
  #
@@ -518,7 +560,8 @@ module Google
518
560
  # the default parameter values, pass an empty Hash as a request object (see above).
519
561
  #
520
562
  # @param name [::String]
521
- # Required. The effective policy to compute. See `Policy` for naming rules.
563
+ # Required. The effective policy to compute. See
564
+ # {::Google::Cloud::OrgPolicy::V2::Policy Policy} for naming requirements.
522
565
  #
523
566
  # @yield [response, operation] Access the result along with the RPC operation
524
567
  # @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
@@ -585,12 +628,12 @@ module Google
585
628
  end
586
629
 
587
630
  ##
588
- # Creates a Policy.
631
+ # Creates a policy.
589
632
  #
590
633
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
591
634
  # constraint does not exist.
592
635
  # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
593
- # policy already exists on the given Cloud resource.
636
+ # policy already exists on the given Google Cloud resource.
594
637
  #
595
638
  # @overload create_policy(request, options = nil)
596
639
  # Pass arguments to `create_policy` via a request object, either of type
@@ -608,14 +651,15 @@ module Google
608
651
  # the default parameter values, pass an empty Hash as a request object (see above).
609
652
  #
610
653
  # @param parent [::String]
611
- # Required. The Cloud resource that will parent the new Policy. Must be in
612
- # one of the following forms:
654
+ # Required. The Google Cloud resource that will parent the new policy. Must
655
+ # be in one of the following forms:
656
+ #
613
657
  # * `projects/{project_number}`
614
658
  # * `projects/{project_id}`
615
659
  # * `folders/{folder_id}`
616
660
  # * `organizations/{organization_id}`
617
661
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
618
- # Required. `Policy` to create.
662
+ # Required. Policy to create.
619
663
  #
620
664
  # @yield [response, operation] Access the result along with the RPC operation
621
665
  # @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
@@ -682,7 +726,7 @@ module Google
682
726
  end
683
727
 
684
728
  ##
685
- # Updates a Policy.
729
+ # Updates a policy.
686
730
  #
687
731
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
688
732
  # constraint or the policy do not exist.
@@ -708,7 +752,7 @@ module Google
708
752
  # the default parameter values, pass an empty Hash as a request object (see above).
709
753
  #
710
754
  # @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
711
- # Required. `Policy` to update.
755
+ # Required. Policy to update.
712
756
  # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
713
757
  # Field mask used to specify the fields to be overwritten in the policy
714
758
  # by the set. The fields specified in the update_mask are relative to the
@@ -779,10 +823,10 @@ module Google
779
823
  end
780
824
 
781
825
  ##
782
- # Deletes a Policy.
826
+ # Deletes a policy.
783
827
  #
784
828
  # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
785
- # constraint or Org Policy does not exist.
829
+ # constraint or organization policy does not exist.
786
830
  #
787
831
  # @overload delete_policy(request, options = nil)
788
832
  # Pass arguments to `delete_policy` via a request object, either of type
@@ -794,14 +838,18 @@ module Google
794
838
  # @param options [::Gapic::CallOptions, ::Hash]
795
839
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
796
840
  #
797
- # @overload delete_policy(name: nil)
841
+ # @overload delete_policy(name: nil, etag: nil)
798
842
  # Pass arguments to `delete_policy` via keyword arguments. Note that at
799
843
  # least one keyword argument is required. To specify no parameters, or to keep all
800
844
  # the default parameter values, pass an empty Hash as a request object (see above).
801
845
  #
802
846
  # @param name [::String]
803
847
  # Required. Name of the policy to delete.
804
- # See `Policy` for naming rules.
848
+ # See the policy entry for naming rules.
849
+ # @param etag [::String]
850
+ # Optional. The current etag of policy. If an etag is provided and does not
851
+ # match the current etag of the policy, deletion will be blocked and an
852
+ # ABORTED error will be returned.
805
853
  #
806
854
  # @yield [response, operation] Access the result along with the RPC operation
807
855
  # @yieldparam response [::Google::Protobuf::Empty]
@@ -867,6 +915,471 @@ module Google
867
915
  raise ::Google::Cloud::Error.from_error(e)
868
916
  end
869
917
 
918
+ ##
919
+ # Creates a custom constraint.
920
+ #
921
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
922
+ # organization does not exist.
923
+ # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
924
+ # constraint already exists on the given organization.
925
+ #
926
+ # @overload create_custom_constraint(request, options = nil)
927
+ # Pass arguments to `create_custom_constraint` via a request object, either of type
928
+ # {::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest} or an equivalent Hash.
929
+ #
930
+ # @param request [::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest, ::Hash]
931
+ # A request object representing the call parameters. Required. To specify no
932
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
933
+ # @param options [::Gapic::CallOptions, ::Hash]
934
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
935
+ #
936
+ # @overload create_custom_constraint(parent: nil, custom_constraint: nil)
937
+ # Pass arguments to `create_custom_constraint` via keyword arguments. Note that at
938
+ # least one keyword argument is required. To specify no parameters, or to keep all
939
+ # the default parameter values, pass an empty Hash as a request object (see above).
940
+ #
941
+ # @param parent [::String]
942
+ # Required. Must be in the following form:
943
+ #
944
+ # * `organizations/{organization_id}`
945
+ # @param custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
946
+ # Required. Custom constraint to create.
947
+ #
948
+ # @yield [response, operation] Access the result along with the RPC operation
949
+ # @yieldparam response [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
950
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
951
+ #
952
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
953
+ #
954
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
955
+ #
956
+ # @example Basic example
957
+ # require "google/cloud/org_policy/v2"
958
+ #
959
+ # # Create a client object. The client can be reused for multiple calls.
960
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
961
+ #
962
+ # # Create a request. To set request fields, pass in keyword arguments.
963
+ # request = Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest.new
964
+ #
965
+ # # Call the create_custom_constraint method.
966
+ # result = client.create_custom_constraint request
967
+ #
968
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
969
+ # p result
970
+ #
971
+ def create_custom_constraint request, options = nil
972
+ raise ::ArgumentError, "request must be provided" if request.nil?
973
+
974
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::CreateCustomConstraintRequest
975
+
976
+ # Converts hash and nil to an options object
977
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
978
+
979
+ # Customize the options with defaults
980
+ metadata = @config.rpcs.create_custom_constraint.metadata.to_h
981
+
982
+ # Set x-goog-api-client and x-goog-user-project headers
983
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
984
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
985
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
986
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
987
+
988
+ header_params = {}
989
+ if request.parent
990
+ header_params["parent"] = request.parent
991
+ end
992
+
993
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
994
+ metadata[:"x-goog-request-params"] ||= request_params_header
995
+
996
+ options.apply_defaults timeout: @config.rpcs.create_custom_constraint.timeout,
997
+ metadata: metadata,
998
+ retry_policy: @config.rpcs.create_custom_constraint.retry_policy
999
+
1000
+ options.apply_defaults timeout: @config.timeout,
1001
+ metadata: @config.metadata,
1002
+ retry_policy: @config.retry_policy
1003
+
1004
+ @org_policy_stub.call_rpc :create_custom_constraint, request, options: options do |response, operation|
1005
+ yield response, operation if block_given?
1006
+ return response
1007
+ end
1008
+ rescue ::GRPC::BadStatus => e
1009
+ raise ::Google::Cloud::Error.from_error(e)
1010
+ end
1011
+
1012
+ ##
1013
+ # Updates a custom constraint.
1014
+ #
1015
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1016
+ # constraint does not exist.
1017
+ #
1018
+ # Note: the supplied policy will perform a full overwrite of all
1019
+ # fields.
1020
+ #
1021
+ # @overload update_custom_constraint(request, options = nil)
1022
+ # Pass arguments to `update_custom_constraint` via a request object, either of type
1023
+ # {::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest} or an equivalent Hash.
1024
+ #
1025
+ # @param request [::Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest, ::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 update_custom_constraint(custom_constraint: nil)
1032
+ # Pass arguments to `update_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 custom_constraint [::Google::Cloud::OrgPolicy::V2::CustomConstraint, ::Hash]
1037
+ # Required. `CustomConstraint` to update.
1038
+ #
1039
+ # @yield [response, operation] Access the result along with the RPC operation
1040
+ # @yieldparam response [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1041
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1042
+ #
1043
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1044
+ #
1045
+ # @raise [::Google::Cloud::Error] if the RPC 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::Client.new
1052
+ #
1053
+ # # Create a request. To set request fields, pass in keyword arguments.
1054
+ # request = Google::Cloud::OrgPolicy::V2::UpdateCustomConstraintRequest.new
1055
+ #
1056
+ # # Call the update_custom_constraint method.
1057
+ # result = client.update_custom_constraint request
1058
+ #
1059
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
1060
+ # p result
1061
+ #
1062
+ def update_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::UpdateCustomConstraintRequest
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
+ metadata = @config.rpcs.update_custom_constraint.metadata.to_h
1072
+
1073
+ # Set x-goog-api-client and x-goog-user-project headers
1074
+ 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
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1078
+
1079
+ header_params = {}
1080
+ if request.custom_constraint&.name
1081
+ header_params["custom_constraint.name"] = request.custom_constraint.name
1082
+ end
1083
+
1084
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1085
+ metadata[:"x-goog-request-params"] ||= request_params_header
1086
+
1087
+ options.apply_defaults timeout: @config.rpcs.update_custom_constraint.timeout,
1088
+ metadata: metadata,
1089
+ retry_policy: @config.rpcs.update_custom_constraint.retry_policy
1090
+
1091
+ options.apply_defaults timeout: @config.timeout,
1092
+ metadata: @config.metadata,
1093
+ retry_policy: @config.retry_policy
1094
+
1095
+ @org_policy_stub.call_rpc :update_custom_constraint, request, options: options do |response, operation|
1096
+ yield response, operation if block_given?
1097
+ return response
1098
+ end
1099
+ rescue ::GRPC::BadStatus => e
1100
+ raise ::Google::Cloud::Error.from_error(e)
1101
+ end
1102
+
1103
+ ##
1104
+ # Gets a custom constraint.
1105
+ #
1106
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1107
+ # custom constraint does not exist.
1108
+ #
1109
+ # @overload get_custom_constraint(request, options = nil)
1110
+ # Pass arguments to `get_custom_constraint` via a request object, either of type
1111
+ # {::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest} or an equivalent Hash.
1112
+ #
1113
+ # @param request [::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest, ::Hash]
1114
+ # A request object representing the call parameters. Required. To specify no
1115
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1116
+ # @param options [::Gapic::CallOptions, ::Hash]
1117
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1118
+ #
1119
+ # @overload get_custom_constraint(name: nil)
1120
+ # Pass arguments to `get_custom_constraint` via keyword arguments. Note that at
1121
+ # least one keyword argument is required. To specify no parameters, or to keep all
1122
+ # the default parameter values, pass an empty Hash as a request object (see above).
1123
+ #
1124
+ # @param name [::String]
1125
+ # Required. Resource name of the custom constraint. See the custom constraint
1126
+ # entry for naming requirements.
1127
+ #
1128
+ # @yield [response, operation] Access the result along with the RPC operation
1129
+ # @yieldparam response [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1130
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1131
+ #
1132
+ # @return [::Google::Cloud::OrgPolicy::V2::CustomConstraint]
1133
+ #
1134
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1135
+ #
1136
+ # @example Basic example
1137
+ # require "google/cloud/org_policy/v2"
1138
+ #
1139
+ # # Create a client object. The client can be reused for multiple calls.
1140
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
1141
+ #
1142
+ # # Create a request. To set request fields, pass in keyword arguments.
1143
+ # request = Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest.new
1144
+ #
1145
+ # # Call the get_custom_constraint method.
1146
+ # result = client.get_custom_constraint request
1147
+ #
1148
+ # # The returned object is of type Google::Cloud::OrgPolicy::V2::CustomConstraint.
1149
+ # p result
1150
+ #
1151
+ def get_custom_constraint request, options = nil
1152
+ raise ::ArgumentError, "request must be provided" if request.nil?
1153
+
1154
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::GetCustomConstraintRequest
1155
+
1156
+ # Converts hash and nil to an options object
1157
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1158
+
1159
+ # Customize the options with defaults
1160
+ metadata = @config.rpcs.get_custom_constraint.metadata.to_h
1161
+
1162
+ # Set x-goog-api-client and x-goog-user-project headers
1163
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1164
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1165
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
1166
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1167
+
1168
+ header_params = {}
1169
+ if request.name
1170
+ header_params["name"] = request.name
1171
+ end
1172
+
1173
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1174
+ metadata[:"x-goog-request-params"] ||= request_params_header
1175
+
1176
+ options.apply_defaults timeout: @config.rpcs.get_custom_constraint.timeout,
1177
+ metadata: metadata,
1178
+ retry_policy: @config.rpcs.get_custom_constraint.retry_policy
1179
+
1180
+ options.apply_defaults timeout: @config.timeout,
1181
+ metadata: @config.metadata,
1182
+ retry_policy: @config.retry_policy
1183
+
1184
+ @org_policy_stub.call_rpc :get_custom_constraint, request, options: options do |response, operation|
1185
+ yield response, operation if block_given?
1186
+ return response
1187
+ end
1188
+ rescue ::GRPC::BadStatus => e
1189
+ raise ::Google::Cloud::Error.from_error(e)
1190
+ end
1191
+
1192
+ ##
1193
+ # Retrieves all of the custom constraints that exist on a particular
1194
+ # organization resource.
1195
+ #
1196
+ # @overload list_custom_constraints(request, options = nil)
1197
+ # Pass arguments to `list_custom_constraints` via a request object, either of type
1198
+ # {::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest} or an equivalent Hash.
1199
+ #
1200
+ # @param request [::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest, ::Hash]
1201
+ # A request object representing the call parameters. Required. To specify no
1202
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1203
+ # @param options [::Gapic::CallOptions, ::Hash]
1204
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1205
+ #
1206
+ # @overload list_custom_constraints(parent: nil, page_size: nil, page_token: nil)
1207
+ # Pass arguments to `list_custom_constraints` via keyword arguments. Note that at
1208
+ # least one keyword argument is required. To specify no parameters, or to keep all
1209
+ # the default parameter values, pass an empty Hash as a request object (see above).
1210
+ #
1211
+ # @param parent [::String]
1212
+ # Required. The target Google Cloud resource that parents the set of custom
1213
+ # constraints that will be returned from this call. Must be in one of the
1214
+ # following forms:
1215
+ #
1216
+ # * `organizations/{organization_id}`
1217
+ # @param page_size [::Integer]
1218
+ # Size of the pages to be returned. This is currently unsupported and will
1219
+ # be ignored. The server may at any point start using this field to limit
1220
+ # page size.
1221
+ # @param page_token [::String]
1222
+ # Page token used to retrieve the next page. This is currently unsupported
1223
+ # and will be ignored. The server may at any point start using this field.
1224
+ #
1225
+ # @yield [response, operation] Access the result along with the RPC operation
1226
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1227
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1228
+ #
1229
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::CustomConstraint>]
1230
+ #
1231
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1232
+ #
1233
+ # @example Basic example
1234
+ # require "google/cloud/org_policy/v2"
1235
+ #
1236
+ # # Create a client object. The client can be reused for multiple calls.
1237
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
1238
+ #
1239
+ # # Create a request. To set request fields, pass in keyword arguments.
1240
+ # request = Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest.new
1241
+ #
1242
+ # # Call the list_custom_constraints method.
1243
+ # result = client.list_custom_constraints request
1244
+ #
1245
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1246
+ # # over elements, and API calls will be issued to fetch pages as needed.
1247
+ # result.each do |item|
1248
+ # # Each element is of type ::Google::Cloud::OrgPolicy::V2::CustomConstraint.
1249
+ # p item
1250
+ # end
1251
+ #
1252
+ def list_custom_constraints request, options = nil
1253
+ raise ::ArgumentError, "request must be provided" if request.nil?
1254
+
1255
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::ListCustomConstraintsRequest
1256
+
1257
+ # Converts hash and nil to an options object
1258
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1259
+
1260
+ # Customize the options with defaults
1261
+ metadata = @config.rpcs.list_custom_constraints.metadata.to_h
1262
+
1263
+ # Set x-goog-api-client and x-goog-user-project headers
1264
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1265
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1266
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
1267
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1268
+
1269
+ header_params = {}
1270
+ if request.parent
1271
+ header_params["parent"] = request.parent
1272
+ end
1273
+
1274
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1275
+ metadata[:"x-goog-request-params"] ||= request_params_header
1276
+
1277
+ options.apply_defaults timeout: @config.rpcs.list_custom_constraints.timeout,
1278
+ metadata: metadata,
1279
+ retry_policy: @config.rpcs.list_custom_constraints.retry_policy
1280
+
1281
+ options.apply_defaults timeout: @config.timeout,
1282
+ metadata: @config.metadata,
1283
+ retry_policy: @config.retry_policy
1284
+
1285
+ @org_policy_stub.call_rpc :list_custom_constraints, request, options: options do |response, operation|
1286
+ response = ::Gapic::PagedEnumerable.new @org_policy_stub, :list_custom_constraints, request, response, operation, options
1287
+ yield response, operation if block_given?
1288
+ return response
1289
+ end
1290
+ rescue ::GRPC::BadStatus => e
1291
+ raise ::Google::Cloud::Error.from_error(e)
1292
+ end
1293
+
1294
+ ##
1295
+ # Deletes a custom constraint.
1296
+ #
1297
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
1298
+ # constraint does not exist.
1299
+ #
1300
+ # @overload delete_custom_constraint(request, options = nil)
1301
+ # Pass arguments to `delete_custom_constraint` via a request object, either of type
1302
+ # {::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest} or an equivalent Hash.
1303
+ #
1304
+ # @param request [::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest, ::Hash]
1305
+ # A request object representing the call parameters. Required. To specify no
1306
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1307
+ # @param options [::Gapic::CallOptions, ::Hash]
1308
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1309
+ #
1310
+ # @overload delete_custom_constraint(name: nil)
1311
+ # Pass arguments to `delete_custom_constraint` via keyword arguments. Note that at
1312
+ # least one keyword argument is required. To specify no parameters, or to keep all
1313
+ # the default parameter values, pass an empty Hash as a request object (see above).
1314
+ #
1315
+ # @param name [::String]
1316
+ # Required. Name of the custom constraint to delete.
1317
+ # See the custom constraint entry for naming rules.
1318
+ #
1319
+ # @yield [response, operation] Access the result along with the RPC operation
1320
+ # @yieldparam response [::Google::Protobuf::Empty]
1321
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1322
+ #
1323
+ # @return [::Google::Protobuf::Empty]
1324
+ #
1325
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1326
+ #
1327
+ # @example Basic example
1328
+ # require "google/cloud/org_policy/v2"
1329
+ #
1330
+ # # Create a client object. The client can be reused for multiple calls.
1331
+ # client = Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
1332
+ #
1333
+ # # Create a request. To set request fields, pass in keyword arguments.
1334
+ # request = Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest.new
1335
+ #
1336
+ # # Call the delete_custom_constraint method.
1337
+ # result = client.delete_custom_constraint request
1338
+ #
1339
+ # # The returned object is of type Google::Protobuf::Empty.
1340
+ # p result
1341
+ #
1342
+ def delete_custom_constraint request, options = nil
1343
+ raise ::ArgumentError, "request must be provided" if request.nil?
1344
+
1345
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::DeleteCustomConstraintRequest
1346
+
1347
+ # Converts hash and nil to an options object
1348
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1349
+
1350
+ # Customize the options with defaults
1351
+ metadata = @config.rpcs.delete_custom_constraint.metadata.to_h
1352
+
1353
+ # Set x-goog-api-client and x-goog-user-project headers
1354
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1355
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1356
+ gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
1357
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1358
+
1359
+ header_params = {}
1360
+ if request.name
1361
+ header_params["name"] = request.name
1362
+ end
1363
+
1364
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1365
+ metadata[:"x-goog-request-params"] ||= request_params_header
1366
+
1367
+ options.apply_defaults timeout: @config.rpcs.delete_custom_constraint.timeout,
1368
+ metadata: metadata,
1369
+ retry_policy: @config.rpcs.delete_custom_constraint.retry_policy
1370
+
1371
+ options.apply_defaults timeout: @config.timeout,
1372
+ metadata: @config.metadata,
1373
+ retry_policy: @config.retry_policy
1374
+
1375
+ @org_policy_stub.call_rpc :delete_custom_constraint, request, options: options do |response, operation|
1376
+ yield response, operation if block_given?
1377
+ return response
1378
+ end
1379
+ rescue ::GRPC::BadStatus => e
1380
+ raise ::Google::Cloud::Error.from_error(e)
1381
+ end
1382
+
870
1383
  ##
871
1384
  # Configuration class for the OrgPolicy API.
872
1385
  #
@@ -897,9 +1410,9 @@ module Google
897
1410
  # end
898
1411
  #
899
1412
  # @!attribute [rw] endpoint
900
- # The hostname or hostname:port of the service endpoint.
901
- # Defaults to `"orgpolicy.googleapis.com"`.
902
- # @return [::String]
1413
+ # A custom service endpoint, as a hostname or hostname:port. The default is
1414
+ # nil, indicating to use the default endpoint in the current universe domain.
1415
+ # @return [::String,nil]
903
1416
  # @!attribute [rw] credentials
904
1417
  # Credentials to send with calls. You may provide any of the following types:
905
1418
  # * (`String`) The path to a service account key file in JSON format
@@ -945,13 +1458,20 @@ module Google
945
1458
  # @!attribute [rw] quota_project
946
1459
  # A separate project against which to charge quota.
947
1460
  # @return [::String]
1461
+ # @!attribute [rw] universe_domain
1462
+ # The universe domain within which to make requests. This determines the
1463
+ # default endpoint URL. The default value of nil uses the environment
1464
+ # universe (usually the default "googleapis.com" universe).
1465
+ # @return [::String,nil]
948
1466
  #
949
1467
  class Configuration
950
1468
  extend ::Gapic::Config
951
1469
 
1470
+ # @private
1471
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
952
1472
  DEFAULT_ENDPOINT = "orgpolicy.googleapis.com"
953
1473
 
954
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
1474
+ config_attr :endpoint, nil, ::String, nil
955
1475
  config_attr :credentials, nil do |value|
956
1476
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
957
1477
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
@@ -966,6 +1486,7 @@ module Google
966
1486
  config_attr :metadata, nil, ::Hash, nil
967
1487
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
968
1488
  config_attr :quota_project, nil, ::String, nil
1489
+ config_attr :universe_domain, nil, ::String, nil
969
1490
 
970
1491
  # @private
971
1492
  def initialize parent_config = nil
@@ -1047,6 +1568,31 @@ module Google
1047
1568
  # @return [::Gapic::Config::Method]
1048
1569
  #
1049
1570
  attr_reader :delete_policy
1571
+ ##
1572
+ # RPC-specific configuration for `create_custom_constraint`
1573
+ # @return [::Gapic::Config::Method]
1574
+ #
1575
+ attr_reader :create_custom_constraint
1576
+ ##
1577
+ # RPC-specific configuration for `update_custom_constraint`
1578
+ # @return [::Gapic::Config::Method]
1579
+ #
1580
+ attr_reader :update_custom_constraint
1581
+ ##
1582
+ # RPC-specific configuration for `get_custom_constraint`
1583
+ # @return [::Gapic::Config::Method]
1584
+ #
1585
+ attr_reader :get_custom_constraint
1586
+ ##
1587
+ # RPC-specific configuration for `list_custom_constraints`
1588
+ # @return [::Gapic::Config::Method]
1589
+ #
1590
+ attr_reader :list_custom_constraints
1591
+ ##
1592
+ # RPC-specific configuration for `delete_custom_constraint`
1593
+ # @return [::Gapic::Config::Method]
1594
+ #
1595
+ attr_reader :delete_custom_constraint
1050
1596
 
1051
1597
  # @private
1052
1598
  def initialize parent_rpcs = nil
@@ -1064,6 +1610,16 @@ module Google
1064
1610
  @update_policy = ::Gapic::Config::Method.new update_policy_config
1065
1611
  delete_policy_config = parent_rpcs.delete_policy if parent_rpcs.respond_to? :delete_policy
1066
1612
  @delete_policy = ::Gapic::Config::Method.new delete_policy_config
1613
+ create_custom_constraint_config = parent_rpcs.create_custom_constraint if parent_rpcs.respond_to? :create_custom_constraint
1614
+ @create_custom_constraint = ::Gapic::Config::Method.new create_custom_constraint_config
1615
+ update_custom_constraint_config = parent_rpcs.update_custom_constraint if parent_rpcs.respond_to? :update_custom_constraint
1616
+ @update_custom_constraint = ::Gapic::Config::Method.new update_custom_constraint_config
1617
+ get_custom_constraint_config = parent_rpcs.get_custom_constraint if parent_rpcs.respond_to? :get_custom_constraint
1618
+ @get_custom_constraint = ::Gapic::Config::Method.new get_custom_constraint_config
1619
+ list_custom_constraints_config = parent_rpcs.list_custom_constraints if parent_rpcs.respond_to? :list_custom_constraints
1620
+ @list_custom_constraints = ::Gapic::Config::Method.new list_custom_constraints_config
1621
+ delete_custom_constraint_config = parent_rpcs.delete_custom_constraint if parent_rpcs.respond_to? :delete_custom_constraint
1622
+ @delete_custom_constraint = ::Gapic::Config::Method.new delete_custom_constraint_config
1067
1623
 
1068
1624
  yield self if block_given?
1069
1625
  end