azure 0.1.1 → 0.5.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/.gitignore +6 -0
- data/ChangeLog.txt +5 -0
- data/Gemfile +16 -3
- data/README.md +344 -2
- data/Rakefile +66 -37
- data/azure.gemspec +30 -11
- data/lib/azure.rb +35 -4
- data/lib/azure/blob/blob.rb +32 -0
- data/lib/azure/blob/blob_service.rb +1423 -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/core.rb +32 -0
- data/lib/azure/core/auth/authorizer.rb +36 -0
- data/lib/azure/core/auth/shared_key.rb +21 -6
- data/lib/azure/core/auth/shared_key_lite.rb +17 -3
- data/lib/azure/core/auth/signer.rb +48 -0
- data/lib/azure/core/configuration.rb +152 -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 +84 -0
- data/lib/azure/core/http/http_filter.rb +53 -0
- data/lib/azure/core/http/http_request.rb +157 -0
- data/lib/azure/core/http/http_response.rb +133 -0
- data/lib/azure/core/http/retry_policy.rb +68 -0
- data/lib/azure/core/http/signer_filter.rb +34 -0
- data/lib/azure/core/service.rb +38 -32
- data/lib/azure/core/signed_service.rb +43 -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 +103 -0
- data/lib/azure/service/access_policy.rb +26 -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 +240 -0
- data/lib/azure/service/signed_identifier.rb +30 -0
- data/lib/azure/service/storage_service.rb +79 -0
- data/lib/azure/service/storage_service_properties.rb +32 -0
- data/lib/azure/service_bus/action.rb +21 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +59 -46
- data/lib/azure/service_bus/auth/wrap_signer.rb +69 -0
- data/lib/azure/service_bus/brokered_message.rb +36 -51
- data/lib/azure/service_bus/brokered_message_serializer.rb +48 -34
- 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/{core/utils → service_bus}/interval.rb +29 -22
- data/lib/azure/service_bus/queue.rb +230 -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 +160 -0
- data/lib/azure/service_bus/service_bus_service.rb +819 -12
- 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/{tables → table}/auth/shared_key.rb +33 -12
- 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 +117 -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 +105 -0
- data/lib/azure/table/table_service.rb +557 -0
- data/lib/azure/version.rb +31 -0
- data/test/fixtures/container_acl.xml +11 -0
- data/test/fixtures/{error.xml → http_error.xml} +0 -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_containers.xml +38 -0
- data/test/fixtures/list_page_ranges.xml +11 -0
- data/test/fixtures/logging.xml +11 -0
- data/test/fixtures/metrics.xml +10 -0
- data/test/fixtures/queues.xml +1 -1
- data/test/fixtures/retention_policy.xml +5 -0
- data/test/fixtures/storage_service_properties.xml +23 -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 +50 -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/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_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/rules_test.rb +145 -0
- data/test/integration/service_bus/scenario_test.rb +102 -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/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/update_entity_batch_test.rb +149 -0
- data/test/integration/table/update_entity_test.rb +131 -0
- data/test/integration/test_helper.rb +23 -9
- data/test/support/env.rb +15 -1
- data/test/support/fixtures.rb +14 -0
- data/test/support/name_generator.rb +74 -0
- data/test/support/stubs.rb +14 -0
- data/test/test_helper.rb +43 -3
- data/test/unit/blob/blob_service_test.rb +1947 -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 +57 -0
- data/test/unit/core/http/http_request_test.rb +66 -0
- data/test/unit/core/http/http_response_test.rb +45 -0
- data/test/unit/service/serialization_test.rb +502 -0
- data/test/unit/service/storage_service_test.rb +291 -0
- data/test/unit/table/edmtype_test.rb +108 -0
- metadata +231 -230
- data/Gemfile.lock +0 -36
- data/lib/azure/atom.rb +0 -170
- data/lib/azure/auth.rb +0 -29
- data/lib/azure/blobs.rb +0 -620
- data/lib/azure/blobs/blob.rb +0 -360
- data/lib/azure/blobs/container.rb +0 -209
- data/lib/azure/blobs/service.rb +0 -396
- data/lib/azure/blobs/shared_access_signature.rb +0 -84
- data/lib/azure/blobs/uri.rb +0 -60
- data/lib/azure/configuration.rb +0 -121
- data/lib/azure/core/collection.rb +0 -118
- data/lib/azure/core/signer.rb +0 -32
- data/lib/azure/core/utils/queryable.rb +0 -74
- data/lib/azure/core/utils/storage_service_properties.rb +0 -83
- data/lib/azure/core/utils/string.rb +0 -59
- data/lib/azure/error.rb +0 -72
- data/lib/azure/queues.rb +0 -272
- data/lib/azure/queues/message.rb +0 -174
- data/lib/azure/queues/queue.rb +0 -187
- data/lib/azure/queues/service.rb +0 -263
- data/lib/azure/queues/service_properties.rb +0 -152
- data/lib/azure/queues/uri.rb +0 -78
- data/lib/azure/request.rb +0 -102
- data/lib/azure/response.rb +0 -93
- data/lib/azure/service_bus.rb +0 -4
- data/lib/azure/service_bus/auth/authorizer.rb +0 -22
- data/lib/azure/service_bus/auth/uri.rb +0 -52
- data/lib/azure/service_bus/auth/wrap.rb +0 -37
- data/lib/azure/service_bus/auth/wrap_token.rb +0 -45
- data/lib/azure/service_bus/auth/wrap_token_manager.rb +0 -46
- data/lib/azure/service_bus/queues.rb +0 -194
- data/lib/azure/service_bus/queues/queue.rb +0 -100
- data/lib/azure/service_bus/queues/queue_serializer.rb +0 -51
- data/lib/azure/service_bus/queues/service.rb +0 -154
- data/lib/azure/service_bus/queues/uri.rb +0 -80
- data/lib/azure/service_bus/rules.rb +0 -110
- data/lib/azure/service_bus/rules/rule.rb +0 -97
- data/lib/azure/service_bus/rules/service.rb +0 -122
- data/lib/azure/service_bus/rules/uri.rb +0 -39
- data/lib/azure/service_bus/subscriptions.rb +0 -170
- data/lib/azure/service_bus/subscriptions/service.rb +0 -133
- data/lib/azure/service_bus/subscriptions/subscription.rb +0 -164
- data/lib/azure/service_bus/subscriptions/subscription_serializer.rb +0 -74
- data/lib/azure/service_bus/subscriptions/uri.rb +0 -71
- data/lib/azure/service_bus/topics.rb +0 -120
- data/lib/azure/service_bus/topics/service.rb +0 -98
- data/lib/azure/service_bus/topics/topic.rb +0 -122
- data/lib/azure/service_bus/topics/topic_serializer.rb +0 -44
- data/lib/azure/service_bus/topics/uri.rb +0 -58
- data/lib/azure/service_runtime/client/goal_state_pipe_monitor.rb +0 -21
- data/lib/azure/service_runtime/client/goal_state_protocol.rb +0 -18
- data/lib/azure/service_runtime/client/runtime_client.rb +0 -135
- data/lib/azure/service_runtime/deployment.rb +0 -24
- data/lib/azure/service_runtime/local_resource.rb +0 -15
- data/lib/azure/service_runtime/role.rb +0 -17
- data/lib/azure/service_runtime/role_environment.rb +0 -206
- data/lib/azure/service_runtime/role_environment_change.rb +0 -32
- data/lib/azure/service_runtime/role_instance.rb +0 -35
- data/lib/azure/service_runtime/role_instance_endpoint.rb +0 -14
- data/lib/azure/tables.rb +0 -215
- data/lib/azure/tables/auth/shared_key_lite.rb +0 -30
- data/lib/azure/tables/entities_collection.rb +0 -66
- data/lib/azure/tables/entity.rb +0 -127
- data/lib/azure/tables/service.rb +0 -211
- data/lib/azure/tables/table.rb +0 -129
- data/lib/azure/tables/tables_collection.rb +0 -62
- data/lib/azure/tables/types.rb +0 -65
- data/lib/azure/tables/uri.rb +0 -62
- data/test/integration/blobs/auth_test.rb +0 -19
- data/test/integration/blobs/blob_test.rb +0 -61
- data/test/integration/blobs/clear_page_range_test.rb +0 -19
- data/test/integration/blobs/copy_test.rb +0 -33
- data/test/integration/blobs/create_blobs_test.rb +0 -51
- data/test/integration/blobs/create_container_test.rb +0 -13
- data/test/integration/blobs/create_snapshot_test.rb +0 -17
- data/test/integration/blobs/delete_blob_snapshots_test.rb +0 -19
- data/test/integration/blobs/delete_blobs_test.rb +0 -25
- data/test/integration/blobs/delete_container_test.rb +0 -24
- data/test/integration/blobs/delete_snapshot_test.rb +0 -17
- data/test/integration/blobs/get_blob_snapshot_test.rb +0 -18
- data/test/integration/blobs/get_blobs_test.rb +0 -31
- data/test/integration/blobs/get_page_range_test.rb +0 -19
- data/test/integration/blobs/list_blobs_test.rb +0 -39
- data/test/integration/blobs/list_containers_test.rb +0 -28
- data/test/integration/blobs/manage_blob_leases_test.rb +0 -45
- data/test/integration/blobs/manage_blob_metadata_test.rb +0 -51
- data/test/integration/blobs/manage_blob_properties_test.rb +0 -25
- data/test/integration/blobs/manage_blob_service_properties_test.rb +0 -38
- data/test/integration/blobs/manage_container_metadata_test.rb +0 -46
- data/test/integration/blobs/manage_container_permissions_test.rb +0 -17
- data/test/integration/blobs/update_page_range_test.rb +0 -20
- data/test/integration/queues/clear_messages_test.rb +0 -22
- data/test/integration/queues/create_queue_test.rb +0 -13
- data/test/integration/queues/delete_message_test.rb +0 -42
- data/test/integration/queues/delete_queue_test.rb +0 -24
- data/test/integration/queues/get_messages_test.rb +0 -39
- data/test/integration/queues/list_queues_test.rb +0 -43
- data/test/integration/queues/manage_queue_metadata_test.rb +0 -45
- data/test/integration/queues/manage_queue_service_properties_test.rb +0 -27
- data/test/integration/queues/peek_messages_test.rb +0 -55
- data/test/integration/queues/put_message_test.rb +0 -31
- data/test/integration/queues/update_message_test.rb +0 -46
- data/test/integration/service_bus/auth_test.rb +0 -18
- data/test/integration/service_bus/queues/create_queue_test.rb +0 -25
- data/test/integration/service_bus/queues/delete_message_from_queue_test.rb +0 -29
- data/test/integration/service_bus/queues/delete_queue_test.rb +0 -25
- data/test/integration/service_bus/queues/get_queue_test.rb +0 -23
- data/test/integration/service_bus/queues/list_queues_test.rb +0 -39
- data/test/integration/service_bus/queues/peek_message_from_queue_test.rb +0 -34
- data/test/integration/service_bus/queues/read_and_delete_message_from_queue_test.rb +0 -31
- data/test/integration/service_bus/queues/send_message_to_queue_test.rb +0 -22
- data/test/integration/service_bus/queues/unlock_message_from_queue_test.rb +0 -36
- data/test/integration/service_bus/rules/create_rule_test.rb +0 -19
- data/test/integration/service_bus/rules/delete_rule_test.rb +0 -17
- data/test/integration/service_bus/rules/get_rule_test.rb +0 -21
- data/test/integration/service_bus/rules/list_rules_test.rb +0 -24
- data/test/integration/service_bus/rules/rule_test.rb +0 -16
- data/test/integration/service_bus/subscriptions/create_subscription_test.rb +0 -25
- data/test/integration/service_bus/subscriptions/delete_message_from_subscription_test.rb +0 -31
- data/test/integration/service_bus/subscriptions/delete_subscription_test.rb +0 -30
- data/test/integration/service_bus/subscriptions/fetch_subscription_test.rb +0 -28
- data/test/integration/service_bus/subscriptions/list_subscriptions_test.rb +0 -23
- data/test/integration/service_bus/subscriptions/peek_lock_message_from_subscription_test.rb +0 -42
- data/test/integration/service_bus/subscriptions/read_delete_message_from_subscription_test.rb +0 -36
- data/test/integration/service_bus/subscriptions/subscription_test.rb +0 -31
- data/test/integration/service_bus/subscriptions/unlock_message_from_subscription_test.rb +0 -43
- data/test/integration/service_bus/topics/create_topic_test.rb +0 -25
- data/test/integration/service_bus/topics/delete_topic_test.rb +0 -25
- data/test/integration/service_bus/topics/get_topic_test.rb +0 -23
- data/test/integration/service_bus/topics/list_topics_test.rb +0 -39
- data/test/integration/service_bus/topics/send_message_to_topic_test.rb +0 -23
- data/test/integration/tables/auth_test.rb +0 -29
- data/test/integration/tables/creating_tables_test.rb +0 -16
- data/test/integration/tables/delete_entity_test.rb +0 -39
- data/test/integration/tables/deleting_table_test.rb +0 -22
- data/test/integration/tables/insert_entity_test.rb +0 -23
- data/test/integration/tables/merge_entity_test.rb +0 -28
- data/test/integration/tables/query_entities_test.rb +0 -131
- data/test/integration/tables/query_tables_test.rb +0 -63
- data/test/integration/tables/update_entity_test.rb +0 -54
- data/test/support/blobs.rb +0 -12
- data/test/support/table_names.rb +0 -44
- data/test/unit/atom_test.rb +0 -58
- data/test/unit/auth_test.rb +0 -24
- data/test/unit/blobs/blob_test.rb +0 -5
- data/test/unit/blobs/container_test.rb +0 -67
- data/test/unit/blobs/service_test.rb +0 -17
- data/test/unit/blobs/shared_access_signature_test.rb +0 -66
- data/test/unit/blobs_test.rb +0 -156
- data/test/unit/core/service_test.rb +0 -57
- data/test/unit/core/utils/interval_test.rb +0 -70
- data/test/unit/core/utils/queryable_test.rb +0 -69
- data/test/unit/core/utils/storage_service_properties_test.rb +0 -66
- data/test/unit/error_test.rb +0 -39
- data/test/unit/queues/message_test.rb +0 -40
- data/test/unit/queues/queue_test.rb +0 -64
- data/test/unit/queues/service_properties.rb +0 -35
- data/test/unit/request_test.rb +0 -38
- data/test/unit/response_test.rb +0 -43
- data/test/unit/service_bus/auth/authorizer_test.rb +0 -27
- data/test/unit/service_bus/auth/wrap_token_test.rb +0 -28
- data/test/unit/service_bus/queues/queue_test.rb +0 -38
- data/test/unit/service_bus/topics/topic_test.rb +0 -33
- data/test/unit/service_runtime/data/goalstate.xml +0 -9
- data/test/unit/service_runtime/data/roleenvironmentdata.xml +0 -29
- data/test/unit/service_runtime/data/runtime.xml +0 -6
- data/test/unit/service_runtime/role_environment_test.rb +0 -144
- data/test/unit/tables/auth/shared_key_lite_test.rb +0 -39
- data/test/unit/tables/auth/shared_key_test.rb +0 -45
- data/test/unit/tables/entities_collection_test.rb +0 -39
- data/test/unit/tables/entity_test.rb +0 -72
- data/test/unit/tables/table_test.rb +0 -57
- data/test/unit/tables_test.rb +0 -302
- data/test/unit/types_test.rb +0 -67
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. 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
|
+
#--------------------------------------------------------------------------
|
|
1
15
|
require "azure/core/auth/shared_key"
|
|
2
16
|
|
|
3
17
|
module Azure
|
|
@@ -23,9 +37,9 @@ module Azure
|
|
|
23
37
|
method.to_s.upcase,
|
|
24
38
|
headers.fetch("Content-MD5", ""),
|
|
25
39
|
headers.fetch("Content-Type", ""),
|
|
26
|
-
headers.fetch("Date") { raise
|
|
27
|
-
canonicalized_headers(
|
|
28
|
-
canonicalized_resource(uri)
|
|
40
|
+
headers.fetch("Date") { raise IndexError, "Headers must include Date" },
|
|
41
|
+
canonicalized_headers(headers),
|
|
42
|
+
canonicalized_resource(uri)
|
|
29
43
|
].join("\n")
|
|
30
44
|
end
|
|
31
45
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require "openssl"
|
|
16
|
+
require "base64"
|
|
17
|
+
require "azure/core/configuration"
|
|
18
|
+
|
|
19
|
+
module Azure
|
|
20
|
+
module Core
|
|
21
|
+
module Auth
|
|
22
|
+
# Public: Utility class to sign strings with HMAC-256 and then encode the
|
|
23
|
+
# signed string using Base64.
|
|
24
|
+
class Signer
|
|
25
|
+
# The access key for the account
|
|
26
|
+
attr :access_key
|
|
27
|
+
|
|
28
|
+
# Public: Initialize the Signer.
|
|
29
|
+
#
|
|
30
|
+
# access_key - The access_key encoded in Base64. Defaults to the one
|
|
31
|
+
# in the global configuration.
|
|
32
|
+
def initialize(access_key=Azure.config.storage_access_key)
|
|
33
|
+
@access_key = Base64.strict_decode64(access_key)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Public: Generate an HMAC signature.
|
|
37
|
+
#
|
|
38
|
+
# body - The string to sign.
|
|
39
|
+
#
|
|
40
|
+
# Returns a Base64 String signed with HMAC.
|
|
41
|
+
def sign(body)
|
|
42
|
+
signed = OpenSSL::HMAC.digest("sha256", access_key, body)
|
|
43
|
+
Base64.strict_encode64(signed)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require "singleton"
|
|
16
|
+
|
|
17
|
+
module Azure
|
|
18
|
+
|
|
19
|
+
# Proxy config method.
|
|
20
|
+
def self.config
|
|
21
|
+
Core.config
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Proxy configure method.
|
|
25
|
+
def self.configure
|
|
26
|
+
yield Core.config
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module Core
|
|
30
|
+
|
|
31
|
+
# Public: Sugar to configure the services in a neatly wrapped DSL.
|
|
32
|
+
#
|
|
33
|
+
# Yields the Azure::Configuration instance.
|
|
34
|
+
#
|
|
35
|
+
# Example:
|
|
36
|
+
#
|
|
37
|
+
# Azure.configure do |config|
|
|
38
|
+
# config.storage_account_name = ENV["AZURE_STORAGE_ACCOUNT"]
|
|
39
|
+
# end
|
|
40
|
+
#
|
|
41
|
+
# Returns nothing.
|
|
42
|
+
def self.configure
|
|
43
|
+
yield config
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Public: Access the service configuration.
|
|
47
|
+
#
|
|
48
|
+
# Returns the Azure::Configuration instance.
|
|
49
|
+
def self.config
|
|
50
|
+
Configuration.instance
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Singleton that keeps the configuration of the system.
|
|
54
|
+
class Configuration
|
|
55
|
+
include Singleton
|
|
56
|
+
|
|
57
|
+
# Public: Get/Set the Access Key for this service.
|
|
58
|
+
attr_accessor :storage_access_key
|
|
59
|
+
|
|
60
|
+
# Public: Get/Set the Account Name for this service.
|
|
61
|
+
attr_accessor :storage_account_name
|
|
62
|
+
|
|
63
|
+
# Public: Get/Set the Service Bus Access Key (Issuer Secret) for this service.
|
|
64
|
+
attr_accessor :sb_access_key
|
|
65
|
+
|
|
66
|
+
# Public: Set the Service Bus Issuer for this service.
|
|
67
|
+
attr_writer :sb_issuer
|
|
68
|
+
|
|
69
|
+
# Public: Get the issuer for the service bus. If you set something using #sb_issuer=,
|
|
70
|
+
# then we use that. Otherwise, we default to the default issuer: "owner"
|
|
71
|
+
def sb_issuer
|
|
72
|
+
@sb_issuer || "owner"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Public: Get/Set the Service Bus Namespace for this service.
|
|
76
|
+
attr_accessor :sb_namespace
|
|
77
|
+
|
|
78
|
+
# Public: Set the host for the Table service. Only set this if you want
|
|
79
|
+
# something custom (like, for example, to point this to a LocalStorage
|
|
80
|
+
# emulator). This should be the complete host, including http:// at the
|
|
81
|
+
# start. When using the emulator, make sure to include your account name at
|
|
82
|
+
# the end.
|
|
83
|
+
#
|
|
84
|
+
# Example:
|
|
85
|
+
#
|
|
86
|
+
# config.storage_table_host = "http://127.0.0.1:10002/devstoreaccount1"
|
|
87
|
+
attr_writer :storage_table_host
|
|
88
|
+
|
|
89
|
+
# Public: Get the host for this service. If you set something using #storage_table_host=,
|
|
90
|
+
# then we use that. Else we default to Azure's default hosts, based
|
|
91
|
+
# on your account name.
|
|
92
|
+
def storage_table_host
|
|
93
|
+
@storage_table_host || default_host(:table)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Public: Set the host for the Blob service. Only set this if you want
|
|
97
|
+
# something custom (like, for example, to point this to a LocalStorage
|
|
98
|
+
# emulator). This should be the complete host, including http:// at the
|
|
99
|
+
# start. When using the emulator, make sure to include your account name at
|
|
100
|
+
# the end.
|
|
101
|
+
#
|
|
102
|
+
# Example:
|
|
103
|
+
#
|
|
104
|
+
# config.storage_blob_host = "http://127.0.0.1:10000/devstoreaccount1"
|
|
105
|
+
attr_writer :storage_blob_host
|
|
106
|
+
|
|
107
|
+
# Public: Get the host for this service. If you set something using #storage_blob_host=,
|
|
108
|
+
# then we use that. Else we default to Azure's default hosts, based
|
|
109
|
+
# on your account name.
|
|
110
|
+
def storage_blob_host
|
|
111
|
+
@storage_blob_host || default_host(:blob)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Public: Set the host for the Queue service. Only set this if you want
|
|
115
|
+
# something custom (like, for example, to point this to a LocalStorage
|
|
116
|
+
# emulator). This should be the complete host, including http:// at the
|
|
117
|
+
# start. When using the emulator, make sure to include your account name at
|
|
118
|
+
# the end.
|
|
119
|
+
#
|
|
120
|
+
# Example:
|
|
121
|
+
#
|
|
122
|
+
# config.storage_queue_host = "http://127.0.0.1:10001/devstoreaccount1"
|
|
123
|
+
attr_writer :storage_queue_host
|
|
124
|
+
|
|
125
|
+
# Public: Get the host for this service. If you set something using #storage_queue_host=,
|
|
126
|
+
# then we use that. Else we default to Azure's default hosts, based
|
|
127
|
+
# on your account name.
|
|
128
|
+
def storage_queue_host
|
|
129
|
+
@storage_queue_host || default_host(:queue)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Public: Get the host for the ACS service.
|
|
133
|
+
def acs_host
|
|
134
|
+
"https://#{sb_namespace}-sb.accesscontrol.windows.net"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Public: Get the host for the Service Bus service.
|
|
138
|
+
def service_bus_host
|
|
139
|
+
"https://#{sb_namespace}.servicebus.windows.net"
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Calculate the default host for a given service in the cloud.
|
|
143
|
+
#
|
|
144
|
+
# service - One of :table, :blob, :queue, etc.
|
|
145
|
+
#
|
|
146
|
+
# Returns a String with the hostname, including your account name.
|
|
147
|
+
def default_host(service)
|
|
148
|
+
"http://#{storage_account_name}.#{service}.core.windows.net"
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. 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
|
+
module Azure
|
|
16
|
+
module Core
|
|
17
|
+
# Public: Superclass for errors generated from this library, so people can
|
|
18
|
+
# just rescue this for generic error handling
|
|
19
|
+
class Error < StandardError
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require 'azure/core/service'
|
|
16
|
+
|
|
17
|
+
module Azure
|
|
18
|
+
module Core
|
|
19
|
+
# A base class for Service implementations
|
|
20
|
+
class FilteredService < Service
|
|
21
|
+
|
|
22
|
+
# Create a new instance of the FilteredService
|
|
23
|
+
#
|
|
24
|
+
# host - String. The hostname. (optional, Default empty)
|
|
25
|
+
def initialize(host='')
|
|
26
|
+
super(host)
|
|
27
|
+
@filters = []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
attr_accessor :filters
|
|
31
|
+
|
|
32
|
+
def call(method, uri, body=nil, headers=nil)
|
|
33
|
+
super(method, uri, body, headers) do |request|
|
|
34
|
+
filters.each { |filter| request.with_filter filter } if filters
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def with_filter(filter=nil, &block)
|
|
39
|
+
filter = filter || block
|
|
40
|
+
filters.push filter if filter
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require "azure/core/http/http_filter"
|
|
16
|
+
|
|
17
|
+
module Azure
|
|
18
|
+
module Core
|
|
19
|
+
module Http
|
|
20
|
+
# A HttpFilter implementation that displays information about the request and response for debugging
|
|
21
|
+
class DebugFilter < HttpFilter
|
|
22
|
+
def call(req, _next)
|
|
23
|
+
puts "--REQUEST-BEGIN---------------------------"
|
|
24
|
+
puts "method:", req.method, "uri:", req.uri, "headers:", req.headers, "body:", req.body
|
|
25
|
+
puts "--REQUEST-END---------------------------"
|
|
26
|
+
|
|
27
|
+
r = _next.call
|
|
28
|
+
puts "--RESPONSE-BEGIN---------------------------"
|
|
29
|
+
puts "status_code:", r.status_code, "headers:", r.headers, "body:", r.body
|
|
30
|
+
puts "--RESPONSE-END---------------------------"
|
|
31
|
+
r
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require "azure/core/error"
|
|
16
|
+
|
|
17
|
+
module Azure
|
|
18
|
+
module Core
|
|
19
|
+
module Http
|
|
20
|
+
# Public: Class for handling all HTTP response errors
|
|
21
|
+
class HTTPError < Azure::Core::Error
|
|
22
|
+
|
|
23
|
+
attr :uri
|
|
24
|
+
|
|
25
|
+
# Public: The HTTP status code of this error
|
|
26
|
+
#
|
|
27
|
+
# Returns a Fixnum
|
|
28
|
+
attr :status_code
|
|
29
|
+
|
|
30
|
+
# Public: The type of error
|
|
31
|
+
#
|
|
32
|
+
# http://msdn.microsoft.com/en-us/library/windowsazure/dd179357
|
|
33
|
+
#
|
|
34
|
+
# Returns a String
|
|
35
|
+
attr :type
|
|
36
|
+
|
|
37
|
+
# Public: Description of the error
|
|
38
|
+
#
|
|
39
|
+
# Returns a String
|
|
40
|
+
attr :description
|
|
41
|
+
|
|
42
|
+
# Public: Detail of the error
|
|
43
|
+
#
|
|
44
|
+
# Returns a String
|
|
45
|
+
attr :detail
|
|
46
|
+
|
|
47
|
+
# Public: Initialize an error
|
|
48
|
+
#
|
|
49
|
+
# http_response - An Azure::Core::HttpResponse
|
|
50
|
+
def initialize(http_response)
|
|
51
|
+
@http_response = http_response
|
|
52
|
+
@uri = http_response.uri
|
|
53
|
+
@status_code = http_response.status_code
|
|
54
|
+
parse_response
|
|
55
|
+
super("#{type} (#{status_code}): #{description}")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Extract the relevant information from the response's body. If the response
|
|
59
|
+
# body is not an XML, we return an 'Unknown' error with the entire body as
|
|
60
|
+
# the description
|
|
61
|
+
#
|
|
62
|
+
# Returns nothing
|
|
63
|
+
def parse_response
|
|
64
|
+
if @http_response.body.include?("<")
|
|
65
|
+
|
|
66
|
+
document = Nokogiri.Slop(@http_response.body)
|
|
67
|
+
|
|
68
|
+
@type = document.css("code").first.text if document.css("code").any?
|
|
69
|
+
@type = document.css("Code").first.text if document.css("Code").any?
|
|
70
|
+
@description = document.css("message").first.text if document.css("message").any?
|
|
71
|
+
@description = document.css("Message").first.text if document.css("Message").any?
|
|
72
|
+
|
|
73
|
+
# service bus uses detail instead of message
|
|
74
|
+
@detail = document.css("detail").first.text if document.css("detail").any?
|
|
75
|
+
@detail = document.css("Detail").first.text if document.css("Detail").any?
|
|
76
|
+
else
|
|
77
|
+
@type = "Unknown"
|
|
78
|
+
@description = @http_response.body.strip
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft. 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
|
+
module Azure
|
|
16
|
+
module Core
|
|
17
|
+
module Http
|
|
18
|
+
# A filter which can modify the HTTP pipeline both before and
|
|
19
|
+
# after requests/responses. Multiple filters can be nested in a
|
|
20
|
+
# "Russian Doll" model to create a compound HTTP pipeline
|
|
21
|
+
class HttpFilter
|
|
22
|
+
|
|
23
|
+
# Initialize a HttpFilter
|
|
24
|
+
#
|
|
25
|
+
# &block - An inline block which implements the filter.
|
|
26
|
+
#
|
|
27
|
+
# The inline block should take parameters |request, _next| where
|
|
28
|
+
# request is a HttpRequest and _next is an object that implements
|
|
29
|
+
# a method .call which returns an HttpResponse. The block passed
|
|
30
|
+
# to the constructor should also return HttpResponse, either as
|
|
31
|
+
# the result of calling _next.call or by customized logic.
|
|
32
|
+
#
|
|
33
|
+
def initialize(&block)
|
|
34
|
+
@block = block
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Executes the filter
|
|
38
|
+
#
|
|
39
|
+
# request - HttpRequest. The request
|
|
40
|
+
# _next - An object that implements .call (no params)
|
|
41
|
+
#
|
|
42
|
+
# NOTE: _next is a either a subsequent HttpFilter wrapped in a
|
|
43
|
+
# closure, or the HttpRequest object's call method. Either way,
|
|
44
|
+
# it must have it's .call method executed within each filter to
|
|
45
|
+
# complete the pipeline. _next.call should return an HttpResponse
|
|
46
|
+
# and so should this Filter.
|
|
47
|
+
def call(request, _next)
|
|
48
|
+
@block ? @block.call(request, _next) : _next.call
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|