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/queue/queue.rb
CHANGED
@@ -19,9 +19,9 @@ module Azure
|
|
19
19
|
module Queue
|
20
20
|
class QueueService < Service::StorageService
|
21
21
|
|
22
|
-
def initialize
|
23
|
-
super()
|
24
|
-
@host =
|
22
|
+
def initialize(options = {})
|
23
|
+
super(nil, nil, options)
|
24
|
+
@host = @client.storage_queue_host
|
25
25
|
end
|
26
26
|
|
27
27
|
# Public: Get a list of Queues from the server
|
@@ -565,4 +565,6 @@ module Azure
|
|
565
565
|
end
|
566
566
|
end
|
567
567
|
end
|
568
|
-
end
|
568
|
+
end
|
569
|
+
|
570
|
+
Azure::QueueService = Azure::Queue::QueueService
|
@@ -20,10 +20,12 @@ module Azure
|
|
20
20
|
class StorageService < Azure::Core::SignedService
|
21
21
|
# Create a new instance of the StorageService
|
22
22
|
#
|
23
|
-
# signer
|
24
|
-
#
|
25
|
-
|
26
|
-
|
23
|
+
# @param signer [Azure::Core::Auth::Signer] An implementation of Signer used for signing requests.
|
24
|
+
# (optional, Default=Azure::Core::Auth::SharedKey.new)
|
25
|
+
# @param account_name [String] The account name (optional, Default=Azure.config.storage_account_name)
|
26
|
+
# @param options [Azure::Configurable] the client configuration context
|
27
|
+
def initialize(signer=Core::Auth::SharedKey.new, account_name=nil, options = {})
|
28
|
+
super(signer, account_name, options)
|
27
29
|
end
|
28
30
|
|
29
31
|
|
@@ -62,7 +64,7 @@ module Azure
|
|
62
64
|
# Returns a URI.
|
63
65
|
def service_properties_uri(query={})
|
64
66
|
query.update(restype: 'service', comp: 'properties')
|
65
|
-
generate_uri(
|
67
|
+
generate_uri('', query)
|
66
68
|
end
|
67
69
|
|
68
70
|
# Adds metadata properties to header hash with required prefix
|
@@ -76,8 +78,9 @@ module Azure
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def service_properties_headers
|
79
|
-
{
|
81
|
+
{'x-ms-version' => '2014-02-14'}
|
80
82
|
end
|
83
|
+
|
81
84
|
end
|
82
85
|
end
|
83
86
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module Azure
|
4
|
+
module ServiceBus
|
5
|
+
module Auth
|
6
|
+
class SharedAccessSigner < Azure::Core::Auth::Signer
|
7
|
+
|
8
|
+
# The number of seconds from the time of signature that the SAS token will expire
|
9
|
+
attr_accessor :expiry_offset, :key_name
|
10
|
+
|
11
|
+
# Public: Initialize the Signer.
|
12
|
+
#
|
13
|
+
# @param key_name [String] The service bus SAS key name. Defaults to the one in the global configuration.
|
14
|
+
# @param key [String] The service bus SAS key encoded in Base64. Defaults to the one in the global configuration.
|
15
|
+
# @param expiry_offset [Integer] The number of seconds from the time of signature that the SAS token will expire. Defaults to 30 minutes.
|
16
|
+
def initialize(key_name=Azure.sb_sas_key_name, key=Azure.sb_sas_key, expiry_offset = 60*5)
|
17
|
+
super(key)
|
18
|
+
@key_name, @expiry_offset = key_name, expiry_offset
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
'SharedAccessSignature'
|
23
|
+
end
|
24
|
+
|
25
|
+
def token(uri)
|
26
|
+
url_encoded_resource = CGI.escape(uri.to_s.downcase).gsub('+', '%20').downcase
|
27
|
+
expiry = Time.now.to_i + expiry_offset
|
28
|
+
sig = CGI.escape(signature(url_encoded_resource, expiry)).gsub('+', '%20')
|
29
|
+
"#{name} sig=#{sig}&se=#{expiry}&skn=#{key_name}&sr=#{url_encoded_resource}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def sign_request(req)
|
33
|
+
req.headers['Authorization'] = token(req.uri)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def signature(url_encoded_resource, expiry)
|
39
|
+
sign([url_encoded_resource, expiry].join("\n"))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -20,10 +20,11 @@ module Azure
|
|
20
20
|
module Auth
|
21
21
|
class WrapService < Azure::Core::FilteredService
|
22
22
|
|
23
|
-
def initialize(host=
|
24
|
-
|
25
|
-
|
26
|
-
@
|
23
|
+
def initialize(host=nil, issuer=nil, access_key=nil, options={})
|
24
|
+
host = host || (options[:client] || Azure).acs_host
|
25
|
+
super(host, options)
|
26
|
+
@issuer = issuer || client.sb_issuer
|
27
|
+
@access_key = access_key || client.sb_access_key
|
27
28
|
end
|
28
29
|
|
29
30
|
# Gets a WRAP access token with specified parameters.
|
@@ -12,28 +12,36 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
15
|
+
require 'uri'
|
16
16
|
|
17
|
-
require
|
18
|
-
require
|
17
|
+
require 'azure/core/auth/signer'
|
18
|
+
require 'azure/service_bus/auth/wrap_service'
|
19
19
|
|
20
20
|
module Azure
|
21
21
|
module ServiceBus
|
22
22
|
module Auth
|
23
23
|
class WrapSigner < Azure::Core::Auth::Signer
|
24
24
|
|
25
|
-
def initialize
|
25
|
+
def initialize(host = nil, options={})
|
26
|
+
client = (options[:client] || Azure)
|
27
|
+
host = host || client.acs_host
|
26
28
|
@tokens = {}
|
27
|
-
@wrap_service = Azure::ServiceBus::Auth::WrapService.new
|
29
|
+
@wrap_service = Azure::ServiceBus::Auth::WrapService.new(host, nil, nil, options)
|
28
30
|
end
|
29
31
|
|
30
32
|
attr_accessor :tokens
|
31
33
|
|
32
34
|
def name
|
33
|
-
|
35
|
+
'WRAP'
|
34
36
|
end
|
35
37
|
|
36
38
|
public
|
39
|
+
|
40
|
+
def sign_request(req)
|
41
|
+
signature = sign(req.method, req.uri, req.headers)
|
42
|
+
req.headers['Authorization'] = "#{name} #{signature}"
|
43
|
+
end
|
44
|
+
|
37
45
|
def sign(method, uri, headers)
|
38
46
|
access_token = get_access_token(create_scope_uri(uri))
|
39
47
|
'access_token="%s"' % access_token
|
@@ -14,6 +14,7 @@
|
|
14
14
|
#--------------------------------------------------------------------------
|
15
15
|
require 'azure/core/signed_service'
|
16
16
|
require 'azure/service_bus/auth/wrap_signer'
|
17
|
+
require 'azure/service_bus/auth/shared_access_signer'
|
17
18
|
require 'azure/service_bus/serialization'
|
18
19
|
|
19
20
|
require 'azure/service_bus/brokered_message_serializer'
|
@@ -25,18 +26,20 @@ module Azure
|
|
25
26
|
|
26
27
|
DEFAULT_TIMEOUT = 60
|
27
28
|
|
28
|
-
def initialize(host=
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
def initialize(host=nil, options = {})
|
30
|
+
client_config = options[:client] || Azure
|
31
|
+
signer = options[:signer] || Auth::WrapSigner.new(client_config.acs_host, client: client_config)
|
32
|
+
super(signer, nil, options)
|
33
|
+
@host = host || @client.config.service_bus_host
|
34
|
+
|
35
|
+
with_filter do |req, res|
|
36
|
+
req.headers.delete 'x-ms-date'
|
37
|
+
req.headers.delete 'x-ms-version'
|
38
|
+
req.headers.delete 'DataServiceVersion'
|
39
|
+
req.headers.delete 'MaxDataServiceVersion'
|
40
|
+
req.headers['X-Process-At'] = 'servicebus'
|
41
|
+
res.call
|
42
|
+
end
|
40
43
|
end
|
41
44
|
|
42
45
|
# Creates a new relay endpoint. Once created, this relay endpoint resource manifest is immutable.
|
@@ -140,7 +143,7 @@ module Azure
|
|
140
143
|
def get_queue(queue)
|
141
144
|
resource_entry(:queue, _name_for(queue))
|
142
145
|
end
|
143
|
-
|
146
|
+
|
144
147
|
# Enumerates the queues in the service namespace.
|
145
148
|
#
|
146
149
|
# ==== Attributes
|
@@ -159,7 +162,7 @@ module Azure
|
|
159
162
|
|
160
163
|
resource_list(:queue, query)
|
161
164
|
end
|
162
|
-
|
165
|
+
|
163
166
|
# Creates a new topic. Once created, this topic resource manifest is immutable.
|
164
167
|
#
|
165
168
|
# ==== Attributes
|
@@ -295,7 +298,7 @@ module Azure
|
|
295
298
|
query["$top"] = options[:top].to_i.to_s if options[:top]
|
296
299
|
|
297
300
|
results = resource_list(:rule, topic_name, subscription_name, query)
|
298
|
-
results.each{|r| r.topic = topic_name; r.subscription=subscription_name}
|
301
|
+
results.each { |r| r.topic = topic_name; r.subscription=subscription_name }
|
299
302
|
|
300
303
|
return results
|
301
304
|
end
|
@@ -349,7 +352,7 @@ module Azure
|
|
349
352
|
# such as Azure::ServiceBus::Subscription instance.
|
350
353
|
def get_subscription(*p)
|
351
354
|
topic_name, subscription_name = _subscription_args(*p)
|
352
|
-
|
355
|
+
|
353
356
|
result = resource_entry(:subscription, topic_name, subscription_name)
|
354
357
|
result.topic = topic_name
|
355
358
|
result
|
@@ -378,7 +381,7 @@ module Azure
|
|
378
381
|
|
379
382
|
return results
|
380
383
|
end
|
381
|
-
|
384
|
+
|
382
385
|
# Enqueues a message into the specified topic. The limit to the number of messages
|
383
386
|
# which may be present in the topic is governed by the message size in MaxTopicSizeInBytes.
|
384
387
|
# If this message causes the topic to exceed its quota, a quota exceeded error is
|
@@ -612,12 +615,11 @@ module Azure
|
|
612
615
|
end
|
613
616
|
|
614
617
|
def _modify_message(method, message)
|
615
|
-
uri =
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
end
|
618
|
+
uri = if (message.respond_to? :location)
|
619
|
+
message.location
|
620
|
+
else
|
621
|
+
message
|
622
|
+
end
|
621
623
|
|
622
624
|
call(method, uri)
|
623
625
|
nil
|
@@ -633,10 +635,10 @@ module Azure
|
|
633
635
|
content_type = message.content_type || 'text/plain'
|
634
636
|
|
635
637
|
headers = {
|
636
|
-
|
638
|
+
'BrokerProperties' => broker_properties
|
637
639
|
}
|
638
640
|
|
639
|
-
message_properties.each do |k,v|
|
641
|
+
message_properties.each do |k, v|
|
640
642
|
headers[k.to_s.encode("UTF-8")] = v.encode("UTF-8")
|
641
643
|
end
|
642
644
|
|
@@ -655,7 +657,7 @@ module Azure
|
|
655
657
|
end
|
656
658
|
|
657
659
|
def _retrieve_message(method, path, timeout=DEFAULT_TIMEOUT)
|
658
|
-
uri = messages_head_uri(path, {
|
660
|
+
uri = messages_head_uri(path, {"timeout" => timeout.to_s})
|
659
661
|
|
660
662
|
response = call(method, uri)
|
661
663
|
(response.status_code == 204) ? nil : BrokeredMessageSerializer.get_from_http_response(response)
|
@@ -665,7 +667,7 @@ module Azure
|
|
665
667
|
rule = nil
|
666
668
|
|
667
669
|
if p.length == 3 or p.length == 4
|
668
|
-
rule = Azure::ServiceBus::Rule.new(p[2]) do |r|
|
670
|
+
rule = Azure::ServiceBus::Rule.new(p[2]) do |r|
|
669
671
|
r.topic = p[0]
|
670
672
|
r.subscription = p[1]
|
671
673
|
r.description = p[3] if p.length == 4
|
@@ -699,11 +701,11 @@ module Azure
|
|
699
701
|
subscription = nil
|
700
702
|
|
701
703
|
if p.length == 3
|
702
|
-
subscription = Azure::ServiceBus::Subscription.new(p[1], p[2]) do |sub|
|
704
|
+
subscription = Azure::ServiceBus::Subscription.new(p[1], p[2]) do |sub|
|
703
705
|
sub.topic = p[0]
|
704
706
|
end
|
705
707
|
elsif p.length == 2
|
706
|
-
subscription = Azure::ServiceBus::Subscription.new(p[1]) do |sub|
|
708
|
+
subscription = Azure::ServiceBus::Subscription.new(p[1]) do |sub|
|
707
709
|
sub.topic = p[0]
|
708
710
|
end
|
709
711
|
elsif p.length == 1 and p[0].respond_to? :name and p[0].respond_to? :topic and p[0].respond_to? :description
|
@@ -892,4 +894,6 @@ module Azure
|
|
892
894
|
end
|
893
895
|
end
|
894
896
|
end
|
895
|
-
end
|
897
|
+
end
|
898
|
+
|
899
|
+
Azure::ServiceBusService = Azure::ServiceBus::ServiceBusService
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
module Azure
|
3
|
+
module SqlDatabaseManagement
|
4
|
+
# Generic error for SQL Management activities
|
5
|
+
class Error < Azure::Core::Error;end
|
6
|
+
# Server does not exist error for SQL Management activities
|
7
|
+
class ServerDoesNotExist < Azure::Core::Error;end
|
8
|
+
# Firewall Rule does not exist error for SQL Management activities
|
9
|
+
class RuleDoesNotExist < Azure::Core::Error;end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# Copyright 2015 Microsoft Open Technologies, Inc.
|
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
|
+
module Azure
|
16
|
+
module SqlDatabaseManagement
|
17
|
+
class FirewallRule
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
yield self if block_given?
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_accessor :name
|
24
|
+
attr_accessor :type
|
25
|
+
attr_accessor :start_ip_address
|
26
|
+
attr_accessor :end_ip_address
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -12,101 +12,88 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require 'azure/sql_database_management/
|
15
|
+
require 'azure/sql_database_management/sql_server'
|
16
|
+
require 'azure/sql_database_management/firewall_rule'
|
16
17
|
|
17
18
|
module Azure
|
18
19
|
module SqlDatabaseManagement
|
19
20
|
module Serialization
|
20
21
|
extend Azure::Core::Utility
|
21
22
|
|
22
|
-
def self.
|
23
|
+
def self.server_to_xml(login, password, location, version = 12.0)
|
23
24
|
builder = Nokogiri::XML::Builder.new do |xml|
|
24
|
-
xml.Server('xmlns'=>'http://schemas.microsoft.com/sqlazure/2010/12/') {
|
25
|
+
xml.Server('xmlns' => 'http://schemas.microsoft.com/sqlazure/2010/12/') {
|
25
26
|
xml.AdministratorLogin login
|
26
27
|
xml.AdministratorLoginPassword password
|
27
28
|
xml.Location location
|
29
|
+
xml.Version version
|
28
30
|
}
|
29
31
|
end
|
30
32
|
builder.doc.to_xml
|
31
33
|
end
|
32
34
|
|
33
|
-
def self.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
def self.servers_from_xml(wrapper_XML)
|
36
|
+
servers_XML = wrapper_XML.css('Servers Server')
|
37
|
+
servers_XML.map do |server_xml|
|
38
|
+
server = SqlServer.new
|
39
|
+
server.name = xml_content(server_xml, 'Name')
|
40
|
+
server.administrator_login = xml_content(server_xml, 'AdministratorLogin')
|
41
|
+
server.location = xml_content(server_xml, 'Location')
|
42
|
+
server.version = xml_content(server_xml, 'Version')
|
43
|
+
server.state = xml_content(server_xml, 'State')
|
44
|
+
server.fully_qualified_domain_name = xml_content(server_xml, 'FullyQualifiedDomainName')
|
45
|
+
server
|
44
46
|
end
|
45
|
-
databases.compact
|
46
47
|
end
|
47
48
|
|
48
|
-
def self.server_name_from_xml(response_xml, login, location)
|
49
|
+
def self.server_name_from_xml(response_xml, login, location, version)
|
49
50
|
server_name = xml_content(response_xml, 'ServerName')
|
50
|
-
|
51
|
+
SqlServer.new do |db|
|
51
52
|
db.name = server_name
|
52
53
|
db.location = location
|
53
54
|
db.administrator_login = login
|
55
|
+
db.version = version
|
56
|
+
db.fully_qualified_domain_name = response_xml.css('ServerName').first['FullyQualifiedDomainName']
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
60
|
def self.reset_password_to_xml(password)
|
58
61
|
builder = Nokogiri::XML::Builder.new do |xml|
|
59
|
-
xml.AdministratorLoginPassword(password, {'xmlns'=>'http://schemas.microsoft.com/sqlazure/2010/12/'})
|
62
|
+
xml.AdministratorLoginPassword(password, {'xmlns' => 'http://schemas.microsoft.com/sqlazure/2010/12/'})
|
60
63
|
end
|
61
64
|
builder.doc.to_xml
|
62
65
|
end
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
# Serialize a firewall rule to xml
|
68
|
+
# @param rule [Azure::SqlDatabaseManagement::FirewallRule] The firewall rule to serialize
|
69
|
+
# @return [String] xml document contain the firewall rule
|
70
|
+
def self.firewall_rule_to_xml(rule)
|
68
71
|
builder = Nokogiri::XML::Builder.new do |xml|
|
69
|
-
xml.
|
70
|
-
|
71
|
-
|
72
|
-
xml.
|
73
|
-
xml.EndIpAddress options[:end_ip_address]
|
72
|
+
xml.ServiceResource('xmlns' => 'http://schemas.microsoft.com/windowsazure') {
|
73
|
+
xml.Name rule.name
|
74
|
+
xml.StartIPAddress rule.start_ip_address
|
75
|
+
xml.EndIPAddress rule.end_ip_address
|
74
76
|
}
|
75
77
|
end
|
76
78
|
builder.doc.to_xml
|
77
79
|
end
|
78
80
|
|
81
|
+
# Create a list of firewall hashes from xml
|
82
|
+
# @param response_xml The xml containing the list of ServiceResources (firewall rules)
|
83
|
+
# @return [Array<Azure::SqlDatabaseManagement::FirewallRule>]
|
79
84
|
def self.database_firewall_from_xml(response_xml)
|
80
|
-
|
81
|
-
if Azure.config.sql_database_authentication_mode == :sql_server
|
82
|
-
database_firewallXML = response_xml.css('FirewallRules FirewallRule')
|
83
|
-
database_firewallXML.each do |firewall_xml|
|
84
|
-
firewall = {
|
85
|
-
:rule => xml_content(firewall_xml, 'Name'),
|
86
|
-
:start_ip_address => xml_content(firewall_xml, 'StartIpAddress'),
|
87
|
-
:end_ip_address => xml_content(firewall_xml, 'EndIpAddress')
|
88
|
-
}
|
89
|
-
firewalls << firewall
|
90
|
-
end
|
91
|
-
else
|
92
|
-
service_resources = response_xml.css(
|
85
|
+
service_resources = response_xml.css(
|
93
86
|
'ServiceResources ServiceResource'
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end_ip_address: xml_content(resource, 'EndIPAddress')
|
102
|
-
}
|
103
|
-
firewalls << firewall
|
104
|
-
end
|
87
|
+
)
|
88
|
+
service_resources.map do |resource|
|
89
|
+
FirewallRule.new do |rule|
|
90
|
+
rule.name = xml_content(resource, 'Name')
|
91
|
+
rule.type = xml_content(resource, 'Type')
|
92
|
+
rule.start_ip_address = xml_content(resource, 'StartIPAddress')
|
93
|
+
rule.end_ip_address = xml_content(resource, 'EndIPAddress')
|
105
94
|
end
|
106
95
|
end
|
107
|
-
firewalls.compact
|
108
96
|
end
|
109
|
-
|
110
97
|
end
|
111
98
|
end
|
112
99
|
end
|