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
@@ -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,73 +24,77 @@ module Azure::ARM::Resources
24
24
 
25
25
  #
26
26
  # Delete a subscription resource tag value.
27
+ #
27
28
  # @param tag_name [String] The name of the tag.
28
29
  # @param tag_value [String] The value of the tag.
29
- # @param [Hash{String => String}] The hash of custom headers need to be
30
- # applied to HTTP request.
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
31
32
  #
32
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
33
- # response.
34
33
  #
35
34
  def delete_value(tag_name, tag_value, custom_headers = nil)
35
+ response = delete_value_async(tag_name, tag_value, custom_headers).value!
36
+ nil
37
+ end
38
+
39
+ #
40
+ # Delete a subscription resource tag value.
41
+ #
42
+ # @param tag_name [String] The name of the tag.
43
+ # @param tag_value [String] The value of the tag.
44
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
45
+ # will be added to the HTTP request.
46
+ #
47
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
48
+ #
49
+ def delete_value_with_http_info(tag_name, tag_value, custom_headers = nil)
50
+ delete_value_async(tag_name, tag_value, custom_headers).value!
51
+ end
52
+
53
+ #
54
+ # Delete a subscription resource tag value.
55
+ #
56
+ # @param tag_name [String] The name of the tag.
57
+ # @param tag_value [String] The value of the tag.
58
+ # @param [Hash{String => String}] A hash of custom headers that will be added
59
+ # to the HTTP request.
60
+ #
61
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
62
+ #
63
+ def delete_value_async(tag_name, tag_value, custom_headers = nil)
36
64
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
37
65
  fail ArgumentError, 'tag_value is nil' if tag_value.nil?
38
66
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
39
67
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
40
- # Construct URL
41
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"
42
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
43
- path['{tagValue}'] = ERB::Util.url_encode(tag_value) if path.include?('{tagValue}')
44
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
45
- url = URI.join(@client.base_url, path)
46
- properties = {}
47
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
48
- unless url.query.nil?
49
- url.query.split('&').each do |url_item|
50
- url_items_parts = url_item.split('=')
51
- properties[url_items_parts[0]] = url_items_parts[1]
52
- end
53
- end
54
- properties.reject!{ |key, value| value.nil? }
55
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
56
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
57
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
58
- url = URI.parse(corrected_url)
59
-
60
- connection = Faraday.new(:url => url) do |faraday|
61
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
62
- faraday.use :cookie_jar
63
- faraday.adapter Faraday.default_adapter
64
- end
65
- request_headers = Hash.new
68
+ request_headers = {}
66
69
 
67
70
  # Set Headers
68
71
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
69
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
70
-
71
- unless custom_headers.nil?
72
- custom_headers.each do |key, value|
73
- request_headers[key] = value
74
- end
75
- end
76
-
77
- # Send Request
78
- promise = Concurrent::Promise.new do
79
- connection.delete do |request|
80
- request.headers = request_headers
81
- @client.credentials.sign_request(request) unless @client.credentials.nil?
82
- end
72
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
73
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'
74
+ options = {
75
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
76
+ path_params: {'tagName' => tag_name,'tagValue' => tag_value,'subscriptionId' => @client.subscription_id},
77
+ query_params: {'api-version' => @client.api_version},
78
+ headers: request_headers.merge(custom_headers || {})
79
+ }
80
+
81
+ request_url = @base_url || @client.base_url
82
+
83
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
84
+ promise = request.run_promise do |req|
85
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
83
86
  end
84
87
 
85
88
  promise = promise.then do |http_response|
86
89
  status_code = http_response.status
87
90
  response_content = http_response.body
88
- unless (status_code == 200 || status_code == 204)
89
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
91
+ unless status_code == 200 || status_code == 204
92
+ error_model = JSON.load(response_content)
93
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
90
94
  end
91
95
 
92
96
  # Create Result
93
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
97
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
94
98
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
95
99
 
96
100
  result
@@ -101,97 +105,101 @@ module Azure::ARM::Resources
101
105
 
102
106
  #
103
107
  # Create a subscription resource tag value.
108
+ #
104
109
  # @param tag_name [String] The name of the tag.
105
110
  # @param tag_value [String] The value of the tag.
106
- # @param [Hash{String => String}] The hash of custom headers need to be
107
- # applied to HTTP request.
111
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
112
+ # will be added to the HTTP request.
108
113
  #
109
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
110
- # response.
114
+ # @return [TagValue] operation results.
111
115
  #
112
116
  def create_or_update_value(tag_name, tag_value, custom_headers = nil)
117
+ response = create_or_update_value_async(tag_name, tag_value, custom_headers).value!
118
+ response.body unless response.nil?
119
+ end
120
+
121
+ #
122
+ # Create a subscription resource tag value.
123
+ #
124
+ # @param tag_name [String] The name of the tag.
125
+ # @param tag_value [String] The value of the tag.
126
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
127
+ # will be added to the HTTP request.
128
+ #
129
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
130
+ #
131
+ def create_or_update_value_with_http_info(tag_name, tag_value, custom_headers = nil)
132
+ create_or_update_value_async(tag_name, tag_value, custom_headers).value!
133
+ end
134
+
135
+ #
136
+ # Create a subscription resource tag value.
137
+ #
138
+ # @param tag_name [String] The name of the tag.
139
+ # @param tag_value [String] The value of the tag.
140
+ # @param [Hash{String => String}] A hash of custom headers that will be added
141
+ # to the HTTP request.
142
+ #
143
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
144
+ #
145
+ def create_or_update_value_async(tag_name, tag_value, custom_headers = nil)
113
146
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
114
147
  fail ArgumentError, 'tag_value is nil' if tag_value.nil?
115
148
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
116
149
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
117
- # Construct URL
118
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"
119
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
120
- path['{tagValue}'] = ERB::Util.url_encode(tag_value) if path.include?('{tagValue}')
121
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
122
- url = URI.join(@client.base_url, path)
123
- properties = {}
124
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
125
- unless url.query.nil?
126
- url.query.split('&').each do |url_item|
127
- url_items_parts = url_item.split('=')
128
- properties[url_items_parts[0]] = url_items_parts[1]
129
- end
130
- end
131
- properties.reject!{ |key, value| value.nil? }
132
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
133
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
134
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
135
- url = URI.parse(corrected_url)
136
-
137
- connection = Faraday.new(:url => url) do |faraday|
138
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
139
- faraday.use :cookie_jar
140
- faraday.adapter Faraday.default_adapter
141
- end
142
- request_headers = Hash.new
150
+ request_headers = {}
143
151
 
144
152
  # Set Headers
145
153
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
146
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
147
-
148
- unless custom_headers.nil?
149
- custom_headers.each do |key, value|
150
- request_headers[key] = value
151
- end
152
- end
153
-
154
- # Send Request
155
- promise = Concurrent::Promise.new do
156
- connection.put do |request|
157
- request.headers = request_headers
158
- @client.credentials.sign_request(request) unless @client.credentials.nil?
159
- end
154
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
155
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'
156
+ options = {
157
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
158
+ path_params: {'tagName' => tag_name,'tagValue' => tag_value,'subscriptionId' => @client.subscription_id},
159
+ query_params: {'api-version' => @client.api_version},
160
+ headers: request_headers.merge(custom_headers || {})
161
+ }
162
+
163
+ request_url = @base_url || @client.base_url
164
+
165
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
166
+ promise = request.run_promise do |req|
167
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
160
168
  end
161
169
 
162
170
  promise = promise.then do |http_response|
163
171
  status_code = http_response.status
164
172
  response_content = http_response.body
165
- unless (status_code == 200 || status_code == 201)
173
+ unless status_code == 200 || status_code == 201
166
174
  error_model = JSON.load(response_content)
167
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
175
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
168
176
  end
169
177
 
170
178
  # Create Result
171
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
179
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
172
180
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
173
181
  # Deserialize Response
174
182
  if status_code == 200
175
183
  begin
176
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
184
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
177
185
  unless parsed_response.nil?
178
186
  parsed_response = TagValue.deserialize_object(parsed_response)
179
187
  end
180
188
  result.body = parsed_response
181
189
  rescue Exception => e
182
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
190
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
183
191
  end
184
192
  end
185
193
  # Deserialize Response
186
194
  if status_code == 201
187
195
  begin
188
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
196
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
189
197
  unless parsed_response.nil?
190
198
  parsed_response = TagValue.deserialize_object(parsed_response)
191
199
  end
192
200
  result.body = parsed_response
193
201
  rescue Exception => e
194
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
202
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
195
203
  end
196
204
  end
197
205
 
@@ -203,94 +211,97 @@ module Azure::ARM::Resources
203
211
 
204
212
  #
205
213
  # Create a subscription resource tag.
214
+ #
206
215
  # @param tag_name [String] The name of the tag.
207
- # @param [Hash{String => String}] The hash of custom headers need to be
208
- # applied to HTTP request.
216
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
217
+ # will be added to the HTTP request.
209
218
  #
210
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
211
- # response.
219
+ # @return [TagDetails] operation results.
212
220
  #
213
221
  def create_or_update(tag_name, custom_headers = nil)
222
+ response = create_or_update_async(tag_name, custom_headers).value!
223
+ response.body unless response.nil?
224
+ end
225
+
226
+ #
227
+ # Create a subscription resource tag.
228
+ #
229
+ # @param tag_name [String] The name of the tag.
230
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
231
+ # will be added to the HTTP request.
232
+ #
233
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
234
+ #
235
+ def create_or_update_with_http_info(tag_name, custom_headers = nil)
236
+ create_or_update_async(tag_name, custom_headers).value!
237
+ end
238
+
239
+ #
240
+ # Create a subscription resource tag.
241
+ #
242
+ # @param tag_name [String] The name of the tag.
243
+ # @param [Hash{String => String}] A hash of custom headers that will be added
244
+ # to the HTTP request.
245
+ #
246
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
247
+ #
248
+ def create_or_update_async(tag_name, custom_headers = nil)
214
249
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
215
250
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
216
251
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
217
- # Construct URL
218
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}"
219
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
220
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
221
- url = URI.join(@client.base_url, path)
222
- properties = {}
223
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
224
- unless url.query.nil?
225
- url.query.split('&').each do |url_item|
226
- url_items_parts = url_item.split('=')
227
- properties[url_items_parts[0]] = url_items_parts[1]
228
- end
229
- end
230
- properties.reject!{ |key, value| value.nil? }
231
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
232
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
233
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
234
- url = URI.parse(corrected_url)
235
-
236
- connection = Faraday.new(:url => url) do |faraday|
237
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
238
- faraday.use :cookie_jar
239
- faraday.adapter Faraday.default_adapter
240
- end
241
- request_headers = Hash.new
252
+ request_headers = {}
242
253
 
243
254
  # Set Headers
244
255
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
245
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
246
-
247
- unless custom_headers.nil?
248
- custom_headers.each do |key, value|
249
- request_headers[key] = value
250
- end
251
- end
252
-
253
- # Send Request
254
- promise = Concurrent::Promise.new do
255
- connection.put do |request|
256
- request.headers = request_headers
257
- @client.credentials.sign_request(request) unless @client.credentials.nil?
258
- end
256
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
257
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}'
258
+ options = {
259
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
260
+ path_params: {'tagName' => tag_name,'subscriptionId' => @client.subscription_id},
261
+ query_params: {'api-version' => @client.api_version},
262
+ headers: request_headers.merge(custom_headers || {})
263
+ }
264
+
265
+ request_url = @base_url || @client.base_url
266
+
267
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
268
+ promise = request.run_promise do |req|
269
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
259
270
  end
260
271
 
261
272
  promise = promise.then do |http_response|
262
273
  status_code = http_response.status
263
274
  response_content = http_response.body
264
- unless (status_code == 200 || status_code == 201)
275
+ unless status_code == 200 || status_code == 201
265
276
  error_model = JSON.load(response_content)
266
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
277
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
267
278
  end
268
279
 
269
280
  # Create Result
270
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
281
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
271
282
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
272
283
  # Deserialize Response
273
284
  if status_code == 200
274
285
  begin
275
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
286
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
276
287
  unless parsed_response.nil?
277
288
  parsed_response = TagDetails.deserialize_object(parsed_response)
278
289
  end
279
290
  result.body = parsed_response
280
291
  rescue Exception => e
281
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
292
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
282
293
  end
283
294
  end
284
295
  # Deserialize Response
285
296
  if status_code == 201
286
297
  begin
287
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
298
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
288
299
  unless parsed_response.nil?
289
300
  parsed_response = TagDetails.deserialize_object(parsed_response)
290
301
  end
291
302
  result.body = parsed_response
292
303
  rescue Exception => e
293
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
304
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
294
305
  end
295
306
  end
296
307
 
@@ -302,70 +313,73 @@ module Azure::ARM::Resources
302
313
 
303
314
  #
304
315
  # Delete a subscription resource tag.
316
+ #
305
317
  # @param tag_name [String] The name of the tag.
306
- # @param [Hash{String => String}] The hash of custom headers need to be
307
- # applied to HTTP request.
318
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
319
+ # will be added to the HTTP request.
308
320
  #
309
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
310
- # response.
311
321
  #
312
322
  def delete(tag_name, custom_headers = nil)
323
+ response = delete_async(tag_name, custom_headers).value!
324
+ nil
325
+ end
326
+
327
+ #
328
+ # Delete a subscription resource tag.
329
+ #
330
+ # @param tag_name [String] The name of the tag.
331
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
332
+ # will be added to the HTTP request.
333
+ #
334
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
335
+ #
336
+ def delete_with_http_info(tag_name, custom_headers = nil)
337
+ delete_async(tag_name, custom_headers).value!
338
+ end
339
+
340
+ #
341
+ # Delete a subscription resource tag.
342
+ #
343
+ # @param tag_name [String] The name of the tag.
344
+ # @param [Hash{String => String}] A hash of custom headers that will be added
345
+ # to the HTTP request.
346
+ #
347
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
348
+ #
349
+ def delete_async(tag_name, custom_headers = nil)
313
350
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
314
351
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
315
352
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
316
- # Construct URL
317
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}"
318
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
319
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
320
- url = URI.join(@client.base_url, path)
321
- properties = {}
322
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
323
- unless url.query.nil?
324
- url.query.split('&').each do |url_item|
325
- url_items_parts = url_item.split('=')
326
- properties[url_items_parts[0]] = url_items_parts[1]
327
- end
328
- end
329
- properties.reject!{ |key, value| value.nil? }
330
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
331
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
332
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
333
- url = URI.parse(corrected_url)
334
-
335
- connection = Faraday.new(:url => url) do |faraday|
336
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
337
- faraday.use :cookie_jar
338
- faraday.adapter Faraday.default_adapter
339
- end
340
- request_headers = Hash.new
353
+ request_headers = {}
341
354
 
342
355
  # Set Headers
343
356
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
344
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
345
-
346
- unless custom_headers.nil?
347
- custom_headers.each do |key, value|
348
- request_headers[key] = value
349
- end
350
- end
351
-
352
- # Send Request
353
- promise = Concurrent::Promise.new do
354
- connection.delete do |request|
355
- request.headers = request_headers
356
- @client.credentials.sign_request(request) unless @client.credentials.nil?
357
- end
357
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
358
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}'
359
+ options = {
360
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
361
+ path_params: {'tagName' => tag_name,'subscriptionId' => @client.subscription_id},
362
+ query_params: {'api-version' => @client.api_version},
363
+ headers: request_headers.merge(custom_headers || {})
364
+ }
365
+
366
+ request_url = @base_url || @client.base_url
367
+
368
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
369
+ promise = request.run_promise do |req|
370
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
358
371
  end
359
372
 
360
373
  promise = promise.then do |http_response|
361
374
  status_code = http_response.status
362
375
  response_content = http_response.body
363
- unless (status_code == 200 || status_code == 204)
364
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
376
+ unless status_code == 200 || status_code == 204
377
+ error_model = JSON.load(response_content)
378
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
365
379
  end
366
380
 
367
381
  # Create Result
368
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
382
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
369
383
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
370
384
 
371
385
  result
@@ -376,79 +390,81 @@ module Azure::ARM::Resources
376
390
 
377
391
  #
378
392
  # Get a list of subscription resource tags.
379
- # @param [Hash{String => String}] The hash of custom headers need to be
380
- # applied to HTTP request.
381
393
  #
382
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
383
- # response.
394
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
395
+ # will be added to the HTTP request.
396
+ #
397
+ # @return [TagsListResult] operation results.
384
398
  #
385
399
  def list(custom_headers = nil)
400
+ response = list_async(custom_headers).value!
401
+ response.body unless response.nil?
402
+ end
403
+
404
+ #
405
+ # Get a list of subscription resource tags.
406
+ #
407
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
408
+ # will be added to the HTTP request.
409
+ #
410
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
411
+ #
412
+ def list_with_http_info(custom_headers = nil)
413
+ list_async(custom_headers).value!
414
+ end
415
+
416
+ #
417
+ # Get a list of subscription resource tags.
418
+ #
419
+ # @param [Hash{String => String}] A hash of custom headers that will be added
420
+ # to the HTTP request.
421
+ #
422
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
423
+ #
424
+ def list_async(custom_headers = nil)
386
425
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
387
426
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
388
- # Construct URL
389
- path = "/subscriptions/{subscriptionId}/tagNames"
390
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
391
- url = URI.join(@client.base_url, path)
392
- properties = {}
393
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
394
- unless url.query.nil?
395
- url.query.split('&').each do |url_item|
396
- url_items_parts = url_item.split('=')
397
- properties[url_items_parts[0]] = url_items_parts[1]
398
- end
399
- end
400
- properties.reject!{ |key, value| value.nil? }
401
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
402
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
403
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
404
- url = URI.parse(corrected_url)
405
-
406
- connection = Faraday.new(:url => url) do |faraday|
407
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
408
- faraday.use :cookie_jar
409
- faraday.adapter Faraday.default_adapter
410
- end
411
- request_headers = Hash.new
427
+ request_headers = {}
412
428
 
413
429
  # Set Headers
414
430
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
415
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
416
-
417
- unless custom_headers.nil?
418
- custom_headers.each do |key, value|
419
- request_headers[key] = value
420
- end
421
- end
422
-
423
- # Send Request
424
- promise = Concurrent::Promise.new do
425
- connection.get do |request|
426
- request.headers = request_headers
427
- @client.credentials.sign_request(request) unless @client.credentials.nil?
428
- end
431
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
432
+ path_template = '/subscriptions/{subscriptionId}/tagNames'
433
+ options = {
434
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
435
+ path_params: {'subscriptionId' => @client.subscription_id},
436
+ query_params: {'api-version' => @client.api_version},
437
+ headers: request_headers.merge(custom_headers || {})
438
+ }
439
+
440
+ request_url = @base_url || @client.base_url
441
+
442
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
443
+ promise = request.run_promise do |req|
444
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
429
445
  end
430
446
 
431
447
  promise = promise.then do |http_response|
432
448
  status_code = http_response.status
433
449
  response_content = http_response.body
434
- unless (status_code == 200)
450
+ unless status_code == 200
435
451
  error_model = JSON.load(response_content)
436
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
452
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
437
453
  end
438
454
 
439
455
  # Create Result
440
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
456
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
441
457
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
442
458
  # Deserialize Response
443
459
  if status_code == 200
444
460
  begin
445
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
461
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
446
462
  unless parsed_response.nil?
447
463
  parsed_response = TagsListResult.deserialize_object(parsed_response)
448
464
  end
449
465
  result.body = parsed_response
450
466
  rescue Exception => e
451
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
467
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
452
468
  end
453
469
  end
454
470
 
@@ -460,79 +476,85 @@ module Azure::ARM::Resources
460
476
 
461
477
  #
462
478
  # Get a list of subscription resource tags.
479
+ #
463
480
  # @param next_page_link [String] The NextLink from the previous successful
464
481
  # call to List operation.
465
- # @param [Hash{String => String}] The hash of custom headers need to be
466
- # applied to HTTP request.
482
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
483
+ # will be added to the HTTP request.
467
484
  #
468
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
469
- # response.
485
+ # @return [TagsListResult] operation results.
470
486
  #
471
487
  def list_next(next_page_link, custom_headers = nil)
488
+ response = list_next_async(next_page_link, custom_headers).value!
489
+ response.body unless response.nil?
490
+ end
491
+
492
+ #
493
+ # Get a list of subscription resource tags.
494
+ #
495
+ # @param next_page_link [String] The NextLink from the previous successful
496
+ # call to List operation.
497
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
498
+ # will be added to the HTTP request.
499
+ #
500
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
501
+ #
502
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
503
+ list_next_async(next_page_link, custom_headers).value!
504
+ end
505
+
506
+ #
507
+ # Get a list of subscription resource tags.
508
+ #
509
+ # @param next_page_link [String] The NextLink from the previous successful
510
+ # call to List operation.
511
+ # @param [Hash{String => String}] A hash of custom headers that will be added
512
+ # to the HTTP request.
513
+ #
514
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
515
+ #
516
+ def list_next_async(next_page_link, custom_headers = nil)
472
517
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
473
- # Construct URL
474
- path = "{nextLink}"
475
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
476
- url = URI.parse(path)
477
- properties = {}
478
- unless url.query.nil?
479
- url.query.split('&').each do |url_item|
480
- url_items_parts = url_item.split('=')
481
- properties[url_items_parts[0]] = url_items_parts[1]
482
- end
483
- end
484
- properties.reject!{ |key, value| value.nil? }
485
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
486
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
487
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
488
- url = URI.parse(corrected_url)
489
-
490
- connection = Faraday.new(:url => url) do |faraday|
491
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
492
- faraday.use :cookie_jar
493
- faraday.adapter Faraday.default_adapter
494
- end
495
- request_headers = Hash.new
518
+ request_headers = {}
496
519
 
497
520
  # Set Headers
498
521
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
499
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
500
-
501
- unless custom_headers.nil?
502
- custom_headers.each do |key, value|
503
- request_headers[key] = value
504
- end
505
- end
506
-
507
- # Send Request
508
- promise = Concurrent::Promise.new do
509
- connection.get do |request|
510
- request.headers = request_headers
511
- @client.credentials.sign_request(request) unless @client.credentials.nil?
512
- end
522
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
523
+ path_template = '{nextLink}'
524
+ options = {
525
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
526
+ skip_encoding_path_params: {'nextLink' => next_page_link},
527
+ headers: request_headers.merge(custom_headers || {})
528
+ }
529
+
530
+ request_url = @base_url || @client.base_url
531
+
532
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
533
+ promise = request.run_promise do |req|
534
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
513
535
  end
514
536
 
515
537
  promise = promise.then do |http_response|
516
538
  status_code = http_response.status
517
539
  response_content = http_response.body
518
- unless (status_code == 200)
540
+ unless status_code == 200
519
541
  error_model = JSON.load(response_content)
520
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
542
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
521
543
  end
522
544
 
523
545
  # Create Result
524
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
546
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
525
547
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
526
548
  # Deserialize Response
527
549
  if status_code == 200
528
550
  begin
529
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
551
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
530
552
  unless parsed_response.nil?
531
553
  parsed_response = TagsListResult.deserialize_object(parsed_response)
532
554
  end
533
555
  result.body = parsed_response
534
556
  rescue Exception => e
535
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
557
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
536
558
  end
537
559
  end
538
560