azure-fix 0.7.0.pre3
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 +13 -0
- data/.gitignore +30 -0
- data/.travis.yml +13 -0
- data/ChangeLog.txt +56 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +202 -0
- data/README.md +702 -0
- data/Rakefile +121 -0
- data/azure.gemspec +51 -0
- data/bin/pfxer +35 -0
- data/lib/azure.rb +147 -0
- data/lib/azure/base_management/affinity_group.rb +32 -0
- data/lib/azure/base_management/base_management_service.rb +220 -0
- data/lib/azure/base_management/location.rb +27 -0
- data/lib/azure/base_management/management_http_request.rb +172 -0
- data/lib/azure/base_management/serialization.rb +135 -0
- data/lib/azure/base_management/sql_management_http_request.rb +35 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +147 -0
- data/lib/azure/blob/blob.rb +32 -0
- data/lib/azure/blob/blob_service.rb +1452 -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/client.rb +31 -0
- data/lib/azure/client_services.rb +98 -0
- data/lib/azure/cloud_service_management/cloud_service.rb +38 -0
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +135 -0
- data/lib/azure/cloud_service_management/serialization.rb +118 -0
- data/lib/azure/configurable.rb +290 -0
- data/lib/azure/core/auth/authorizer.rb +36 -0
- data/lib/azure/core/auth/shared_key.rb +118 -0
- data/lib/azure/core/auth/shared_key_lite.rb +48 -0
- data/lib/azure/core/auth/signer.rb +51 -0
- data/lib/azure/core/error.rb +21 -0
- data/lib/azure/core/filtered_service.rb +45 -0
- data/lib/azure/core/http/debug_filter.rb +36 -0
- data/lib/azure/core/http/http_error.rb +86 -0
- data/lib/azure/core/http/http_filter.rb +53 -0
- data/lib/azure/core/http/http_request.rb +173 -0
- data/lib/azure/core/http/http_response.rb +96 -0
- data/lib/azure/core/http/retry_policy.rb +74 -0
- data/lib/azure/core/http/signer_filter.rb +33 -0
- data/lib/azure/core/service.rb +46 -0
- data/lib/azure/core/signed_service.rb +45 -0
- data/lib/azure/core/utility.rb +244 -0
- data/lib/azure/default.rb +126 -0
- data/lib/azure/http_client.rb +85 -0
- data/lib/azure/queue/message.rb +30 -0
- data/lib/azure/queue/queue.rb +28 -0
- data/lib/azure/queue/queue_service.rb +570 -0
- data/lib/azure/queue/serialization.rb +105 -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 +86 -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/shared_access_signer.rb +44 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +90 -0
- data/lib/azure/service_bus/auth/wrap_signer.rb +77 -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 +899 -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/errors.rb +11 -0
- data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
- data/lib/azure/sql_database_management/serialization.rb +99 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +211 -0
- data/lib/azure/sql_database_management/sql_server.rb +32 -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 +207 -0
- data/lib/azure/table/auth/shared_key.rb +59 -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 +563 -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 +83 -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 +552 -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 +108 -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 +24 -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/management_certificate.pfx +0 -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 +87 -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 +55 -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 +81 -0
- data/test/integration/database/create_sql_server_test.rb +53 -0
- data/test/integration/database/delete_sql_server_firewall_test.rb +64 -0
- data/test/integration/database/delete_sql_server_test.rb +45 -0
- data/test/integration/database/list_sql_server_firewall_test.rb +44 -0
- data/test/integration/database/list_sql_servers_test.rb +44 -0
- data/test/integration/database/reset_password_sql_server_test.rb +53 -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 +43 -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 +196 -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 +40 -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 +47 -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/base_management_service_test.rb +19 -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 +1970 -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/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 +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 +61 -0
- data/test/unit/core/http/http_request_test.rb +138 -0
- data/test/unit/core/http/http_response_test.rb +20 -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 +94 -0
- data/test/unit/database/sql_database_server_service_test.rb +341 -0
- data/test/unit/http_client_test.rb +74 -0
- data/test/unit/service/serialization_test.rb +533 -0
- data/test/unit/service/storage_service_test.rb +297 -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 +480 -0
- data/test/unit/vnet/serialization_test.rb +187 -0
- data/test/unit/vnet/virtual_network_management_service_test.rb +131 -0
- metadata +579 -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,172 @@
|
|
|
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
|
+
|
|
18
|
+
# Represents an HTTP request that can perform synchronous queries to
|
|
19
|
+
# an HTTP server, returning a HttpResponse
|
|
20
|
+
module Azure
|
|
21
|
+
module BaseManagement
|
|
22
|
+
class ManagementHttpRequest < Azure::Core::Http::HttpRequest
|
|
23
|
+
include Azure::Core::Utility
|
|
24
|
+
attr_accessor :warn
|
|
25
|
+
|
|
26
|
+
# Creates the ManagementHttpRequest
|
|
27
|
+
#
|
|
28
|
+
# @param method [Symbol] The HTTP method to use (:get, :post, :put, :del, etc...)
|
|
29
|
+
# @param path [URI] The URI of the HTTP endpoint to query
|
|
30
|
+
# @param options_or_body [Hash|IO|String] The request options including {:client, :body} or raw body only
|
|
31
|
+
def initialize(method, path, options_or_body = {})
|
|
32
|
+
options ||= unless options_or_body.is_a?(Hash)
|
|
33
|
+
{body: options_or_body}
|
|
34
|
+
end || options_or_body || {}
|
|
35
|
+
options[:client] ||= Azure
|
|
36
|
+
super(method, self.class.request_uri(path, options[:client]), options)
|
|
37
|
+
@warn = options.fetch(:warn, false)
|
|
38
|
+
content_length = body ? body.bytesize.to_s : '0'
|
|
39
|
+
headers.update({
|
|
40
|
+
'x-ms-version' => '2015-04-01',
|
|
41
|
+
'Content-Type' => 'application/xml',
|
|
42
|
+
'Content-Length' => content_length
|
|
43
|
+
})
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Public: Sends a request to HTTP server and returns a HttpResponse
|
|
47
|
+
#
|
|
48
|
+
# Returns a Nokogiri::XML instance of HttpResponse body
|
|
49
|
+
def call
|
|
50
|
+
conn = http_setup
|
|
51
|
+
res = conn.run_request(method.to_sym, uri, nil, nil) do |req|
|
|
52
|
+
req.body = body if body
|
|
53
|
+
req.headers = headers if headers
|
|
54
|
+
end
|
|
55
|
+
response = wait_for_completion(Azure::Core::Http::HttpResponse.new(res))
|
|
56
|
+
Nokogiri::XML response.body unless response.nil?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def apply_body_headers
|
|
60
|
+
super
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Public: Wait for HTTP request completion.
|
|
64
|
+
#
|
|
65
|
+
# ==== Attributes
|
|
66
|
+
#
|
|
67
|
+
# * +response+ - Azure::Core::Http::HttpResponse. HttpResponse Response
|
|
68
|
+
#
|
|
69
|
+
# Print Error or Success of HttpRequest
|
|
70
|
+
def wait_for_completion(response)
|
|
71
|
+
ret_val = Nokogiri::XML response.body
|
|
72
|
+
if ret_val.at_css('Error Code') && ret_val.at_css('Error Code').content == 'AuthenticationFailed'
|
|
73
|
+
Azure::Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
|
|
74
|
+
end
|
|
75
|
+
if response.status_code.to_i == 200 || response.status_code.to_i == 201
|
|
76
|
+
response
|
|
77
|
+
elsif redirected? response
|
|
78
|
+
rebuild_request response
|
|
79
|
+
elsif response.status_code.to_i > 201 && response.status_code.to_i <= 299
|
|
80
|
+
check_completion(response.headers['x-ms-request-id'])
|
|
81
|
+
elsif warn && !response.success?
|
|
82
|
+
response
|
|
83
|
+
elsif response.body
|
|
84
|
+
if ret_val.at_css('Error Code') && ret_val.at_css('Error Message')
|
|
85
|
+
Azure::Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
|
|
86
|
+
else
|
|
87
|
+
Azure::Loggerx.exception_message "http error: #{response.status_code}"
|
|
88
|
+
end
|
|
89
|
+
else
|
|
90
|
+
Azure::Loggerx.exception_message "http error: #{response.status_code}"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def http_setup
|
|
95
|
+
http = super
|
|
96
|
+
http.ssl[:client_cert] = @client.http_certificate_key if @client.http_certificate_key
|
|
97
|
+
http.ssl[:client_key] = @client.http_private_key if @client.http_private_key
|
|
98
|
+
http
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Public: Gets the status of the specified operation and determines whether
|
|
102
|
+
# the operation has succeeded, failed, or is still in progress.
|
|
103
|
+
#
|
|
104
|
+
# ==== Attributes
|
|
105
|
+
#
|
|
106
|
+
# * +request_id+ - String. x-ms-request-id response header of request
|
|
107
|
+
#
|
|
108
|
+
# See: http://msdn.microsoft.com/en-us/library/azure/ee460783.aspx
|
|
109
|
+
#
|
|
110
|
+
# Print Error or Success of Operation.
|
|
111
|
+
def check_completion(request_id)
|
|
112
|
+
request_path = "/#{client.subscription_id}/operations/#{request_id}"
|
|
113
|
+
conn = http_setup
|
|
114
|
+
headers['Content-Length'] = '0'
|
|
115
|
+
@method = :get
|
|
116
|
+
done = false
|
|
117
|
+
until done
|
|
118
|
+
Azure::Loggerx.info('# ')
|
|
119
|
+
res = conn.run_request(method.to_sym, URI(request_path), nil, nil) do |req|
|
|
120
|
+
req.body = body if body
|
|
121
|
+
req.headers = headers if headers
|
|
122
|
+
end
|
|
123
|
+
response = Azure::Core::Http::HttpResponse.new(res)
|
|
124
|
+
ret_val = Nokogiri::XML response.body
|
|
125
|
+
status = xml_content(ret_val, 'Operation Status')
|
|
126
|
+
status_code = response.status_code.to_i
|
|
127
|
+
if status != 'InProgress'
|
|
128
|
+
done = true
|
|
129
|
+
end
|
|
130
|
+
if redirected? response
|
|
131
|
+
@uri = self.class.request_uri(response.headers['location'], client)
|
|
132
|
+
conn = http_setup
|
|
133
|
+
done = false
|
|
134
|
+
end
|
|
135
|
+
if done
|
|
136
|
+
if status.downcase != 'succeeded'
|
|
137
|
+
error_code = xml_content(ret_val, 'Operation Error Code')
|
|
138
|
+
error_msg = xml_content(ret_val, 'Operation Error Message')
|
|
139
|
+
Azure::Loggerx.exception_message "#{error_code}: #{error_msg}"
|
|
140
|
+
else
|
|
141
|
+
Azure::Loggerx.success "#{status.downcase} (#{status_code})"
|
|
142
|
+
end
|
|
143
|
+
return
|
|
144
|
+
else
|
|
145
|
+
sleep(5)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def rebuild_request(response)
|
|
151
|
+
host_uri = URI.parse(response.headers['location'])
|
|
152
|
+
conn = http_setup
|
|
153
|
+
res = conn.run_request(method.to_sym, host_uri, nil, nil) do |req|
|
|
154
|
+
req.body = body if body
|
|
155
|
+
req.headers = headers if headers
|
|
156
|
+
end
|
|
157
|
+
wait_for_completion(HttpResponse.new(res))
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def redirected?(response)
|
|
161
|
+
(response.status_code.to_i == 307)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
private
|
|
165
|
+
|
|
166
|
+
def self.request_uri(path, client)
|
|
167
|
+
relative_path = path =~ /^\// ? path[1..-1] : path # remove the starting slash in the relative path if exists
|
|
168
|
+
URI.join(client.management_endpoint, '/' + client.subscription_id + '/', relative_path)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
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,35 @@
|
|
|
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
|
+
|
|
22
|
+
# Creates the SqlManagementHttpRequest
|
|
23
|
+
#
|
|
24
|
+
# @param method [Symbol] The HTTP method to use (:get, :post, :put, :del, etc...)
|
|
25
|
+
# @param path [URI] The URI of the HTTP endpoint to query
|
|
26
|
+
# @param options_or_body [Hash|IO|String] The request options including {:client, :body} or raw body only
|
|
27
|
+
def initialize(method, path, options_or_body = {})
|
|
28
|
+
path = '/services/sqlservers' + (path.start_with?('/') ? path : '/' + path)
|
|
29
|
+
super(method, path, options_or_body)
|
|
30
|
+
headers['x-ms-version'] = '2012-03-01'
|
|
31
|
+
self.uri = URI.parse(Azure.config.sql_database_management_endpoint + Azure.config.subscription_id + path)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
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/auth/signer'
|
|
19
|
+
|
|
20
|
+
# This will break if used against API version prior to 2013-08-15 as the format
|
|
21
|
+
# changed
|
|
22
|
+
# @see https://msdn.microsoft.com/library/azure/dn140255.aspx for more information on construction
|
|
23
|
+
module Azure
|
|
24
|
+
module Blob
|
|
25
|
+
module Auth
|
|
26
|
+
class SharedAccessSignature < Azure::Core::Auth::Signer
|
|
27
|
+
DEFAULTS = {
|
|
28
|
+
resource: 'b',
|
|
29
|
+
permissions: 'r',
|
|
30
|
+
version: '2014-02-14'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
KEY_MAPPINGS = {
|
|
34
|
+
permissions: :sp,
|
|
35
|
+
start: :st,
|
|
36
|
+
expiry: :se,
|
|
37
|
+
resource: :sr,
|
|
38
|
+
identifier: :si,
|
|
39
|
+
version: :sv,
|
|
40
|
+
cache_control: :rscc,
|
|
41
|
+
content_disposition: :rscd,
|
|
42
|
+
content_encoding: :rsce,
|
|
43
|
+
content_language: :rscl,
|
|
44
|
+
content_type: :rsct
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
OPTIONAL_QUERY_PARAMS = [:sp, :si, :rscc, :rscd, :rsce, :rscl, :rsct]
|
|
48
|
+
|
|
49
|
+
attr :account_name
|
|
50
|
+
|
|
51
|
+
# Public: Initialize the Signer.
|
|
52
|
+
#
|
|
53
|
+
# @param account_name [String] The account name. Defaults to the one in the global configuration.
|
|
54
|
+
# @param access_key [String] The access_key encoded in Base64. Defaults to the one in the global configuration.
|
|
55
|
+
def initialize(account_name=Azure.storage_account_name, access_key=Azure.storage_access_key)
|
|
56
|
+
@account_name = account_name
|
|
57
|
+
super(access_key)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Construct the plaintext to the spec required for signatures
|
|
61
|
+
# @return [String]
|
|
62
|
+
def signable_string(path, options)
|
|
63
|
+
# Order is significant
|
|
64
|
+
# The newlines from empty strings here are required
|
|
65
|
+
[
|
|
66
|
+
options[:permissions],
|
|
67
|
+
options[:start],
|
|
68
|
+
options[:expiry],
|
|
69
|
+
canonicalized_resource(path),
|
|
70
|
+
options[:identifier],
|
|
71
|
+
|
|
72
|
+
options[:version],
|
|
73
|
+
|
|
74
|
+
options[:cache_control],
|
|
75
|
+
options[:content_disposition],
|
|
76
|
+
options[:content_encoding],
|
|
77
|
+
options[:content_language],
|
|
78
|
+
options[:content_type]
|
|
79
|
+
].join("\n")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Return the cononicalized resource representation of the blob resource
|
|
83
|
+
# @return [String]
|
|
84
|
+
def canonicalized_resource(path)
|
|
85
|
+
"/#{account_name}#{path.start_with?('/') ? '' : '/'}#{path}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# A customised URI reflecting options for the resource signed with the Shared Access Signature
|
|
89
|
+
# @param uri [URI] uri to resource including query options
|
|
90
|
+
# @param options [Hash]
|
|
91
|
+
#
|
|
92
|
+
# ==== Options
|
|
93
|
+
#
|
|
94
|
+
# * +:resource+ - String. Resource type, either 'b' (blob) or 'c' (container). Default 'b'
|
|
95
|
+
# * +:permissions+ - String. Combination of 'r','w','d','l' (container only) in this order. Default 'r'
|
|
96
|
+
# * +:start+ - String. UTC Date/Time in ISO8601 format. Optional.
|
|
97
|
+
# * +:expiry+ - String. UTC Date/Time in ISO8601 format. Optional. Default now + 30 minutes.
|
|
98
|
+
# * +:identifier+ - String. Identifier for stored access policy. Optional
|
|
99
|
+
# * +:version+ - String. API version. Default 2014-02-14
|
|
100
|
+
#
|
|
101
|
+
# * +:cache_control+ - String. Response header override. Optional.
|
|
102
|
+
# * +:content_disposition+ - String. Response header override. Optional.
|
|
103
|
+
# * +:content_encoding+ - String. Response header override. Optional.
|
|
104
|
+
# * +:content_language+ - String. Response header override. Optional.
|
|
105
|
+
# * +:content_type+ - String. Response header override. Optional.
|
|
106
|
+
def signed_uri(uri, options)
|
|
107
|
+
parsed_query = CGI::parse(uri.query || '').inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
|
108
|
+
|
|
109
|
+
options[:expiry] ||= (Time.now + 60*30).utc.iso8601
|
|
110
|
+
|
|
111
|
+
if parsed_query.has_key?(:restype)
|
|
112
|
+
options[:resource] = parsed_query[:restype].first == 'container' ? 'c' : 'b'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
options = DEFAULTS.merge(options)
|
|
116
|
+
sas_params = URI.encode_www_form(query_hash(uri.path, options))
|
|
117
|
+
URI.parse(uri.to_s + (uri.query.nil? ? '?' : '&') + sas_params)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def sign_request(req)
|
|
121
|
+
header_options = {}.tap do |opts|
|
|
122
|
+
opts[:version] = req.headers['x-ms-version'] if req.headers.has_key?('x-ms-version')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
req.uri = signed_uri(req.uri, header_options)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
def signature(path, options)
|
|
131
|
+
sign(signable_string(path, options))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def query_hash(path, options)
|
|
135
|
+
Hash[options.map { |k, v|
|
|
136
|
+
[KEY_MAPPINGS[k], v]
|
|
137
|
+
}].reject { |k, v|
|
|
138
|
+
OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == ''
|
|
139
|
+
}.merge(
|
|
140
|
+
sig: signature(path, options)
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|