azure 0.7.1 → 0.7.3

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 (216) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +31 -0
  3. data/azure.gemspec +2 -1
  4. data/lib/azure.rb +1 -0
  5. data/lib/azure/base_management/management_http_request.rb +3 -12
  6. data/lib/azure/blob/auth/shared_access_signature.rb +4 -0
  7. data/lib/azure/blob/blob_service.rb +2 -2
  8. data/lib/azure/client_services.rb +13 -13
  9. data/lib/azure/core/http/http_request.rb +3 -14
  10. data/lib/azure/core/service.rb +2 -1
  11. data/lib/azure/http_client.rb +1 -17
  12. data/lib/azure/http_response_helper.rb +38 -0
  13. data/lib/azure/sql_database_management/serialization.rb +4 -0
  14. data/lib/azure/sql_database_management/sql_database_management_service.rb +10 -9
  15. data/lib/azure/version.rb +1 -1
  16. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +2 -2
  17. data/lib/azure/virtual_machine_management/serialization.rb +21 -12
  18. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +8 -3
  19. metadata +17 -199
  20. data/test/fixtures/32px-fulls-black.jpg +0 -0
  21. data/test/fixtures/affinity_group.xml +0 -33
  22. data/test/fixtures/all_containers.xml +0 -20
  23. data/test/fixtures/all_tables.xml +0 -22
  24. data/test/fixtures/container_acl.xml +0 -11
  25. data/test/fixtures/create_sql_database_server.xml +0 -2
  26. data/test/fixtures/create_storage_desc_error.xml +0 -5
  27. data/test/fixtures/create_storage_extendedprop_error.xml +0 -8
  28. data/test/fixtures/create_storage_extendedpropname_error.xml +0 -6
  29. data/test/fixtures/create_storage_full_error.xml +0 -6
  30. data/test/fixtures/create_storage_label_error.xml +0 -5
  31. data/test/fixtures/create_storage_location_error.xml +0 -5
  32. data/test/fixtures/create_storage_name_error.xml +0 -6
  33. data/test/fixtures/create_table_response_entry.xml +0 -15
  34. data/test/fixtures/delete_storage_container_error.xml +0 -5
  35. data/test/fixtures/delete_storage_error.xml +0 -5
  36. data/test/fixtures/deployment_error.xml +0 -5
  37. data/test/fixtures/empty_xml_file +0 -0
  38. data/test/fixtures/get_storage_account_error.xml +0 -5
  39. data/test/fixtures/get_storage_account_properties.xml +0 -34
  40. data/test/fixtures/get_storage_account_properties_new.xml +0 -32
  41. data/test/fixtures/http_error.xml +0 -5
  42. data/test/fixtures/insert_entity_response_entry.xml +0 -25
  43. data/test/fixtures/list_affinity_groups.xml +0 -22
  44. data/test/fixtures/list_blobs.xml +0 -121
  45. data/test/fixtures/list_block_all_with_none_committed.xml +0 -22
  46. data/test/fixtures/list_blocks_all.xml +0 -23
  47. data/test/fixtures/list_blocks_committed.xml +0 -13
  48. data/test/fixtures/list_cloud_services.xml +0 -39
  49. data/test/fixtures/list_containers.xml +0 -38
  50. data/test/fixtures/list_firewall_management_endpoint.xml +0 -27
  51. data/test/fixtures/list_locations.xml +0 -212
  52. data/test/fixtures/list_os_images.xml +0 -110
  53. data/test/fixtures/list_page_ranges.xml +0 -11
  54. data/test/fixtures/list_sql_database.xml +0 -24
  55. data/test/fixtures/list_sql_server_firewall.xml +0 -23
  56. data/test/fixtures/list_storage_account_single.xml +0 -25
  57. data/test/fixtures/list_storage_accounts.xml +0 -48
  58. data/test/fixtures/list_virtual_networks.xml +0 -91
  59. data/test/fixtures/list_vm_images.xml +0 -21
  60. data/test/fixtures/logging.xml +0 -11
  61. data/test/fixtures/management_certificate.pem +0 -55
  62. data/test/fixtures/management_certificate.pfx +0 -0
  63. data/test/fixtures/management_certificate.publishsettings +0 -12
  64. data/test/fixtures/messages.xml +0 -12
  65. data/test/fixtures/metrics.xml +0 -10
  66. data/test/fixtures/privatekey.key +0 -28
  67. data/test/fixtures/query_entities_empty_response.xml +0 -7
  68. data/test/fixtures/query_entities_response.xml +0 -45
  69. data/test/fixtures/queue_service_properties.xml +0 -22
  70. data/test/fixtures/queue_service_properties_original.xml +0 -19
  71. data/test/fixtures/queues.xml +0 -16
  72. data/test/fixtures/retention_policy.xml +0 -5
  73. data/test/fixtures/sb_default_create_queue_response.xml +0 -23
  74. data/test/fixtures/sb_default_create_relay_response.xml +0 -15
  75. data/test/fixtures/sb_default_create_topic_response.xml +0 -18
  76. data/test/fixtures/sb_get_access_token_response.txt +0 -1
  77. data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +0 -9
  78. data/test/fixtures/storage_service_keys.xml +0 -8
  79. data/test/fixtures/storage_service_properties.xml +0 -55
  80. data/test/fixtures/update_storage_account.xml +0 -16
  81. data/test/fixtures/update_storage_error.xml +0 -5
  82. data/test/fixtures/updated_storage_accounts.xml +0 -55
  83. data/test/fixtures/virtual_machine.xml +0 -116
  84. data/test/fixtures/windows_virtual_machine.xml +0 -106
  85. data/test/integration/affinity_group/Affinity_test.rb +0 -55
  86. data/test/integration/affinity_group/Create_Affinity_test.rb +0 -64
  87. data/test/integration/affinity_group/Delete_Affinity_test.rb +0 -56
  88. data/test/integration/affinity_group/List_Affinity_test.rb +0 -41
  89. data/test/integration/affinity_group/Update_Affinity_test.rb +0 -87
  90. data/test/integration/blob/blob_gb18030_test.rb +0 -199
  91. data/test/integration/blob/blob_metadata_test.rb +0 -75
  92. data/test/integration/blob/blob_pages_test.rb +0 -119
  93. data/test/integration/blob/blob_properties_test.rb +0 -77
  94. data/test/integration/blob/block_blob_test.rb +0 -303
  95. data/test/integration/blob/container/container_acl_test.rb +0 -69
  96. data/test/integration/blob/container/container_metadata_test.rb +0 -50
  97. data/test/integration/blob/container/create_container_test.rb +0 -60
  98. data/test/integration/blob/container/delete_container_test.rb +0 -39
  99. data/test/integration/blob/container/get_container_properties_test.rb +0 -48
  100. data/test/integration/blob/container/list_containers_test.rb +0 -79
  101. data/test/integration/blob/container/root_container_test.rb +0 -55
  102. data/test/integration/blob/copy_blob_test.rb +0 -113
  103. data/test/integration/blob/create_blob_snapshot_test.rb +0 -80
  104. data/test/integration/blob/create_page_blob_test.rb +0 -83
  105. data/test/integration/blob/delete_blob_test.rb +0 -159
  106. data/test/integration/blob/get_blob_test.rb +0 -65
  107. data/test/integration/blob/informative_errors_test.rb +0 -39
  108. data/test/integration/blob/lease/acquire_lease_test.rb +0 -36
  109. data/test/integration/blob/lease/break_lease_test.rb +0 -40
  110. data/test/integration/blob/lease/release_lease_test.rb +0 -40
  111. data/test/integration/blob/lease/renew_lease_test.rb +0 -42
  112. data/test/integration/blob/list_blobs_test.rb +0 -113
  113. data/test/integration/cloud_service/Cloud_Create_test.rb +0 -45
  114. data/test/integration/cloud_service/Cloud_Delete_test.rb +0 -45
  115. data/test/integration/database/create_sql_server_firewall_test.rb +0 -81
  116. data/test/integration/database/create_sql_server_test.rb +0 -53
  117. data/test/integration/database/delete_sql_server_firewall_test.rb +0 -63
  118. data/test/integration/database/delete_sql_server_test.rb +0 -44
  119. data/test/integration/database/list_sql_server_firewall_test.rb +0 -44
  120. data/test/integration/database/list_sql_servers_test.rb +0 -44
  121. data/test/integration/database/reset_password_sql_server_test.rb +0 -53
  122. data/test/integration/location/Location_List_test.rb +0 -38
  123. data/test/integration/location/RoleSize_List_test.rb +0 -34
  124. data/test/integration/queue/clear_messages_test.rb +0 -42
  125. data/test/integration/queue/create_message_test.rb +0 -75
  126. data/test/integration/queue/create_queue_test.rb +0 -50
  127. data/test/integration/queue/delete_message_test.rb +0 -67
  128. data/test/integration/queue/delete_queue_test.rb +0 -45
  129. data/test/integration/queue/informative_errors_test.rb +0 -42
  130. data/test/integration/queue/list_messages_encoded_test.rb +0 -79
  131. data/test/integration/queue/list_messages_test.rb +0 -79
  132. data/test/integration/queue/list_queues_test.rb +0 -43
  133. data/test/integration/queue/peek_messages_test.rb +0 -59
  134. data/test/integration/queue/queue_gb18030_test.rb +0 -131
  135. data/test/integration/queue/queue_metadata_test.rb +0 -40
  136. data/test/integration/queue/update_message_test.rb +0 -74
  137. data/test/integration/service_bus/informative_errors_test.rb +0 -37
  138. data/test/integration/service_bus/queues_scenario_test.rb +0 -200
  139. data/test/integration/service_bus/queues_test.rb +0 -266
  140. data/test/integration/service_bus/relay_test.rb +0 -132
  141. data/test/integration/service_bus/rules_test.rb +0 -145
  142. data/test/integration/service_bus/sb_queue_gb18030_test.rb +0 -182
  143. data/test/integration/service_bus/scenario_test.rb +0 -101
  144. data/test/integration/service_bus/subscriptions_test.rb +0 -211
  145. data/test/integration/service_bus/topics_scenario_test.rb +0 -406
  146. data/test/integration/service_bus/topics_test.rb +0 -129
  147. data/test/integration/storage_management/storage_management_test.rb +0 -185
  148. data/test/integration/table/create_table_test.rb +0 -36
  149. data/test/integration/table/delete_entity_batch_test.rb +0 -107
  150. data/test/integration/table/delete_entity_test.rb +0 -94
  151. data/test/integration/table/delete_table_test.rb +0 -40
  152. data/test/integration/table/get_table_test.rb +0 -37
  153. data/test/integration/table/informative_errors_test.rb +0 -39
  154. data/test/integration/table/insert_entity_batch_test.rb +0 -100
  155. data/test/integration/table/insert_entity_test.rb +0 -88
  156. data/test/integration/table/insert_or_merge_entity_batch_test.rb +0 -159
  157. data/test/integration/table/insert_or_merge_entity_test.rb +0 -143
  158. data/test/integration/table/insert_or_replace_entity_batch_test.rb +0 -152
  159. data/test/integration/table/insert_or_replace_entity_test.rb +0 -137
  160. data/test/integration/table/merge_entity_batch_test.rb +0 -128
  161. data/test/integration/table/merge_entity_test.rb +0 -113
  162. data/test/integration/table/query_entities_test.rb +0 -196
  163. data/test/integration/table/query_tables_test.rb +0 -43
  164. data/test/integration/table/query_test.rb +0 -251
  165. data/test/integration/table/table_acl_test.rb +0 -52
  166. data/test/integration/table/table_gb18030_test.rb +0 -355
  167. data/test/integration/table/update_entity_batch_test.rb +0 -149
  168. data/test/integration/table/update_entity_test.rb +0 -131
  169. data/test/integration/test_helper.rb +0 -40
  170. data/test/integration/vm/VM_Create_test.rb +0 -262
  171. data/test/integration/vm/VM_Delete_test.rb +0 -53
  172. data/test/integration/vm/VM_Operations_test.rb +0 -172
  173. data/test/integration/vm_image/virtual_machine_disk_test.rb +0 -37
  174. data/test/integration/vm_image/virtual_machine_image_test.rb +0 -37
  175. data/test/integration/vnet/Virtual_Network_Create_test.rb +0 -116
  176. data/test/integration/vnet/Virtual_Network_list_test.rb +0 -48
  177. data/test/support/env.rb +0 -19
  178. data/test/support/fixtures.rb +0 -36
  179. data/test/support/name_generator.rb +0 -168
  180. data/test/support/stubs.rb +0 -42
  181. data/test/support/virtual_machine_name_generator.rb +0 -102
  182. data/test/support/virtual_network_helper.rb +0 -73
  183. data/test/test_helper.rb +0 -47
  184. data/test/unit/affinity_group/affinity_group_test.rb +0 -189
  185. data/test/unit/affinity_group/serialization_test.rb +0 -87
  186. data/test/unit/base_management/base_management_service_test.rb +0 -19
  187. data/test/unit/base_management/location_test.rb +0 -56
  188. data/test/unit/base_management/role_size_test.rb +0 -50
  189. data/test/unit/blob/auth/shared_access_signature_test.rb +0 -71
  190. data/test/unit/blob/blob_service_test.rb +0 -1970
  191. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +0 -94
  192. data/test/unit/cloud_service_management/serialization_test.rb +0 -169
  193. data/test/unit/config/azure_test.rb +0 -131
  194. data/test/unit/config/client_test.rb +0 -37
  195. data/test/unit/core/auth/shared_key_lite_test.rb +0 -51
  196. data/test/unit/core/auth/shared_key_test.rb +0 -58
  197. data/test/unit/core/auth/signer_test.rb +0 -30
  198. data/test/unit/core/http/http_error_test.rb +0 -61
  199. data/test/unit/core/http/http_request_test.rb +0 -138
  200. data/test/unit/core/http/http_response_test.rb +0 -20
  201. data/test/unit/core/http/retry_policy_test.rb +0 -23
  202. data/test/unit/core/utility_test.rb +0 -122
  203. data/test/unit/database/serialization_test.rb +0 -94
  204. data/test/unit/database/sql_database_server_service_test.rb +0 -341
  205. data/test/unit/http_client_test.rb +0 -74
  206. data/test/unit/service/serialization_test.rb +0 -533
  207. data/test/unit/service/storage_service_test.rb +0 -297
  208. data/test/unit/storage_management/serialization_test.rb +0 -244
  209. data/test/unit/storage_management/storage_management_service_test.rb +0 -247
  210. data/test/unit/table/edmtype_test.rb +0 -108
  211. data/test/unit/virtual_machine_image_management/serialization_test.rb +0 -50
  212. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +0 -114
  213. data/test/unit/virtual_machine_management/serialization_test.rb +0 -316
  214. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +0 -480
  215. data/test/unit/vnet/serialization_test.rb +0 -187
  216. data/test/unit/vnet/virtual_network_management_service_test.rb +0 -131
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bda06759b70c920d48fe1272ce87ca645aaebd5
4
- data.tar.gz: fafc97c79406bd2ff47b696e90fc025c8e0b9945
3
+ metadata.gz: 5ba36bbb5faaf4c52e3fc3b2f41b741b7c36722a
4
+ data.tar.gz: 0458b5f67633e4908c5b76a2cd314d31c99f4424
5
5
  SHA512:
6
- metadata.gz: af50fd89146d0af1b830bcb88a54cfa44e6f95349cbd39447ea9438604108425f379cff689b7609075221aca35bdb0a6df1d3f0418aa630080fdecd2d4202f92
7
- data.tar.gz: 96a63eb8ee3b996079d62bcf7c030e8563ade20200a144705a9a1266a3710d2d40daf9316c67e215892c06f05dcd30322c7b52fc77807ddc55acde8fea463b17
6
+ metadata.gz: bd1dc4d1b7c57f4dcf2b81d3830f9fe086b97dd35f23766ace5f6df20349e287dd1097b0e7a3a108d3ee7cdf15959130c3c1054531faff2f12e77a9e35945a51
7
+ data.tar.gz: 0b8723c181c732524b3dd2cb91e9163e76cc879ea847f19dec3a0e3619d25e41a4e3170433271cf3e2980ff0387c36c4188ccb0225a8f462f78a9aec384a5ed6
data/Rakefile CHANGED
@@ -88,6 +88,7 @@ namespace :test do
88
88
 
89
89
  component_task :affinity_group
90
90
  component_task :blob
91
+ component_task :cloud_service
91
92
  component_task :database
92
93
  component_task :location
93
94
  component_task :queue
@@ -99,6 +100,36 @@ namespace :test do
99
100
  component_task :vnet
100
101
  end
101
102
 
103
+ Rake::TestTask.new :recorded do |t|
104
+ t.test_files = Dir['test/integration/**/*_test.rb'].reject do |path|
105
+ # Reject the test paths those are not yet VCR recorded
106
+ # Following three are Azure-Storage gem features and need to be removed when we take dependency on azure-storage gem
107
+ path.include?('blob') || path.include?('queue') || path.include?('table')
108
+ end
109
+ t.verbose = true
110
+ t.libs = %w(lib test)
111
+ end
112
+
113
+ namespace :recorded do
114
+ def component_task(component)
115
+ Rake::TestTask.new component do |t|
116
+ t.pattern = "test/integration/#{component}/**/*_test.rb"
117
+ t.verbose = true
118
+ t.libs = %w(lib test)
119
+ end
120
+ end
121
+
122
+ component_task :affinity_group
123
+ component_task :cloud_service
124
+ component_task :database
125
+ component_task :location
126
+ component_task :service_bus
127
+ component_task :storage_management
128
+ component_task :vm
129
+ component_task :vm_image
130
+ component_task :vnet
131
+ end
132
+
102
133
  task :cleanup => :require_environment do
103
134
  $:.unshift 'lib'
104
135
  require 'azure'
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.summary = 'Official ruby client library to consume Microsoft Azure services.'
26
26
  s.homepage = 'http://github.com/azure/azure-sdk-for-ruby'
27
27
  s.license = 'Apache License, Version 2.0'
28
- s.files = `git ls-files`.split("\n").reject { |f| f.start_with?("lib/azure/arm") }
28
+ s.files = `git ls-files`.split("\n").reject { |f| f.start_with?("test") }
29
29
  s.bindir = 'bin'
30
30
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
31
 
@@ -48,4 +48,5 @@ Gem::Specification.new do |s|
48
48
  s.add_development_dependency('rake', '~> 10.0')
49
49
  s.add_development_dependency('timecop', '~> 0.7')
50
50
  s.add_development_dependency('yard', '~> 0.8')
51
+ s.add_development_dependency('vcr', '~> 3.0')
51
52
  end
@@ -30,6 +30,7 @@ module Azure
30
30
  autoload :Default, 'azure/default'
31
31
  autoload :HttpClient, 'azure/http_client'
32
32
  autoload :Version, 'azure/version'
33
+ autoload :HttpResponseHelper, 'azure/http_response_helper'
33
34
 
34
35
  # helpers because the naming is far too verbose
35
36
  autoload :BaseManagementService, 'azure/base_management/base_management_service'
@@ -48,10 +48,7 @@ module Azure
48
48
  # Returns a Nokogiri::XML instance of HttpResponse body
49
49
  def call
50
50
  conn = http_setup
51
- res = conn.run_request(method.to_sym, uri, nil, nil) do |req|
52
- req.body = body if body
53
- req.headers = headers if headers
54
- end
51
+ res = set_up_response(method.to_sym, uri, conn, headers ,body)
55
52
  response = wait_for_completion(Azure::Core::Http::HttpResponse.new(res))
56
53
  Nokogiri::XML response.body unless response.nil?
57
54
  end
@@ -116,10 +113,7 @@ module Azure
116
113
  done = false
117
114
  until done
118
115
  Azure::Loggerx.info('# ')
119
- res = conn.run_request(method.to_sym, URI(request_path), nil, nil) do |req|
120
- req.body = body if body
121
- req.headers = headers if headers
122
- end
116
+ res = set_up_response(method.to_sym, URI(request_path), conn, headers ,body)
123
117
  response = Azure::Core::Http::HttpResponse.new(res)
124
118
  ret_val = Nokogiri::XML response.body
125
119
  status = xml_content(ret_val, 'Operation Status')
@@ -150,10 +144,7 @@ module Azure
150
144
  def rebuild_request(response)
151
145
  host_uri = URI.parse(response.headers['location'])
152
146
  conn = http_setup
153
- res = conn.run_request(method.to_sym, host_uri, nil, nil) do |req|
154
- req.body = body if body
155
- req.headers = headers if headers
156
- end
147
+ res = set_up_response(method.to_sym, host_uri, conn, headers ,body)
157
148
  wait_for_completion(HttpResponse.new(res))
158
149
  end
159
150
 
@@ -62,6 +62,8 @@ module Azure
62
62
  def signable_string(path, options)
63
63
  # Order is significant
64
64
  # The newlines from empty strings here are required
65
+ options[:start] = Time.parse(options[:start]).utc.iso8601 if options[:start]
66
+ options[:expiry] = Time.parse(options[:expiry]).utc.iso8601 if options[:expiry]
65
67
  [
66
68
  options[:permissions],
67
69
  options[:start],
@@ -106,6 +108,8 @@ module Azure
106
108
  def signed_uri(uri, options)
107
109
  parsed_query = CGI::parse(uri.query || '').inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
108
110
 
111
+ options[:start] = Time.parse(options[:start]).utc.iso8601 if options[:start]
112
+ options[:expiry] = Time.parse(options[:expiry]).utc.iso8601 if options[:expiry]
109
113
  options[:expiry] ||= (Time.now + 60*30).utc.iso8601
110
114
 
111
115
  if parsed_query.has_key?(:restype)
@@ -1378,8 +1378,8 @@ module Azure
1378
1378
  end
1379
1379
 
1380
1380
  # Azure Storage Service expects content-encoding to be lowercase.
1381
- # Authentication will fail otherwise.
1382
- headers['Content-Encoding'].downcase!
1381
+ # Authentication will fail otherwise.
1382
+ headers['Content-Encoding'] = headers['Content-Encoding'].downcase
1383
1383
  end
1384
1384
 
1385
1385
  response = super
@@ -20,79 +20,79 @@ module Azure
20
20
  # Azure Blob service configured for this Azure client instance
21
21
  # @return [Azure::Blob::BlobService]
22
22
  def blobs(options = {})
23
- @blobs ||= Azure::Blob::BlobService.new(default_client(options))
23
+ Azure::Blob::BlobService.new(default_client(options))
24
24
  end
25
25
 
26
26
  # Azure Queue service configured for this Azure client instance
27
27
  # @return [Azure::Queue::QueueService]
28
28
  def queues(options = {})
29
- @queues ||= Azure::Queue::QueueService.new(default_client(options))
29
+ Azure::Queue::QueueService.new(default_client(options))
30
30
  end
31
31
 
32
32
  # Azure Table service configured for this Azure client instance
33
33
  # @return [Azure::Table::TableService]
34
34
  def tables(options = {})
35
- @tables ||= Azure::Table::TableService.new(default_client(options))
35
+ Azure::Table::TableService.new(default_client(options))
36
36
  end
37
37
 
38
38
  # Azure Service Bus service configured for this Azure client instance
39
39
  # @return [Azure::ServiceBus::ServiceBusService]
40
40
  def service_bus(options = {})
41
- @sb ||= Azure::ServiceBus::ServiceBusService.new(service_bus_host, default_client(options))
41
+ Azure::ServiceBus::ServiceBusService.new(service_bus_host, default_client(options))
42
42
  end
43
43
 
44
44
  # Azure Virtual Image management service configured for this Azure client instance
45
45
  # @return [Azure::VirtualMachineImageManagement::VirtualMachineImageManagementService]
46
46
  def vm_image_management(options = {})
47
- @vm_image_mgmt ||= Azure::VirtualMachineImageManagement::VirtualMachineImageManagementService.new(default_client(options))
47
+ Azure::VirtualMachineImageManagement::VirtualMachineImageManagementService.new(default_client(options))
48
48
  end
49
49
 
50
50
  # Azure Virtual Machine disk management service configured for this Azure client instance
51
51
  # @return [Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService]
52
52
  def vm_disk_management(options = {})
53
- @vm_disk_mgmt ||= Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService.new(default_client(options))
53
+ Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService.new(default_client(options))
54
54
  end
55
55
 
56
56
  # Azure Virtual Machine management service configured for this Azure client instance
57
57
  # @return [Azure::VirtualMachineManagement::VirtualMachineManagementService]
58
58
  def vm_management(options = {})
59
- @vm_mgmt ||= Azure::VirtualMachineManagement::VirtualMachineManagementService.new(default_client(options))
59
+ Azure::VirtualMachineManagement::VirtualMachineManagementService.new(default_client(options))
60
60
  end
61
61
 
62
62
  # Azure SQL Database management service configured for this Azure client instance
63
63
  # @return [Azure::SqlDatabaseManagement::SqlDatabaseManagementService]
64
64
  def sql_database_management(options = {})
65
- @sql_mgmt ||= Azure::SqlDatabaseManagement::SqlDatabaseManagementService.new(default_client(options))
65
+ Azure::SqlDatabaseManagement::SqlDatabaseManagementService.new(default_client(options))
66
66
  end
67
67
 
68
68
  # Azure Network management service configured for this Azure client instance
69
69
  # @return [Azure::VirtualNetworkManagement::VirtualNetworkManagementService]
70
70
  def network_management(options = {})
71
- @network_mgmt ||= Azure::VirtualNetworkManagement::VirtualNetworkManagementService.new(default_client(options))
71
+ Azure::VirtualNetworkManagement::VirtualNetworkManagementService.new(default_client(options))
72
72
  end
73
73
 
74
74
  # Azure Cloud Service management service configured for this Azure client instance
75
75
  # @return [Azure::CloudServiceManagement::CloudServiceManagementService]
76
76
  def cloud_service_management(options = {})
77
- @cs_mgmt ||= Azure::CloudServiceManagement::CloudServiceManagementService.new(default_client(options))
77
+ Azure::CloudServiceManagement::CloudServiceManagementService.new(default_client(options))
78
78
  end
79
79
 
80
80
  # Azure Storage management service configured for this Azure client instance
81
81
  # @return [Azure::StorageManagement::StorageManagementService]
82
82
  def storage_management(options = {})
83
- @store_mgmt ||= Azure::StorageManagement::StorageManagementService.new(default_client(options))
83
+ Azure::StorageManagement::StorageManagementService.new(default_client(options))
84
84
  end
85
85
 
86
86
  # Azure Generic management service configured for this Azure client instance
87
87
  # @return [Azure::BaseManagement::BaseManagementService]
88
88
  def base_management(options = {})
89
- @base_mgmt ||= Azure::BaseManagement::BaseManagementService.new(default_client(options))
89
+ Azure::BaseManagement::BaseManagementService.new(default_client(options))
90
90
  end
91
91
 
92
92
  private
93
93
 
94
94
  def default_client(opts)
95
- {client: self}.merge(opts || {})
95
+ {client: Azure.client(opts || {})}
96
96
  end
97
97
  end
98
98
  end
@@ -26,7 +26,7 @@ module Azure
26
26
  # Represents a HTTP request can perform synchronous queries to a
27
27
  # HTTP server, returning a HttpResponse
28
28
  class HttpRequest
29
-
29
+ include Azure::HttpResponseHelper
30
30
  alias_method :_method, :method
31
31
 
32
32
  # The HTTP method to use (:get, :post, :put, :delete, etc...)
@@ -120,14 +120,7 @@ module Azure
120
120
  end
121
121
 
122
122
  def http_setup
123
- http = @client.agents(uri)
124
-
125
- unless headers.nil?
126
- keep_alive = headers['Keep-Alive'] || headers['keep-alive']
127
- http.read_timeout = keep_alive.split('=').last.to_i unless keep_alive.nil?
128
- end
129
-
130
- http
123
+ @client.agents(uri)
131
124
  end
132
125
 
133
126
  def body=(body)
@@ -140,11 +133,7 @@ module Azure
140
133
  # @return [HttpResponse]
141
134
  def call
142
135
  conn = http_setup
143
- res = conn.run_request(method.to_sym, uri, nil, nil) do |req|
144
- req.body = body if body
145
- req.headers = headers if headers
146
- end
147
-
136
+ res = set_up_response(method.to_sym, uri, conn, headers ,body)
148
137
  response = HttpResponse.new(res)
149
138
  response.uri = uri
150
139
  raise response.error unless response.success?
@@ -37,7 +37,8 @@ module Azure
37
37
  end
38
38
 
39
39
  def generate_uri(path='', query={})
40
- uri = URI.parse(File.join(host, path))
40
+ enconded_file_uri_string = URI.encode(File.join(host, path))
41
+ uri = URI.parse(enconded_file_uri_string)
41
42
  uri.query = URI.encode_www_form(query) unless query == nil or query.empty?
42
43
  uri
43
44
  end
@@ -49,24 +49,8 @@ module Azure
49
49
  # @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint
50
50
  # @return [Net::HTTP] http agent for a given uri
51
51
  def agents(uri)
52
- uri = URI.parse(uri) if uri.is_a?(String)
53
- key = uri.scheme.to_s + uri.host.to_s + uri.port.to_s
54
- @agents ||= {}
55
- unless @agents.key?(key)
56
- @agents[key] = build_http(uri)
57
- end
58
- @agents[key]
59
- end
60
-
61
- # Empties all the http agents
62
- def reset_agents!
63
- @agents = nil
64
- end
65
-
66
- private
67
-
68
- def build_http(uri)
69
52
  ssl_options = {}
53
+ uri = URI.parse(uri) if uri.is_a?(String)
70
54
  if uri.scheme.downcase == 'https'
71
55
  ssl_options[:ca_file] = self.ca_file if self.ca_file
72
56
  ssl_options[:verify] = true
@@ -0,0 +1,38 @@
1
+ #-------------------------------------------------------------------------
2
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #--------------------------------------------------------------------------
15
+
16
+ module Azure
17
+ module HttpResponseHelper
18
+
19
+ # Sends request to HTTP server and returns a Faraday::Response
20
+ # @param method [Symbol] The HTTP method to use (:get, :post, :put, :del, etc...)
21
+ # @param url [URI] The URI of the HTTP endpoint to query
22
+ # @param conn [Net::HTTP] http agent for a given uri
23
+ # @param headers [String] The request headers
24
+ # @param body [String] The request body
25
+ #returns Faraday::Response
26
+ def set_up_response(method, url, conn, headers ,body)
27
+ conn.run_request(method, url, nil, nil) do |req|
28
+ req.body = body if body
29
+ req.headers = headers if headers
30
+ unless headers.nil?
31
+ keep_alive = headers['Keep-Alive'] || headers['keep-alive']
32
+ req.options[:timeout] = keep_alive.split('=').last.to_i unless keep_alive.nil?
33
+ end
34
+ req.options[:open_timeout] ||= 60
35
+ end
36
+ end
37
+ end
38
+ end
@@ -47,6 +47,10 @@ module Azure
47
47
  end
48
48
 
49
49
  def self.server_name_from_xml(response_xml, login, location, version)
50
+ if response_xml.css('Error').css('Message').to_s != ''
51
+ raise Azure::SqlDatabaseManagement::Error.new(response_xml.css('Error').css('Message').to_s)
52
+ end
53
+
50
54
  server_name = xml_content(response_xml, 'ServerName')
51
55
  SqlServer.new do |db|
52
56
  db.name = server_name
@@ -14,6 +14,7 @@
14
14
  #--------------------------------------------------------------------------
15
15
 
16
16
  require 'socket'
17
+ require 'net/http'
17
18
  require 'azure/sql_database_management/sql_server'
18
19
  require 'azure/sql_database_management/firewall_rule'
19
20
  require 'azure/sql_database_management/serialization'
@@ -26,7 +27,7 @@ module Azure
26
27
 
27
28
  # Gets a list of database servers available under the current subscription.
28
29
  #
29
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715269.aspx
30
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505702.aspx
30
31
  #
31
32
  # @return Array<Azure::SqlDatabaseManagement::SqlServer>
32
33
  def list_servers
@@ -41,7 +42,7 @@ module Azure
41
42
  # @param location [String] The location where the database server will be created.
42
43
  # @param version [String|Integer] The version of the SQL server (default 12.0)
43
44
  #
44
- # @see https://msdn.microsoft.com/en-us/library/azure/dn505699.aspx
45
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505699.aspx
45
46
  #
46
47
  # @return [Azure::SqlDatabaseManagement::SqlServer]
47
48
  def create_server(login, password, location, version = 12.0)
@@ -74,7 +75,7 @@ module Azure
74
75
  #
75
76
  # @param name [String] SqlServer name.
76
77
  #
77
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715285.aspx
78
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505695.aspx
78
79
  #
79
80
  # @return [void]
80
81
  def delete_server(name)
@@ -89,13 +90,13 @@ module Azure
89
90
  # @param name [String] SqlServer name.
90
91
  # @param password [String] SqlServer new password.
91
92
  #
92
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715272.aspx
93
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505696.aspx
93
94
  #
94
95
  # @return [void]
95
96
  def reset_password(name, password)
96
97
  ensure_server_exists!(name)
97
98
  body = Serialization.reset_password_to_xml(password)
98
- request_path = servers_path + "#{name}?op=ResetPassword"
99
+ request_path = servers_path "#{name}?op=ResetPassword"
99
100
  request = client.sql_management_request(:post, request_path, body)
100
101
  request.call
101
102
  Azure::Loggerx.info "Password for server #{name} changed successfully."
@@ -112,7 +113,7 @@ module Azure
112
113
  # addresses equal to or less than this can attempt to connect to the server. The
113
114
  # highest possible IP address is 255.255.255.255. (default: first local public ip)
114
115
  #
115
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715280.aspx
116
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505707.aspx
116
117
  #
117
118
  # @return [void]
118
119
  def set_sql_server_firewall_rule(server_name, rule_name, start_ip = public_ipv4, end_ip = public_ipv4)
@@ -145,7 +146,7 @@ module Azure
145
146
  #
146
147
  # @param server_name [String] Database server name.
147
148
  #
148
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715278.aspx
149
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505715.aspx
149
150
  #
150
151
  # @return [Array<Azure::SqlDatabaseManagement::FirewallRule>]
151
152
  def list_sql_server_firewall_rules(server_name)
@@ -160,7 +161,7 @@ module Azure
160
161
  # @param server_name [String] SQL database server name.
161
162
  # @param rule_name [String] SQL database server firewall rule name.
162
163
  #
163
- # @see http://msdn.microsoft.com/en-us/library/azure/gg715277.aspx
164
+ # @see http://msdn.microsoft.com/en-us/library/azure/dn505706.aspx
164
165
  #
165
166
  # @return [void]
166
167
  def delete_sql_server_firewall_rule(server_name, rule_name)
@@ -201,7 +202,7 @@ module Azure
201
202
  end
202
203
 
203
204
  def public_ipv4
204
- @public_ip ||= `curl -s whatismyip.akamai.com`
205
+ @public_ip ||= Net::HTTP.get('whatismyip.akamai.com', '/')
205
206
  end
206
207
 
207
208
  end