ms_rest_azure 0.10.8 → 0.11.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d37dfda37f047cab1ca8ede97a21b4b6e948cca
|
4
|
+
data.tar.gz: be8a83887c0f8e6d1a9bb532db78af7844e1639b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a64ed4cdf61a5d096afa34373487c64a39b10f2a1d4b0a407b052a2446df05d656da0b2749202b8dbc35448269690c90ff14774527a01f4d3145028f83afdd1
|
7
|
+
data.tar.gz: 683983a519bc16e11f76f275fcab91190567bb56987ee50f9b48e8ef6e2ff78c3905297b1be82648b237ee01861145998c98fdc5f2c4db5415ae66235a160dc4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
##2018.07.31 ms_rest_azure version 0.11.0
|
2
|
+
* Added USER_DEFINED_IMDS_MAX_RETRY_TIME to msi_token_provider. Refer [PR #1539](https://github.com/Azure/azure-sdk-for-ruby/pull/1539) and [Issue #1344](https://github.com/Azure/azure-sdk-for-ruby/issues/1344) for further details.
|
3
|
+
* Modified Long Running Operation Logic to make final calls based on Final State Via value. Refer [PR #1537](https://github.com/Azure/azure-sdk-for-ruby/pull/1537) for further details.
|
4
|
+
|
1
5
|
##2018.06.08 ms_rest_azure version 0.10.8
|
2
6
|
* Added case insensitive comparison to Operation status.
|
3
7
|
|
data/lib/ms_rest_azure.rb
CHANGED
@@ -10,6 +10,7 @@ require 'ms_rest_azure/azure_operation_error.rb'
|
|
10
10
|
require 'ms_rest_azure/azure_operation_response.rb'
|
11
11
|
require 'ms_rest_azure/azure_service_client.rb'
|
12
12
|
require 'ms_rest_azure/cloud_error_data.rb'
|
13
|
+
require 'ms_rest_azure/final_state_via.rb'
|
13
14
|
require 'ms_rest_azure/credentials/application_token_provider.rb'
|
14
15
|
require 'ms_rest_azure/credentials/cognitive_services_credentials.rb'
|
15
16
|
require 'ms_rest_azure/credentials/topic_credentials.rb'
|
@@ -30,10 +30,11 @@ module MsRestAzure
|
|
30
30
|
# Retrieves the result of 'POST','DELETE','PUT' or 'PATCH' operation. Performs polling of required.
|
31
31
|
# @param azure_response [MsRestAzure::AzureOperationResponse] response from Azure service.
|
32
32
|
# @param custom_deserialization_block [Proc] custom logic for response deserialization.
|
33
|
+
# @param final_state_via [MsRestAzure::FinalStateVia] Final State via value
|
33
34
|
#
|
34
35
|
# @return [MsRest::HttpOperationResponse] the response.
|
35
36
|
#
|
36
|
-
def get_long_running_operation_result(azure_response, custom_deserialization_block)
|
37
|
+
def get_long_running_operation_result(azure_response, custom_deserialization_block, final_state_via = FinalStateVia::DEFAULT)
|
37
38
|
check_for_status_code_failure(azure_response)
|
38
39
|
|
39
40
|
http_method = azure_response.request.method
|
@@ -47,13 +48,22 @@ module MsRestAzure
|
|
47
48
|
if !polling_state.azure_async_operation_header_link.nil?
|
48
49
|
update_state_from_azure_async_operation_header(polling_state.get_request(headers: request.headers, base_uri: request.base_uri, user_agent_extended: user_agent_extended), polling_state)
|
49
50
|
elsif !polling_state.location_header_link.nil?
|
50
|
-
update_state_from_location_header(polling_state.get_request(headers: request.headers, base_uri: request.base_uri, user_agent_extended: user_agent_extended), polling_state, custom_deserialization_block)
|
51
|
+
update_state_from_location_header(polling_state.get_request(headers: request.headers, base_uri: request.base_uri, user_agent_extended: user_agent_extended), polling_state, custom_deserialization_block, final_state_via)
|
51
52
|
elsif http_method === :put
|
52
53
|
get_request = MsRest::HttpOperationRequest.new(request.base_uri, request.build_path.to_s, :get, {query_params: request.query_params, headers: request.headers, user_agent_extended: user_agent_extended})
|
53
54
|
update_state_from_get_resource_operation(get_request, polling_state, custom_deserialization_block)
|
54
55
|
else
|
55
56
|
task.shutdown
|
56
|
-
|
57
|
+
if final_state_via == FinalStateVia::LOCATION
|
58
|
+
if !polling_state.response.body.to_s.empty?
|
59
|
+
body = JSON.load(polling_state.response.body)
|
60
|
+
polling_state.resource = custom_deserialization_block.call(body)
|
61
|
+
else
|
62
|
+
fail AzureOperationError, 'Location header is missing from long running operation'
|
63
|
+
end
|
64
|
+
else
|
65
|
+
fail AzureOperationError, 'Location header is missing from long running operation'
|
66
|
+
end
|
57
67
|
end
|
58
68
|
|
59
69
|
if AsyncOperationStatus.is_terminal_status(polling_state.status)
|
@@ -83,6 +93,12 @@ module MsRestAzure
|
|
83
93
|
update_state_from_get_resource_operation(get_request, polling_state, custom_deserialization_block)
|
84
94
|
end
|
85
95
|
|
96
|
+
if final_state_via == FinalStateVia::LOCATION
|
97
|
+
if((http_method === :post || http_method === :delete) && !polling_state.location_header_link.nil?)
|
98
|
+
update_state_from_location_header(polling_state.get_request(headers: request.headers, base_uri: request.base_uri, user_agent_extended: user_agent_extended), polling_state, custom_deserialization_block, final_state_via)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
86
102
|
# Process long-running POST/DELETE operation with schema defined on success status codes
|
87
103
|
if (http_method === :post || http_method === :delete) && custom_deserialization_block && polling_state.response
|
88
104
|
unless polling_state.response.body.to_s.empty?
|
@@ -152,8 +168,9 @@ module MsRestAzure
|
|
152
168
|
# @param request [MsRest::HttpOperationRequest] The url retrieve data from.
|
153
169
|
# @param polling_state [MsRestAzure::PollingState] polling state to update.
|
154
170
|
# @param custom_deserialization_block [Proc] custom deserialization method for parsing response.
|
171
|
+
# @param final_state_via [MsRestAzure::FinalStateVia] Final State via value
|
155
172
|
#
|
156
|
-
def update_state_from_location_header(request, polling_state, custom_deserialization_block)
|
173
|
+
def update_state_from_location_header(request, polling_state, custom_deserialization_block, final_state_via = FinalStateVia::DEFAULT)
|
157
174
|
result = get_async_with_custom_deserialization(request, custom_deserialization_block)
|
158
175
|
|
159
176
|
polling_state.update_response(result.response)
|
@@ -173,6 +190,8 @@ module MsRestAzure
|
|
173
190
|
|
174
191
|
polling_state.error_data = error_data
|
175
192
|
polling_state.resource = result.body
|
193
|
+
elsif final_state_via == FinalStateVia::LOCATION && status_code === 404 && http_method === :delete && !polling_state.azure_async_operation_header_link.nil? && !polling_state.location_header_link.nil?
|
194
|
+
polling_state.status = AsyncOperationStatus::SUCCESS_STATUS
|
176
195
|
else
|
177
196
|
fail AzureOperationError, "The response from long running operation does not have a valid status code. Method: #{http_method}, Status Code: #{status_code}"
|
178
197
|
end
|
@@ -106,13 +106,15 @@ module MsRestAzure
|
|
106
106
|
retry_value = 1
|
107
107
|
max_retry = 20
|
108
108
|
response = nil
|
109
|
+
user_defined_time_limit = ENV['USER_DEFINED_IMDS_MAX_RETRY_TIME'].nil? ? 104900:ENV['USER_DEFINED_IMDS_MAX_RETRY_TIME']
|
110
|
+
total_wait = 0
|
109
111
|
|
110
112
|
slots = []
|
111
113
|
(0..max_retry-1).each do |i|
|
112
114
|
slots << (100 * ((2 << i) - 1) /1000.to_f)
|
113
115
|
end
|
114
116
|
|
115
|
-
while retry_value <= max_retry
|
117
|
+
while retry_value <= max_retry && total_wait < user_defined_time_limit
|
116
118
|
response = connection.get do |request|
|
117
119
|
request.headers['Metadata'] = 'true'
|
118
120
|
request.headers['User-Agent'] = "Azure-SDK-For-Ruby/ms_rest_azure/#{MsRestAzure::VERSION}"
|
@@ -127,7 +129,9 @@ module MsRestAzure
|
|
127
129
|
if (retry_value > max_retry)
|
128
130
|
break
|
129
131
|
end
|
132
|
+
wait = wait > user_defined_time_limit ? user_defined_time_limit : wait
|
130
133
|
sleep(wait)
|
134
|
+
total_wait += wait
|
131
135
|
elsif response.status != 200
|
132
136
|
fail AzureOperationError, "Couldn't acquire access token from Managed Service Identity, please verify your tenant id, port and settings"
|
133
137
|
else
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Class which represents a final state via of Azure long running operation.
|
8
|
+
#
|
9
|
+
class FinalStateVia
|
10
|
+
NONE = -1
|
11
|
+
DEFAULT = 0
|
12
|
+
AZURE_ASYNC_OPERATION = 0
|
13
|
+
LOCATION = 1
|
14
|
+
ORIGINAL_URI = 2
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms_rest_azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/ms_rest_azure/credentials/cognitive_services_credentials.rb
|
132
132
|
- lib/ms_rest_azure/credentials/msi_token_provider.rb
|
133
133
|
- lib/ms_rest_azure/credentials/topic_credentials.rb
|
134
|
+
- lib/ms_rest_azure/final_state_via.rb
|
134
135
|
- lib/ms_rest_azure/polling_state.rb
|
135
136
|
- lib/ms_rest_azure/serialization.rb
|
136
137
|
- lib/ms_rest_azure/version.rb
|
@@ -142,7 +143,7 @@ metadata:
|
|
142
143
|
changelog_uri: https://github.com/Azure/azure-sdk-for-ruby/blob/master/runtime/ms_rest_azure/CHANGELOG.md
|
143
144
|
documentation_uri: https://azure.microsoft.com/en-us/develop/ruby/
|
144
145
|
homepage_uri: https://aka.ms/azure-sdk-for-ruby
|
145
|
-
source_code_uri: https://github.com/Azure/azure-sdk-for-ruby/tree/ms_rest_azure-v0.
|
146
|
+
source_code_uri: https://github.com/Azure/azure-sdk-for-ruby/tree/ms_rest_azure-v0.11.0
|
146
147
|
post_install_message:
|
147
148
|
rdoc_options: []
|
148
149
|
require_paths:
|