azure 0.6.4 → 0.7.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env_sample +11 -0
- data/.gitignore +4 -1
- data/.travis.yml +3 -1
- data/ChangeLog.txt +17 -1
- data/LICENSE.txt +202 -0
- data/README.md +58 -20
- data/Rakefile +27 -35
- data/azure.gemspec +17 -13
- data/bin/pfxer +35 -0
- data/lib/azure.rb +8 -0
- data/lib/azure/base_management/base_management_service.rb +24 -26
- data/lib/azure/base_management/management_http_request.rb +17 -14
- data/lib/azure/base_management/serialization.rb +1 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
- data/lib/azure/blob/blob_service.rb +221 -217
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +27 -30
- data/lib/azure/cloud_service_management/serialization.rb +1 -0
- data/lib/azure/core.rb +17 -15
- data/lib/azure/core/configuration.rb +7 -0
- data/lib/azure/core/http/http_error.rb +1 -1
- data/lib/azure/core/http/http_request.rb +4 -1
- data/lib/azure/core/utility.rb +16 -1
- data/lib/azure/queue/queue_service.rb +13 -13
- data/lib/azure/service/cors.rb +11 -0
- data/lib/azure/service/cors_rule.rb +15 -0
- data/lib/azure/service/serialization.rb +69 -10
- data/lib/azure/service/storage_service.rb +10 -6
- data/lib/azure/service/storage_service_properties.rb +8 -3
- data/lib/azure/service_bus/brokered_message.rb +1 -1
- data/lib/azure/service_bus/relay.rb +88 -0
- data/lib/azure/service_bus/serialization.rb +1 -0
- data/lib/azure/service_bus/service_bus_service.rb +70 -4
- data/lib/azure/sql_database_management/serialization.rb +1 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +22 -22
- data/lib/azure/storage_management/serialization.rb +34 -14
- data/lib/azure/storage_management/storage_account.rb +9 -1
- data/lib/azure/storage_management/storage_management_service.rb +74 -32
- data/lib/azure/table/batch.rb +6 -6
- data/lib/azure/table/table_service.rb +13 -13
- data/lib/azure/version.rb +3 -3
- data/lib/azure/virtual_machine_image_management/serialization.rb +19 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +30 -7
- data/lib/azure/virtual_machine_management/serialization.rb +32 -12
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +92 -81
- data/lib/azure/virtual_network_management/serialization.rb +12 -5
- data/lib/azure/virtual_network_management/virtual_network.rb +1 -0
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +11 -11
- data/test/fixtures/get_storage_account_properties.xml +6 -4
- data/test/fixtures/{list_images.xml → list_os_images.xml} +1 -1
- data/test/fixtures/list_storage_accounts.xml +2 -0
- data/test/fixtures/list_vm_images.xml +21 -0
- data/test/fixtures/metrics.xml +2 -2
- data/test/fixtures/sb_default_create_relay_response.xml +15 -0
- data/test/fixtures/storage_service_keys.xml +8 -0
- data/test/fixtures/storage_service_properties.xml +35 -3
- data/test/fixtures/updated_storage_accounts.xml +2 -0
- data/test/fixtures/virtual_machine.xml +3 -1
- data/test/integration/affinity_group/Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Create_Affinity_test.rb +8 -7
- data/test/integration/affinity_group/Delete_Affinity_test.rb +3 -3
- data/test/integration/affinity_group/List_Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Update_Affinity_test.rb +9 -8
- data/test/integration/cloud_service/Cloud_Create_test.rb +3 -2
- data/test/integration/cloud_service/Cloud_Delete_test.rb +5 -4
- data/test/integration/database/create_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/create_sql_server_test.rb +1 -1
- data/test/integration/database/delete_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/delete_sql_server_test.rb +1 -1
- data/test/integration/database/list_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/list_sql_servers_test.rb +1 -1
- data/test/integration/database/reset_password_sql_server_test.rb +1 -1
- data/test/integration/service_bus/queues_test.rb +22 -22
- data/test/integration/service_bus/relay_test.rb +132 -0
- data/test/integration/storage_management/storage_management_test.rb +58 -33
- data/test/integration/test_helper.rb +11 -15
- data/test/integration/vm/VM_Create_test.rb +17 -18
- data/test/integration/vm/VM_Delete_test.rb +2 -4
- data/test/integration/vm/VM_Operations_test.rb +1 -2
- data/test/integration/vnet/Virtual_Network_Create_test.rb +9 -15
- data/test/integration/vnet/Virtual_Network_list_test.rb +4 -9
- data/test/support/name_generator.rb +8 -0
- data/test/support/virtual_network_helper.rb +2 -2
- data/test/test_helper.rb +13 -24
- data/test/unit/affinity_group/affinity_group_test.rb +10 -13
- data/test/unit/affinity_group/serialization_test.rb +7 -8
- data/test/unit/base_management/location_test.rb +1 -2
- data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
- data/test/unit/blob/blob_service_test.rb +393 -371
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +16 -16
- data/test/unit/core/auth/shared_key_lite_test.rb +4 -4
- data/test/unit/core/auth/shared_key_test.rb +2 -2
- data/test/unit/core/http/http_error_test.rb +10 -5
- data/test/unit/core/http/http_request_test.rb +72 -25
- data/test/unit/database/serialization_test.rb +7 -7
- data/test/unit/database/sql_database_server_service_test.rb +43 -47
- data/test/unit/service/serialization_test.rb +40 -9
- data/test/unit/service/storage_service_test.rb +13 -11
- data/test/unit/storage_management/serialization_test.rb +26 -14
- data/test/unit/storage_management/storage_management_service_test.rb +48 -62
- data/test/unit/virtual_machine_image_management/serialization_test.rb +20 -5
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +78 -29
- data/test/unit/virtual_machine_management/serialization_test.rb +112 -43
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +123 -100
- data/test/unit/vnet/serialization_test.rb +7 -7
- data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
- metadata +70 -16
- data/test/fixtures/certificate.pem +0 -21
@@ -16,12 +16,14 @@ require 'azure/cloud_service_management/serialization'
|
|
16
16
|
|
17
17
|
module Azure
|
18
18
|
module CloudServiceManagement
|
19
|
-
class CloudServiceManagementService < BaseManagementService
|
19
|
+
class CloudServiceManagementService < BaseManagement::BaseManagementService
|
20
|
+
include Azure::Core::Utility
|
21
|
+
|
20
22
|
def initialize
|
21
23
|
super()
|
22
24
|
end
|
23
25
|
|
24
|
-
# Public: Creates a new cloud service in
|
26
|
+
# Public: Creates a new cloud service in Microsoft Azure.
|
25
27
|
#
|
26
28
|
# ==== Attributes
|
27
29
|
#
|
@@ -43,18 +45,18 @@ module Azure
|
|
43
45
|
# properties to add to the cloud service. The key is used as the
|
44
46
|
# property name and the value as its value. (optional)
|
45
47
|
#
|
46
|
-
# See http://msdn.microsoft.com/en-us/library/
|
48
|
+
# See http://msdn.microsoft.com/en-us/library/azure/gg441304.aspx
|
47
49
|
#
|
48
50
|
# Returns None
|
49
51
|
def create_cloud_service(name, options = {})
|
50
|
-
Loggerx.error_with_exit 'Cloud service name is not valid ' unless name
|
52
|
+
Azure::Loggerx.error_with_exit 'Cloud service name is not valid ' unless name
|
51
53
|
if get_cloud_service(name)
|
52
|
-
Loggerx.warn "Cloud service #{name} already exists. Skipped..."
|
54
|
+
Azure::Loggerx.warn "Cloud service #{name} already exists. Skipped..."
|
53
55
|
else
|
54
|
-
Loggerx.info "Creating cloud service #{name}."
|
56
|
+
Azure::Loggerx.info "Creating cloud service #{name}."
|
55
57
|
request_path = '/services/hostedservices'
|
56
58
|
body = Serialization.cloud_services_to_xml(name, options)
|
57
|
-
request = ManagementHttpRequest.new(:post, request_path, body)
|
59
|
+
request = BaseManagement::ManagementHttpRequest.new(:post, request_path, body)
|
58
60
|
request.call
|
59
61
|
end
|
60
62
|
end
|
@@ -64,7 +66,7 @@ module Azure
|
|
64
66
|
# Returns an array of Azure::CloudServiceManagement::CloudService objects
|
65
67
|
def list_cloud_services
|
66
68
|
request_path = '/services/hostedservices'
|
67
|
-
request = ManagementHttpRequest.new(:get, request_path, nil)
|
69
|
+
request = BaseManagement::ManagementHttpRequest.new(:get, request_path, nil)
|
68
70
|
response = request.call
|
69
71
|
Serialization.cloud_services_from_xml(response)
|
70
72
|
end
|
@@ -79,25 +81,17 @@ module Azure
|
|
79
81
|
# If true, the cloud service is available. If false, the cloud service
|
80
82
|
# does not exist.
|
81
83
|
def get_cloud_service(name)
|
82
|
-
|
83
|
-
flag = false
|
84
|
-
list_cloud_services.each do |cloud_service|
|
85
|
-
if cloud_service.name == name
|
86
|
-
flag = true
|
87
|
-
break
|
88
|
-
end
|
89
|
-
end
|
90
|
-
flag
|
84
|
+
list_cloud_services.select { |x| x.name.casecmp(name) == 0 }.first
|
91
85
|
end
|
92
86
|
|
93
87
|
def get_cloud_service_properties(name)
|
94
88
|
request_path = "/services/hostedservices/#{name}?embed-detail=true"
|
95
|
-
request = ManagementHttpRequest.new(:get, request_path)
|
89
|
+
request = BaseManagement::ManagementHttpRequest.new(:get, request_path)
|
96
90
|
response = request.call
|
97
91
|
Serialization.cloud_services_from_xml(response).first
|
98
92
|
end
|
99
93
|
|
100
|
-
# Public: Deletes the specified cloud service of given subscription id from
|
94
|
+
# Public: Deletes the specified cloud service of given subscription id from Microsoft Azure.
|
101
95
|
#
|
102
96
|
# ==== Attributes
|
103
97
|
#
|
@@ -105,9 +99,9 @@ module Azure
|
|
105
99
|
#
|
106
100
|
# Returns: None
|
107
101
|
def delete_cloud_service(cloud_service_name)
|
108
|
-
request_path
|
109
|
-
request = ManagementHttpRequest.new(:delete, request_path)
|
110
|
-
Loggerx.info "Deleting cloud service #{cloud_service_name}. \n"
|
102
|
+
request_path= "/services/hostedservices/#{cloud_service_name}"
|
103
|
+
request = BaseManagement::ManagementHttpRequest.new(:delete, request_path)
|
104
|
+
Azure::Loggerx.info "Deleting cloud service #{cloud_service_name}. \n"
|
111
105
|
request.call
|
112
106
|
end
|
113
107
|
|
@@ -116,23 +110,26 @@ module Azure
|
|
116
110
|
# ==== Attributes
|
117
111
|
#
|
118
112
|
# * +cloud_service_name+ - String. Cloud service name.
|
113
|
+
# * +slot+ - String. 'production' or 'staging'. Optional parameters.
|
114
|
+
# Default if not specified is 'production'
|
119
115
|
#
|
120
|
-
# See http://msdn.microsoft.com/en-us/library/
|
116
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee460815.aspx
|
121
117
|
#
|
122
118
|
# Returns NONE
|
123
|
-
def delete_cloud_service_deployment(cloud_service_name)
|
124
|
-
|
125
|
-
|
126
|
-
|
119
|
+
def delete_cloud_service_deployment(cloud_service_name, slot='production')
|
120
|
+
slot = 'production' unless slot
|
121
|
+
request_path= "/services/hostedservices/#{cloud_service_name}/deploymentslots/#{slot}"
|
122
|
+
request = BaseManagement::ManagementHttpRequest.new(:delete, request_path)
|
123
|
+
Azure::Loggerx.info "Deleting deployment of cloud service \"#{cloud_service_name}\" ..."
|
127
124
|
request.call
|
128
125
|
end
|
129
126
|
|
130
127
|
def upload_certificate(cloud_service_name, ssh)
|
131
128
|
data = export_der(ssh[:cert], ssh[:key])
|
132
|
-
request_path
|
129
|
+
request_path= "/services/hostedservices/#{cloud_service_name}/certificates"
|
133
130
|
body = Serialization.add_certificate_to_xml(data)
|
134
|
-
Loggerx.info "Uploading certificate to cloud service #{cloud_service_name}..."
|
135
|
-
request = ManagementHttpRequest.new(:post, request_path, body)
|
131
|
+
Azure::Loggerx.info "Uploading certificate to cloud service #{cloud_service_name}..."
|
132
|
+
request = BaseManagement::ManagementHttpRequest.new(:post, request_path, body)
|
136
133
|
request.call
|
137
134
|
end
|
138
135
|
end
|
@@ -19,6 +19,7 @@ require 'azure/virtual_machine_management/serialization'
|
|
19
19
|
module Azure
|
20
20
|
module CloudServiceManagement
|
21
21
|
module Serialization
|
22
|
+
extend Azure::Core::Utility
|
22
23
|
def self.cloud_services_to_xml(name, options = {})
|
23
24
|
options[:label] = options[:label] || name
|
24
25
|
|
data/lib/azure/core.rb
CHANGED
@@ -15,25 +15,27 @@
|
|
15
15
|
|
16
16
|
module Azure::Core; end
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require 'azure/core/error'
|
19
|
+
require 'azure/core/configuration'
|
20
20
|
|
21
21
|
# load default configuration from environment variables
|
22
22
|
# (user can always override this later)
|
23
23
|
Azure.configure do |config|
|
24
|
-
config.storage_access_key = ENV[
|
25
|
-
config.storage_account_name = ENV[
|
26
|
-
config.storage_table_host = ENV[
|
27
|
-
config.storage_blob_host = ENV[
|
28
|
-
config.storage_queue_host = ENV[
|
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
29
|
|
30
|
-
config.sb_namespace = ENV[
|
31
|
-
config.sb_access_key = ENV[
|
32
|
-
config.sb_issuer = ENV[
|
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
33
|
|
34
|
-
config.management_certificate = ENV[
|
35
|
-
config.subscription_id = ENV[
|
36
|
-
config.management_endpoint = ENV[
|
37
|
-
config.sql_database_management_endpoint = ENV[
|
38
|
-
config.sql_database_authentication_mode = ENV[
|
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']
|
39
41
|
end
|
@@ -66,6 +66,13 @@ module Azure
|
|
66
66
|
# Public: Set the Service Bus Issuer for this service.
|
67
67
|
attr_writer :sb_issuer
|
68
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
|
+
|
69
76
|
# Public: Get the issuer for the service bus. If you set something using #sb_issuer=,
|
70
77
|
# then we use that. Otherwise, we default to the default issuer: "owner"
|
71
78
|
def sb_issuer
|
@@ -140,10 +140,13 @@ module Azure
|
|
140
140
|
http = Net::HTTP.new(uri.host, uri.port)
|
141
141
|
end
|
142
142
|
|
143
|
+
http.read_timeout = headers['Keep-Alive'].split('=').last.to_i unless headers.nil? || headers['Keep-Alive'].nil?
|
144
|
+
|
143
145
|
if uri.scheme.downcase == 'https'
|
144
146
|
# require 'net/https'
|
147
|
+
http.ca_file = Azure.config.ca_file if Azure.config.ca_file
|
145
148
|
http.use_ssl = true
|
146
|
-
http.verify_mode = OpenSSL::SSL::
|
149
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
147
150
|
end
|
148
151
|
|
149
152
|
response = HttpResponse.new(http.request(request))
|
data/lib/azure/core/utility.rb
CHANGED
@@ -60,7 +60,7 @@ module Azure
|
|
60
60
|
elsif File.exist?(File.join(ENV['HOME'], name))
|
61
61
|
File.join(ENV['HOME'], name)
|
62
62
|
else
|
63
|
-
Loggerx.error_with_exit "Unable to find #{name} file "
|
63
|
+
Azure::Loggerx.error_with_exit "Unable to find #{name} file "
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -79,6 +79,21 @@ module Azure
|
|
79
79
|
def enable_winrm?(winrm_transport)
|
80
80
|
(!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase == 'http' || x.downcase == 'https' }.size > 0))
|
81
81
|
end
|
82
|
+
|
83
|
+
def get_certificate(private_key_file)
|
84
|
+
rsa = OpenSSL::PKey.read File.read(private_key_file)
|
85
|
+
cert = OpenSSL::X509::Certificate.new
|
86
|
+
cert.version = 2
|
87
|
+
cert.serial = 0
|
88
|
+
name = OpenSSL::X509::Name.new([['CN', 'Azure Management Certificate']])
|
89
|
+
cert.subject = cert.issuer = name
|
90
|
+
cert.not_before = Time.now
|
91
|
+
cert.not_after = cert.not_before + (60*60*24*365)
|
92
|
+
cert.public_key = rsa.public_key
|
93
|
+
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
|
94
|
+
cert
|
95
|
+
end
|
96
|
+
|
82
97
|
end
|
83
98
|
|
84
99
|
# Logger
|
@@ -55,7 +55,7 @@ module Azure
|
|
55
55
|
# service. Beginning with that version, all metadata names must adhere to the naming
|
56
56
|
# conventions for C# identifiers.
|
57
57
|
#
|
58
|
-
# See http://msdn.microsoft.com/en-us/library/
|
58
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179466
|
59
59
|
#
|
60
60
|
# Any metadata with invalid names which were previously stored, will be returned with the
|
61
61
|
# key "x-ms-invalid-name" in the metadata hash. This may contain multiple values and be an
|
@@ -95,7 +95,7 @@ module Azure
|
|
95
95
|
# Accepted key/value pairs in options parameter are:
|
96
96
|
# * +:timeout+ - Integer. A timeout in seconds.
|
97
97
|
#
|
98
|
-
# See http://msdn.microsoft.com/en-us/library/
|
98
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179454
|
99
99
|
#
|
100
100
|
# Returns nil on success
|
101
101
|
def clear_messages(queue_name, options={})
|
@@ -119,7 +119,7 @@ module Azure
|
|
119
119
|
# * +:metadata+ - Hash. A hash of user defined metadata.
|
120
120
|
# * +:timeout+ - Integer. A timeout in seconds.
|
121
121
|
#
|
122
|
-
# See http://msdn.microsoft.com/en-us/library/
|
122
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179342
|
123
123
|
#
|
124
124
|
# Returns nil on success
|
125
125
|
def create_queue(queue_name, options={})
|
@@ -147,7 +147,7 @@ module Azure
|
|
147
147
|
# Accepted key/value pairs in options parameter are:
|
148
148
|
# * +:timeout+ - Integer. A timeout in seconds.
|
149
149
|
#
|
150
|
-
# See http://msdn.microsoft.com/en-us/library/
|
150
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179436
|
151
151
|
#
|
152
152
|
# Returns nil on success
|
153
153
|
def delete_queue(queue_name, options={})
|
@@ -172,7 +172,7 @@ module Azure
|
|
172
172
|
# Accepted key/value pairs in options parameter are:
|
173
173
|
# * +:timeout+ - Integer. A timeout in seconds.
|
174
174
|
#
|
175
|
-
# See http://msdn.microsoft.com/en-us/library/
|
175
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179384
|
176
176
|
#
|
177
177
|
# Returns a tuple of (approximate_message_count, metadata)
|
178
178
|
# * approximate_messages_count - Integer. The approximate number of messages in the queue. This number is not
|
@@ -207,7 +207,7 @@ module Azure
|
|
207
207
|
# Accepted key/value pairs in options parameter are:
|
208
208
|
# * +:timeout+ - Integer. A timeout in seconds.
|
209
209
|
#
|
210
|
-
# See http://msdn.microsoft.com/en-us/library/
|
210
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179348
|
211
211
|
#
|
212
212
|
# Returns nil on success
|
213
213
|
def set_queue_metadata(queue_name, metadata, options={})
|
@@ -235,7 +235,7 @@ module Azure
|
|
235
235
|
# Accepted key/value pairs in options parameter are:
|
236
236
|
# * +:timeout+ - Integer. A timeout in seconds.
|
237
237
|
#
|
238
|
-
# See http://msdn.microsoft.com/en-us/library/
|
238
|
+
# See http://msdn.microsoft.com/en-us/library/azure/jj159101
|
239
239
|
#
|
240
240
|
# Returns a list of Azure::Entity::SignedIdentifier instances
|
241
241
|
def get_queue_acl(queue_name, options={})
|
@@ -262,7 +262,7 @@ module Azure
|
|
262
262
|
# * +:signed_identifiers+ - Array. A list of Azure::Entity::SignedIdentifier instances
|
263
263
|
# * +:timeout+ - Integer. A timeout in seconds.
|
264
264
|
#
|
265
|
-
# See http://msdn.microsoft.com/en-us/library/
|
265
|
+
# See http://msdn.microsoft.com/en-us/library/azure/jj159099
|
266
266
|
#
|
267
267
|
# Returns nil on success
|
268
268
|
def set_queue_acl(queue_name, options={})
|
@@ -298,7 +298,7 @@ module Azure
|
|
298
298
|
# * +:encode+ - Boolean. If set to true, the message will be base64 encoded.
|
299
299
|
# * +:timeout+ - Integer. A timeout in seconds.
|
300
300
|
#
|
301
|
-
# See http://msdn.microsoft.com/en-us/library/
|
301
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179346
|
302
302
|
#
|
303
303
|
# Returns nil on success
|
304
304
|
def create_message(queue_name, message_text, options={})
|
@@ -332,7 +332,7 @@ module Azure
|
|
332
332
|
# Accepted key/value pairs in options parameter are:
|
333
333
|
# * +:timeout+ - Integer. A timeout in seconds.
|
334
334
|
#
|
335
|
-
# See http://msdn.microsoft.com/en-us/library/
|
335
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179347
|
336
336
|
#
|
337
337
|
# Returns nil on success
|
338
338
|
#
|
@@ -397,7 +397,7 @@ module Azure
|
|
397
397
|
# * +:decode+ - Boolean. Boolean value indicating if the message should be base64 decoded.
|
398
398
|
# * +:timeout+ - Integer. A timeout in seconds.
|
399
399
|
#
|
400
|
-
# See http://msdn.microsoft.com/en-us/library/
|
400
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179472
|
401
401
|
#
|
402
402
|
# Returns a list of Azure::Entity::Queue::Message instances
|
403
403
|
def peek_messages(queue_name, options={})
|
@@ -429,7 +429,7 @@ module Azure
|
|
429
429
|
# * +:timeout+ - Integer. A timeout in seconds.
|
430
430
|
# * +:decode+ - Boolean. Boolean value indicating if the message should be base64 decoded.
|
431
431
|
#
|
432
|
-
# See http://msdn.microsoft.com/en-us/library/
|
432
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179474
|
433
433
|
#
|
434
434
|
# Returns a list of Azure::Entity::Queue::Message instances
|
435
435
|
def list_messages(queue_name, visibility_timeout, options={})
|
@@ -465,7 +465,7 @@ module Azure
|
|
465
465
|
# * +:encode+ - Boolean. If set to true, the message will be base64 encoded.
|
466
466
|
# * +:timeout+ - Integer. A timeout in seconds.
|
467
467
|
#
|
468
|
-
# See http://msdn.microsoft.com/en-us/library/
|
468
|
+
# See http://msdn.microsoft.com/en-us/library/azure/hh452234
|
469
469
|
#
|
470
470
|
# Returns a tuple of (pop_receipt, time_next_visible)
|
471
471
|
# * pop_receipt - String. The pop receipt of the queue message.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Azure
|
2
|
+
module Service
|
3
|
+
class CorsRule
|
4
|
+
def initialize
|
5
|
+
yield self if block_given?
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :allowed_origins
|
9
|
+
attr_accessor :allowed_methods
|
10
|
+
attr_accessor :max_age_in_seconds
|
11
|
+
attr_accessor :exposed_headers
|
12
|
+
attr_accessor :allowed_headers
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -22,6 +22,8 @@ require 'azure/service/storage_service_properties'
|
|
22
22
|
require 'azure/service/logging'
|
23
23
|
require 'azure/service/metrics'
|
24
24
|
require 'azure/service/retention_policy'
|
25
|
+
require 'azure/service/cors'
|
26
|
+
require 'azure/service/cors_rule'
|
25
27
|
|
26
28
|
module Azure
|
27
29
|
module Service
|
@@ -148,18 +150,27 @@ module Azure
|
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
151
|
-
def
|
152
|
-
xml.
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
def metrics_to_xml_children(metrics, xml)
|
154
|
+
xml.Version metrics.version if metrics.version
|
155
|
+
xml.Enabled metrics.enabled unless metrics.enabled == nil
|
156
|
+
xml.IncludeAPIs metrics.include_apis unless metrics.include_apis == nil
|
157
|
+
retention_policy_to_xml(metrics.retention_policy, xml) if metrics.retention_policy
|
158
|
+
end
|
159
|
+
|
160
|
+
def hour_metrics_to_xml(metrics, xml)
|
161
|
+
xml.HourMetrics {
|
162
|
+
metrics_to_xml_children(metrics, xml)
|
163
|
+
}
|
164
|
+
end
|
165
|
+
|
166
|
+
def minute_metrics_to_xml(metrics, xml)
|
167
|
+
xml.MinuteMetrics {
|
168
|
+
metrics_to_xml_children(metrics, xml)
|
157
169
|
}
|
158
170
|
end
|
159
171
|
|
160
172
|
def metrics_from_xml(xml)
|
161
173
|
xml = slopify(xml)
|
162
|
-
expect_node("Metrics", xml)
|
163
174
|
|
164
175
|
Metrics.new do |metrics|
|
165
176
|
metrics.version = xml.Version.text if (xml > "Version").any?
|
@@ -191,13 +202,59 @@ module Azure
|
|
191
202
|
logging.retention_policy = retention_policy_from_xml(xml.RetentionPolicy)
|
192
203
|
end
|
193
204
|
end
|
205
|
+
|
206
|
+
def cors_to_xml(cors, xml)
|
207
|
+
xml.Cors {
|
208
|
+
cors.cors_rules.to_a.each do |cors_rule|
|
209
|
+
cors_rule_to_xml(cors_rule, xml)
|
210
|
+
end
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
def cors_rule_to_xml(cors_rule, xml)
|
215
|
+
xml.CorsRule {
|
216
|
+
xml.AllowedOrigins cors_rule.allowed_origins.join(",") if cors_rule.allowed_origins
|
217
|
+
xml.AllowedMethods cors_rule.allowed_methods.join(",") if cors_rule.allowed_methods
|
218
|
+
xml.MaxAgeInSeconds cors_rule.max_age_in_seconds if cors_rule.max_age_in_seconds
|
219
|
+
xml.ExposedHeaders cors_rule.exposed_headers.join(",") if cors_rule.exposed_headers
|
220
|
+
xml.AllowedHeaders cors_rule.allowed_headers.join(",") if cors_rule.allowed_headers
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
def cors_from_xml(xml)
|
225
|
+
xml = slopify(xml)
|
226
|
+
expect_node("Cors", xml)
|
227
|
+
|
228
|
+
Cors.new do |cors|
|
229
|
+
cors.cors_rules = xml.children.to_a.map {|child| cors_rule_from_xml(child)}
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def cors_rule_from_xml(xml)
|
234
|
+
xml = slopify(xml)
|
235
|
+
expect_node("CorsRule", xml)
|
236
|
+
|
237
|
+
CorsRule.new do |cors_rule|
|
238
|
+
cors_rule.allowed_origins = ary_from_node(xml.AllowedOrigins) if (xml > "AllowedOrigins").any?
|
239
|
+
cors_rule.allowed_methods = ary_from_node(xml.AllowedMethods) if (xml > "AllowedMethods").any?
|
240
|
+
cors_rule.max_age_in_seconds = xml.MaxAgeInSeconds.text.to_i if (xml > "MaxAgeInSeconds").any?
|
241
|
+
cors_rule.exposed_headers = ary_from_node(xml.ExposedHeaders) if (xml > "ExposedHeaders").any?
|
242
|
+
cors_rule.allowed_headers = ary_from_node(xml.AllowedHeaders) if (xml > "AllowedHeaders").any?
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def ary_from_node(node)
|
247
|
+
node.text.split(",").map {|s| s.strip}
|
248
|
+
end
|
194
249
|
|
195
250
|
def service_properties_to_xml(properties)
|
196
251
|
builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
|
197
252
|
xml.StorageServiceProperties {
|
253
|
+
xml.DefaultServiceVersion(properties.default_service_version) if properties.default_service_version
|
198
254
|
logging_to_xml(properties.logging, xml) if properties.logging
|
199
|
-
|
200
|
-
|
255
|
+
hour_metrics_to_xml(properties.hour_metrics, xml) if properties.hour_metrics
|
256
|
+
minute_metrics_to_xml(properties.minute_metrics, xml) if properties.minute_metrics
|
257
|
+
cors_to_xml(properties.cors, xml) if properties.cors
|
201
258
|
}
|
202
259
|
end
|
203
260
|
builder.to_xml
|
@@ -210,7 +267,9 @@ module Azure
|
|
210
267
|
StorageServiceProperties.new do |props|
|
211
268
|
props.default_service_version = xml.DefaultServiceVersion.text if (xml > "DefaultServiceVersion").any?
|
212
269
|
props.logging = logging_from_xml(xml.Logging)
|
213
|
-
props.
|
270
|
+
props.hour_metrics = metrics_from_xml(xml.HourMetrics)
|
271
|
+
props.minute_metrics = metrics_from_xml(xml.MinuteMetrics)
|
272
|
+
props.cors = cors_from_xml(xml.Cors)
|
214
273
|
end
|
215
274
|
end
|
216
275
|
|