azure_mgmt_resources 0.1.0 → 0.3.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.
Files changed (62) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +1 -27
  3. data/azure_mgmt_resources.gemspec +2 -6
  4. data/lib/azure_mgmt_resources/deployment_operations.rb +161 -141
  5. data/lib/azure_mgmt_resources/deployments.rb +684 -310
  6. data/lib/azure_mgmt_resources/{Models → models}/basic_dependency.rb +1 -3
  7. data/lib/azure_mgmt_resources/models/debug_setting.rb +56 -0
  8. data/lib/azure_mgmt_resources/{Models → models}/dependency.rb +4 -6
  9. data/lib/azure_mgmt_resources/{Models → models}/deployment.rb +1 -3
  10. data/lib/azure_mgmt_resources/models/deployment_export_result.rb +56 -0
  11. data/lib/azure_mgmt_resources/{Models → models}/deployment_extended.rb +8 -9
  12. data/lib/azure_mgmt_resources/{Models → models}/deployment_extended_filter.rb +1 -3
  13. data/lib/azure_mgmt_resources/{Models → models}/deployment_list_result.rb +4 -6
  14. data/lib/azure_mgmt_resources/{Models → models}/deployment_mode.rb +2 -1
  15. data/lib/azure_mgmt_resources/{Models → models}/deployment_operation.rb +1 -3
  16. data/lib/azure_mgmt_resources/{Models → models}/deployment_operation_properties.rb +41 -2
  17. data/lib/azure_mgmt_resources/{Models → models}/deployment_operations_list_result.rb +4 -6
  18. data/lib/azure_mgmt_resources/{Models → models}/deployment_properties.rb +19 -4
  19. data/lib/azure_mgmt_resources/{Models → models}/deployment_properties_extended.rb +25 -10
  20. data/lib/azure_mgmt_resources/{Models → models}/deployment_validate_result.rb +1 -3
  21. data/lib/azure_mgmt_resources/models/export_template_request.rb +69 -0
  22. data/lib/azure_mgmt_resources/{Models → models}/generic_resource.rb +1 -3
  23. data/lib/azure_mgmt_resources/{Models → models}/generic_resource_filter.rb +1 -3
  24. data/lib/azure_mgmt_resources/models/http_message.rb +56 -0
  25. data/lib/azure_mgmt_resources/{Models → models}/parameters_link.rb +2 -4
  26. data/lib/azure_mgmt_resources/{Models → models}/plan.rb +1 -3
  27. data/lib/azure_mgmt_resources/{Models → models}/provider.rb +4 -6
  28. data/lib/azure_mgmt_resources/{Models → models}/provider_list_result.rb +4 -6
  29. data/lib/azure_mgmt_resources/{Models → models}/provider_resource_type.rb +1 -3
  30. data/lib/azure_mgmt_resources/{Models → models}/resource_group.rb +8 -9
  31. data/lib/azure_mgmt_resources/models/resource_group_export_result.rb +71 -0
  32. data/lib/azure_mgmt_resources/{Models → models}/resource_group_filter.rb +1 -3
  33. data/lib/azure_mgmt_resources/{Models → models}/resource_group_list_result.rb +11 -12
  34. data/lib/azure_mgmt_resources/{Models → models}/resource_group_properties.rb +1 -3
  35. data/lib/azure_mgmt_resources/{Models → models}/resource_list_result.rb +11 -12
  36. data/lib/azure_mgmt_resources/{Models → models}/resource_management_error_with_details.rb +29 -28
  37. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_definition.rb +1 -3
  38. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_detail_list_result.rb +4 -6
  39. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_display_properties.rb +1 -3
  40. data/lib/azure_mgmt_resources/{Models → models}/resources_move_info.rb +1 -3
  41. data/lib/azure_mgmt_resources/{Models → models}/tag_count.rb +1 -3
  42. data/lib/azure_mgmt_resources/{Models → models}/tag_details.rb +4 -6
  43. data/lib/azure_mgmt_resources/{Models → models}/tag_value.rb +1 -3
  44. data/lib/azure_mgmt_resources/{Models → models}/tags_list_result.rb +11 -12
  45. data/lib/azure_mgmt_resources/{Models → models}/target_resource.rb +1 -3
  46. data/lib/azure_mgmt_resources/{Models → models}/template_link.rb +2 -4
  47. data/lib/azure_mgmt_resources/module_definition.rb +5 -3
  48. data/lib/azure_mgmt_resources/providers.rb +265 -239
  49. data/lib/azure_mgmt_resources/resource_groups.rb +604 -465
  50. data/lib/azure_mgmt_resources/resource_management_client.rb +18 -11
  51. data/lib/azure_mgmt_resources/resource_provider_operation_details.rb +154 -47
  52. data/lib/azure_mgmt_resources/resources.rb +425 -380
  53. data/lib/azure_mgmt_resources/tags.rb +310 -288
  54. data/lib/azure_mgmt_resources/version.rb +5 -3
  55. data/lib/azure_mgmt_resources.rb +20 -19
  56. metadata +68 -126
  57. data/.travis.yml +0 -3
  58. data/Gemfile +0 -14
  59. data/lib/azure_mgmt_resources/Models/resource_group_extended.rb +0 -113
  60. data/lib/azure_mgmt_resources/Models/resource_group_extended_filter.rb +0 -63
  61. data/lib/azure_mgmt_resources/Models/resource_group_format_resource_properties.rb +0 -54
  62. data/lib/azure_mgmt_resources/Models/resource_management_error.rb +0 -77
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bdc702845014bce0e6d43808d03d714853126812
4
- data.tar.gz: 31e78f0b2a51ca61074f305092accea37a80b720
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTllYmEzYmI3ODVhM2IyYzVlZDUyYTdiZDEwYjI2NDg3ZTJlNTkwNg==
5
+ data.tar.gz: !binary |-
6
+ MmY5ZTg4MTVmZGU4NzM5OTQwNDg4MGNmMDA1ZGQ3YjlkZGQ2OGMzZQ==
5
7
  SHA512:
6
- metadata.gz: cceaadb4a910c71ef0cd7c2591bbf4f600a4978e1e4bdafd2e8720fd18cbb9aea6593108f0c23915557369996955434d6ea5c6346e36b24c32892ee26060d563
7
- data.tar.gz: 0b31ff3cd4f1d79e4966a66b02f0f93efa6e62cec0e7158eb2711247ae748639df992fb3a752361c4af3a5aa654c357eb4388a317265c45daff2cf1d8cafacbc
8
+ metadata.gz: !binary |-
9
+ ODBkNTU4ZGRmZWIzMDc3MmVjOWQ2YzliZGE3ZWY3YjU4ZWViMWFlYjY2Y2E2
10
+ OWRkZmIwZjJjNTBjOWRlNWQ1ZjU4M2VjYThkYzFhOGMzZTllZTIzYzE1NDQw
11
+ NTY3NzhlYjM5MDAwMjZhNjRjYTk2N2FkMWUwOTNjMDllNGE4ZjE=
12
+ data.tar.gz: !binary |-
13
+ YzI4ZThhMGQ5MDJkY2FmNzNiZTBmOTFhOGU0MTVlYWRmOGMzODM2ODNlY2Vk
14
+ MzhhZjg5N2JjMjI5NjRmYTM1YTk4NzQzZWJmNjg4YWEzMDlmZDdiNmZmNjVi
15
+ NDFmODEyOTcyMDEyYzViODdkYTdhMDdiOGExYjUxMDUyOWZkYzY=
data/README.md CHANGED
@@ -51,7 +51,7 @@ client.subscription_id = subscription_id
51
51
  resource_group = Azure::ARM::Resources::Models::ResourceGroup.new()
52
52
  resource_group.location = 'westus'
53
53
 
54
- promise = client.resource_groups.create_or_update('new_test_resource_group', resource_group)
54
+ promise = client.resource_groups.create_or_update_async('new_test_resource_group', resource_group)
55
55
  ```
56
56
 
57
57
  The SDK method returns a promise which you can utilize depending on your needs. E.g. if you need to get result immediately via sync blocking call - do the following:
@@ -78,29 +78,3 @@ p resource_group.id # the id of resource group
78
78
  ```
79
79
 
80
80
  Congrats, you've create an ARM resource group. We encourage you to try more stuff and let us know your feedback!
81
-
82
- # Running tests
83
-
84
- ## Adding env variables
85
-
86
- To run the tests you would need to set the following environment variables with your real Azure data:
87
-
88
- * azure_tenant_id
89
- * azure_client_id
90
- * azure_client_secret
91
- * subscription_id
92
-
93
- * run_long_tasks - set this to '1' only if you would like to run time consuming tests like VM creation.
94
-
95
- ## Starting tests
96
-
97
- Just run 'rspec' command from the current gem folder.
98
-
99
- # Contribution
100
-
101
- All the SDK code was generated by tool 'AutoRest' - https://github.com/Azure/autorest
102
- So if you have found a bug or have an idea for a new feature - suggest, discuss and contribute it into the AutoRest repository. After that SDK maintainers will update the sources and the gem.
103
-
104
- # Provide feedback
105
-
106
- Send email to the azsdkteam@microsoft.com or file new issue in this repository.
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.name = 'azure_mgmt_resources'
13
13
  spec.version = Azure::ARM::Resources::VERSION
14
14
  spec.authors = 'Microsoft Corporation'
15
- spec.email = 'azsdkteam@microsoft.com'
15
+ spec.email = 'azrubyteam@microsoft.com'
16
16
  spec.description = 'Microsoft Azure Resource Management Client Library for Ruby'
17
17
  spec.summary = 'Official ruby client library to consume Microsoft Azure Resource Management services.'
18
18
  spec.homepage = 'http://github.com/azure/azure-sdk-for-ruby'
@@ -30,9 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'rspec', '~> 3'
31
31
  spec.add_development_dependency 'dotenv', '~> 2'
32
32
 
33
- spec.add_runtime_dependency 'json', '~> 1.8'
34
- spec.add_runtime_dependency 'concurrent-ruby', ['>= 1.0.0.pre1', '<2']
35
- spec.add_runtime_dependency 'faraday', '~> 0.9'
36
- spec.add_runtime_dependency 'faraday-cookie_jar', '~> 0.0.6'
37
- spec.add_runtime_dependency 'ms_rest_azure', '~> 0.1'
33
+ spec.add_runtime_dependency 'ms_rest_azure', '~> 0.2.3'
38
34
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
@@ -24,89 +24,96 @@ module Azure::ARM::Resources
24
24
 
25
25
  #
26
26
  # Get a list of deployments operations.
27
+ #
27
28
  # @param resource_group_name [String] The name of the resource group. The name
28
29
  # is case insensitive.
29
30
  # @param deployment_name [String] The name of the deployment.
30
31
  # @param operation_id [String] Operation Id.
31
- # @param [Hash{String => String}] The hash of custom headers need to be
32
- # applied to HTTP request.
32
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
33
+ # will be added to the HTTP request.
33
34
  #
34
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
35
- # response.
35
+ # @return [DeploymentOperation] operation results.
36
36
  #
37
37
  def get(resource_group_name, deployment_name, operation_id, custom_headers = nil)
38
+ response = get_async(resource_group_name, deployment_name, operation_id, custom_headers).value!
39
+ response.body unless response.nil?
40
+ end
41
+
42
+ #
43
+ # Get a list of deployments operations.
44
+ #
45
+ # @param resource_group_name [String] The name of the resource group. The name
46
+ # is case insensitive.
47
+ # @param deployment_name [String] The name of the deployment.
48
+ # @param operation_id [String] Operation Id.
49
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
50
+ # will be added to the HTTP request.
51
+ #
52
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
53
+ #
54
+ def get_with_http_info(resource_group_name, deployment_name, operation_id, custom_headers = nil)
55
+ get_async(resource_group_name, deployment_name, operation_id, custom_headers).value!
56
+ end
57
+
58
+ #
59
+ # Get a list of deployments operations.
60
+ #
61
+ # @param resource_group_name [String] The name of the resource group. The name
62
+ # is case insensitive.
63
+ # @param deployment_name [String] The name of the deployment.
64
+ # @param operation_id [String] Operation Id.
65
+ # @param [Hash{String => String}] A hash of custom headers that will be added
66
+ # to the HTTP request.
67
+ #
68
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
69
+ #
70
+ def get_async(resource_group_name, deployment_name, operation_id, custom_headers = nil)
38
71
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
39
72
  fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
40
73
  fail ArgumentError, 'operation_id is nil' if operation_id.nil?
41
74
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
42
75
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
43
- # Construct URL
44
- path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"
45
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
46
- path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
47
- path['{operationId}'] = ERB::Util.url_encode(operation_id) if path.include?('{operationId}')
48
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
49
- url = URI.join(@client.base_url, path)
50
- properties = {}
51
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
52
- unless url.query.nil?
53
- url.query.split('&').each do |url_item|
54
- url_items_parts = url_item.split('=')
55
- properties[url_items_parts[0]] = url_items_parts[1]
56
- end
57
- end
58
- properties.reject!{ |key, value| value.nil? }
59
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
60
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
61
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
62
- url = URI.parse(corrected_url)
63
-
64
- connection = Faraday.new(:url => url) do |faraday|
65
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
66
- faraday.use :cookie_jar
67
- faraday.adapter Faraday.default_adapter
68
- end
69
- request_headers = Hash.new
76
+ request_headers = {}
70
77
 
71
78
  # Set Headers
72
79
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
73
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
80
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
81
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'
82
+ options = {
83
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
84
+ path_params: {'resourceGroupName' => resource_group_name,'deploymentName' => deployment_name,'operationId' => operation_id,'subscriptionId' => @client.subscription_id},
85
+ query_params: {'api-version' => @client.api_version},
86
+ headers: request_headers.merge(custom_headers || {})
87
+ }
74
88
 
75
- unless custom_headers.nil?
76
- custom_headers.each do |key, value|
77
- request_headers[key] = value
78
- end
79
- end
89
+ request_url = @base_url || @client.base_url
80
90
 
81
- # Send Request
82
- promise = Concurrent::Promise.new do
83
- connection.get do |request|
84
- request.headers = request_headers
85
- @client.credentials.sign_request(request) unless @client.credentials.nil?
86
- end
91
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
92
+ promise = request.run_promise do |req|
93
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
87
94
  end
88
95
 
89
96
  promise = promise.then do |http_response|
90
97
  status_code = http_response.status
91
98
  response_content = http_response.body
92
- unless (status_code == 200)
99
+ unless status_code == 200
93
100
  error_model = JSON.load(response_content)
94
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
101
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
95
102
  end
96
103
 
97
104
  # Create Result
98
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
105
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
99
106
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
100
107
  # Deserialize Response
101
108
  if status_code == 200
102
109
  begin
103
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
110
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
104
111
  unless parsed_response.nil?
105
112
  parsed_response = DeploymentOperation.deserialize_object(parsed_response)
106
113
  end
107
114
  result.body = parsed_response
108
115
  rescue Exception => e
109
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
116
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
110
117
  end
111
118
  end
112
119
 
@@ -118,88 +125,95 @@ module Azure::ARM::Resources
118
125
 
119
126
  #
120
127
  # Gets a list of deployments operations.
128
+ #
121
129
  # @param resource_group_name [String] The name of the resource group. The name
122
130
  # is case insensitive.
123
131
  # @param deployment_name [String] The name of the deployment.
124
132
  # @param top [Integer] Query parameters.
125
- # @param [Hash{String => String}] The hash of custom headers need to be
126
- # applied to HTTP request.
133
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
134
+ # will be added to the HTTP request.
127
135
  #
128
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
129
- # response.
136
+ # @return [DeploymentOperationsListResult] operation results.
130
137
  #
131
138
  def list(resource_group_name, deployment_name, top = nil, custom_headers = nil)
139
+ response = list_async(resource_group_name, deployment_name, top, custom_headers).value!
140
+ response.body unless response.nil?
141
+ end
142
+
143
+ #
144
+ # Gets a list of deployments operations.
145
+ #
146
+ # @param resource_group_name [String] The name of the resource group. The name
147
+ # is case insensitive.
148
+ # @param deployment_name [String] The name of the deployment.
149
+ # @param top [Integer] Query parameters.
150
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
151
+ # will be added to the HTTP request.
152
+ #
153
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
154
+ #
155
+ def list_with_http_info(resource_group_name, deployment_name, top = nil, custom_headers = nil)
156
+ list_async(resource_group_name, deployment_name, top, custom_headers).value!
157
+ end
158
+
159
+ #
160
+ # Gets a list of deployments operations.
161
+ #
162
+ # @param resource_group_name [String] The name of the resource group. The name
163
+ # is case insensitive.
164
+ # @param deployment_name [String] The name of the deployment.
165
+ # @param top [Integer] Query parameters.
166
+ # @param [Hash{String => String}] A hash of custom headers that will be added
167
+ # to the HTTP request.
168
+ #
169
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
170
+ #
171
+ def list_async(resource_group_name, deployment_name, top = nil, custom_headers = nil)
132
172
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
133
173
  fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
134
174
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
135
175
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
136
- # Construct URL
137
- path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"
138
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
139
- path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
140
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
141
- url = URI.join(@client.base_url, path)
142
- properties = {}
143
- properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
144
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
145
- unless url.query.nil?
146
- url.query.split('&').each do |url_item|
147
- url_items_parts = url_item.split('=')
148
- properties[url_items_parts[0]] = url_items_parts[1]
149
- end
150
- end
151
- properties.reject!{ |key, value| value.nil? }
152
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
153
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
154
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
155
- url = URI.parse(corrected_url)
156
-
157
- connection = Faraday.new(:url => url) do |faraday|
158
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
159
- faraday.use :cookie_jar
160
- faraday.adapter Faraday.default_adapter
161
- end
162
- request_headers = Hash.new
176
+ request_headers = {}
163
177
 
164
178
  # Set Headers
165
179
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
166
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
180
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
181
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'
182
+ options = {
183
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
184
+ path_params: {'resourceGroupName' => resource_group_name,'deploymentName' => deployment_name,'subscriptionId' => @client.subscription_id},
185
+ query_params: {'$top' => top,'api-version' => @client.api_version},
186
+ headers: request_headers.merge(custom_headers || {})
187
+ }
167
188
 
168
- unless custom_headers.nil?
169
- custom_headers.each do |key, value|
170
- request_headers[key] = value
171
- end
172
- end
189
+ request_url = @base_url || @client.base_url
173
190
 
174
- # Send Request
175
- promise = Concurrent::Promise.new do
176
- connection.get do |request|
177
- request.headers = request_headers
178
- @client.credentials.sign_request(request) unless @client.credentials.nil?
179
- end
191
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
192
+ promise = request.run_promise do |req|
193
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
180
194
  end
181
195
 
182
196
  promise = promise.then do |http_response|
183
197
  status_code = http_response.status
184
198
  response_content = http_response.body
185
- unless (status_code == 200)
199
+ unless status_code == 200
186
200
  error_model = JSON.load(response_content)
187
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
201
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
188
202
  end
189
203
 
190
204
  # Create Result
191
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
205
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
192
206
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
193
207
  # Deserialize Response
194
208
  if status_code == 200
195
209
  begin
196
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
210
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
197
211
  unless parsed_response.nil?
198
212
  parsed_response = DeploymentOperationsListResult.deserialize_object(parsed_response)
199
213
  end
200
214
  result.body = parsed_response
201
215
  rescue Exception => e
202
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
216
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
203
217
  end
204
218
  end
205
219
 
@@ -211,79 +225,85 @@ module Azure::ARM::Resources
211
225
 
212
226
  #
213
227
  # Gets a list of deployments operations.
228
+ #
214
229
  # @param next_page_link [String] The NextLink from the previous successful
215
230
  # call to List operation.
216
- # @param [Hash{String => String}] The hash of custom headers need to be
217
- # applied to HTTP request.
231
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
232
+ # will be added to the HTTP request.
218
233
  #
219
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
220
- # response.
234
+ # @return [DeploymentOperationsListResult] operation results.
221
235
  #
222
236
  def list_next(next_page_link, custom_headers = nil)
237
+ response = list_next_async(next_page_link, custom_headers).value!
238
+ response.body unless response.nil?
239
+ end
240
+
241
+ #
242
+ # Gets a list of deployments operations.
243
+ #
244
+ # @param next_page_link [String] The NextLink from the previous successful
245
+ # call to List operation.
246
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
247
+ # will be added to the HTTP request.
248
+ #
249
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
250
+ #
251
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
252
+ list_next_async(next_page_link, custom_headers).value!
253
+ end
254
+
255
+ #
256
+ # Gets a list of deployments operations.
257
+ #
258
+ # @param next_page_link [String] The NextLink from the previous successful
259
+ # call to List operation.
260
+ # @param [Hash{String => String}] A hash of custom headers that will be added
261
+ # to the HTTP request.
262
+ #
263
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
264
+ #
265
+ def list_next_async(next_page_link, custom_headers = nil)
223
266
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
224
- # Construct URL
225
- path = "{nextLink}"
226
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
227
- url = URI.parse(path)
228
- properties = {}
229
- unless url.query.nil?
230
- url.query.split('&').each do |url_item|
231
- url_items_parts = url_item.split('=')
232
- properties[url_items_parts[0]] = url_items_parts[1]
233
- end
234
- end
235
- properties.reject!{ |key, value| value.nil? }
236
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
237
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
238
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
239
- url = URI.parse(corrected_url)
240
-
241
- connection = Faraday.new(:url => url) do |faraday|
242
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
243
- faraday.use :cookie_jar
244
- faraday.adapter Faraday.default_adapter
245
- end
246
- request_headers = Hash.new
267
+ request_headers = {}
247
268
 
248
269
  # Set Headers
249
270
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
250
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
271
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
272
+ path_template = '{nextLink}'
273
+ options = {
274
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
275
+ skip_encoding_path_params: {'nextLink' => next_page_link},
276
+ headers: request_headers.merge(custom_headers || {})
277
+ }
251
278
 
252
- unless custom_headers.nil?
253
- custom_headers.each do |key, value|
254
- request_headers[key] = value
255
- end
256
- end
279
+ request_url = @base_url || @client.base_url
257
280
 
258
- # Send Request
259
- promise = Concurrent::Promise.new do
260
- connection.get do |request|
261
- request.headers = request_headers
262
- @client.credentials.sign_request(request) unless @client.credentials.nil?
263
- end
281
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
282
+ promise = request.run_promise do |req|
283
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
264
284
  end
265
285
 
266
286
  promise = promise.then do |http_response|
267
287
  status_code = http_response.status
268
288
  response_content = http_response.body
269
- unless (status_code == 200)
289
+ unless status_code == 200
270
290
  error_model = JSON.load(response_content)
271
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
291
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
272
292
  end
273
293
 
274
294
  # Create Result
275
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
295
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
276
296
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
277
297
  # Deserialize Response
278
298
  if status_code == 200
279
299
  begin
280
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
300
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
281
301
  unless parsed_response.nil?
282
302
  parsed_response = DeploymentOperationsListResult.deserialize_object(parsed_response)
283
303
  end
284
304
  result.body = parsed_response
285
305
  rescue Exception => e
286
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
306
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
287
307
  end
288
308
  end
289
309