azure_mgmt_authorization 0.2.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/.rspec +3 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +5 -0
- data/azure_mgmt_authorization.gemspec +34 -0
- data/lib/azure_mgmt_authorization/authorization_management_client.rb +84 -0
- data/lib/azure_mgmt_authorization/classic_administrators.rb +145 -0
- data/lib/azure_mgmt_authorization/models/classic_administrator.rb +90 -0
- data/lib/azure_mgmt_authorization/models/classic_administrator_list_result.rb +77 -0
- data/lib/azure_mgmt_authorization/models/classic_administrator_properties.rb +65 -0
- data/lib/azure_mgmt_authorization/models/permission.rb +66 -0
- data/lib/azure_mgmt_authorization/models/permission_get_result.rb +76 -0
- data/lib/azure_mgmt_authorization/models/provider_operation.rb +92 -0
- data/lib/azure_mgmt_authorization/models/provider_operations_metadata.rb +142 -0
- data/lib/azure_mgmt_authorization/models/provider_operations_metadata_list_result.rb +77 -0
- data/lib/azure_mgmt_authorization/models/resource_type.rb +95 -0
- data/lib/azure_mgmt_authorization/models/role_assignment.rb +90 -0
- data/lib/azure_mgmt_authorization/models/role_assignment_create_parameters.rb +63 -0
- data/lib/azure_mgmt_authorization/models/role_assignment_filter.rb +56 -0
- data/lib/azure_mgmt_authorization/models/role_assignment_list_result.rb +86 -0
- data/lib/azure_mgmt_authorization/models/role_assignment_properties.rb +65 -0
- data/lib/azure_mgmt_authorization/models/role_assignment_properties_with_scope.rb +74 -0
- data/lib/azure_mgmt_authorization/models/role_definition.rb +90 -0
- data/lib/azure_mgmt_authorization/models/role_definition_filter.rb +56 -0
- data/lib/azure_mgmt_authorization/models/role_definition_list_result.rb +76 -0
- data/lib/azure_mgmt_authorization/models/role_definition_properties.rb +113 -0
- data/lib/azure_mgmt_authorization/module_definition.rb +8 -0
- data/lib/azure_mgmt_authorization/permissions.rb +277 -0
- data/lib/azure_mgmt_authorization/provider_operations_metadata_operations.rb +207 -0
- data/lib/azure_mgmt_authorization/role_assignments.rb +907 -0
- data/lib/azure_mgmt_authorization/role_definitions.rb +408 -0
- data/lib/azure_mgmt_authorization/version.rb +8 -0
- data/lib/azure_mgmt_authorization.rb +50 -0
- metadata +147 -0
@@ -0,0 +1,907 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Authorization
|
7
|
+
#
|
8
|
+
# RoleAssignments
|
9
|
+
#
|
10
|
+
class RoleAssignments
|
11
|
+
include Azure::ARM::Authorization::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the RoleAssignments class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return reference to the AuthorizationManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# Gets role assignments of the resource.
|
27
|
+
#
|
28
|
+
# @param resource_group_name [String] The name of the resource group.
|
29
|
+
# @param resource_provider_namespace [String] Resource identity.
|
30
|
+
# @param parent_resource_path [String] Resource identity.
|
31
|
+
# @param resource_type [String] Resource identity.
|
32
|
+
# @param resource_name [String] Resource identity.
|
33
|
+
# @param filter [String] The filter to apply on the operation.
|
34
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
35
|
+
# applied to HTTP request.
|
36
|
+
#
|
37
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
38
|
+
# response.
|
39
|
+
#
|
40
|
+
def list_for_resource(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter = nil, custom_headers = nil)
|
41
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
42
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
43
|
+
fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
|
44
|
+
fail ArgumentError, 'resource_type is nil' if resource_type.nil?
|
45
|
+
fail ArgumentError, 'resource_name is nil' if resource_name.nil?
|
46
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
47
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
48
|
+
request_headers = {}
|
49
|
+
|
50
|
+
# Set Headers
|
51
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
52
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
53
|
+
path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}providers/Microsoft.Authorization/roleAssignments'
|
54
|
+
options = {
|
55
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
56
|
+
path_params: {'resourceGroupName' => resource_group_name,'resourceProviderNamespace' => resource_provider_namespace,'resourceName' => resource_name,'subscriptionId' => @client.subscription_id},
|
57
|
+
skip_encoding_path_params: {'parentResourcePath' => parent_resource_path,'resourceType' => resource_type},
|
58
|
+
query_params: {'$filter' => filter,'api-version' => @client.api_version},
|
59
|
+
headers: request_headers.merge(custom_headers || {})
|
60
|
+
}
|
61
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
62
|
+
promise = request.run_promise do |req|
|
63
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
promise = promise.then do |http_response|
|
67
|
+
status_code = http_response.status
|
68
|
+
response_content = http_response.body
|
69
|
+
unless status_code == 200
|
70
|
+
error_model = JSON.load(response_content)
|
71
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Create Result
|
75
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
76
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
77
|
+
# Deserialize Response
|
78
|
+
if status_code == 200
|
79
|
+
begin
|
80
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
81
|
+
unless parsed_response.nil?
|
82
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
83
|
+
end
|
84
|
+
result.body = parsed_response
|
85
|
+
rescue Exception => e
|
86
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
result
|
91
|
+
end
|
92
|
+
|
93
|
+
promise.execute
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Gets role assignments of the resource group.
|
98
|
+
#
|
99
|
+
# @param resource_group_name [String] Resource group name.
|
100
|
+
# @param filter [String] The filter to apply on the operation.
|
101
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
102
|
+
# applied to HTTP request.
|
103
|
+
#
|
104
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
105
|
+
# response.
|
106
|
+
#
|
107
|
+
def list_for_resource_group(resource_group_name, filter = nil, custom_headers = nil)
|
108
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
109
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
110
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
111
|
+
request_headers = {}
|
112
|
+
|
113
|
+
# Set Headers
|
114
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
115
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
116
|
+
path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'
|
117
|
+
options = {
|
118
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
119
|
+
path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
|
120
|
+
query_params: {'$filter' => filter,'api-version' => @client.api_version},
|
121
|
+
headers: request_headers.merge(custom_headers || {})
|
122
|
+
}
|
123
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
124
|
+
promise = request.run_promise do |req|
|
125
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
126
|
+
end
|
127
|
+
|
128
|
+
promise = promise.then do |http_response|
|
129
|
+
status_code = http_response.status
|
130
|
+
response_content = http_response.body
|
131
|
+
unless status_code == 200
|
132
|
+
error_model = JSON.load(response_content)
|
133
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Create Result
|
137
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
138
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
139
|
+
# Deserialize Response
|
140
|
+
if status_code == 200
|
141
|
+
begin
|
142
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
143
|
+
unless parsed_response.nil?
|
144
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
145
|
+
end
|
146
|
+
result.body = parsed_response
|
147
|
+
rescue Exception => e
|
148
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
result
|
153
|
+
end
|
154
|
+
|
155
|
+
promise.execute
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
# Delete role assignment.
|
160
|
+
#
|
161
|
+
# @param scope [String] Scope.
|
162
|
+
# @param role_assignment_name [String] Role assignment name.
|
163
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
164
|
+
# applied to HTTP request.
|
165
|
+
#
|
166
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
167
|
+
# response.
|
168
|
+
#
|
169
|
+
def delete(scope, role_assignment_name, custom_headers = nil)
|
170
|
+
fail ArgumentError, 'scope is nil' if scope.nil?
|
171
|
+
fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
|
172
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
173
|
+
request_headers = {}
|
174
|
+
|
175
|
+
# Set Headers
|
176
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
177
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
178
|
+
path_template = '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
|
179
|
+
options = {
|
180
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
181
|
+
path_params: {'roleAssignmentName' => role_assignment_name},
|
182
|
+
skip_encoding_path_params: {'scope' => scope},
|
183
|
+
query_params: {'api-version' => @client.api_version},
|
184
|
+
headers: request_headers.merge(custom_headers || {})
|
185
|
+
}
|
186
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
|
187
|
+
promise = request.run_promise do |req|
|
188
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
189
|
+
end
|
190
|
+
|
191
|
+
promise = promise.then do |http_response|
|
192
|
+
status_code = http_response.status
|
193
|
+
response_content = http_response.body
|
194
|
+
unless status_code == 200
|
195
|
+
error_model = JSON.load(response_content)
|
196
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
197
|
+
end
|
198
|
+
|
199
|
+
# Create Result
|
200
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
201
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
202
|
+
# Deserialize Response
|
203
|
+
if status_code == 200
|
204
|
+
begin
|
205
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
206
|
+
unless parsed_response.nil?
|
207
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
208
|
+
end
|
209
|
+
result.body = parsed_response
|
210
|
+
rescue Exception => e
|
211
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
result
|
216
|
+
end
|
217
|
+
|
218
|
+
promise.execute
|
219
|
+
end
|
220
|
+
|
221
|
+
#
|
222
|
+
# Create role assignment.
|
223
|
+
#
|
224
|
+
# @param scope [String] Scope.
|
225
|
+
# @param role_assignment_name [String] Role assignment name.
|
226
|
+
# @param parameters [RoleAssignmentCreateParameters] Role assignment.
|
227
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
228
|
+
# applied to HTTP request.
|
229
|
+
#
|
230
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
231
|
+
# response.
|
232
|
+
#
|
233
|
+
def create(scope, role_assignment_name, parameters, custom_headers = nil)
|
234
|
+
fail ArgumentError, 'scope is nil' if scope.nil?
|
235
|
+
fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
|
236
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
237
|
+
parameters.validate unless parameters.nil?
|
238
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
239
|
+
request_headers = {}
|
240
|
+
|
241
|
+
# Set Headers
|
242
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
243
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
244
|
+
|
245
|
+
# Serialize Request
|
246
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
247
|
+
unless parameters.nil?
|
248
|
+
parameters = RoleAssignmentCreateParameters.serialize_object(parameters)
|
249
|
+
end
|
250
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
251
|
+
path_template = '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
|
252
|
+
options = {
|
253
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
254
|
+
path_params: {'roleAssignmentName' => role_assignment_name},
|
255
|
+
skip_encoding_path_params: {'scope' => scope},
|
256
|
+
query_params: {'api-version' => @client.api_version},
|
257
|
+
body: request_content,
|
258
|
+
headers: request_headers.merge(custom_headers || {})
|
259
|
+
}
|
260
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
|
261
|
+
promise = request.run_promise do |req|
|
262
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
263
|
+
end
|
264
|
+
|
265
|
+
promise = promise.then do |http_response|
|
266
|
+
status_code = http_response.status
|
267
|
+
response_content = http_response.body
|
268
|
+
unless status_code == 201
|
269
|
+
error_model = JSON.load(response_content)
|
270
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
271
|
+
end
|
272
|
+
|
273
|
+
# Create Result
|
274
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
275
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
276
|
+
# Deserialize Response
|
277
|
+
if status_code == 201
|
278
|
+
begin
|
279
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
280
|
+
unless parsed_response.nil?
|
281
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
282
|
+
end
|
283
|
+
result.body = parsed_response
|
284
|
+
rescue Exception => e
|
285
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
result
|
290
|
+
end
|
291
|
+
|
292
|
+
promise.execute
|
293
|
+
end
|
294
|
+
|
295
|
+
#
|
296
|
+
# Get single role assignment.
|
297
|
+
#
|
298
|
+
# @param scope [String] Scope.
|
299
|
+
# @param role_assignment_name [String] Role assignment name.
|
300
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
301
|
+
# applied to HTTP request.
|
302
|
+
#
|
303
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
304
|
+
# response.
|
305
|
+
#
|
306
|
+
def get(scope, role_assignment_name, custom_headers = nil)
|
307
|
+
fail ArgumentError, 'scope is nil' if scope.nil?
|
308
|
+
fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
|
309
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
310
|
+
request_headers = {}
|
311
|
+
|
312
|
+
# Set Headers
|
313
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
314
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
315
|
+
path_template = '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
|
316
|
+
options = {
|
317
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
318
|
+
path_params: {'roleAssignmentName' => role_assignment_name},
|
319
|
+
skip_encoding_path_params: {'scope' => scope},
|
320
|
+
query_params: {'api-version' => @client.api_version},
|
321
|
+
headers: request_headers.merge(custom_headers || {})
|
322
|
+
}
|
323
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
324
|
+
promise = request.run_promise do |req|
|
325
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
326
|
+
end
|
327
|
+
|
328
|
+
promise = promise.then do |http_response|
|
329
|
+
status_code = http_response.status
|
330
|
+
response_content = http_response.body
|
331
|
+
unless status_code == 200
|
332
|
+
error_model = JSON.load(response_content)
|
333
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
334
|
+
end
|
335
|
+
|
336
|
+
# Create Result
|
337
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
338
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
339
|
+
# Deserialize Response
|
340
|
+
if status_code == 200
|
341
|
+
begin
|
342
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
343
|
+
unless parsed_response.nil?
|
344
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
345
|
+
end
|
346
|
+
result.body = parsed_response
|
347
|
+
rescue Exception => e
|
348
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
result
|
353
|
+
end
|
354
|
+
|
355
|
+
promise.execute
|
356
|
+
end
|
357
|
+
|
358
|
+
#
|
359
|
+
# Delete role assignment.
|
360
|
+
#
|
361
|
+
# @param role_assignment_id [String] Role assignment Id
|
362
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
363
|
+
# applied to HTTP request.
|
364
|
+
#
|
365
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
366
|
+
# response.
|
367
|
+
#
|
368
|
+
def delete_by_id(role_assignment_id, custom_headers = nil)
|
369
|
+
fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
|
370
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
371
|
+
request_headers = {}
|
372
|
+
|
373
|
+
# Set Headers
|
374
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
375
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
376
|
+
path_template = '/{roleAssignmentId}'
|
377
|
+
options = {
|
378
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
379
|
+
skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
|
380
|
+
query_params: {'api-version' => @client.api_version},
|
381
|
+
headers: request_headers.merge(custom_headers || {})
|
382
|
+
}
|
383
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
|
384
|
+
promise = request.run_promise do |req|
|
385
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
386
|
+
end
|
387
|
+
|
388
|
+
promise = promise.then do |http_response|
|
389
|
+
status_code = http_response.status
|
390
|
+
response_content = http_response.body
|
391
|
+
unless status_code == 200
|
392
|
+
error_model = JSON.load(response_content)
|
393
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
394
|
+
end
|
395
|
+
|
396
|
+
# Create Result
|
397
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
398
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
399
|
+
# Deserialize Response
|
400
|
+
if status_code == 200
|
401
|
+
begin
|
402
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
403
|
+
unless parsed_response.nil?
|
404
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
405
|
+
end
|
406
|
+
result.body = parsed_response
|
407
|
+
rescue Exception => e
|
408
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
result
|
413
|
+
end
|
414
|
+
|
415
|
+
promise.execute
|
416
|
+
end
|
417
|
+
|
418
|
+
#
|
419
|
+
# Create role assignment by Id.
|
420
|
+
#
|
421
|
+
# @param role_assignment_id [String] Role assignment Id
|
422
|
+
# @param parameters [RoleAssignmentCreateParameters] Role assignment.
|
423
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
424
|
+
# applied to HTTP request.
|
425
|
+
#
|
426
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
427
|
+
# response.
|
428
|
+
#
|
429
|
+
def create_by_id(role_assignment_id, parameters, custom_headers = nil)
|
430
|
+
fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
|
431
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
432
|
+
parameters.validate unless parameters.nil?
|
433
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
434
|
+
request_headers = {}
|
435
|
+
|
436
|
+
# Set Headers
|
437
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
438
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
439
|
+
|
440
|
+
# Serialize Request
|
441
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
442
|
+
unless parameters.nil?
|
443
|
+
parameters = RoleAssignmentCreateParameters.serialize_object(parameters)
|
444
|
+
end
|
445
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
446
|
+
path_template = '/{roleAssignmentId}'
|
447
|
+
options = {
|
448
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
449
|
+
skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
|
450
|
+
query_params: {'api-version' => @client.api_version},
|
451
|
+
body: request_content,
|
452
|
+
headers: request_headers.merge(custom_headers || {})
|
453
|
+
}
|
454
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
|
455
|
+
promise = request.run_promise do |req|
|
456
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
457
|
+
end
|
458
|
+
|
459
|
+
promise = promise.then do |http_response|
|
460
|
+
status_code = http_response.status
|
461
|
+
response_content = http_response.body
|
462
|
+
unless status_code == 201
|
463
|
+
error_model = JSON.load(response_content)
|
464
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
465
|
+
end
|
466
|
+
|
467
|
+
# Create Result
|
468
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
469
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
470
|
+
# Deserialize Response
|
471
|
+
if status_code == 201
|
472
|
+
begin
|
473
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
474
|
+
unless parsed_response.nil?
|
475
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
476
|
+
end
|
477
|
+
result.body = parsed_response
|
478
|
+
rescue Exception => e
|
479
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
result
|
484
|
+
end
|
485
|
+
|
486
|
+
promise.execute
|
487
|
+
end
|
488
|
+
|
489
|
+
#
|
490
|
+
# Get single role assignment.
|
491
|
+
#
|
492
|
+
# @param role_assignment_id [String] Role assignment Id
|
493
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
494
|
+
# applied to HTTP request.
|
495
|
+
#
|
496
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
497
|
+
# response.
|
498
|
+
#
|
499
|
+
def get_by_id(role_assignment_id, custom_headers = nil)
|
500
|
+
fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
|
501
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
502
|
+
request_headers = {}
|
503
|
+
|
504
|
+
# Set Headers
|
505
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
506
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
507
|
+
path_template = '/{roleAssignmentId}'
|
508
|
+
options = {
|
509
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
510
|
+
skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
|
511
|
+
query_params: {'api-version' => @client.api_version},
|
512
|
+
headers: request_headers.merge(custom_headers || {})
|
513
|
+
}
|
514
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
515
|
+
promise = request.run_promise do |req|
|
516
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
517
|
+
end
|
518
|
+
|
519
|
+
promise = promise.then do |http_response|
|
520
|
+
status_code = http_response.status
|
521
|
+
response_content = http_response.body
|
522
|
+
unless status_code == 200
|
523
|
+
error_model = JSON.load(response_content)
|
524
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
525
|
+
end
|
526
|
+
|
527
|
+
# Create Result
|
528
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
529
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
530
|
+
# Deserialize Response
|
531
|
+
if status_code == 200
|
532
|
+
begin
|
533
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
534
|
+
unless parsed_response.nil?
|
535
|
+
parsed_response = RoleAssignment.deserialize_object(parsed_response)
|
536
|
+
end
|
537
|
+
result.body = parsed_response
|
538
|
+
rescue Exception => e
|
539
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
result
|
544
|
+
end
|
545
|
+
|
546
|
+
promise.execute
|
547
|
+
end
|
548
|
+
|
549
|
+
#
|
550
|
+
# Gets role assignments of the subscription.
|
551
|
+
#
|
552
|
+
# @param filter [String] The filter to apply on the operation.
|
553
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
554
|
+
# applied to HTTP request.
|
555
|
+
#
|
556
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
557
|
+
# response.
|
558
|
+
#
|
559
|
+
def list(filter = nil, custom_headers = nil)
|
560
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
561
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
562
|
+
request_headers = {}
|
563
|
+
|
564
|
+
# Set Headers
|
565
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
566
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
567
|
+
path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'
|
568
|
+
options = {
|
569
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
570
|
+
path_params: {'subscriptionId' => @client.subscription_id},
|
571
|
+
query_params: {'$filter' => filter,'api-version' => @client.api_version},
|
572
|
+
headers: request_headers.merge(custom_headers || {})
|
573
|
+
}
|
574
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
575
|
+
promise = request.run_promise do |req|
|
576
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
577
|
+
end
|
578
|
+
|
579
|
+
promise = promise.then do |http_response|
|
580
|
+
status_code = http_response.status
|
581
|
+
response_content = http_response.body
|
582
|
+
unless status_code == 200
|
583
|
+
error_model = JSON.load(response_content)
|
584
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
585
|
+
end
|
586
|
+
|
587
|
+
# Create Result
|
588
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
589
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
590
|
+
# Deserialize Response
|
591
|
+
if status_code == 200
|
592
|
+
begin
|
593
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
594
|
+
unless parsed_response.nil?
|
595
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
596
|
+
end
|
597
|
+
result.body = parsed_response
|
598
|
+
rescue Exception => e
|
599
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
result
|
604
|
+
end
|
605
|
+
|
606
|
+
promise.execute
|
607
|
+
end
|
608
|
+
|
609
|
+
#
|
610
|
+
# Gets role assignments of the scope.
|
611
|
+
#
|
612
|
+
# @param scope [String] Scope.
|
613
|
+
# @param filter [String] The filter to apply on the operation.
|
614
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
615
|
+
# applied to HTTP request.
|
616
|
+
#
|
617
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
618
|
+
# response.
|
619
|
+
#
|
620
|
+
def list_for_scope(scope, filter = nil, custom_headers = nil)
|
621
|
+
fail ArgumentError, 'scope is nil' if scope.nil?
|
622
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
623
|
+
request_headers = {}
|
624
|
+
|
625
|
+
# Set Headers
|
626
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
627
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
628
|
+
path_template = '/{scope}/providers/Microsoft.Authorization/roleAssignments'
|
629
|
+
options = {
|
630
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
631
|
+
skip_encoding_path_params: {'scope' => scope},
|
632
|
+
query_params: {'$filter' => filter,'api-version' => @client.api_version},
|
633
|
+
headers: request_headers.merge(custom_headers || {})
|
634
|
+
}
|
635
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
636
|
+
promise = request.run_promise do |req|
|
637
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
638
|
+
end
|
639
|
+
|
640
|
+
promise = promise.then do |http_response|
|
641
|
+
status_code = http_response.status
|
642
|
+
response_content = http_response.body
|
643
|
+
unless status_code == 200
|
644
|
+
error_model = JSON.load(response_content)
|
645
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
646
|
+
end
|
647
|
+
|
648
|
+
# Create Result
|
649
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
650
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
651
|
+
# Deserialize Response
|
652
|
+
if status_code == 200
|
653
|
+
begin
|
654
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
655
|
+
unless parsed_response.nil?
|
656
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
657
|
+
end
|
658
|
+
result.body = parsed_response
|
659
|
+
rescue Exception => e
|
660
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
result
|
665
|
+
end
|
666
|
+
|
667
|
+
promise.execute
|
668
|
+
end
|
669
|
+
|
670
|
+
#
|
671
|
+
# Gets role assignments of the resource.
|
672
|
+
#
|
673
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
674
|
+
# call to List operation.
|
675
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
676
|
+
# applied to HTTP request.
|
677
|
+
#
|
678
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
679
|
+
# response.
|
680
|
+
#
|
681
|
+
def list_for_resource_next(next_page_link, custom_headers = nil)
|
682
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
683
|
+
request_headers = {}
|
684
|
+
|
685
|
+
# Set Headers
|
686
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
687
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
688
|
+
path_template = '{nextLink}'
|
689
|
+
options = {
|
690
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
691
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
692
|
+
headers: request_headers.merge(custom_headers || {})
|
693
|
+
}
|
694
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
695
|
+
promise = request.run_promise do |req|
|
696
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
697
|
+
end
|
698
|
+
|
699
|
+
promise = promise.then do |http_response|
|
700
|
+
status_code = http_response.status
|
701
|
+
response_content = http_response.body
|
702
|
+
unless status_code == 200
|
703
|
+
error_model = JSON.load(response_content)
|
704
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
705
|
+
end
|
706
|
+
|
707
|
+
# Create Result
|
708
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
709
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
710
|
+
# Deserialize Response
|
711
|
+
if status_code == 200
|
712
|
+
begin
|
713
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
714
|
+
unless parsed_response.nil?
|
715
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
716
|
+
end
|
717
|
+
result.body = parsed_response
|
718
|
+
rescue Exception => e
|
719
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
result
|
724
|
+
end
|
725
|
+
|
726
|
+
promise.execute
|
727
|
+
end
|
728
|
+
|
729
|
+
#
|
730
|
+
# Gets role assignments of the resource group.
|
731
|
+
#
|
732
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
733
|
+
# call to List operation.
|
734
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
735
|
+
# applied to HTTP request.
|
736
|
+
#
|
737
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
738
|
+
# response.
|
739
|
+
#
|
740
|
+
def list_for_resource_group_next(next_page_link, custom_headers = nil)
|
741
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
742
|
+
request_headers = {}
|
743
|
+
|
744
|
+
# Set Headers
|
745
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
746
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
747
|
+
path_template = '{nextLink}'
|
748
|
+
options = {
|
749
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
750
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
751
|
+
headers: request_headers.merge(custom_headers || {})
|
752
|
+
}
|
753
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
754
|
+
promise = request.run_promise do |req|
|
755
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
756
|
+
end
|
757
|
+
|
758
|
+
promise = promise.then do |http_response|
|
759
|
+
status_code = http_response.status
|
760
|
+
response_content = http_response.body
|
761
|
+
unless status_code == 200
|
762
|
+
error_model = JSON.load(response_content)
|
763
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
764
|
+
end
|
765
|
+
|
766
|
+
# Create Result
|
767
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
768
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
769
|
+
# Deserialize Response
|
770
|
+
if status_code == 200
|
771
|
+
begin
|
772
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
773
|
+
unless parsed_response.nil?
|
774
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
775
|
+
end
|
776
|
+
result.body = parsed_response
|
777
|
+
rescue Exception => e
|
778
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
779
|
+
end
|
780
|
+
end
|
781
|
+
|
782
|
+
result
|
783
|
+
end
|
784
|
+
|
785
|
+
promise.execute
|
786
|
+
end
|
787
|
+
|
788
|
+
#
|
789
|
+
# Gets role assignments of the subscription.
|
790
|
+
#
|
791
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
792
|
+
# call to List operation.
|
793
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
794
|
+
# applied to HTTP request.
|
795
|
+
#
|
796
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
797
|
+
# response.
|
798
|
+
#
|
799
|
+
def list_next(next_page_link, custom_headers = nil)
|
800
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
801
|
+
request_headers = {}
|
802
|
+
|
803
|
+
# Set Headers
|
804
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
805
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
806
|
+
path_template = '{nextLink}'
|
807
|
+
options = {
|
808
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
809
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
810
|
+
headers: request_headers.merge(custom_headers || {})
|
811
|
+
}
|
812
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
813
|
+
promise = request.run_promise do |req|
|
814
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
815
|
+
end
|
816
|
+
|
817
|
+
promise = promise.then do |http_response|
|
818
|
+
status_code = http_response.status
|
819
|
+
response_content = http_response.body
|
820
|
+
unless status_code == 200
|
821
|
+
error_model = JSON.load(response_content)
|
822
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
823
|
+
end
|
824
|
+
|
825
|
+
# Create Result
|
826
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
827
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
828
|
+
# Deserialize Response
|
829
|
+
if status_code == 200
|
830
|
+
begin
|
831
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
832
|
+
unless parsed_response.nil?
|
833
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
834
|
+
end
|
835
|
+
result.body = parsed_response
|
836
|
+
rescue Exception => e
|
837
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
result
|
842
|
+
end
|
843
|
+
|
844
|
+
promise.execute
|
845
|
+
end
|
846
|
+
|
847
|
+
#
|
848
|
+
# Gets role assignments of the scope.
|
849
|
+
#
|
850
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
851
|
+
# call to List operation.
|
852
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
853
|
+
# applied to HTTP request.
|
854
|
+
#
|
855
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
856
|
+
# response.
|
857
|
+
#
|
858
|
+
def list_for_scope_next(next_page_link, custom_headers = nil)
|
859
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
860
|
+
request_headers = {}
|
861
|
+
|
862
|
+
# Set Headers
|
863
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
864
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
865
|
+
path_template = '{nextLink}'
|
866
|
+
options = {
|
867
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
868
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
869
|
+
headers: request_headers.merge(custom_headers || {})
|
870
|
+
}
|
871
|
+
request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
|
872
|
+
promise = request.run_promise do |req|
|
873
|
+
@client.credentials.sign_request(req) unless @client.credentials.nil?
|
874
|
+
end
|
875
|
+
|
876
|
+
promise = promise.then do |http_response|
|
877
|
+
status_code = http_response.status
|
878
|
+
response_content = http_response.body
|
879
|
+
unless status_code == 200
|
880
|
+
error_model = JSON.load(response_content)
|
881
|
+
fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
|
882
|
+
end
|
883
|
+
|
884
|
+
# Create Result
|
885
|
+
result = MsRestAzure::AzureOperationResponse.new(request, http_response)
|
886
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
887
|
+
# Deserialize Response
|
888
|
+
if status_code == 200
|
889
|
+
begin
|
890
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
891
|
+
unless parsed_response.nil?
|
892
|
+
parsed_response = RoleAssignmentListResult.deserialize_object(parsed_response)
|
893
|
+
end
|
894
|
+
result.body = parsed_response
|
895
|
+
rescue Exception => e
|
896
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
897
|
+
end
|
898
|
+
end
|
899
|
+
|
900
|
+
result
|
901
|
+
end
|
902
|
+
|
903
|
+
promise.execute
|
904
|
+
end
|
905
|
+
|
906
|
+
end
|
907
|
+
end
|