azure 0.7.0.pre → 0.7.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.env_sample +3 -1
  3. data/.gitignore +15 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +322 -248
  6. data/Rakefile +3 -1
  7. data/azure.gemspec +18 -14
  8. data/lib/azure.rb +124 -38
  9. data/lib/azure/base_management/base_management_service.rb +57 -69
  10. data/lib/azure/base_management/location.rb +1 -1
  11. data/lib/azure/base_management/management_http_request.rb +55 -58
  12. data/lib/azure/base_management/serialization.rb +5 -0
  13. data/lib/azure/base_management/sql_management_http_request.rb +10 -20
  14. data/lib/azure/blob/auth/shared_access_signature.rb +82 -76
  15. data/lib/azure/blob/blob_service.rb +196 -171
  16. data/lib/azure/client.rb +31 -0
  17. data/lib/azure/client_services.rb +98 -0
  18. data/lib/azure/cloud_service_management/cloud_service_management_service.rb +8 -10
  19. data/lib/azure/configurable.rb +290 -0
  20. data/lib/azure/core/auth/authorizer.rb +1 -1
  21. data/lib/azure/core/auth/shared_key.rb +48 -40
  22. data/lib/azure/core/auth/shared_key_lite.rb +9 -9
  23. data/lib/azure/core/auth/signer.rb +15 -12
  24. data/lib/azure/core/error.rb +2 -3
  25. data/lib/azure/core/filtered_service.rb +4 -3
  26. data/lib/azure/core/http/http_error.rb +10 -12
  27. data/lib/azure/core/http/http_request.rb +82 -69
  28. data/lib/azure/core/http/http_response.rb +12 -56
  29. data/lib/azure/core/http/signer_filter.rb +3 -4
  30. data/lib/azure/core/service.rb +8 -25
  31. data/lib/azure/core/signed_service.rb +7 -5
  32. data/lib/azure/core/utility.rb +45 -6
  33. data/lib/azure/default.rb +126 -0
  34. data/lib/azure/http_client.rb +85 -0
  35. data/lib/azure/queue/queue.rb +0 -1
  36. data/lib/azure/queue/queue_service.rb +6 -4
  37. data/lib/azure/queue/serialization.rb +0 -1
  38. data/lib/azure/service/storage_service.rb +9 -6
  39. data/lib/azure/service_bus/auth/shared_access_signer.rb +44 -0
  40. data/lib/azure/service_bus/auth/wrap_service.rb +5 -4
  41. data/lib/azure/service_bus/auth/wrap_signer.rb +14 -6
  42. data/lib/azure/service_bus/service_bus_service.rb +34 -30
  43. data/lib/azure/sql_database_management/errors.rb +11 -0
  44. data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
  45. data/lib/azure/sql_database_management/serialization.rb +40 -53
  46. data/lib/azure/sql_database_management/sql_database_management_service.rb +141 -130
  47. data/lib/azure/sql_database_management/{sql_database.rb → sql_server.rb} +4 -3
  48. data/lib/azure/storage_management/storage_management_service.rb +9 -10
  49. data/lib/azure/table/auth/shared_key.rb +17 -50
  50. data/lib/azure/table/auth/shared_key_lite.rb +3 -3
  51. data/lib/azure/table/serialization.rb +24 -24
  52. data/lib/azure/table/table_service.rb +21 -18
  53. data/lib/azure/version.rb +1 -1
  54. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +6 -12
  55. data/lib/azure/virtual_machine_management/serialization.rb +4 -1
  56. data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
  57. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +29 -37
  58. data/lib/azure/virtual_network_management/virtual_network_management_service.rb +5 -6
  59. data/test/fixtures/list_locations.xml +150 -0
  60. data/test/fixtures/list_sql_database.xml +6 -18
  61. data/test/fixtures/list_sql_server_firewall.xml +18 -18
  62. data/test/fixtures/management_certificate.pfx +0 -0
  63. data/test/fixtures/virtual_machine.xml +1 -0
  64. data/test/integration/affinity_group/Create_Affinity_test.rb +1 -1
  65. data/test/integration/affinity_group/Update_Affinity_test.rb +4 -0
  66. data/test/integration/blob/blob_gb18030_test.rb +29 -29
  67. data/test/integration/blob/blob_pages_test.rb +16 -16
  68. data/test/integration/blob/container/create_container_test.rb +6 -6
  69. data/test/integration/blob/container/root_container_test.rb +2 -1
  70. data/test/integration/database/create_sql_server_firewall_test.rb +26 -31
  71. data/test/integration/database/create_sql_server_test.rb +6 -6
  72. data/test/integration/database/delete_sql_server_firewall_test.rb +18 -24
  73. data/test/integration/database/delete_sql_server_test.rb +9 -22
  74. data/test/integration/database/list_sql_server_firewall_test.rb +7 -8
  75. data/test/integration/database/list_sql_servers_test.rb +4 -4
  76. data/test/integration/database/reset_password_sql_server_test.rb +9 -11
  77. data/test/integration/location/RoleSize_List_test.rb +35 -0
  78. data/test/integration/queue/list_queues_test.rb +0 -1
  79. data/test/integration/service_bus/queues_scenario_test.rb +11 -11
  80. data/test/integration/service_bus/queues_test.rb +2 -2
  81. data/test/integration/service_bus/subscriptions_test.rb +25 -25
  82. data/test/integration/service_bus/topics_scenario_test.rb +6 -6
  83. data/test/integration/service_bus/topics_test.rb +15 -15
  84. data/test/integration/table/query_entities_test.rb +1 -0
  85. data/test/integration/table/table_acl_test.rb +9 -9
  86. data/test/integration/test_helper.rb +11 -9
  87. data/test/integration/vm/VM_Create_test.rb +23 -20
  88. data/test/integration/vnet/Virtual_Network_list_test.rb +1 -1
  89. data/test/test_helper.rb +5 -0
  90. data/test/unit/affinity_group/affinity_group_test.rb +4 -4
  91. data/test/unit/base_management/base_management_service_test.rb +19 -0
  92. data/test/unit/base_management/location_test.rb +6 -6
  93. data/test/unit/base_management/role_size_test.rb +50 -0
  94. data/test/unit/blob/auth/shared_access_signature_test.rb +19 -19
  95. data/test/unit/blob/blob_service_test.rb +583 -582
  96. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +2 -2
  97. data/test/unit/config/azure_test.rb +112 -0
  98. data/test/unit/config/client_test.rb +37 -0
  99. data/test/unit/core/auth/shared_key_lite_test.rb +15 -15
  100. data/test/unit/core/auth/shared_key_test.rb +26 -26
  101. data/test/unit/core/http/http_error_test.rb +13 -14
  102. data/test/unit/core/http/http_request_test.rb +78 -53
  103. data/test/unit/core/http/http_response_test.rb +2 -27
  104. data/test/unit/core/http/retry_policy_test.rb +3 -3
  105. data/test/unit/core/utility_test.rb +122 -0
  106. data/test/unit/database/serialization_test.rb +17 -20
  107. data/test/unit/database/sql_database_server_service_test.rb +97 -40
  108. data/test/unit/http_client_test.rb +74 -0
  109. data/test/unit/service/storage_service_test.rb +105 -101
  110. data/test/unit/storage_management/storage_management_service_test.rb +28 -28
  111. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +4 -4
  112. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +37 -20
  113. data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
  114. metadata +91 -20
  115. data/lib/azure/core.rb +0 -41
  116. data/lib/azure/core/configuration.rb +0 -218
@@ -1,41 +0,0 @@
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::Core; end
17
-
18
- require 'azure/core/error'
19
- require 'azure/core/configuration'
20
-
21
- # load default configuration from environment variables
22
- # (user can always override this later)
23
- Azure.configure do |config|
24
- config.storage_access_key = ENV['AZURE_STORAGE_ACCESS_KEY']
25
- config.storage_account_name = ENV['AZURE_STORAGE_ACCOUNT']
26
- config.storage_table_host = ENV['AZURE_STORAGE_TABLE_HOST']
27
- config.storage_blob_host = ENV['AZURE_STORAGE_BLOB_HOST']
28
- config.storage_queue_host = ENV['AZURE_STORAGE_QUEUE_HOST']
29
-
30
- config.sb_namespace = ENV['AZURE_SERVICEBUS_NAMESPACE']
31
- config.sb_access_key = ENV['AZURE_SERVICEBUS_ACCESS_KEY']
32
- config.sb_issuer = ENV['AZURE_SERVICEBUS_ISSUER']
33
-
34
- config.management_certificate = ENV['AZURE_MANAGEMENT_CERTIFICATE']
35
- config.subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
36
- config.management_endpoint = ENV['AZURE_MANAGEMENT_ENDPOINT']
37
- config.sql_database_management_endpoint = ENV['AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT']
38
- config.sql_database_authentication_mode = ENV['AZURE_SQL_DATABASE_AUTHENTICATION_MODE']
39
-
40
- config.ca_file = ENV['SSL_CERT_FILE']
41
- end
@@ -1,218 +0,0 @@
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
- require "singleton"
16
-
17
- module Azure
18
-
19
- # Proxy config method.
20
- def self.config
21
- Core.config
22
- end
23
-
24
- # Proxy configure method.
25
- def self.configure
26
- yield Core.config
27
- end
28
-
29
- module Core
30
-
31
- # Public: Sugar to configure the services in a neatly wrapped DSL.
32
- #
33
- # Yields the Azure::Configuration instance.
34
- #
35
- # Example:
36
- #
37
- # Azure.configure do |config|
38
- # config.storage_account_name = ENV["AZURE_STORAGE_ACCOUNT"]
39
- # end
40
- #
41
- # Returns nothing.
42
- def self.configure
43
- yield config
44
- end
45
-
46
- # Public: Access the service configuration.
47
- #
48
- # Returns the Azure::Configuration instance.
49
- def self.config
50
- Configuration.instance
51
- end
52
-
53
- # Singleton that keeps the configuration of the system.
54
- class Configuration
55
- include Singleton
56
-
57
- # Public: Get/Set the Access Key for this service.
58
- attr_accessor :storage_access_key
59
-
60
- # Public: Get/Set the Account Name for this service.
61
- attr_accessor :storage_account_name
62
-
63
- # Public: Get/Set the Service Bus Access Key (Issuer Secret) for this service.
64
- attr_accessor :sb_access_key
65
-
66
- # Public: Set the Service Bus Issuer for this service.
67
- attr_writer :sb_issuer
68
-
69
- # Public: Get/Set path of a CA certification directory containing certifications in
70
- # PEM format.
71
- #
72
- # For example:
73
- # config.ca_file = 'ca_cert.pem'
74
- attr_accessor :ca_file
75
-
76
- # Public: Get the issuer for the service bus. If you set something using #sb_issuer=,
77
- # then we use that. Otherwise, we default to the default issuer: "owner"
78
- def sb_issuer
79
- @sb_issuer || "owner"
80
- end
81
-
82
- # Public: Get/Set the Service Bus Namespace for this service.
83
- attr_accessor :sb_namespace
84
-
85
- # Public: Set the host for the Table service. Only set this if you want
86
- # something custom (like, for example, to point this to a LocalStorage
87
- # emulator). This should be the complete host, including http:// at the
88
- # start. When using the emulator, make sure to include your account name at
89
- # the end.
90
- #
91
- # Example:
92
- #
93
- # config.storage_table_host = "http://127.0.0.1:10002/devstoreaccount1"
94
- attr_writer :storage_table_host
95
-
96
- # Public: Get the host for this service. If you set something using #storage_table_host=,
97
- # then we use that. Else we default to Azure's default hosts, based
98
- # on your account name.
99
- def storage_table_host
100
- @storage_table_host || default_host(:table)
101
- end
102
-
103
- # Public: Set the host for the Blob service. Only set this if you want
104
- # something custom (like, for example, to point this to a LocalStorage
105
- # emulator). This should be the complete host, including http:// at the
106
- # start. When using the emulator, make sure to include your account name at
107
- # the end.
108
- #
109
- # Example:
110
- #
111
- # config.storage_blob_host = "http://127.0.0.1:10000/devstoreaccount1"
112
- attr_writer :storage_blob_host
113
-
114
- # Public: Get the host for this service. If you set something using #storage_blob_host=,
115
- # then we use that. Else we default to Azure's default hosts, based
116
- # on your account name.
117
- def storage_blob_host
118
- @storage_blob_host || default_host(:blob)
119
- end
120
-
121
- # Public: Set the host for the Queue service. Only set this if you want
122
- # something custom (like, for example, to point this to a LocalStorage
123
- # emulator). This should be the complete host, including http:// at the
124
- # start. When using the emulator, make sure to include your account name at
125
- # the end.
126
- #
127
- # Example:
128
- #
129
- # config.storage_queue_host = "http://127.0.0.1:10001/devstoreaccount1"
130
- attr_writer :storage_queue_host
131
-
132
- # Public: Get the host for this service. If you set something using #storage_queue_host=,
133
- # then we use that. Else we default to Azure's default hosts, based
134
- # on your account name.
135
- def storage_queue_host
136
- @storage_queue_host || default_host(:queue)
137
- end
138
-
139
- # Public: Get the host for the ACS service.
140
- def acs_host
141
- "https://#{sb_namespace}-sb.accesscontrol.windows.net"
142
- end
143
-
144
- # Public: Get the host for the Service Bus service.
145
- def service_bus_host
146
- "https://#{sb_namespace}.servicebus.windows.net"
147
- end
148
-
149
- # Calculate the default host for a given service in the cloud.
150
- #
151
- # service - One of :table, :blob, :queue, etc.
152
- #
153
- # Returns a String with the hostname, including your account name.
154
- def default_host(service)
155
- "http://#{storage_account_name}.#{service}.core.windows.net"
156
- end
157
-
158
- #===================================================================
159
- #*******************Management API configuration********************
160
- #===================================================================
161
-
162
- # Public: Get the Subscription Id and certificate key for the management API.
163
- attr_accessor :management_certificate
164
-
165
- # Public: Get/Set the Subscription Id for the management API.
166
- attr_accessor :subscription_id
167
-
168
- # Public: Set the host for the management API.
169
- attr_writer :management_endpoint
170
-
171
- #Public: Set the private key for SSL/HTTPS request with PEM certificate
172
- attr_accessor :http_private_key
173
-
174
- #Public: Set the certificate key for SSL/HTTPS request with PEM certificate
175
- attr_accessor :http_certificate_key
176
-
177
- # Public: Set the host for SQL Management API (SQL Server authentication Endpoint)
178
- attr_accessor :sql_database_management_endpoint
179
-
180
- def management_endpoint
181
- if @management_endpoint.nil? or @management_endpoint.empty?
182
- "https://management.core.windows.net/"
183
- elsif !@management_endpoint.end_with?('/')
184
- @management_endpoint += '/'
185
- elsif URI(@management_endpoint).scheme.nil?
186
- "https://#{@management_endpoint}"
187
- else
188
- @management_endpoint
189
- end
190
- end
191
-
192
- def sql_database_management_endpoint
193
- if @sql_database_management_endpoint.nil? or @sql_database_management_endpoint.empty?
194
- "https://management.database.windows.net:8443/"
195
- elsif !@sql_database_management_endpoint.end_with?('/')
196
- @sql_database_management_endpoint += '/'
197
- elsif URI(@sql_database_management_endpoint).scheme.nil?
198
- "https://#{@sql_database_management_endpoint}"
199
- else
200
- @management_endpoint
201
- end
202
- end
203
-
204
- # Public: Set this to enable Management certificate authentication or SQL Server authentication
205
- attr_accessor :sql_database_authentication_mode
206
-
207
- def sql_database_authentication_mode
208
- sdam = @sql_database_authentication_mode || :sql_server
209
- if [:sql_server, :management_certificate].include? sdam.to_sym
210
- sdam.to_sym
211
- else
212
- :sql_server
213
- end
214
- end
215
-
216
- end
217
- end
218
- end