google-cloud-org_policy-v2 0.1.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.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +139 -0
- data/lib/google-cloud-org_policy-v2.rb +21 -0
- data/lib/google/cloud/org_policy/v2.rb +38 -0
- data/lib/google/cloud/org_policy/v2/org_policy.rb +68 -0
- data/lib/google/cloud/org_policy/v2/org_policy/client.rb +948 -0
- data/lib/google/cloud/org_policy/v2/org_policy/credentials.rb +51 -0
- data/lib/google/cloud/org_policy/v2/org_policy/paths.rb +127 -0
- data/lib/google/cloud/org_policy/v2/version.rb +28 -0
- data/lib/google/cloud/orgpolicy/v2/constraint_pb.rb +45 -0
- data/lib/google/cloud/orgpolicy/v2/orgpolicy_pb.rb +103 -0
- data/lib/google/cloud/orgpolicy/v2/orgpolicy_services_pb.rb +101 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +65 -0
- data/proto_docs/google/api/resource.rb +283 -0
- data/proto_docs/google/cloud/orgpolicy/v2/constraint.rb +120 -0
- data/proto_docs/google/cloud/orgpolicy/v2/orgpolicy.rb +320 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/timestamp.rb +129 -0
- data/proto_docs/google/type/expr.rb +52 -0
- metadata +208 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
# This gem does not autoload during Bundler.require. To load this gem,
|
20
|
+
# issue explicit require statements for the packages desired, e.g.:
|
21
|
+
# require "google/cloud/org_policy/v2"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/org_policy/v2/org_policy"
|
20
|
+
require "google/cloud/org_policy/v2/version"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module OrgPolicy
|
25
|
+
##
|
26
|
+
# To load this package, including all its services, and instantiate a client:
|
27
|
+
#
|
28
|
+
# require "google/cloud/org_policy/v2"
|
29
|
+
# client = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
|
30
|
+
#
|
31
|
+
module V2
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
helper_path = ::File.join __dir__, "v2", "_helpers.rb"
|
38
|
+
require "google/cloud/org_policy/v2/_helpers" if ::File.file? helper_path
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "gapic/common"
|
20
|
+
require "gapic/config"
|
21
|
+
require "gapic/config/method"
|
22
|
+
|
23
|
+
require "google/cloud/org_policy/v2/version"
|
24
|
+
|
25
|
+
require "google/cloud/org_policy/v2/org_policy/credentials"
|
26
|
+
require "google/cloud/org_policy/v2/org_policy/paths"
|
27
|
+
require "google/cloud/org_policy/v2/org_policy/client"
|
28
|
+
|
29
|
+
module Google
|
30
|
+
module Cloud
|
31
|
+
module OrgPolicy
|
32
|
+
module V2
|
33
|
+
##
|
34
|
+
# An interface for managing organization policies.
|
35
|
+
#
|
36
|
+
# The Cloud Org Policy service provides a simple mechanism for organizations to
|
37
|
+
# restrict the allowed configurations across their entire Cloud Resource
|
38
|
+
# hierarchy.
|
39
|
+
#
|
40
|
+
# You can use a `policy` to configure restrictions in Cloud resources. For
|
41
|
+
# example, you can enforce a `policy` that restricts which Google
|
42
|
+
# Cloud Platform APIs can be activated in a certain part of your resource
|
43
|
+
# hierarchy, or prevents serial port access to VM instances in a particular
|
44
|
+
# folder.
|
45
|
+
#
|
46
|
+
# `Policies` are inherited down through the resource hierarchy. A `policy`
|
47
|
+
# applied to a parent resource automatically applies to all its child resources
|
48
|
+
# unless overridden with a `policy` lower in the hierarchy.
|
49
|
+
#
|
50
|
+
# A `constraint` defines an aspect of a resource's configuration that can be
|
51
|
+
# controlled by an organization's policy administrator. `Policies` are a
|
52
|
+
# collection of `constraints` that defines their allowable configuration on a
|
53
|
+
# particular resource and its child resources.
|
54
|
+
#
|
55
|
+
# To load this service and instantiate a client:
|
56
|
+
#
|
57
|
+
# require "google/cloud/org_policy/v2/org_policy"
|
58
|
+
# client = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
|
59
|
+
#
|
60
|
+
module OrgPolicy
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
helper_path = ::File.join __dir__, "org_policy", "helpers.rb"
|
68
|
+
require "google/cloud/org_policy/v2/org_policy/helpers" if ::File.file? helper_path
|
@@ -0,0 +1,948 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/orgpolicy/v2/orgpolicy_pb"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module OrgPolicy
|
25
|
+
module V2
|
26
|
+
module OrgPolicy
|
27
|
+
##
|
28
|
+
# Client for the OrgPolicy service.
|
29
|
+
#
|
30
|
+
# An interface for managing organization policies.
|
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.
|
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.
|
41
|
+
#
|
42
|
+
# `Policies` are inherited down through the resource hierarchy. A `policy`
|
43
|
+
# applied to a parent resource automatically applies to all its child resources
|
44
|
+
# unless overridden with a `policy` lower in the hierarchy.
|
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
|
49
|
+
# particular resource and its child resources.
|
50
|
+
#
|
51
|
+
class Client
|
52
|
+
include Paths
|
53
|
+
|
54
|
+
# @private
|
55
|
+
attr_reader :org_policy_stub
|
56
|
+
|
57
|
+
##
|
58
|
+
# Configure the OrgPolicy Client class.
|
59
|
+
#
|
60
|
+
# See {::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client::Configuration}
|
61
|
+
# for a description of the configuration fields.
|
62
|
+
#
|
63
|
+
# ## Example
|
64
|
+
#
|
65
|
+
# To modify the configuration for all OrgPolicy clients:
|
66
|
+
#
|
67
|
+
# ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.configure do |config|
|
68
|
+
# config.timeout = 10.0
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# @yield [config] Configure the Client client.
|
72
|
+
# @yieldparam config [Client::Configuration]
|
73
|
+
#
|
74
|
+
# @return [Client::Configuration]
|
75
|
+
#
|
76
|
+
def self.configure
|
77
|
+
@configure ||= begin
|
78
|
+
namespace = ["Google", "Cloud", "OrgPolicy", "V2"]
|
79
|
+
parent_config = while namespace.any?
|
80
|
+
parent_name = namespace.join "::"
|
81
|
+
parent_const = const_get parent_name
|
82
|
+
break parent_const.configure if parent_const&.respond_to? :configure
|
83
|
+
namespace.pop
|
84
|
+
end
|
85
|
+
default_config = Client::Configuration.new parent_config
|
86
|
+
|
87
|
+
default_config.rpcs.list_constraints.timeout = 60.0
|
88
|
+
default_config.rpcs.list_constraints.retry_policy = {
|
89
|
+
initial_delay: 1.0,
|
90
|
+
max_delay: 10.0,
|
91
|
+
multiplier: 1.3,
|
92
|
+
retry_codes: [14, 4]
|
93
|
+
}
|
94
|
+
|
95
|
+
default_config.rpcs.list_policies.timeout = 60.0
|
96
|
+
default_config.rpcs.list_policies.retry_policy = {
|
97
|
+
initial_delay: 1.0,
|
98
|
+
max_delay: 10.0,
|
99
|
+
multiplier: 1.3,
|
100
|
+
retry_codes: [14, 4]
|
101
|
+
}
|
102
|
+
|
103
|
+
default_config.rpcs.get_policy.timeout = 60.0
|
104
|
+
default_config.rpcs.get_policy.retry_policy = {
|
105
|
+
initial_delay: 1.0,
|
106
|
+
max_delay: 10.0,
|
107
|
+
multiplier: 1.3,
|
108
|
+
retry_codes: [14, 4]
|
109
|
+
}
|
110
|
+
|
111
|
+
default_config.rpcs.get_effective_policy.timeout = 60.0
|
112
|
+
default_config.rpcs.get_effective_policy.retry_policy = {
|
113
|
+
initial_delay: 1.0,
|
114
|
+
max_delay: 10.0,
|
115
|
+
multiplier: 1.3,
|
116
|
+
retry_codes: [14, 4]
|
117
|
+
}
|
118
|
+
|
119
|
+
default_config.rpcs.create_policy.timeout = 60.0
|
120
|
+
default_config.rpcs.create_policy.retry_policy = {
|
121
|
+
initial_delay: 1.0,
|
122
|
+
max_delay: 10.0,
|
123
|
+
multiplier: 1.3,
|
124
|
+
retry_codes: [14, 4]
|
125
|
+
}
|
126
|
+
|
127
|
+
default_config.rpcs.update_policy.timeout = 60.0
|
128
|
+
default_config.rpcs.update_policy.retry_policy = {
|
129
|
+
initial_delay: 1.0,
|
130
|
+
max_delay: 10.0,
|
131
|
+
multiplier: 1.3,
|
132
|
+
retry_codes: [14, 4]
|
133
|
+
}
|
134
|
+
|
135
|
+
default_config.rpcs.delete_policy.timeout = 60.0
|
136
|
+
default_config.rpcs.delete_policy.retry_policy = {
|
137
|
+
initial_delay: 1.0,
|
138
|
+
max_delay: 10.0,
|
139
|
+
multiplier: 1.3,
|
140
|
+
retry_codes: [14, 4]
|
141
|
+
}
|
142
|
+
|
143
|
+
default_config
|
144
|
+
end
|
145
|
+
yield @configure if block_given?
|
146
|
+
@configure
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Configure the OrgPolicy Client instance.
|
151
|
+
#
|
152
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
153
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
154
|
+
# should be made on {Client.configure}.
|
155
|
+
#
|
156
|
+
# See {::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client::Configuration}
|
157
|
+
# for a description of the configuration fields.
|
158
|
+
#
|
159
|
+
# @yield [config] Configure the Client client.
|
160
|
+
# @yieldparam config [Client::Configuration]
|
161
|
+
#
|
162
|
+
# @return [Client::Configuration]
|
163
|
+
#
|
164
|
+
def configure
|
165
|
+
yield @config if block_given?
|
166
|
+
@config
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Create a new OrgPolicy client object.
|
171
|
+
#
|
172
|
+
# ## Examples
|
173
|
+
#
|
174
|
+
# To create a new OrgPolicy client with the default
|
175
|
+
# configuration:
|
176
|
+
#
|
177
|
+
# client = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new
|
178
|
+
#
|
179
|
+
# To create a new OrgPolicy client with a custom
|
180
|
+
# configuration:
|
181
|
+
#
|
182
|
+
# client = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new do |config|
|
183
|
+
# config.timeout = 10.0
|
184
|
+
# end
|
185
|
+
#
|
186
|
+
# @yield [config] Configure the OrgPolicy client.
|
187
|
+
# @yieldparam config [Client::Configuration]
|
188
|
+
#
|
189
|
+
def initialize
|
190
|
+
# These require statements are intentionally placed here to initialize
|
191
|
+
# the gRPC module only when it's required.
|
192
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
193
|
+
require "gapic/grpc"
|
194
|
+
require "google/cloud/orgpolicy/v2/orgpolicy_services_pb"
|
195
|
+
|
196
|
+
# Create the configuration object
|
197
|
+
@config = Configuration.new Client.configure
|
198
|
+
|
199
|
+
# Yield the configuration if needed
|
200
|
+
yield @config if block_given?
|
201
|
+
|
202
|
+
# Create credentials
|
203
|
+
credentials = @config.credentials
|
204
|
+
# Use self-signed JWT if the scope and endpoint are unchanged from default,
|
205
|
+
# but only if the default endpoint does not have a region prefix.
|
206
|
+
enable_self_signed_jwt = @config.scope == Client.configure.scope &&
|
207
|
+
@config.endpoint == Client.configure.endpoint &&
|
208
|
+
!@config.endpoint.split(".").first.include?("-")
|
209
|
+
credentials ||= Credentials.default scope: @config.scope,
|
210
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
211
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
212
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
213
|
+
end
|
214
|
+
@quota_project_id = @config.quota_project
|
215
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
216
|
+
|
217
|
+
@org_policy_stub = ::Gapic::ServiceStub.new(
|
218
|
+
::Google::Cloud::OrgPolicy::V2::OrgPolicy::Stub,
|
219
|
+
credentials: credentials,
|
220
|
+
endpoint: @config.endpoint,
|
221
|
+
channel_args: @config.channel_args,
|
222
|
+
interceptors: @config.interceptors
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
# Service calls
|
227
|
+
|
228
|
+
##
|
229
|
+
# Lists `Constraints` that could be applied on the specified resource.
|
230
|
+
#
|
231
|
+
# @overload list_constraints(request, options = nil)
|
232
|
+
# Pass arguments to `list_constraints` via a request object, either of type
|
233
|
+
# {::Google::Cloud::OrgPolicy::V2::ListConstraintsRequest} or an equivalent Hash.
|
234
|
+
#
|
235
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::ListConstraintsRequest, ::Hash]
|
236
|
+
# A request object representing the call parameters. Required. To specify no
|
237
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
238
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
239
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
240
|
+
#
|
241
|
+
# @overload list_constraints(parent: nil, page_size: nil, page_token: nil)
|
242
|
+
# Pass arguments to `list_constraints` via keyword arguments. Note that at
|
243
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
244
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
245
|
+
#
|
246
|
+
# @param parent [::String]
|
247
|
+
# Required. The Cloud resource that parents the constraint. Must be in one of the
|
248
|
+
# following forms:
|
249
|
+
# * `projects/{project_number}`
|
250
|
+
# * `projects/{project_id}`
|
251
|
+
# * `folders/{folder_id}`
|
252
|
+
# * `organizations/{organization_id}`
|
253
|
+
# @param page_size [::Integer]
|
254
|
+
# Size of the pages to be returned. This is currently unsupported and will
|
255
|
+
# be ignored. The server may at any point start using this field to limit
|
256
|
+
# page size.
|
257
|
+
# @param page_token [::String]
|
258
|
+
# Page token used to retrieve the next page. This is currently unsupported
|
259
|
+
# and will be ignored. The server may at any point start using this field.
|
260
|
+
#
|
261
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
262
|
+
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Constraint>]
|
263
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
264
|
+
#
|
265
|
+
# @return [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Constraint>]
|
266
|
+
#
|
267
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
268
|
+
#
|
269
|
+
def list_constraints request, options = nil
|
270
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
271
|
+
|
272
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::ListConstraintsRequest
|
273
|
+
|
274
|
+
# Converts hash and nil to an options object
|
275
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
276
|
+
|
277
|
+
# Customize the options with defaults
|
278
|
+
metadata = @config.rpcs.list_constraints.metadata.to_h
|
279
|
+
|
280
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
281
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
282
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
283
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
284
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
285
|
+
|
286
|
+
header_params = {
|
287
|
+
"parent" => request.parent
|
288
|
+
}
|
289
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
290
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
291
|
+
|
292
|
+
options.apply_defaults timeout: @config.rpcs.list_constraints.timeout,
|
293
|
+
metadata: metadata,
|
294
|
+
retry_policy: @config.rpcs.list_constraints.retry_policy
|
295
|
+
options.apply_defaults metadata: @config.metadata,
|
296
|
+
retry_policy: @config.retry_policy
|
297
|
+
|
298
|
+
@org_policy_stub.call_rpc :list_constraints, request, options: options do |response, operation|
|
299
|
+
response = ::Gapic::PagedEnumerable.new @org_policy_stub, :list_constraints, request, response, operation, options
|
300
|
+
yield response, operation if block_given?
|
301
|
+
return response
|
302
|
+
end
|
303
|
+
rescue ::GRPC::BadStatus => e
|
304
|
+
raise ::Google::Cloud::Error.from_error(e)
|
305
|
+
end
|
306
|
+
|
307
|
+
##
|
308
|
+
# Retrieves all of the `Policies` that exist on a particular resource.
|
309
|
+
#
|
310
|
+
# @overload list_policies(request, options = nil)
|
311
|
+
# Pass arguments to `list_policies` via a request object, either of type
|
312
|
+
# {::Google::Cloud::OrgPolicy::V2::ListPoliciesRequest} or an equivalent Hash.
|
313
|
+
#
|
314
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::ListPoliciesRequest, ::Hash]
|
315
|
+
# A request object representing the call parameters. Required. To specify no
|
316
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
317
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
318
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
319
|
+
#
|
320
|
+
# @overload list_policies(parent: nil, page_size: nil, page_token: nil)
|
321
|
+
# Pass arguments to `list_policies` via keyword arguments. Note that at
|
322
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
323
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
324
|
+
#
|
325
|
+
# @param parent [::String]
|
326
|
+
# Required. The target Cloud resource that parents the set of constraints and policies
|
327
|
+
# that will be returned from this call. Must be in one of the following
|
328
|
+
# forms:
|
329
|
+
# * `projects/{project_number}`
|
330
|
+
# * `projects/{project_id}`
|
331
|
+
# * `folders/{folder_id}`
|
332
|
+
# * `organizations/{organization_id}`
|
333
|
+
# @param page_size [::Integer]
|
334
|
+
# Size of the pages to be returned. This is currently unsupported and will
|
335
|
+
# be ignored. The server may at any point start using this field to limit
|
336
|
+
# page size.
|
337
|
+
# @param page_token [::String]
|
338
|
+
# Page token used to retrieve the next page. This is currently unsupported
|
339
|
+
# and will be ignored. The server may at any point start using this field.
|
340
|
+
#
|
341
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
342
|
+
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Policy>]
|
343
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
344
|
+
#
|
345
|
+
# @return [::Gapic::PagedEnumerable<::Google::Cloud::OrgPolicy::V2::Policy>]
|
346
|
+
#
|
347
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
348
|
+
#
|
349
|
+
def list_policies request, options = nil
|
350
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
351
|
+
|
352
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::ListPoliciesRequest
|
353
|
+
|
354
|
+
# Converts hash and nil to an options object
|
355
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
356
|
+
|
357
|
+
# Customize the options with defaults
|
358
|
+
metadata = @config.rpcs.list_policies.metadata.to_h
|
359
|
+
|
360
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
361
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
362
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
363
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
364
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
365
|
+
|
366
|
+
header_params = {
|
367
|
+
"parent" => request.parent
|
368
|
+
}
|
369
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
370
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
371
|
+
|
372
|
+
options.apply_defaults timeout: @config.rpcs.list_policies.timeout,
|
373
|
+
metadata: metadata,
|
374
|
+
retry_policy: @config.rpcs.list_policies.retry_policy
|
375
|
+
options.apply_defaults metadata: @config.metadata,
|
376
|
+
retry_policy: @config.retry_policy
|
377
|
+
|
378
|
+
@org_policy_stub.call_rpc :list_policies, request, options: options do |response, operation|
|
379
|
+
response = ::Gapic::PagedEnumerable.new @org_policy_stub, :list_policies, request, response, operation, options
|
380
|
+
yield response, operation if block_given?
|
381
|
+
return response
|
382
|
+
end
|
383
|
+
rescue ::GRPC::BadStatus => e
|
384
|
+
raise ::Google::Cloud::Error.from_error(e)
|
385
|
+
end
|
386
|
+
|
387
|
+
##
|
388
|
+
# Gets a `Policy` on a resource.
|
389
|
+
#
|
390
|
+
# If no `Policy` is set on the resource, NOT_FOUND is returned. The
|
391
|
+
# `etag` value can be used with `UpdatePolicy()` to update a
|
392
|
+
# `Policy` during read-modify-write.
|
393
|
+
#
|
394
|
+
# @overload get_policy(request, options = nil)
|
395
|
+
# Pass arguments to `get_policy` via a request object, either of type
|
396
|
+
# {::Google::Cloud::OrgPolicy::V2::GetPolicyRequest} or an equivalent Hash.
|
397
|
+
#
|
398
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::GetPolicyRequest, ::Hash]
|
399
|
+
# A request object representing the call parameters. Required. To specify no
|
400
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
401
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
402
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
403
|
+
#
|
404
|
+
# @overload get_policy(name: nil)
|
405
|
+
# Pass arguments to `get_policy` via keyword arguments. Note that at
|
406
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
407
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
408
|
+
#
|
409
|
+
# @param name [::String]
|
410
|
+
# Required. Resource name of the policy. See `Policy` for naming requirements.
|
411
|
+
#
|
412
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
413
|
+
# @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
|
414
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
415
|
+
#
|
416
|
+
# @return [::Google::Cloud::OrgPolicy::V2::Policy]
|
417
|
+
#
|
418
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
419
|
+
#
|
420
|
+
def get_policy request, options = nil
|
421
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
422
|
+
|
423
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::GetPolicyRequest
|
424
|
+
|
425
|
+
# Converts hash and nil to an options object
|
426
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
427
|
+
|
428
|
+
# Customize the options with defaults
|
429
|
+
metadata = @config.rpcs.get_policy.metadata.to_h
|
430
|
+
|
431
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
432
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
433
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
434
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
435
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
436
|
+
|
437
|
+
header_params = {
|
438
|
+
"name" => request.name
|
439
|
+
}
|
440
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
441
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
442
|
+
|
443
|
+
options.apply_defaults timeout: @config.rpcs.get_policy.timeout,
|
444
|
+
metadata: metadata,
|
445
|
+
retry_policy: @config.rpcs.get_policy.retry_policy
|
446
|
+
options.apply_defaults metadata: @config.metadata,
|
447
|
+
retry_policy: @config.retry_policy
|
448
|
+
|
449
|
+
@org_policy_stub.call_rpc :get_policy, request, options: options do |response, operation|
|
450
|
+
yield response, operation if block_given?
|
451
|
+
return response
|
452
|
+
end
|
453
|
+
rescue ::GRPC::BadStatus => e
|
454
|
+
raise ::Google::Cloud::Error.from_error(e)
|
455
|
+
end
|
456
|
+
|
457
|
+
##
|
458
|
+
# Gets the effective `Policy` on a resource. This is the result of merging
|
459
|
+
# `Policies` in the resource hierarchy and evaluating conditions. The
|
460
|
+
# returned `Policy` will not have an `etag` or `condition` set because it is
|
461
|
+
# a computed `Policy` across multiple resources.
|
462
|
+
# Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
|
463
|
+
# not be expanded.
|
464
|
+
#
|
465
|
+
# @overload get_effective_policy(request, options = nil)
|
466
|
+
# Pass arguments to `get_effective_policy` via a request object, either of type
|
467
|
+
# {::Google::Cloud::OrgPolicy::V2::GetEffectivePolicyRequest} or an equivalent Hash.
|
468
|
+
#
|
469
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::GetEffectivePolicyRequest, ::Hash]
|
470
|
+
# A request object representing the call parameters. Required. To specify no
|
471
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
472
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
473
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
474
|
+
#
|
475
|
+
# @overload get_effective_policy(name: nil)
|
476
|
+
# Pass arguments to `get_effective_policy` via keyword arguments. Note that at
|
477
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
478
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
479
|
+
#
|
480
|
+
# @param name [::String]
|
481
|
+
# Required. The effective policy to compute. See `Policy` for naming rules.
|
482
|
+
#
|
483
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
484
|
+
# @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
|
485
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
486
|
+
#
|
487
|
+
# @return [::Google::Cloud::OrgPolicy::V2::Policy]
|
488
|
+
#
|
489
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
490
|
+
#
|
491
|
+
def get_effective_policy request, options = nil
|
492
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
493
|
+
|
494
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::GetEffectivePolicyRequest
|
495
|
+
|
496
|
+
# Converts hash and nil to an options object
|
497
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
498
|
+
|
499
|
+
# Customize the options with defaults
|
500
|
+
metadata = @config.rpcs.get_effective_policy.metadata.to_h
|
501
|
+
|
502
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
503
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
504
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
505
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
506
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
507
|
+
|
508
|
+
header_params = {
|
509
|
+
"name" => request.name
|
510
|
+
}
|
511
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
512
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
513
|
+
|
514
|
+
options.apply_defaults timeout: @config.rpcs.get_effective_policy.timeout,
|
515
|
+
metadata: metadata,
|
516
|
+
retry_policy: @config.rpcs.get_effective_policy.retry_policy
|
517
|
+
options.apply_defaults metadata: @config.metadata,
|
518
|
+
retry_policy: @config.retry_policy
|
519
|
+
|
520
|
+
@org_policy_stub.call_rpc :get_effective_policy, request, options: options do |response, operation|
|
521
|
+
yield response, operation if block_given?
|
522
|
+
return response
|
523
|
+
end
|
524
|
+
rescue ::GRPC::BadStatus => e
|
525
|
+
raise ::Google::Cloud::Error.from_error(e)
|
526
|
+
end
|
527
|
+
|
528
|
+
##
|
529
|
+
# Creates a Policy.
|
530
|
+
#
|
531
|
+
# Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
|
532
|
+
# constraint does not exist.
|
533
|
+
# Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
|
534
|
+
# policy already exists on the given Cloud resource.
|
535
|
+
#
|
536
|
+
# @overload create_policy(request, options = nil)
|
537
|
+
# Pass arguments to `create_policy` via a request object, either of type
|
538
|
+
# {::Google::Cloud::OrgPolicy::V2::CreatePolicyRequest} or an equivalent Hash.
|
539
|
+
#
|
540
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::CreatePolicyRequest, ::Hash]
|
541
|
+
# A request object representing the call parameters. Required. To specify no
|
542
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
543
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
544
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
545
|
+
#
|
546
|
+
# @overload create_policy(parent: nil, policy: nil)
|
547
|
+
# Pass arguments to `create_policy` via keyword arguments. Note that at
|
548
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
549
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
550
|
+
#
|
551
|
+
# @param parent [::String]
|
552
|
+
# Required. The Cloud resource that will parent the new Policy. Must be in one of the
|
553
|
+
# following forms:
|
554
|
+
# * `projects/{project_number}`
|
555
|
+
# * `projects/{project_id}`
|
556
|
+
# * `folders/{folder_id}`
|
557
|
+
# * `organizations/{organization_id}`
|
558
|
+
# @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
|
559
|
+
# Required. `Policy` to create.
|
560
|
+
#
|
561
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
562
|
+
# @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
|
563
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
564
|
+
#
|
565
|
+
# @return [::Google::Cloud::OrgPolicy::V2::Policy]
|
566
|
+
#
|
567
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
568
|
+
#
|
569
|
+
def create_policy request, options = nil
|
570
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
571
|
+
|
572
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::CreatePolicyRequest
|
573
|
+
|
574
|
+
# Converts hash and nil to an options object
|
575
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
576
|
+
|
577
|
+
# Customize the options with defaults
|
578
|
+
metadata = @config.rpcs.create_policy.metadata.to_h
|
579
|
+
|
580
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
581
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
582
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
583
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
584
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
585
|
+
|
586
|
+
header_params = {
|
587
|
+
"parent" => request.parent
|
588
|
+
}
|
589
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
590
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
591
|
+
|
592
|
+
options.apply_defaults timeout: @config.rpcs.create_policy.timeout,
|
593
|
+
metadata: metadata,
|
594
|
+
retry_policy: @config.rpcs.create_policy.retry_policy
|
595
|
+
options.apply_defaults metadata: @config.metadata,
|
596
|
+
retry_policy: @config.retry_policy
|
597
|
+
|
598
|
+
@org_policy_stub.call_rpc :create_policy, request, options: options do |response, operation|
|
599
|
+
yield response, operation if block_given?
|
600
|
+
return response
|
601
|
+
end
|
602
|
+
rescue ::GRPC::BadStatus => e
|
603
|
+
raise ::Google::Cloud::Error.from_error(e)
|
604
|
+
end
|
605
|
+
|
606
|
+
##
|
607
|
+
# Updates a Policy.
|
608
|
+
#
|
609
|
+
# Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
|
610
|
+
# constraint or the policy do not exist.
|
611
|
+
# Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
|
612
|
+
# supplied in the request does not match the persisted etag of the policy
|
613
|
+
#
|
614
|
+
# Note: the supplied policy will perform a full overwrite of all
|
615
|
+
# fields.
|
616
|
+
#
|
617
|
+
# @overload update_policy(request, options = nil)
|
618
|
+
# Pass arguments to `update_policy` via a request object, either of type
|
619
|
+
# {::Google::Cloud::OrgPolicy::V2::UpdatePolicyRequest} or an equivalent Hash.
|
620
|
+
#
|
621
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::UpdatePolicyRequest, ::Hash]
|
622
|
+
# A request object representing the call parameters. Required. To specify no
|
623
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
624
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
625
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
626
|
+
#
|
627
|
+
# @overload update_policy(policy: nil)
|
628
|
+
# Pass arguments to `update_policy` via keyword arguments. Note that at
|
629
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
630
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
631
|
+
#
|
632
|
+
# @param policy [::Google::Cloud::OrgPolicy::V2::Policy, ::Hash]
|
633
|
+
# Required. `Policy` to update.
|
634
|
+
#
|
635
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
636
|
+
# @yieldparam response [::Google::Cloud::OrgPolicy::V2::Policy]
|
637
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
638
|
+
#
|
639
|
+
# @return [::Google::Cloud::OrgPolicy::V2::Policy]
|
640
|
+
#
|
641
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
642
|
+
#
|
643
|
+
def update_policy request, options = nil
|
644
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
645
|
+
|
646
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::UpdatePolicyRequest
|
647
|
+
|
648
|
+
# Converts hash and nil to an options object
|
649
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
650
|
+
|
651
|
+
# Customize the options with defaults
|
652
|
+
metadata = @config.rpcs.update_policy.metadata.to_h
|
653
|
+
|
654
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
655
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
656
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
657
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
658
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
659
|
+
|
660
|
+
header_params = {
|
661
|
+
"policy.name" => request.policy.name
|
662
|
+
}
|
663
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
664
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
665
|
+
|
666
|
+
options.apply_defaults timeout: @config.rpcs.update_policy.timeout,
|
667
|
+
metadata: metadata,
|
668
|
+
retry_policy: @config.rpcs.update_policy.retry_policy
|
669
|
+
options.apply_defaults metadata: @config.metadata,
|
670
|
+
retry_policy: @config.retry_policy
|
671
|
+
|
672
|
+
@org_policy_stub.call_rpc :update_policy, request, options: options do |response, operation|
|
673
|
+
yield response, operation if block_given?
|
674
|
+
return response
|
675
|
+
end
|
676
|
+
rescue ::GRPC::BadStatus => e
|
677
|
+
raise ::Google::Cloud::Error.from_error(e)
|
678
|
+
end
|
679
|
+
|
680
|
+
##
|
681
|
+
# Deletes a Policy.
|
682
|
+
#
|
683
|
+
# Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
|
684
|
+
# constraint or Org Policy does not exist.
|
685
|
+
#
|
686
|
+
# @overload delete_policy(request, options = nil)
|
687
|
+
# Pass arguments to `delete_policy` via a request object, either of type
|
688
|
+
# {::Google::Cloud::OrgPolicy::V2::DeletePolicyRequest} or an equivalent Hash.
|
689
|
+
#
|
690
|
+
# @param request [::Google::Cloud::OrgPolicy::V2::DeletePolicyRequest, ::Hash]
|
691
|
+
# A request object representing the call parameters. Required. To specify no
|
692
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
693
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
694
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
695
|
+
#
|
696
|
+
# @overload delete_policy(name: nil)
|
697
|
+
# Pass arguments to `delete_policy` via keyword arguments. Note that at
|
698
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
699
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
700
|
+
#
|
701
|
+
# @param name [::String]
|
702
|
+
# Required. Name of the policy to delete.
|
703
|
+
# See `Policy` for naming rules.
|
704
|
+
#
|
705
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
706
|
+
# @yieldparam response [::Google::Protobuf::Empty]
|
707
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
708
|
+
#
|
709
|
+
# @return [::Google::Protobuf::Empty]
|
710
|
+
#
|
711
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
712
|
+
#
|
713
|
+
def delete_policy request, options = nil
|
714
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
715
|
+
|
716
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OrgPolicy::V2::DeletePolicyRequest
|
717
|
+
|
718
|
+
# Converts hash and nil to an options object
|
719
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
720
|
+
|
721
|
+
# Customize the options with defaults
|
722
|
+
metadata = @config.rpcs.delete_policy.metadata.to_h
|
723
|
+
|
724
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
725
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
726
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
727
|
+
gapic_version: ::Google::Cloud::OrgPolicy::V2::VERSION
|
728
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
729
|
+
|
730
|
+
header_params = {
|
731
|
+
"name" => request.name
|
732
|
+
}
|
733
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
734
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
735
|
+
|
736
|
+
options.apply_defaults timeout: @config.rpcs.delete_policy.timeout,
|
737
|
+
metadata: metadata,
|
738
|
+
retry_policy: @config.rpcs.delete_policy.retry_policy
|
739
|
+
options.apply_defaults metadata: @config.metadata,
|
740
|
+
retry_policy: @config.retry_policy
|
741
|
+
|
742
|
+
@org_policy_stub.call_rpc :delete_policy, request, options: options do |response, operation|
|
743
|
+
yield response, operation if block_given?
|
744
|
+
return response
|
745
|
+
end
|
746
|
+
rescue ::GRPC::BadStatus => e
|
747
|
+
raise ::Google::Cloud::Error.from_error(e)
|
748
|
+
end
|
749
|
+
|
750
|
+
##
|
751
|
+
# Configuration class for the OrgPolicy API.
|
752
|
+
#
|
753
|
+
# This class represents the configuration for OrgPolicy,
|
754
|
+
# providing control over timeouts, retry behavior, logging, transport
|
755
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
756
|
+
# applied individually to specific RPCs. See
|
757
|
+
# {::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client::Configuration::Rpcs}
|
758
|
+
# for a list of RPCs that can be configured independently.
|
759
|
+
#
|
760
|
+
# Configuration can be applied globally to all clients, or to a single client
|
761
|
+
# on construction.
|
762
|
+
#
|
763
|
+
# # Examples
|
764
|
+
#
|
765
|
+
# To modify the global config, setting the timeout for list_constraints
|
766
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
767
|
+
#
|
768
|
+
# ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.configure do |config|
|
769
|
+
# config.timeout = 10.0
|
770
|
+
# config.rpcs.list_constraints.timeout = 20.0
|
771
|
+
# end
|
772
|
+
#
|
773
|
+
# To apply the above configuration only to a new client:
|
774
|
+
#
|
775
|
+
# client = ::Google::Cloud::OrgPolicy::V2::OrgPolicy::Client.new do |config|
|
776
|
+
# config.timeout = 10.0
|
777
|
+
# config.rpcs.list_constraints.timeout = 20.0
|
778
|
+
# end
|
779
|
+
#
|
780
|
+
# @!attribute [rw] endpoint
|
781
|
+
# The hostname or hostname:port of the service endpoint.
|
782
|
+
# Defaults to `"orgpolicy.googleapis.com"`.
|
783
|
+
# @return [::String]
|
784
|
+
# @!attribute [rw] credentials
|
785
|
+
# Credentials to send with calls. You may provide any of the following types:
|
786
|
+
# * (`String`) The path to a service account key file in JSON format
|
787
|
+
# * (`Hash`) A service account key as a Hash
|
788
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
789
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
790
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
791
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
792
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
793
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
794
|
+
# * (`nil`) indicating no credentials
|
795
|
+
# @return [::Object]
|
796
|
+
# @!attribute [rw] scope
|
797
|
+
# The OAuth scopes
|
798
|
+
# @return [::Array<::String>]
|
799
|
+
# @!attribute [rw] lib_name
|
800
|
+
# The library name as recorded in instrumentation and logging
|
801
|
+
# @return [::String]
|
802
|
+
# @!attribute [rw] lib_version
|
803
|
+
# The library version as recorded in instrumentation and logging
|
804
|
+
# @return [::String]
|
805
|
+
# @!attribute [rw] channel_args
|
806
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
807
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
808
|
+
# @return [::Hash]
|
809
|
+
# @!attribute [rw] interceptors
|
810
|
+
# An array of interceptors that are run before calls are executed.
|
811
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
812
|
+
# @!attribute [rw] timeout
|
813
|
+
# The call timeout in seconds.
|
814
|
+
# @return [::Numeric]
|
815
|
+
# @!attribute [rw] metadata
|
816
|
+
# Additional gRPC headers to be sent with the call.
|
817
|
+
# @return [::Hash{::Symbol=>::String}]
|
818
|
+
# @!attribute [rw] retry_policy
|
819
|
+
# The retry policy. The value is a hash with the following keys:
|
820
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
821
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
822
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
823
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
824
|
+
# trigger a retry.
|
825
|
+
# @return [::Hash]
|
826
|
+
# @!attribute [rw] quota_project
|
827
|
+
# A separate project against which to charge quota.
|
828
|
+
# @return [::String]
|
829
|
+
#
|
830
|
+
class Configuration
|
831
|
+
extend ::Gapic::Config
|
832
|
+
|
833
|
+
config_attr :endpoint, "orgpolicy.googleapis.com", ::String
|
834
|
+
config_attr :credentials, nil do |value|
|
835
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
836
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
837
|
+
allowed.any? { |klass| klass === value }
|
838
|
+
end
|
839
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
840
|
+
config_attr :lib_name, nil, ::String, nil
|
841
|
+
config_attr :lib_version, nil, ::String, nil
|
842
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
|
843
|
+
config_attr :interceptors, nil, ::Array, nil
|
844
|
+
config_attr :timeout, nil, ::Numeric, nil
|
845
|
+
config_attr :metadata, nil, ::Hash, nil
|
846
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
847
|
+
config_attr :quota_project, nil, ::String, nil
|
848
|
+
|
849
|
+
# @private
|
850
|
+
def initialize parent_config = nil
|
851
|
+
@parent_config = parent_config unless parent_config.nil?
|
852
|
+
|
853
|
+
yield self if block_given?
|
854
|
+
end
|
855
|
+
|
856
|
+
##
|
857
|
+
# Configurations for individual RPCs
|
858
|
+
# @return [Rpcs]
|
859
|
+
#
|
860
|
+
def rpcs
|
861
|
+
@rpcs ||= begin
|
862
|
+
parent_rpcs = nil
|
863
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
|
864
|
+
Rpcs.new parent_rpcs
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
##
|
869
|
+
# Configuration RPC class for the OrgPolicy API.
|
870
|
+
#
|
871
|
+
# Includes fields providing the configuration for each RPC in this service.
|
872
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
873
|
+
# the following configuration fields:
|
874
|
+
#
|
875
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
876
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
877
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
878
|
+
# include the following keys:
|
879
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
880
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
881
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
882
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
883
|
+
# trigger a retry.
|
884
|
+
#
|
885
|
+
class Rpcs
|
886
|
+
##
|
887
|
+
# RPC-specific configuration for `list_constraints`
|
888
|
+
# @return [::Gapic::Config::Method]
|
889
|
+
#
|
890
|
+
attr_reader :list_constraints
|
891
|
+
##
|
892
|
+
# RPC-specific configuration for `list_policies`
|
893
|
+
# @return [::Gapic::Config::Method]
|
894
|
+
#
|
895
|
+
attr_reader :list_policies
|
896
|
+
##
|
897
|
+
# RPC-specific configuration for `get_policy`
|
898
|
+
# @return [::Gapic::Config::Method]
|
899
|
+
#
|
900
|
+
attr_reader :get_policy
|
901
|
+
##
|
902
|
+
# RPC-specific configuration for `get_effective_policy`
|
903
|
+
# @return [::Gapic::Config::Method]
|
904
|
+
#
|
905
|
+
attr_reader :get_effective_policy
|
906
|
+
##
|
907
|
+
# RPC-specific configuration for `create_policy`
|
908
|
+
# @return [::Gapic::Config::Method]
|
909
|
+
#
|
910
|
+
attr_reader :create_policy
|
911
|
+
##
|
912
|
+
# RPC-specific configuration for `update_policy`
|
913
|
+
# @return [::Gapic::Config::Method]
|
914
|
+
#
|
915
|
+
attr_reader :update_policy
|
916
|
+
##
|
917
|
+
# RPC-specific configuration for `delete_policy`
|
918
|
+
# @return [::Gapic::Config::Method]
|
919
|
+
#
|
920
|
+
attr_reader :delete_policy
|
921
|
+
|
922
|
+
# @private
|
923
|
+
def initialize parent_rpcs = nil
|
924
|
+
list_constraints_config = parent_rpcs&.list_constraints if parent_rpcs&.respond_to? :list_constraints
|
925
|
+
@list_constraints = ::Gapic::Config::Method.new list_constraints_config
|
926
|
+
list_policies_config = parent_rpcs&.list_policies if parent_rpcs&.respond_to? :list_policies
|
927
|
+
@list_policies = ::Gapic::Config::Method.new list_policies_config
|
928
|
+
get_policy_config = parent_rpcs&.get_policy if parent_rpcs&.respond_to? :get_policy
|
929
|
+
@get_policy = ::Gapic::Config::Method.new get_policy_config
|
930
|
+
get_effective_policy_config = parent_rpcs&.get_effective_policy if parent_rpcs&.respond_to? :get_effective_policy
|
931
|
+
@get_effective_policy = ::Gapic::Config::Method.new get_effective_policy_config
|
932
|
+
create_policy_config = parent_rpcs&.create_policy if parent_rpcs&.respond_to? :create_policy
|
933
|
+
@create_policy = ::Gapic::Config::Method.new create_policy_config
|
934
|
+
update_policy_config = parent_rpcs&.update_policy if parent_rpcs&.respond_to? :update_policy
|
935
|
+
@update_policy = ::Gapic::Config::Method.new update_policy_config
|
936
|
+
delete_policy_config = parent_rpcs&.delete_policy if parent_rpcs&.respond_to? :delete_policy
|
937
|
+
@delete_policy = ::Gapic::Config::Method.new delete_policy_config
|
938
|
+
|
939
|
+
yield self if block_given?
|
940
|
+
end
|
941
|
+
end
|
942
|
+
end
|
943
|
+
end
|
944
|
+
end
|
945
|
+
end
|
946
|
+
end
|
947
|
+
end
|
948
|
+
end
|