juliusl-azure-sdk-for-ruby 0.7.0
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.
- checksums.yaml +7 -0
- data/.env_sample +11 -0
- data/.gitignore +15 -0
- data/.travis.yml +13 -0
- data/ChangeLog.txt +56 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +202 -0
- data/README.md +630 -0
- data/Rakefile +121 -0
- data/azure.gemspec +47 -0
- data/bin/pfxer +35 -0
- data/lib/azure.rb +60 -0
- data/lib/azure/base_management/affinity_group.rb +32 -0
- data/lib/azure/base_management/base_management_service.rb +245 -0
- data/lib/azure/base_management/location.rb +27 -0
- data/lib/azure/base_management/management_http_request.rb +175 -0
- data/lib/azure/base_management/serialization.rb +135 -0
- data/lib/azure/base_management/sql_management_http_request.rb +45 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
- data/lib/azure/blob/blob.rb +32 -0
- data/lib/azure/blob/blob_service.rb +1427 -0
- data/lib/azure/blob/block.rb +31 -0
- data/lib/azure/blob/container.rb +32 -0
- data/lib/azure/blob/serialization.rb +285 -0
- data/lib/azure/cloud_service_management/cloud_service.rb +38 -0
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +137 -0
- data/lib/azure/cloud_service_management/serialization.rb +118 -0
- data/lib/azure/core.rb +41 -0
- data/lib/azure/core/auth/authorizer.rb +36 -0
- data/lib/azure/core/auth/shared_key.rb +110 -0
- data/lib/azure/core/auth/shared_key_lite.rb +48 -0
- data/lib/azure/core/auth/signer.rb +52 -0
- data/lib/azure/core/configuration.rb +218 -0
- data/lib/azure/core/error.rb +22 -0
- data/lib/azure/core/filtered_service.rb +44 -0
- data/lib/azure/core/http/debug_filter.rb +36 -0
- data/lib/azure/core/http/http_error.rb +88 -0
- data/lib/azure/core/http/http_filter.rb +53 -0
- data/lib/azure/core/http/http_request.rb +160 -0
- data/lib/azure/core/http/http_response.rb +140 -0
- data/lib/azure/core/http/retry_policy.rb +74 -0
- data/lib/azure/core/http/signer_filter.rb +34 -0
- data/lib/azure/core/service.rb +63 -0
- data/lib/azure/core/signed_service.rb +43 -0
- data/lib/azure/core/utility.rb +242 -0
- data/lib/azure/queue/message.rb +30 -0
- data/lib/azure/queue/queue.rb +29 -0
- data/lib/azure/queue/queue_service.rb +568 -0
- data/lib/azure/queue/serialization.rb +106 -0
- data/lib/azure/service/access_policy.rb +26 -0
- data/lib/azure/service/cors.rb +11 -0
- data/lib/azure/service/cors_rule.rb +15 -0
- data/lib/azure/service/enumeration_results.rb +21 -0
- data/lib/azure/service/logging.rb +32 -0
- data/lib/azure/service/metrics.rb +31 -0
- data/lib/azure/service/retention_policy.rb +25 -0
- data/lib/azure/service/serialization.rb +299 -0
- data/lib/azure/service/signed_identifier.rb +30 -0
- data/lib/azure/service/storage_service.rb +83 -0
- data/lib/azure/service/storage_service_properties.rb +37 -0
- data/lib/azure/service_bus/action.rb +21 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +89 -0
- data/lib/azure/service_bus/auth/wrap_signer.rb +69 -0
- data/lib/azure/service_bus/brokered_message.rb +124 -0
- data/lib/azure/service_bus/brokered_message_serializer.rb +159 -0
- data/lib/azure/service_bus/correlation_filter.rb +45 -0
- data/lib/azure/service_bus/empty_rule_action.rb +30 -0
- data/lib/azure/service_bus/false_filter.rb +38 -0
- data/lib/azure/service_bus/filter.rb +21 -0
- data/lib/azure/service_bus/interval.rb +104 -0
- data/lib/azure/service_bus/queue.rb +230 -0
- data/lib/azure/service_bus/relay.rb +88 -0
- data/lib/azure/service_bus/resource.rb +109 -0
- data/lib/azure/service_bus/rule.rb +98 -0
- data/lib/azure/service_bus/rule_aspect.rb +34 -0
- data/lib/azure/service_bus/serialization.rb +161 -0
- data/lib/azure/service_bus/service_bus_service.rb +895 -0
- data/lib/azure/service_bus/sql_filter.rb +50 -0
- data/lib/azure/service_bus/sql_rule_action.rb +50 -0
- data/lib/azure/service_bus/subscription.rb +184 -0
- data/lib/azure/service_bus/topic.rb +187 -0
- data/lib/azure/service_bus/true_filter.rb +38 -0
- data/lib/azure/sql_database_management/serialization.rb +112 -0
- data/lib/azure/sql_database_management/sql_database.rb +31 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +200 -0
- data/lib/azure/storage_management/serialization.rb +204 -0
- data/lib/azure/storage_management/storage_account.rb +48 -0
- data/lib/azure/storage_management/storage_management_service.rb +208 -0
- data/lib/azure/table/auth/shared_key.rb +92 -0
- data/lib/azure/table/auth/shared_key_lite.rb +44 -0
- data/lib/azure/table/batch.rb +330 -0
- data/lib/azure/table/batch_response.rb +118 -0
- data/lib/azure/table/edmtype.rb +127 -0
- data/lib/azure/table/entity.rb +31 -0
- data/lib/azure/table/guid.rb +24 -0
- data/lib/azure/table/query.rb +112 -0
- data/lib/azure/table/serialization.rb +108 -0
- data/lib/azure/table/table_service.rb +560 -0
- data/lib/azure/version.rb +31 -0
- data/lib/azure/virtual_machine_image_management/serialization.rb +70 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +25 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +25 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +89 -0
- data/lib/azure/virtual_machine_management/serialization.rb +459 -0
- data/lib/azure/virtual_machine_management/virtual_machine.rb +44 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +554 -0
- data/lib/azure/virtual_network_management/serialization.rb +193 -0
- data/lib/azure/virtual_network_management/virtual_network.rb +37 -0
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +109 -0
- data/test/fixtures/32px-fulls-black.jpg +0 -0
- data/test/fixtures/affinity_group.xml +33 -0
- data/test/fixtures/all_containers.xml +20 -0
- data/test/fixtures/all_tables.xml +22 -0
- data/test/fixtures/container_acl.xml +11 -0
- data/test/fixtures/create_sql_database_server.xml +2 -0
- data/test/fixtures/create_storage_desc_error.xml +5 -0
- data/test/fixtures/create_storage_extendedprop_error.xml +8 -0
- data/test/fixtures/create_storage_extendedpropname_error.xml +6 -0
- data/test/fixtures/create_storage_full_error.xml +6 -0
- data/test/fixtures/create_storage_label_error.xml +5 -0
- data/test/fixtures/create_storage_location_error.xml +5 -0
- data/test/fixtures/create_storage_name_error.xml +6 -0
- data/test/fixtures/create_table_response_entry.xml +15 -0
- data/test/fixtures/delete_storage_container_error.xml +5 -0
- data/test/fixtures/delete_storage_error.xml +5 -0
- data/test/fixtures/deployment_error.xml +5 -0
- data/test/fixtures/empty_xml_file +0 -0
- data/test/fixtures/get_storage_account_error.xml +5 -0
- data/test/fixtures/get_storage_account_properties.xml +34 -0
- data/test/fixtures/get_storage_account_properties_new.xml +32 -0
- data/test/fixtures/http_error.xml +5 -0
- data/test/fixtures/insert_entity_response_entry.xml +25 -0
- data/test/fixtures/list_affinity_groups.xml +22 -0
- data/test/fixtures/list_blobs.xml +121 -0
- data/test/fixtures/list_block_all_with_none_committed.xml +22 -0
- data/test/fixtures/list_blocks_all.xml +23 -0
- data/test/fixtures/list_blocks_committed.xml +13 -0
- data/test/fixtures/list_cloud_services.xml +39 -0
- data/test/fixtures/list_containers.xml +38 -0
- data/test/fixtures/list_firewall_management_endpoint.xml +27 -0
- data/test/fixtures/list_locations.xml +212 -0
- data/test/fixtures/list_os_images.xml +110 -0
- data/test/fixtures/list_page_ranges.xml +11 -0
- data/test/fixtures/list_sql_database.xml +36 -0
- data/test/fixtures/list_sql_server_firewall.xml +23 -0
- data/test/fixtures/list_storage_account_single.xml +25 -0
- data/test/fixtures/list_storage_accounts.xml +48 -0
- data/test/fixtures/list_virtual_networks.xml +92 -0
- data/test/fixtures/list_vm_images.xml +21 -0
- data/test/fixtures/logging.xml +11 -0
- data/test/fixtures/messages.xml +12 -0
- data/test/fixtures/metrics.xml +10 -0
- data/test/fixtures/privatekey.key +28 -0
- data/test/fixtures/query_entities_empty_response.xml +7 -0
- data/test/fixtures/query_entities_response.xml +45 -0
- data/test/fixtures/queue_service_properties.xml +22 -0
- data/test/fixtures/queue_service_properties_original.xml +19 -0
- data/test/fixtures/queues.xml +16 -0
- data/test/fixtures/retention_policy.xml +5 -0
- data/test/fixtures/sb_default_create_queue_response.xml +23 -0
- data/test/fixtures/sb_default_create_relay_response.xml +15 -0
- data/test/fixtures/sb_default_create_topic_response.xml +18 -0
- data/test/fixtures/sb_get_access_token_response.txt +1 -0
- data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +9 -0
- data/test/fixtures/storage_service_keys.xml +8 -0
- data/test/fixtures/storage_service_properties.xml +55 -0
- data/test/fixtures/update_storage_account.xml +16 -0
- data/test/fixtures/update_storage_error.xml +5 -0
- data/test/fixtures/updated_storage_accounts.xml +55 -0
- data/test/fixtures/virtual_machine.xml +116 -0
- data/test/fixtures/windows_virtual_machine.xml +106 -0
- data/test/integration/affinity_group/Affinity_test.rb +55 -0
- data/test/integration/affinity_group/Create_Affinity_test.rb +64 -0
- data/test/integration/affinity_group/Delete_Affinity_test.rb +56 -0
- data/test/integration/affinity_group/List_Affinity_test.rb +41 -0
- data/test/integration/affinity_group/Update_Affinity_test.rb +83 -0
- data/test/integration/blob/blob_gb18030_test.rb +199 -0
- data/test/integration/blob/blob_metadata_test.rb +75 -0
- data/test/integration/blob/blob_pages_test.rb +119 -0
- data/test/integration/blob/blob_properties_test.rb +77 -0
- data/test/integration/blob/block_blob_test.rb +254 -0
- data/test/integration/blob/container/container_acl_test.rb +69 -0
- data/test/integration/blob/container/container_metadata_test.rb +50 -0
- data/test/integration/blob/container/create_container_test.rb +60 -0
- data/test/integration/blob/container/delete_container_test.rb +39 -0
- data/test/integration/blob/container/get_container_properties_test.rb +48 -0
- data/test/integration/blob/container/list_containers_test.rb +79 -0
- data/test/integration/blob/container/root_container_test.rb +54 -0
- data/test/integration/blob/copy_blob_test.rb +113 -0
- data/test/integration/blob/create_blob_snapshot_test.rb +80 -0
- data/test/integration/blob/create_page_blob_test.rb +83 -0
- data/test/integration/blob/delete_blob_test.rb +159 -0
- data/test/integration/blob/get_blob_test.rb +65 -0
- data/test/integration/blob/informative_errors_test.rb +39 -0
- data/test/integration/blob/lease/acquire_lease_test.rb +36 -0
- data/test/integration/blob/lease/break_lease_test.rb +40 -0
- data/test/integration/blob/lease/release_lease_test.rb +40 -0
- data/test/integration/blob/lease/renew_lease_test.rb +42 -0
- data/test/integration/blob/list_blobs_test.rb +113 -0
- data/test/integration/cloud_service/Cloud_Create_test.rb +45 -0
- data/test/integration/cloud_service/Cloud_Delete_test.rb +45 -0
- data/test/integration/database/create_sql_server_firewall_test.rb +86 -0
- data/test/integration/database/create_sql_server_test.rb +53 -0
- data/test/integration/database/delete_sql_server_firewall_test.rb +70 -0
- data/test/integration/database/delete_sql_server_test.rb +58 -0
- data/test/integration/database/list_sql_server_firewall_test.rb +45 -0
- data/test/integration/database/list_sql_servers_test.rb +44 -0
- data/test/integration/database/reset_password_sql_server_test.rb +55 -0
- data/test/integration/location/Location_List_test.rb +39 -0
- data/test/integration/location/RoleSize_List_test.rb +35 -0
- data/test/integration/queue/clear_messages_test.rb +42 -0
- data/test/integration/queue/create_message_test.rb +75 -0
- data/test/integration/queue/create_queue_test.rb +50 -0
- data/test/integration/queue/delete_message_test.rb +67 -0
- data/test/integration/queue/delete_queue_test.rb +45 -0
- data/test/integration/queue/informative_errors_test.rb +42 -0
- data/test/integration/queue/list_messages_encoded_test.rb +79 -0
- data/test/integration/queue/list_messages_test.rb +79 -0
- data/test/integration/queue/list_queues_test.rb +44 -0
- data/test/integration/queue/peek_messages_test.rb +59 -0
- data/test/integration/queue/queue_gb18030_test.rb +131 -0
- data/test/integration/queue/queue_metadata_test.rb +40 -0
- data/test/integration/queue/update_message_test.rb +74 -0
- data/test/integration/service_bus/informative_errors_test.rb +37 -0
- data/test/integration/service_bus/queues_scenario_test.rb +200 -0
- data/test/integration/service_bus/queues_test.rb +266 -0
- data/test/integration/service_bus/relay_test.rb +132 -0
- data/test/integration/service_bus/rules_test.rb +145 -0
- data/test/integration/service_bus/sb_queue_gb18030_test.rb +182 -0
- data/test/integration/service_bus/scenario_test.rb +101 -0
- data/test/integration/service_bus/subscriptions_test.rb +211 -0
- data/test/integration/service_bus/topics_scenario_test.rb +406 -0
- data/test/integration/service_bus/topics_test.rb +129 -0
- data/test/integration/storage_management/storage_management_test.rb +185 -0
- data/test/integration/table/create_table_test.rb +36 -0
- data/test/integration/table/delete_entity_batch_test.rb +107 -0
- data/test/integration/table/delete_entity_test.rb +94 -0
- data/test/integration/table/delete_table_test.rb +40 -0
- data/test/integration/table/get_table_test.rb +37 -0
- data/test/integration/table/informative_errors_test.rb +39 -0
- data/test/integration/table/insert_entity_batch_test.rb +100 -0
- data/test/integration/table/insert_entity_test.rb +88 -0
- data/test/integration/table/insert_or_merge_entity_batch_test.rb +159 -0
- data/test/integration/table/insert_or_merge_entity_test.rb +143 -0
- data/test/integration/table/insert_or_replace_entity_batch_test.rb +152 -0
- data/test/integration/table/insert_or_replace_entity_test.rb +137 -0
- data/test/integration/table/merge_entity_batch_test.rb +128 -0
- data/test/integration/table/merge_entity_test.rb +113 -0
- data/test/integration/table/query_entities_test.rb +195 -0
- data/test/integration/table/query_tables_test.rb +43 -0
- data/test/integration/table/query_test.rb +251 -0
- data/test/integration/table/table_acl_test.rb +52 -0
- data/test/integration/table/table_gb18030_test.rb +355 -0
- data/test/integration/table/update_entity_batch_test.rb +149 -0
- data/test/integration/table/update_entity_test.rb +131 -0
- data/test/integration/test_helper.rb +38 -0
- data/test/integration/vm/VM_Create_test.rb +262 -0
- data/test/integration/vm/VM_Delete_test.rb +53 -0
- data/test/integration/vm/VM_Operations_test.rb +172 -0
- data/test/integration/vm_image/virtual_machine_disk_test.rb +37 -0
- data/test/integration/vm_image/virtual_machine_image_test.rb +37 -0
- data/test/integration/vnet/Virtual_Network_Create_test.rb +116 -0
- data/test/integration/vnet/Virtual_Network_list_test.rb +48 -0
- data/test/support/env.rb +19 -0
- data/test/support/fixtures.rb +36 -0
- data/test/support/name_generator.rb +168 -0
- data/test/support/stubs.rb +42 -0
- data/test/support/virtual_machine_name_generator.rb +102 -0
- data/test/support/virtual_network_helper.rb +73 -0
- data/test/test_helper.rb +44 -0
- data/test/unit/affinity_group/affinity_group_test.rb +189 -0
- data/test/unit/affinity_group/serialization_test.rb +87 -0
- data/test/unit/base_management/location_test.rb +56 -0
- data/test/unit/base_management/role_size_test.rb +50 -0
- data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
- data/test/unit/blob/blob_service_test.rb +1969 -0
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +94 -0
- data/test/unit/cloud_service_management/serialization_test.rb +169 -0
- data/test/unit/core/auth/shared_key_lite_test.rb +51 -0
- data/test/unit/core/auth/shared_key_test.rb +58 -0
- data/test/unit/core/auth/signer_test.rb +30 -0
- data/test/unit/core/http/http_error_test.rb +62 -0
- data/test/unit/core/http/http_request_test.rb +113 -0
- data/test/unit/core/http/http_response_test.rb +45 -0
- data/test/unit/core/http/retry_policy_test.rb +23 -0
- data/test/unit/core/utility_test.rb +122 -0
- data/test/unit/database/serialization_test.rb +97 -0
- data/test/unit/database/sql_database_server_service_test.rb +284 -0
- data/test/unit/service/serialization_test.rb +533 -0
- data/test/unit/service/storage_service_test.rb +293 -0
- data/test/unit/storage_management/serialization_test.rb +244 -0
- data/test/unit/storage_management/storage_management_service_test.rb +247 -0
- data/test/unit/table/edmtype_test.rb +108 -0
- data/test/unit/virtual_machine_image_management/serialization_test.rb +50 -0
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +114 -0
- data/test/unit/virtual_machine_management/serialization_test.rb +316 -0
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +478 -0
- data/test/unit/vnet/serialization_test.rb +187 -0
- data/test/unit/vnet/virtual_network_management_service_test.rb +131 -0
- metadata +512 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 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
|
+
require "azure/base_management/serialization"
|
|
16
|
+
|
|
17
|
+
module Azure
|
|
18
|
+
module BaseManagement
|
|
19
|
+
class Location
|
|
20
|
+
attr_accessor :name, :available_services, :role_sizes
|
|
21
|
+
|
|
22
|
+
def initialize
|
|
23
|
+
yield self if block_given?
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 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
|
+
require 'azure/core/http/http_response'
|
|
16
|
+
require 'azure/core/http/http_request'
|
|
17
|
+
include Azure::Core::Http
|
|
18
|
+
|
|
19
|
+
# Represents an HTTP request that can perform synchronous queries to
|
|
20
|
+
# an HTTP server, returning a HttpResponse
|
|
21
|
+
module Azure
|
|
22
|
+
module BaseManagement
|
|
23
|
+
class ManagementHttpRequest < HttpRequest
|
|
24
|
+
include Azure::Core::Utility
|
|
25
|
+
attr_accessor :uri, :warn, :key, :cert
|
|
26
|
+
|
|
27
|
+
# Public: Creates the ManagementHttpRequest
|
|
28
|
+
#
|
|
29
|
+
# method - Symbol. The HTTP method to use (:get, :post, :put, :del, etc...)
|
|
30
|
+
# path - URI. The URI of the HTTP endpoint to query
|
|
31
|
+
# body - IO or String. The request body (optional)
|
|
32
|
+
# key - String. The request key
|
|
33
|
+
# cert - String. The request certificate
|
|
34
|
+
def initialize(method, path, body = nil)
|
|
35
|
+
super
|
|
36
|
+
@warn = false
|
|
37
|
+
content_length = body ? body.bytesize.to_s : '0'
|
|
38
|
+
@headers.update({
|
|
39
|
+
'x-ms-version' => '2014-06-01',
|
|
40
|
+
'Content-Type' => 'application/xml',
|
|
41
|
+
'Content-Length' => content_length
|
|
42
|
+
})
|
|
43
|
+
@uri = URI.parse(Azure.config.management_endpoint + Azure.config.subscription_id + path)
|
|
44
|
+
@key = Azure.config.http_private_key
|
|
45
|
+
@cert = Azure.config.http_certificate_key
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Public: Sends a request to HTTP server and returns a HttpResponse
|
|
49
|
+
#
|
|
50
|
+
# Returns a Nokogiri::XML instance of HttpResponse body
|
|
51
|
+
def call
|
|
52
|
+
request = http_request_class.new(uri.request_uri, headers)
|
|
53
|
+
request.body = body if body
|
|
54
|
+
http = http_setup
|
|
55
|
+
# http.set_debug_output($stdout)
|
|
56
|
+
response = wait_for_completion(HttpResponse.new(http.request(request)))
|
|
57
|
+
Nokogiri::XML response.body unless response.nil?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Public: Wait for HTTP request completion.
|
|
61
|
+
#
|
|
62
|
+
# ==== Attributes
|
|
63
|
+
#
|
|
64
|
+
# * +response+ - Azure::Core::Http::HttpResponse. HttpResponse Response
|
|
65
|
+
#
|
|
66
|
+
# Print Error or Success of HttpRequest
|
|
67
|
+
def wait_for_completion(response)
|
|
68
|
+
ret_val = Nokogiri::XML response.body
|
|
69
|
+
if ret_val.at_css('Error Code') && ret_val.at_css('Error Code').content == 'AuthenticationFailed'
|
|
70
|
+
Azure::Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
|
|
71
|
+
end
|
|
72
|
+
if response.status_code.to_i == 200 || response.status_code.to_i == 201
|
|
73
|
+
return response
|
|
74
|
+
elsif redirected? response
|
|
75
|
+
rebuild_request response
|
|
76
|
+
elsif response.status_code.to_i > 201 && response.status_code.to_i <= 299
|
|
77
|
+
check_completion(response.headers['x-ms-request-id'])
|
|
78
|
+
elsif response.status_code.to_i == 307
|
|
79
|
+
@uri = URI::parse (response.headers['location'])
|
|
80
|
+
call
|
|
81
|
+
elsif warn && !response.success?
|
|
82
|
+
elsif response.body
|
|
83
|
+
if ret_val.at_css('Error Code') && ret_val.at_css('Error Message')
|
|
84
|
+
Azure::Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
|
|
85
|
+
else
|
|
86
|
+
Azure::Loggerx.exception_message "http error: #{response.status_code}"
|
|
87
|
+
end
|
|
88
|
+
else
|
|
89
|
+
Azure::Loggerx.exception_message "http error: #{response.status_code}"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Public: Gets the status of the specified operation and determines whether
|
|
94
|
+
# the operation has succeeded, failed, or is still in progress.
|
|
95
|
+
#
|
|
96
|
+
# ==== Attributes
|
|
97
|
+
#
|
|
98
|
+
# * +request_id+ - String. x-ms-request-id response header of request
|
|
99
|
+
#
|
|
100
|
+
# See: http://msdn.microsoft.com/en-us/library/azure/ee460783.aspx
|
|
101
|
+
#
|
|
102
|
+
# Print Error or Success of Operation.
|
|
103
|
+
def check_completion(request_id)
|
|
104
|
+
request_path = "/#{Azure.config.subscription_id}/operations/#{request_id}"
|
|
105
|
+
http = http_setup
|
|
106
|
+
headers['Content-Length'] = '0'
|
|
107
|
+
@method = :get
|
|
108
|
+
done = false
|
|
109
|
+
while not done
|
|
110
|
+
print '# '
|
|
111
|
+
request = http_request_class.new(request_path, headers)
|
|
112
|
+
response = HttpResponse.new(http.request(request))
|
|
113
|
+
ret_val = Nokogiri::XML response.body
|
|
114
|
+
status = xml_content(ret_val, 'Operation Status')
|
|
115
|
+
status_code = response.status_code.to_i
|
|
116
|
+
if status != 'InProgress'
|
|
117
|
+
done = true
|
|
118
|
+
end
|
|
119
|
+
if redirected? response
|
|
120
|
+
host_uri = URI.parse(response.headers['location'])
|
|
121
|
+
http = http_setup(host_uri)
|
|
122
|
+
done = false
|
|
123
|
+
end
|
|
124
|
+
if done
|
|
125
|
+
if status.downcase != 'succeeded'
|
|
126
|
+
error_code = xml_content(ret_val, 'Operation Error Code')
|
|
127
|
+
error_msg = xml_content(ret_val, 'Operation Error Message')
|
|
128
|
+
Azure::Loggerx.exception_message "#{error_code}: #{error_msg}"
|
|
129
|
+
else
|
|
130
|
+
Azure::Loggerx.success "#{status.downcase} (#{status_code})"
|
|
131
|
+
end
|
|
132
|
+
return
|
|
133
|
+
else
|
|
134
|
+
sleep(5)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def rebuild_request(response)
|
|
140
|
+
host_uri = URI.parse(response.headers['location'])
|
|
141
|
+
request = http_request_class.new(host_uri.request_uri, headers)
|
|
142
|
+
request.body = body if body
|
|
143
|
+
http = http_setup(host_uri)
|
|
144
|
+
wait_for_completion(HttpResponse.new(http.request(request)))
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def redirected?(response)
|
|
148
|
+
(response.status_code.to_i == 307)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def http_setup(host_uri = nil)
|
|
152
|
+
@uri = host_uri if host_uri
|
|
153
|
+
http = nil
|
|
154
|
+
if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY']
|
|
155
|
+
if ENV['HTTP_PROXY']
|
|
156
|
+
proxy_uri = URI.parse(ENV['HTTP_PROXY'])
|
|
157
|
+
else
|
|
158
|
+
proxy_uri = URI.parse(ENV['HTTPS_PROXY'])
|
|
159
|
+
end
|
|
160
|
+
http = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(uri.host, uri.port)
|
|
161
|
+
else
|
|
162
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if uri.scheme.downcase == 'https'
|
|
166
|
+
http.use_ssl = true
|
|
167
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
168
|
+
http.cert = cert
|
|
169
|
+
http.key = key
|
|
170
|
+
end
|
|
171
|
+
http
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 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
|
+
|
|
16
|
+
module Azure
|
|
17
|
+
module BaseManagement
|
|
18
|
+
module Serialization
|
|
19
|
+
extend Azure::Core::Utility
|
|
20
|
+
def self.locations_from_xml(locationXML)
|
|
21
|
+
location_objs = []
|
|
22
|
+
xml = locationXML.css('Locations Location')
|
|
23
|
+
xml.each do |meta_node|
|
|
24
|
+
loc = Location.new
|
|
25
|
+
loc.name = xml_content(meta_node, 'Name')
|
|
26
|
+
available_services = meta_node.css('AvailableServices').children
|
|
27
|
+
loc.available_services = available_services.to_ary.join(', ')
|
|
28
|
+
role_sizes = []
|
|
29
|
+
meta_node.css('VirtualMachinesRoleSizes RoleSize').each do | role_size_node |
|
|
30
|
+
role_sizes << role_size_node.text
|
|
31
|
+
end
|
|
32
|
+
loc.role_sizes = role_sizes
|
|
33
|
+
location_objs << loc
|
|
34
|
+
end
|
|
35
|
+
location_objs
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.affinity_group_to_xml(name, location, label, options = {})
|
|
39
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
|
40
|
+
xml.CreateAffinityGroup(
|
|
41
|
+
'xmlns' => 'http://schemas.microsoft.com/windowsazure'
|
|
42
|
+
) do
|
|
43
|
+
xml.Name name
|
|
44
|
+
xml.Label Base64.encode64(label).strip
|
|
45
|
+
xml.Description options[:description]
|
|
46
|
+
xml.Location location
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
builder.doc.to_xml
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.affinity_groups_from_xml(affinity_xml)
|
|
53
|
+
affinity_groups = []
|
|
54
|
+
affinity_group_services_xml = affinity_xml.css(
|
|
55
|
+
'AffinityGroups AffinityGroup'
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
affinity_group_services_xml.each do |ag_xml|
|
|
59
|
+
affinity_group = AffinityGroup.new
|
|
60
|
+
affinity_group.name = xml_content(ag_xml, 'Name')
|
|
61
|
+
affinity_group.label = Base64.decode64(xml_content(ag_xml, 'Label'))
|
|
62
|
+
affinity_group.description = xml_content(ag_xml, 'Description')
|
|
63
|
+
affinity_group.location = xml_content(ag_xml, 'Location')
|
|
64
|
+
|
|
65
|
+
capabilities = ag_xml.css('Capabilities Capability')
|
|
66
|
+
affinity_group.capability = capabilities.map { |x| x.content }
|
|
67
|
+
affinity_groups << affinity_group
|
|
68
|
+
end
|
|
69
|
+
affinity_groups.compact
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.affinity_group_from_xml(affinity_xml)
|
|
73
|
+
hosted_services_xml = affinity_xml.css(
|
|
74
|
+
'AffinityGroup HostedServices HostedService'
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
storage_services_xml = affinity_xml.css(
|
|
78
|
+
'AffinityGroup StorageServices StorageService'
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
capability_xml = affinity_xml.css(
|
|
82
|
+
'AffinityGroup Capabilities Capability'
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
AffinityGroup.new do |affinity_group|
|
|
86
|
+
affinity_group.name = xml_content(
|
|
87
|
+
affinity_xml,
|
|
88
|
+
'AffinityGroup Name'
|
|
89
|
+
)
|
|
90
|
+
affinity_group.label = Base64.decode64(
|
|
91
|
+
xml_content(
|
|
92
|
+
affinity_xml,
|
|
93
|
+
'AffinityGroup Label'
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
affinity_group.description = xml_content(
|
|
97
|
+
affinity_xml,
|
|
98
|
+
'AffinityGroup Description'
|
|
99
|
+
)
|
|
100
|
+
affinity_group.location = xml_content(
|
|
101
|
+
affinity_xml,
|
|
102
|
+
'AffinityGroup Location'
|
|
103
|
+
)
|
|
104
|
+
affinity_group.hosted_services = []
|
|
105
|
+
hosted_services_xml.each do |hosted_service_xml|
|
|
106
|
+
affinity_group.hosted_services << {
|
|
107
|
+
url: xml_content(hosted_service_xml, 'Url'),
|
|
108
|
+
service_name: xml_content(hosted_service_xml, 'ServiceName')
|
|
109
|
+
}
|
|
110
|
+
end
|
|
111
|
+
affinity_group.storage_services = []
|
|
112
|
+
storage_services_xml.each do |storage_service_xml|
|
|
113
|
+
affinity_group.storage_services << {
|
|
114
|
+
url: xml_content(storage_service_xml, 'Url'),
|
|
115
|
+
service_name: xml_content(storage_service_xml, 'ServiceName')
|
|
116
|
+
}
|
|
117
|
+
end
|
|
118
|
+
affinity_group.capability = capability_xml.map { |x| x.content }
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def self.resource_to_xml(label, options = {})
|
|
123
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
|
124
|
+
xml.UpdateAffinityGroup(
|
|
125
|
+
'xmlns' => 'http://schemas.microsoft.com/windowsazure'
|
|
126
|
+
) do
|
|
127
|
+
xml.Label Base64.encode64(label).strip
|
|
128
|
+
xml.Description options[:description] if options[:description]
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
builder.doc.to_xml
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 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
|
+
# Represents an HTTP request that can perform synchronous queries to
|
|
16
|
+
# an HTTP server, returning a HttpResponse
|
|
17
|
+
module Azure
|
|
18
|
+
module BaseManagement
|
|
19
|
+
# This class is used for communicating with the Management certificate authentication API endpoint
|
|
20
|
+
class SqlManagementHttpRequest < ManagementHttpRequest
|
|
21
|
+
attr_accessor :uri
|
|
22
|
+
# Public: Creates the ManagementHttpRequest
|
|
23
|
+
#
|
|
24
|
+
# method - Symbol. The HTTP method to use (:get, :post, :put, :del, etc...)
|
|
25
|
+
# path - URI. The URI of the HTTP endpoint to query
|
|
26
|
+
# body - IO or String. The request body (optional)
|
|
27
|
+
def initialize(method, path, body = nil)
|
|
28
|
+
if sql_endpoint?
|
|
29
|
+
super(method, path, body)
|
|
30
|
+
@headers['x-ms-version'] = '1.0'
|
|
31
|
+
@uri = URI.parse(Azure.config.sql_database_management_endpoint + Azure.config.subscription_id + path)
|
|
32
|
+
else
|
|
33
|
+
path = "/services/sqlservers#{path}"
|
|
34
|
+
super(method, path, body)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def sql_endpoint?
|
|
41
|
+
Azure.config.sql_database_authentication_mode == :sql_server
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
# TODO: extract common SAS logic, add support for the other SAS types
|
|
17
|
+
|
|
18
|
+
require "azure/core/configuration"
|
|
19
|
+
require "azure/core/auth/signer"
|
|
20
|
+
|
|
21
|
+
# This will break if used against API version prior to 2013-08-15 as the format
|
|
22
|
+
# changed
|
|
23
|
+
# See https://msdn.microsoft.com/library/azure/dn140255.aspx for more information on construction
|
|
24
|
+
module Azure
|
|
25
|
+
module Blob
|
|
26
|
+
module Auth
|
|
27
|
+
class SharedAccessSignature < Core::Auth::Signer
|
|
28
|
+
DEFAULTS = {
|
|
29
|
+
resource: 'b',
|
|
30
|
+
permissions: 'r',
|
|
31
|
+
version: '2013-08-15'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
KEY_MAPPINGS = {
|
|
35
|
+
permissions: :sp,
|
|
36
|
+
start: :st,
|
|
37
|
+
expiry: :se,
|
|
38
|
+
resource: :sr,
|
|
39
|
+
identifier: :si,
|
|
40
|
+
version: :sv,
|
|
41
|
+
cache_control: :rscc,
|
|
42
|
+
content_disposition: :rscd,
|
|
43
|
+
content_encoding: :rsce,
|
|
44
|
+
content_language: :rscl,
|
|
45
|
+
content_type: :rsct
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
OPTIONAL_QUERY_PARAMS = [:sp, :si, :rscc, :rscd, :rsce, :rscl, :rsct]
|
|
49
|
+
|
|
50
|
+
attr :path
|
|
51
|
+
attr :options
|
|
52
|
+
attr :account_name
|
|
53
|
+
|
|
54
|
+
# Public: Initialize the Signer.
|
|
55
|
+
#
|
|
56
|
+
# ==== Attributes
|
|
57
|
+
#
|
|
58
|
+
# * +path+ - the container or blob path
|
|
59
|
+
# * +options+ - Hash. Required and optional parameters
|
|
60
|
+
# * +account_name+ - The account name. Defaults to the one in the
|
|
61
|
+
# global configuration.
|
|
62
|
+
# * +access_key+ - The access_key encoded in Base64. Defaults to the
|
|
63
|
+
# one in the global configuration.
|
|
64
|
+
#
|
|
65
|
+
# ==== Options
|
|
66
|
+
#
|
|
67
|
+
# * +:resource+ - String. Resource type, either 'b' (blob) or 'c' (container). Default 'b'
|
|
68
|
+
# * +:permissions+ - String. Combination of 'r','w','d','l' (container only) in this order. Default 'r'
|
|
69
|
+
# * +:start+ - String. UTC Date/Time in ISO8601 format. Optional.
|
|
70
|
+
# * +:expiry+ - String. UTC Date/Time in ISO8601 format. Required.
|
|
71
|
+
# * +:identifier+ - String. Identifier for stored access policy. Optional
|
|
72
|
+
# * +:version+ - String. API version. Default '2013-08-15'
|
|
73
|
+
#
|
|
74
|
+
# * +:cache_control - String. Response header override. Optional.
|
|
75
|
+
# * +:content_disposition - String. Response header override. Optional.
|
|
76
|
+
# * +:content_encoding - String. Response header override. Optional.
|
|
77
|
+
# * +:content_language - String. Response header override. Optional.
|
|
78
|
+
# * +:content_type - String. Response header override. Optional.
|
|
79
|
+
def initialize(path, options, account_name=Azure.config.storage_account_name, access_key=Azure.config.storage_access_key)
|
|
80
|
+
@path = path
|
|
81
|
+
@account_name = account_name
|
|
82
|
+
@options = DEFAULTS.merge(options)
|
|
83
|
+
|
|
84
|
+
super(access_key)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Public: Construct the plaintext to the spec required for signatures
|
|
88
|
+
def signable_string
|
|
89
|
+
# Order is significant
|
|
90
|
+
# The newlines from empty strings here are required
|
|
91
|
+
[
|
|
92
|
+
options[:permissions],
|
|
93
|
+
options[:start],
|
|
94
|
+
options[:expiry],
|
|
95
|
+
canonicalized_resource,
|
|
96
|
+
options[:identifier],
|
|
97
|
+
|
|
98
|
+
options[:version],
|
|
99
|
+
|
|
100
|
+
options[:cache_control],
|
|
101
|
+
options[:content_disposition],
|
|
102
|
+
options[:content_encoding],
|
|
103
|
+
options[:content_language],
|
|
104
|
+
options[:content_type]
|
|
105
|
+
].join("\n")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def canonicalized_resource
|
|
109
|
+
"/#{account_name}/#{path}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Public: A customised URI reflecting options for the resource signed with the Shared Access Signature
|
|
113
|
+
def signed_uri
|
|
114
|
+
query_params = URI.encode_www_form(query_hash)
|
|
115
|
+
"https://#{account_name}.blob.core.windows.net/#{path}?#{query_params}"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def to_s
|
|
119
|
+
signed_uri
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
def signature
|
|
125
|
+
sign(signable_string)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def query_hash
|
|
129
|
+
Hash[options.map { |k, v|
|
|
130
|
+
[KEY_MAPPINGS[k], v]
|
|
131
|
+
}].reject { |k,v|
|
|
132
|
+
OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == ''
|
|
133
|
+
}.merge(
|
|
134
|
+
sig: signature
|
|
135
|
+
)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|