google-iam-v2 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,343 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/iam/v2/policy_pb"
20
+
21
+ module Google
22
+ module Iam
23
+ module V2
24
+ module Policies
25
+ module Rest
26
+ ##
27
+ # REST service stub for the Policies service.
28
+ # Service stub contains baseline method implementations
29
+ # including transcoding, making the REST call, and deserialing the response.
30
+ #
31
+ class ServiceStub
32
+ def initialize endpoint:, credentials:
33
+ # These require statements are intentionally placed here to initialize
34
+ # the REST modules only when it's required.
35
+ require "gapic/rest"
36
+
37
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
38
+ numeric_enums: true,
39
+ raise_faraday_errors: false
40
+ end
41
+
42
+ ##
43
+ # Baseline implementation for the list_policies REST call
44
+ #
45
+ # @param request_pb [::Google::Iam::V2::ListPoliciesRequest]
46
+ # A request object representing the call parameters. Required.
47
+ # @param options [::Gapic::CallOptions]
48
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
49
+ #
50
+ # @yield [result, operation] Access the result along with the TransportOperation object
51
+ # @yieldparam result [::Google::Iam::V2::ListPoliciesResponse]
52
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
53
+ #
54
+ # @return [::Google::Iam::V2::ListPoliciesResponse]
55
+ # A result object deserialized from the server's reply
56
+ def list_policies request_pb, options = nil
57
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
58
+
59
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_policies_request request_pb
60
+ query_string_params = if query_string_params.any?
61
+ query_string_params.to_h { |p| p.split("=", 2) }
62
+ else
63
+ {}
64
+ end
65
+
66
+ response = @client_stub.make_http_request(
67
+ verb,
68
+ uri: uri,
69
+ body: body || "",
70
+ params: query_string_params,
71
+ options: options
72
+ )
73
+ operation = ::Gapic::Rest::TransportOperation.new response
74
+ result = ::Google::Iam::V2::ListPoliciesResponse.decode_json response.body, ignore_unknown_fields: true
75
+
76
+ yield result, operation if block_given?
77
+ result
78
+ end
79
+
80
+ ##
81
+ # Baseline implementation for the get_policy REST call
82
+ #
83
+ # @param request_pb [::Google::Iam::V2::GetPolicyRequest]
84
+ # A request object representing the call parameters. Required.
85
+ # @param options [::Gapic::CallOptions]
86
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
87
+ #
88
+ # @yield [result, operation] Access the result along with the TransportOperation object
89
+ # @yieldparam result [::Google::Iam::V2::Policy]
90
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
91
+ #
92
+ # @return [::Google::Iam::V2::Policy]
93
+ # A result object deserialized from the server's reply
94
+ def get_policy request_pb, options = nil
95
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
96
+
97
+ verb, uri, query_string_params, body = ServiceStub.transcode_get_policy_request request_pb
98
+ query_string_params = if query_string_params.any?
99
+ query_string_params.to_h { |p| p.split("=", 2) }
100
+ else
101
+ {}
102
+ end
103
+
104
+ response = @client_stub.make_http_request(
105
+ verb,
106
+ uri: uri,
107
+ body: body || "",
108
+ params: query_string_params,
109
+ options: options
110
+ )
111
+ operation = ::Gapic::Rest::TransportOperation.new response
112
+ result = ::Google::Iam::V2::Policy.decode_json response.body, ignore_unknown_fields: true
113
+
114
+ yield result, operation if block_given?
115
+ result
116
+ end
117
+
118
+ ##
119
+ # Baseline implementation for the create_policy REST call
120
+ #
121
+ # @param request_pb [::Google::Iam::V2::CreatePolicyRequest]
122
+ # A request object representing the call parameters. Required.
123
+ # @param options [::Gapic::CallOptions]
124
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
125
+ #
126
+ # @yield [result, operation] Access the result along with the TransportOperation object
127
+ # @yieldparam result [::Google::Longrunning::Operation]
128
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
129
+ #
130
+ # @return [::Google::Longrunning::Operation]
131
+ # A result object deserialized from the server's reply
132
+ def create_policy request_pb, options = nil
133
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
134
+
135
+ verb, uri, query_string_params, body = ServiceStub.transcode_create_policy_request request_pb
136
+ query_string_params = if query_string_params.any?
137
+ query_string_params.to_h { |p| p.split("=", 2) }
138
+ else
139
+ {}
140
+ end
141
+
142
+ response = @client_stub.make_http_request(
143
+ verb,
144
+ uri: uri,
145
+ body: body || "",
146
+ params: query_string_params,
147
+ options: options
148
+ )
149
+ operation = ::Gapic::Rest::TransportOperation.new response
150
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
151
+
152
+ yield result, operation if block_given?
153
+ result
154
+ end
155
+
156
+ ##
157
+ # Baseline implementation for the update_policy REST call
158
+ #
159
+ # @param request_pb [::Google::Iam::V2::UpdatePolicyRequest]
160
+ # A request object representing the call parameters. Required.
161
+ # @param options [::Gapic::CallOptions]
162
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
163
+ #
164
+ # @yield [result, operation] Access the result along with the TransportOperation object
165
+ # @yieldparam result [::Google::Longrunning::Operation]
166
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
167
+ #
168
+ # @return [::Google::Longrunning::Operation]
169
+ # A result object deserialized from the server's reply
170
+ def update_policy request_pb, options = nil
171
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
172
+
173
+ verb, uri, query_string_params, body = ServiceStub.transcode_update_policy_request request_pb
174
+ query_string_params = if query_string_params.any?
175
+ query_string_params.to_h { |p| p.split("=", 2) }
176
+ else
177
+ {}
178
+ end
179
+
180
+ response = @client_stub.make_http_request(
181
+ verb,
182
+ uri: uri,
183
+ body: body || "",
184
+ params: query_string_params,
185
+ options: options
186
+ )
187
+ operation = ::Gapic::Rest::TransportOperation.new response
188
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
189
+
190
+ yield result, operation if block_given?
191
+ result
192
+ end
193
+
194
+ ##
195
+ # Baseline implementation for the delete_policy REST call
196
+ #
197
+ # @param request_pb [::Google::Iam::V2::DeletePolicyRequest]
198
+ # A request object representing the call parameters. Required.
199
+ # @param options [::Gapic::CallOptions]
200
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
201
+ #
202
+ # @yield [result, operation] Access the result along with the TransportOperation object
203
+ # @yieldparam result [::Google::Longrunning::Operation]
204
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
205
+ #
206
+ # @return [::Google::Longrunning::Operation]
207
+ # A result object deserialized from the server's reply
208
+ def delete_policy request_pb, options = nil
209
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
210
+
211
+ verb, uri, query_string_params, body = ServiceStub.transcode_delete_policy_request request_pb
212
+ query_string_params = if query_string_params.any?
213
+ query_string_params.to_h { |p| p.split("=", 2) }
214
+ else
215
+ {}
216
+ end
217
+
218
+ response = @client_stub.make_http_request(
219
+ verb,
220
+ uri: uri,
221
+ body: body || "",
222
+ params: query_string_params,
223
+ options: options
224
+ )
225
+ operation = ::Gapic::Rest::TransportOperation.new response
226
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
227
+
228
+ yield result, operation if block_given?
229
+ result
230
+ end
231
+
232
+ ##
233
+ # @private
234
+ #
235
+ # GRPC transcoding helper method for the list_policies REST call
236
+ #
237
+ # @param request_pb [::Google::Iam::V2::ListPoliciesRequest]
238
+ # A request object representing the call parameters. Required.
239
+ # @return [Array(String, [String, nil], Hash{String => String})]
240
+ # Uri, Body, Query string parameters
241
+ def self.transcode_list_policies_request request_pb
242
+ transcoder = Gapic::Rest::GrpcTranscoder.new
243
+ .with_bindings(
244
+ uri_method: :get,
245
+ uri_template: "/v2/{parent}",
246
+ matches: [
247
+ ["parent", %r{^policies/[^/]+/[^/]+/?$}, false]
248
+ ]
249
+ )
250
+ transcoder.transcode request_pb
251
+ end
252
+
253
+ ##
254
+ # @private
255
+ #
256
+ # GRPC transcoding helper method for the get_policy REST call
257
+ #
258
+ # @param request_pb [::Google::Iam::V2::GetPolicyRequest]
259
+ # A request object representing the call parameters. Required.
260
+ # @return [Array(String, [String, nil], Hash{String => String})]
261
+ # Uri, Body, Query string parameters
262
+ def self.transcode_get_policy_request request_pb
263
+ transcoder = Gapic::Rest::GrpcTranscoder.new
264
+ .with_bindings(
265
+ uri_method: :get,
266
+ uri_template: "/v2/{name}",
267
+ matches: [
268
+ ["name", %r{^policies/[^/]+/[^/]+/[^/]+/?$}, false]
269
+ ]
270
+ )
271
+ transcoder.transcode request_pb
272
+ end
273
+
274
+ ##
275
+ # @private
276
+ #
277
+ # GRPC transcoding helper method for the create_policy REST call
278
+ #
279
+ # @param request_pb [::Google::Iam::V2::CreatePolicyRequest]
280
+ # A request object representing the call parameters. Required.
281
+ # @return [Array(String, [String, nil], Hash{String => String})]
282
+ # Uri, Body, Query string parameters
283
+ def self.transcode_create_policy_request request_pb
284
+ transcoder = Gapic::Rest::GrpcTranscoder.new
285
+ .with_bindings(
286
+ uri_method: :post,
287
+ uri_template: "/v2/{parent}",
288
+ body: "policy",
289
+ matches: [
290
+ ["parent", %r{^policies/[^/]+/[^/]+/?$}, false]
291
+ ]
292
+ )
293
+ transcoder.transcode request_pb
294
+ end
295
+
296
+ ##
297
+ # @private
298
+ #
299
+ # GRPC transcoding helper method for the update_policy REST call
300
+ #
301
+ # @param request_pb [::Google::Iam::V2::UpdatePolicyRequest]
302
+ # A request object representing the call parameters. Required.
303
+ # @return [Array(String, [String, nil], Hash{String => String})]
304
+ # Uri, Body, Query string parameters
305
+ def self.transcode_update_policy_request request_pb
306
+ transcoder = Gapic::Rest::GrpcTranscoder.new
307
+ .with_bindings(
308
+ uri_method: :put,
309
+ uri_template: "/v2/{policy.name}",
310
+ body: "policy",
311
+ matches: [
312
+ ["policy.name", %r{^policies/[^/]+/[^/]+/[^/]+/?$}, false]
313
+ ]
314
+ )
315
+ transcoder.transcode request_pb
316
+ end
317
+
318
+ ##
319
+ # @private
320
+ #
321
+ # GRPC transcoding helper method for the delete_policy REST call
322
+ #
323
+ # @param request_pb [::Google::Iam::V2::DeletePolicyRequest]
324
+ # A request object representing the call parameters. Required.
325
+ # @return [Array(String, [String, nil], Hash{String => String})]
326
+ # Uri, Body, Query string parameters
327
+ def self.transcode_delete_policy_request request_pb
328
+ transcoder = Gapic::Rest::GrpcTranscoder.new
329
+ .with_bindings(
330
+ uri_method: :delete,
331
+ uri_template: "/v2/{name}",
332
+ matches: [
333
+ ["name", %r{^policies/[^/]+/[^/]+/[^/]+/?$}, false]
334
+ ]
335
+ )
336
+ transcoder.transcode request_pb
337
+ end
338
+ end
339
+ end
340
+ end
341
+ end
342
+ end
343
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/iam/v2/version"
24
+
25
+ require "google/iam/v2/policies/credentials"
26
+ require "google/iam/v2/policies/rest/operations"
27
+ require "google/iam/v2/policies/rest/client"
28
+
29
+ module Google
30
+ module Iam
31
+ module V2
32
+ ##
33
+ # An interface for managing Identity and Access Management (IAM) policies.
34
+ #
35
+ # To load this service and instantiate a REST client:
36
+ #
37
+ # require "google/iam/v2/policies/rest"
38
+ # client = ::Google::Iam::V2::Policies::Rest::Client.new
39
+ #
40
+ module Policies
41
+ # Client for the REST transport
42
+ module Rest
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
50
+ require "google/iam/v2/policies/rest/helpers" if ::File.file? helper_path
@@ -25,6 +25,7 @@ require "google/iam/v2/version"
25
25
  require "google/iam/v2/policies/credentials"
26
26
  require "google/iam/v2/policies/operations"
27
27
  require "google/iam/v2/policies/client"
28
+ require "google/iam/v2/policies/rest"
28
29
 
29
30
  module Google
30
31
  module Iam
@@ -32,11 +33,16 @@ module Google
32
33
  ##
33
34
  # An interface for managing Identity and Access Management (IAM) policies.
34
35
  #
35
- # To load this service and instantiate a client:
36
+ # @example Load this service and instantiate a gRPC client
36
37
  #
37
38
  # require "google/iam/v2/policies"
38
39
  # client = ::Google::Iam::V2::Policies::Client.new
39
40
  #
41
+ # @example Load this service and instantiate a REST client
42
+ #
43
+ # require "google/iam/v2/policies/rest"
44
+ # client = ::Google::Iam::V2::Policies::Rest::Client.new
45
+ #
40
46
  module Policies
41
47
  end
42
48
  end
@@ -55,17 +55,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
55
55
  optional :name, :string, 1
56
56
  optional :etag, :string, 2
57
57
  end
58
- add_message "google.iam.v2.ListApplicablePoliciesRequest" do
59
- optional :attachment_point, :string, 1
60
- optional :filter, :string, 2
61
- optional :page_token, :string, 3
62
- optional :page_size, :int32, 4
63
- end
64
- add_message "google.iam.v2.ListApplicablePoliciesResponse" do
65
- repeated :policies, :message, 1, "google.iam.v2.Policy"
66
- repeated :inaccessible, :string, 2
67
- optional :next_page_token, :string, 3
68
- end
69
58
  add_message "google.iam.v2.PolicyOperationMetadata" do
70
59
  optional :create_time, :message, 1, "google.protobuf.Timestamp"
71
60
  end
@@ -83,8 +72,6 @@ module Google
83
72
  CreatePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.CreatePolicyRequest").msgclass
84
73
  UpdatePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.UpdatePolicyRequest").msgclass
85
74
  DeletePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.DeletePolicyRequest").msgclass
86
- ListApplicablePoliciesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.ListApplicablePoliciesRequest").msgclass
87
- ListApplicablePoliciesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.ListApplicablePoliciesResponse").msgclass
88
75
  PolicyOperationMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.iam.v2.PolicyOperationMetadata").msgclass
89
76
  end
90
77
  end
@@ -48,8 +48,7 @@ module Google
48
48
  #
49
49
  # To update a policy, you should use a read-modify-write loop:
50
50
  #
51
- # 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current
52
- # version of the policy.
51
+ # 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy.
53
52
  # 2. Modify the policy as needed.
54
53
  # 3. Use `UpdatePolicy` to write the updated policy.
55
54
  #
@@ -57,17 +56,6 @@ module Google
57
56
  rpc :UpdatePolicy, ::Google::Iam::V2::UpdatePolicyRequest, ::Google::Longrunning::Operation
58
57
  # Deletes a policy. This action is permanent.
59
58
  rpc :DeletePolicy, ::Google::Iam::V2::DeletePolicyRequest, ::Google::Longrunning::Operation
60
- # Retrieves all the policies that are attached to the specified resource,
61
- # or anywhere in the ancestry of the resource. For example, for a project
62
- # this endpoint would return all the `denyPolicy` kind policies attached to
63
- # the project, its parent folder (if any), and its parent organization (if
64
- # any).
65
- # The endpoint requires the same permissions that it would take to call
66
- # `ListPolicies` or `GetPolicy`.
67
- #
68
- # The main reason to use this endpoint is as a policy admin to debug access
69
- # issues for a resource.
70
- rpc :ListApplicablePolicies, ::Google::Iam::V2::ListApplicablePoliciesRequest, ::Google::Iam::V2::ListApplicablePoliciesResponse
71
59
  end
72
60
 
73
61
  Stub = Service.rpc_stub_class
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/iam/v2/policies/rest"
20
+ require "google/iam/v2/version"
21
+
22
+ module Google
23
+ module Iam
24
+ ##
25
+ # To load just the REST part of this package, including all its services, and instantiate a REST client:
26
+ #
27
+ # @example
28
+ #
29
+ # require "google/iam/v2/rest"
30
+ # client = ::Google::Iam::V2::Policies::Rest::Client.new
31
+ #
32
+ module V2
33
+ end
34
+ end
35
+ end
@@ -20,7 +20,7 @@
20
20
  module Google
21
21
  module Iam
22
22
  module V2
23
- VERSION = "0.1.1"
23
+ VERSION = "0.2.0"
24
24
  end
25
25
  end
26
26
  end
data/lib/google/iam/v2.rb CHANGED
@@ -22,13 +22,18 @@ require "google/iam/v2/version"
22
22
  module Google
23
23
  module Iam
24
24
  ##
25
- # To load this package, including all its services, and instantiate a client:
25
+ # API client module.
26
26
  #
27
- # @example
27
+ # @example Load this package, including all its services, and instantiate a gRPC client
28
28
  #
29
29
  # require "google/iam/v2"
30
30
  # client = ::Google::Iam::V2::Policies::Client.new
31
31
  #
32
+ # @example Load this package, including all its services, and instantiate a REST client
33
+ #
34
+ # require "google/iam/v2"
35
+ # client = ::Google::Iam::V2::Policies::Rest::Client.new
36
+ #
32
37
  module V2
33
38
  end
34
39
  end