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.
- checksums.yaml +4 -4
- data/.env_sample +3 -1
- data/.gitignore +15 -0
- data/LICENSE.txt +1 -1
- data/README.md +322 -248
- data/Rakefile +3 -1
- data/azure.gemspec +18 -14
- data/lib/azure.rb +124 -38
- data/lib/azure/base_management/base_management_service.rb +57 -69
- data/lib/azure/base_management/location.rb +1 -1
- data/lib/azure/base_management/management_http_request.rb +55 -58
- data/lib/azure/base_management/serialization.rb +5 -0
- data/lib/azure/base_management/sql_management_http_request.rb +10 -20
- data/lib/azure/blob/auth/shared_access_signature.rb +82 -76
- data/lib/azure/blob/blob_service.rb +196 -171
- data/lib/azure/client.rb +31 -0
- data/lib/azure/client_services.rb +98 -0
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +8 -10
- data/lib/azure/configurable.rb +290 -0
- data/lib/azure/core/auth/authorizer.rb +1 -1
- data/lib/azure/core/auth/shared_key.rb +48 -40
- data/lib/azure/core/auth/shared_key_lite.rb +9 -9
- data/lib/azure/core/auth/signer.rb +15 -12
- data/lib/azure/core/error.rb +2 -3
- data/lib/azure/core/filtered_service.rb +4 -3
- data/lib/azure/core/http/http_error.rb +10 -12
- data/lib/azure/core/http/http_request.rb +82 -69
- data/lib/azure/core/http/http_response.rb +12 -56
- data/lib/azure/core/http/signer_filter.rb +3 -4
- data/lib/azure/core/service.rb +8 -25
- data/lib/azure/core/signed_service.rb +7 -5
- data/lib/azure/core/utility.rb +45 -6
- data/lib/azure/default.rb +126 -0
- data/lib/azure/http_client.rb +85 -0
- data/lib/azure/queue/queue.rb +0 -1
- data/lib/azure/queue/queue_service.rb +6 -4
- data/lib/azure/queue/serialization.rb +0 -1
- data/lib/azure/service/storage_service.rb +9 -6
- data/lib/azure/service_bus/auth/shared_access_signer.rb +44 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +5 -4
- data/lib/azure/service_bus/auth/wrap_signer.rb +14 -6
- data/lib/azure/service_bus/service_bus_service.rb +34 -30
- data/lib/azure/sql_database_management/errors.rb +11 -0
- data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
- data/lib/azure/sql_database_management/serialization.rb +40 -53
- data/lib/azure/sql_database_management/sql_database_management_service.rb +141 -130
- data/lib/azure/sql_database_management/{sql_database.rb → sql_server.rb} +4 -3
- data/lib/azure/storage_management/storage_management_service.rb +9 -10
- data/lib/azure/table/auth/shared_key.rb +17 -50
- data/lib/azure/table/auth/shared_key_lite.rb +3 -3
- data/lib/azure/table/serialization.rb +24 -24
- data/lib/azure/table/table_service.rb +21 -18
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +6 -12
- data/lib/azure/virtual_machine_management/serialization.rb +4 -1
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +29 -37
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +5 -6
- data/test/fixtures/list_locations.xml +150 -0
- data/test/fixtures/list_sql_database.xml +6 -18
- data/test/fixtures/list_sql_server_firewall.xml +18 -18
- data/test/fixtures/management_certificate.pfx +0 -0
- data/test/fixtures/virtual_machine.xml +1 -0
- data/test/integration/affinity_group/Create_Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Update_Affinity_test.rb +4 -0
- data/test/integration/blob/blob_gb18030_test.rb +29 -29
- data/test/integration/blob/blob_pages_test.rb +16 -16
- data/test/integration/blob/container/create_container_test.rb +6 -6
- data/test/integration/blob/container/root_container_test.rb +2 -1
- data/test/integration/database/create_sql_server_firewall_test.rb +26 -31
- data/test/integration/database/create_sql_server_test.rb +6 -6
- data/test/integration/database/delete_sql_server_firewall_test.rb +18 -24
- data/test/integration/database/delete_sql_server_test.rb +9 -22
- data/test/integration/database/list_sql_server_firewall_test.rb +7 -8
- data/test/integration/database/list_sql_servers_test.rb +4 -4
- data/test/integration/database/reset_password_sql_server_test.rb +9 -11
- data/test/integration/location/RoleSize_List_test.rb +35 -0
- data/test/integration/queue/list_queues_test.rb +0 -1
- data/test/integration/service_bus/queues_scenario_test.rb +11 -11
- data/test/integration/service_bus/queues_test.rb +2 -2
- data/test/integration/service_bus/subscriptions_test.rb +25 -25
- data/test/integration/service_bus/topics_scenario_test.rb +6 -6
- data/test/integration/service_bus/topics_test.rb +15 -15
- data/test/integration/table/query_entities_test.rb +1 -0
- data/test/integration/table/table_acl_test.rb +9 -9
- data/test/integration/test_helper.rb +11 -9
- data/test/integration/vm/VM_Create_test.rb +23 -20
- data/test/integration/vnet/Virtual_Network_list_test.rb +1 -1
- data/test/test_helper.rb +5 -0
- data/test/unit/affinity_group/affinity_group_test.rb +4 -4
- data/test/unit/base_management/base_management_service_test.rb +19 -0
- data/test/unit/base_management/location_test.rb +6 -6
- data/test/unit/base_management/role_size_test.rb +50 -0
- data/test/unit/blob/auth/shared_access_signature_test.rb +19 -19
- data/test/unit/blob/blob_service_test.rb +583 -582
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +2 -2
- data/test/unit/config/azure_test.rb +112 -0
- data/test/unit/config/client_test.rb +37 -0
- data/test/unit/core/auth/shared_key_lite_test.rb +15 -15
- data/test/unit/core/auth/shared_key_test.rb +26 -26
- data/test/unit/core/http/http_error_test.rb +13 -14
- data/test/unit/core/http/http_request_test.rb +78 -53
- data/test/unit/core/http/http_response_test.rb +2 -27
- data/test/unit/core/http/retry_policy_test.rb +3 -3
- data/test/unit/core/utility_test.rb +122 -0
- data/test/unit/database/serialization_test.rb +17 -20
- data/test/unit/database/sql_database_server_service_test.rb +97 -40
- data/test/unit/http_client_test.rb +74 -0
- data/test/unit/service/storage_service_test.rb +105 -101
- data/test/unit/storage_management/storage_management_service_test.rb +28 -28
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +4 -4
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +37 -20
- data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
- metadata +91 -20
- data/lib/azure/core.rb +0 -41
- data/lib/azure/core/configuration.rb +0 -218
data/lib/azure/core.rb
DELETED
@@ -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
|