gitlab-fog-azure-rm 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.arclint +8 -0
- data/.codeclimate.yml +17 -0
- data/.gitignore +6 -0
- data/.gitlab-ci.yml +17 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +274 -0
- data/.travis.yml +49 -0
- data/CHANGELOG.md +414 -0
- data/CONTRIBUTING.md +40 -0
- data/CONTRIBUTORS.md +12 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +100 -0
- data/gitlab-fog-azure-rm.gemspec +31 -0
- data/lib/fog/azurerm.rb +30 -0
- data/lib/fog/azurerm/async_response.rb +44 -0
- data/lib/fog/azurerm/config.rb +1 -0
- data/lib/fog/azurerm/constants.rb +72 -0
- data/lib/fog/azurerm/credentials.rb +40 -0
- data/lib/fog/azurerm/custom_fog_errors.rb +52 -0
- data/lib/fog/azurerm/docs/storage.md +398 -0
- data/lib/fog/azurerm/docs/structure.md +53 -0
- data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
- data/lib/fog/azurerm/models/resources/azure_resources.rb +40 -0
- data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
- data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
- data/lib/fog/azurerm/models/resources/deployments.rb +30 -0
- data/lib/fog/azurerm/models/resources/provider.rb +27 -0
- data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
- data/lib/fog/azurerm/models/resources/resource_group.rb +34 -0
- data/lib/fog/azurerm/models/resources/resource_groups.rb +29 -0
- data/lib/fog/azurerm/models/storage/directories.rb +75 -0
- data/lib/fog/azurerm/models/storage/directory.rb +151 -0
- data/lib/fog/azurerm/models/storage/file.rb +265 -0
- data/lib/fog/azurerm/models/storage/files.rb +183 -0
- data/lib/fog/azurerm/models/storage/kind.rb +12 -0
- data/lib/fog/azurerm/models/storage/sku_name.rb +15 -0
- data/lib/fog/azurerm/models/storage/sku_tier.rb +12 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +92 -0
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +47 -0
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +32 -0
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +32 -0
- data/lib/fog/azurerm/requests/storage/check_container_exists.rb +30 -0
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
- data/lib/fog/azurerm/requests/storage/copy_object.rb +20 -0
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +40 -0
- data/lib/fog/azurerm/requests/storage/create_disk.rb +62 -0
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +32 -0
- data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/delete_container.rb +31 -0
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
- data/lib/fog/azurerm/requests/storage/delete_object_url.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +55 -0
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +41 -0
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
- data/lib/fog/azurerm/requests/storage/get_object_url.rb +21 -0
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +168 -0
- data/lib/fog/azurerm/requests/storage/list_containers.rb +73 -0
- data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
- data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_object_url.rb +30 -0
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +30 -0
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +30 -0
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
- data/lib/fog/azurerm/storage.rb +126 -0
- data/lib/fog/azurerm/utilities/general.rb +186 -0
- data/lib/fog/azurerm/utilities/logger_messages.yml +19 -0
- data/lib/fog/azurerm/version.rb +5 -0
- data/rake-script.sh +10 -0
- data/rakefile +29 -0
- data/test/api_stub.rb +147 -0
- data/test/api_stub/models/storage/directory.rb +178 -0
- data/test/api_stub/models/storage/file.rb +181 -0
- data/test/api_stub/requests/storage/directory.rb +89 -0
- data/test/api_stub/requests/storage/file.rb +252 -0
- data/test/integration/README.md +14 -0
- data/test/integration/blob.rb +297 -0
- data/test/integration/container.rb +160 -0
- data/test/integration/credentials/azure.yml +5 -0
- data/test/integration/storage_account.rb +135 -0
- data/test/models/storage/test_directories.rb +74 -0
- data/test/models/storage/test_directory.rb +178 -0
- data/test/models/storage/test_file.rb +294 -0
- data/test/models/storage/test_files.rb +234 -0
- data/test/requests/storage/test_acquire_blob_lease.rb +36 -0
- data/test/requests/storage/test_acquire_container_lease.rb +36 -0
- data/test/requests/storage/test_check_container_exists.rb +18 -0
- data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
- data/test/requests/storage/test_compare_container_blobs.rb +36 -0
- data/test/requests/storage/test_copy_blob.rb +39 -0
- data/test/requests/storage/test_copy_blob_from_uri.rb +36 -0
- data/test/requests/storage/test_create_block_blob.rb +80 -0
- data/test/requests/storage/test_create_container.rb +36 -0
- data/test/requests/storage/test_create_disk.rb +70 -0
- data/test/requests/storage/test_create_page_blob.rb +34 -0
- data/test/requests/storage/test_delete_blob.rb +42 -0
- data/test/requests/storage/test_delete_blob_https_url.rb +32 -0
- data/test/requests/storage/test_delete_container.rb +42 -0
- data/test/requests/storage/test_delete_disk.rb +30 -0
- data/test/requests/storage/test_get_blob.rb +141 -0
- data/test/requests/storage/test_get_blob_http_url.rb +30 -0
- data/test/requests/storage/test_get_blob_https_url.rb +32 -0
- data/test/requests/storage/test_get_blob_properties.rb +47 -0
- data/test/requests/storage/test_get_blob_url.rb +75 -0
- data/test/requests/storage/test_get_container_acl.rb +37 -0
- data/test/requests/storage/test_get_container_properties.rb +45 -0
- data/test/requests/storage/test_get_container_url.rb +33 -0
- data/test/requests/storage/test_list_blobs.rb +77 -0
- data/test/requests/storage/test_list_containers.rb +54 -0
- data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
- data/test/requests/storage/test_put_blob_block.rb +34 -0
- data/test/requests/storage/test_put_blob_https_url.rb +32 -0
- data/test/requests/storage/test_put_blob_metadata.rb +36 -0
- data/test/requests/storage/test_put_blob_pages.rb +34 -0
- data/test/requests/storage/test_put_blob_properties.rb +39 -0
- data/test/requests/storage/test_put_container_acl.rb +34 -0
- data/test/requests/storage/test_put_container_metadata.rb +36 -0
- data/test/requests/storage/test_release_blob_lease.rb +34 -0
- data/test/requests/storage/test_release_container_lease.rb +34 -0
- data/test/requests/storage/test_save_page_blob.rb +115 -0
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
- data/test/smoke_tests/compute/test_resource_group_smoke.rb +37 -0
- data/test/test_credentials.rb +63 -0
- data/test/test_helper.rb +846 -0
- metadata +352 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Get a pre-signed URL to delete an object in Azure blob storage
|
7
|
+
# This is to make this library compatible with CarrierWave.
|
8
|
+
#
|
9
|
+
# @param container_name [String] Name of container containing blob
|
10
|
+
# @param blob_name [String] Name of blob to get expiring url for
|
11
|
+
# @param expires [Time] An expiry time for this url
|
12
|
+
#
|
13
|
+
# @return [String] - https url for blob
|
14
|
+
#
|
15
|
+
# @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob
|
16
|
+
#
|
17
|
+
def delete_object_url(container_name, blob_name, expires)
|
18
|
+
delete_blob_https_url(container_name, blob_name, expires)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This class provides the mock implementation for unit tests.
|
23
|
+
class Mock
|
24
|
+
def delete_object_url(*args)
|
25
|
+
delete_blob_https_url(*args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
BLOCK_SIZE = 32 * 1024 * 1024 # 32 MB
|
7
|
+
|
8
|
+
def get_blob_with_block_given(container_name, blob_name, options, &_block)
|
9
|
+
options[:request_id] = SecureRandom.uuid
|
10
|
+
msg = "get_blob_with_block_given: blob #{blob_name} in the container #{container_name}. options: #{options}"
|
11
|
+
Fog::Logger.debug msg
|
12
|
+
|
13
|
+
begin
|
14
|
+
blob = @blob_client.get_blob_properties(container_name, blob_name, options)
|
15
|
+
rescue Azure::Core::Http::HTTPError => ex
|
16
|
+
raise 'NotFound' if ex.message.include?('(404)')
|
17
|
+
raise_azure_exception(ex, msg)
|
18
|
+
end
|
19
|
+
|
20
|
+
content_length = blob.properties[:content_length]
|
21
|
+
if content_length.zero?
|
22
|
+
Proc.new.call('', 0, 0)
|
23
|
+
return [blob, '']
|
24
|
+
end
|
25
|
+
|
26
|
+
start_range = 0
|
27
|
+
end_range = content_length - 1
|
28
|
+
start_range = options[:start_range] if options[:start_range]
|
29
|
+
end_range = options[:end_range] if options[:end_range]
|
30
|
+
raise ArgumentError.new(':end_range MUST be greater than :start_range') if start_range > end_range
|
31
|
+
|
32
|
+
if start_range == end_range
|
33
|
+
Proc.new.call('', 0, 0)
|
34
|
+
return [blob, '']
|
35
|
+
end
|
36
|
+
|
37
|
+
buffer_size = BLOCK_SIZE
|
38
|
+
buffer_size = options[:block_size] if options[:block_size]
|
39
|
+
buffer_start_range = start_range
|
40
|
+
total_bytes = end_range - start_range + 1
|
41
|
+
params = options.dup
|
42
|
+
|
43
|
+
while buffer_start_range < end_range
|
44
|
+
buffer_end_range = [end_range, buffer_start_range + buffer_size - 1].min
|
45
|
+
params[:start_range] = buffer_start_range
|
46
|
+
params[:end_range] = buffer_end_range
|
47
|
+
params[:request_id] = SecureRandom.uuid
|
48
|
+
|
49
|
+
begin
|
50
|
+
msg = "get_blob_with_block_given: blob #{blob_name} in the container #{container_name}. options: #{params}"
|
51
|
+
Fog::Logger.debug msg
|
52
|
+
_, content = @blob_client.get_blob(container_name, blob_name, params)
|
53
|
+
rescue Azure::Core::Http::HTTPError => ex
|
54
|
+
raise 'NotFound' if ex.message.include?('(404)')
|
55
|
+
raise_azure_exception(ex, msg)
|
56
|
+
end
|
57
|
+
|
58
|
+
Proc.new.call(content, end_range - buffer_end_range, total_bytes)
|
59
|
+
buffer_start_range += buffer_size
|
60
|
+
end
|
61
|
+
# No need to return content when block is given.
|
62
|
+
[blob, '']
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_blob(container_name, blob_name, options = {}, &block)
|
66
|
+
if block_given?
|
67
|
+
get_blob_with_block_given(container_name, blob_name, options, &block)
|
68
|
+
else
|
69
|
+
options[:request_id] = SecureRandom.uuid
|
70
|
+
msg = "get_blob blob #{blob_name} in the container #{container_name}. options: #{options}"
|
71
|
+
Fog::Logger.debug msg
|
72
|
+
|
73
|
+
begin
|
74
|
+
blob, content = @blob_client.get_blob(container_name, blob_name, options)
|
75
|
+
Fog::Logger.debug "Get blob #{blob_name} successfully."
|
76
|
+
[blob, content]
|
77
|
+
rescue Azure::Core::Http::HTTPError => ex
|
78
|
+
raise 'NotFound' if ex.message.include?('(404)')
|
79
|
+
raise_azure_exception(ex, msg)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# This class provides the mock implementation for unit tests.
|
86
|
+
class Mock
|
87
|
+
def get_blob(_container_name, _blob_name, _options = {}, &_block)
|
88
|
+
Fog::Logger.debug 'get_blob successfully.'
|
89
|
+
unless block_given?
|
90
|
+
return [
|
91
|
+
{
|
92
|
+
'name' => 'test_blob',
|
93
|
+
'metadata' => {},
|
94
|
+
'properties' => {
|
95
|
+
'last_modified' => 'Mon, 04 Jul 2016 09:30:31 GMT',
|
96
|
+
'etag' => '0x8D3A3EDD7C2B777',
|
97
|
+
'lease_status' => 'unlocked',
|
98
|
+
'lease_state' => 'available',
|
99
|
+
'lease_duration' => nil,
|
100
|
+
'content_length' => 4_194_304,
|
101
|
+
'content_type' => 'application/octet-stream',
|
102
|
+
'content_encoding' => nil,
|
103
|
+
'content_language' => nil,
|
104
|
+
'content_disposition' => nil,
|
105
|
+
'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
|
106
|
+
'cache_control' => nil,
|
107
|
+
'sequence_number' => 0,
|
108
|
+
'blob_type' => 'PageBlob',
|
109
|
+
'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
|
110
|
+
'copy_status' => 'success',
|
111
|
+
'copy_source' => 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
|
112
|
+
'copy_progress' => '4194304/4194304',
|
113
|
+
'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
|
114
|
+
'copy_status_description' => nil,
|
115
|
+
'accept_ranges' => 0
|
116
|
+
}
|
117
|
+
},
|
118
|
+
'content'
|
119
|
+
]
|
120
|
+
end
|
121
|
+
data = StringIO.new('content')
|
122
|
+
remaining = total_bytes = data.length
|
123
|
+
while remaining > 0
|
124
|
+
chunk = data.read([remaining, 2].min)
|
125
|
+
Proc.new.call(chunk, remaining, total_bytes)
|
126
|
+
remaining -= 2
|
127
|
+
end
|
128
|
+
|
129
|
+
[
|
130
|
+
{
|
131
|
+
'name' => 'test_blob',
|
132
|
+
'metadata' => {},
|
133
|
+
'properties' => {
|
134
|
+
'last_modified' => 'Mon, 04 Jul 2016 09:30:31 GMT',
|
135
|
+
'etag' => '0x8D3A3EDD7C2B777',
|
136
|
+
'lease_status' => 'unlocked',
|
137
|
+
'lease_state' => 'available',
|
138
|
+
'lease_duration' => nil,
|
139
|
+
'content_length' => 4_194_304,
|
140
|
+
'content_type' => 'application/octet-stream',
|
141
|
+
'content_encoding' => nil,
|
142
|
+
'content_language' => nil,
|
143
|
+
'content_disposition' => nil,
|
144
|
+
'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
|
145
|
+
'cache_control' => nil,
|
146
|
+
'sequence_number' => 0,
|
147
|
+
'blob_type' => 'PageBlob',
|
148
|
+
'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
|
149
|
+
'copy_status' => 'success',
|
150
|
+
'copy_source' => 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
|
151
|
+
'copy_progress' => '4194304/4194304',
|
152
|
+
'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
|
153
|
+
'copy_status_description' => nil,
|
154
|
+
'accept_ranges' => 0
|
155
|
+
}
|
156
|
+
},
|
157
|
+
''
|
158
|
+
]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Get an expiring http blob url from Azure blob storage
|
7
|
+
#
|
8
|
+
# @param container_name [String] Name of container containing blob
|
9
|
+
# @param blob_name [String] Name of blob to get expiring url for
|
10
|
+
# @param expires [Time] An expiry time for this url
|
11
|
+
#
|
12
|
+
# @return [String] - http url for blob
|
13
|
+
#
|
14
|
+
# @see https://msdn.microsoft.com/en-us/library/azure/mt584140.aspx
|
15
|
+
#
|
16
|
+
def get_blob_http_url(container_name, blob_name, expires)
|
17
|
+
relative_path = "#{container_name}/#{blob_name}"
|
18
|
+
params = {
|
19
|
+
service: 'b',
|
20
|
+
resource: 'b',
|
21
|
+
permissions: 'r',
|
22
|
+
expiry: expires.utc.iso8601
|
23
|
+
}
|
24
|
+
token = @signature_client.generate_service_sas_token(relative_path, params)
|
25
|
+
uri = @blob_client.generate_uri(relative_path)
|
26
|
+
url = "#{uri}?#{token}"
|
27
|
+
url.gsub('https:', 'http:')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# This class provides the mock implementation for unit tests.
|
32
|
+
class Mock
|
33
|
+
def get_blob_http_url(*)
|
34
|
+
'http://sa.blob.core.windows.net/test_container/test_blob?token'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Get an expiring https blob url from Azure blob storage
|
7
|
+
#
|
8
|
+
# @param container_name [String] Name of container containing blob
|
9
|
+
# @param blob_name [String] Name of blob to get expiring url for
|
10
|
+
# @param expires [Time] An expiry time for this url
|
11
|
+
#
|
12
|
+
# @return [String] - https url for blob
|
13
|
+
#
|
14
|
+
# @see https://msdn.microsoft.com/en-us/library/azure/mt584140.aspx
|
15
|
+
#
|
16
|
+
def get_blob_https_url(container_name, blob_name, expires)
|
17
|
+
relative_path = "#{container_name}/#{blob_name}"
|
18
|
+
params = {
|
19
|
+
service: 'b',
|
20
|
+
resource: 'b',
|
21
|
+
permissions: 'r',
|
22
|
+
expiry: expires.utc.iso8601,
|
23
|
+
protocol: 'https'
|
24
|
+
}
|
25
|
+
token = @signature_client.generate_service_sas_token(relative_path, params)
|
26
|
+
uri = @blob_client.generate_uri(relative_path)
|
27
|
+
"#{uri}?#{token}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# This class provides the mock implementation for unit tests.
|
32
|
+
class Mock
|
33
|
+
def get_blob_https_url(*)
|
34
|
+
'https://sa.blob.core.windows.net/test_container/test_blob?token'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def get_blob_properties(container_name, name, options = {})
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "Get Blob #{name} properties in container #{container_name}, options: #{options}."
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
begin
|
11
|
+
blob = @blob_client.get_blob_properties(container_name, name, options)
|
12
|
+
rescue Azure::Core::Http::HTTPError => ex
|
13
|
+
raise 'NotFound' if ex.message.include?('(404)')
|
14
|
+
raise_azure_exception(ex, msg)
|
15
|
+
end
|
16
|
+
Fog::Logger.debug "Getting properties of blob #{name} successfully."
|
17
|
+
blob
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# This class provides the mock implementation for unit tests.
|
22
|
+
class Mock
|
23
|
+
def get_blob_properties(*)
|
24
|
+
blob = Azure::Storage::Blob::Blob.new
|
25
|
+
blob.name = 'test_blob'
|
26
|
+
blob.metadata = {}
|
27
|
+
blob.properties = {
|
28
|
+
last_modified: 'Mon, 04 Jul 2016 09:30:31 GMT',
|
29
|
+
etag: '0x8D3A3EDD7C2B777',
|
30
|
+
lease_status: 'unlocked',
|
31
|
+
lease_state: 'available',
|
32
|
+
lease_duration: nil,
|
33
|
+
content_length: 4_194_304,
|
34
|
+
content_type: 'application/octet-stream',
|
35
|
+
content_encoding: nil,
|
36
|
+
content_language: nil,
|
37
|
+
content_disposition: nil,
|
38
|
+
content_md5: 'tXAohIyxuu/t94Lp/ujeRw==',
|
39
|
+
cache_control: nil,
|
40
|
+
sequence_number: 0,
|
41
|
+
blob_type: 'PageBlob',
|
42
|
+
copy_id: '095adc3b-e277-4c3d-97e0-0abca881f60c',
|
43
|
+
copy_status: 'success',
|
44
|
+
copy_source: 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
|
45
|
+
copy_progress: '4194304/4194304',
|
46
|
+
copy_completion_time: 'Thu, 04 Feb 2016 08:35:52 GMT',
|
47
|
+
copy_status_description: nil,
|
48
|
+
accept_ranges: 0
|
49
|
+
}
|
50
|
+
blob
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Get a public blob url from Azure blob storage
|
7
|
+
def get_blob_url(container_name, blob_name, options = {})
|
8
|
+
uri = @blob_client.generate_uri("#{container_name}/#{blob_name}")
|
9
|
+
|
10
|
+
if options[:scheme] == 'http'
|
11
|
+
uri.to_s.gsub('https:', 'http:')
|
12
|
+
else
|
13
|
+
uri.to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# This class provides the mock implementation for unit tests.
|
19
|
+
class Mock
|
20
|
+
def get_blob_url(_container_name, _blob_name, options = {})
|
21
|
+
url = 'https://sa.blob.core.windows.net/test_container/test_blob'
|
22
|
+
url.gsub!('https:', 'http:') if options[:scheme] == 'http'
|
23
|
+
url
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def get_container_acl(container_name, options = {})
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "Get container ACL: #{container_name}. options: #{options}"
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
|
11
|
+
begin
|
12
|
+
container, signed_identifiers = @blob_client.get_container_acl(container_name, options)
|
13
|
+
rescue Azure::Core::Http::HTTPError => ex
|
14
|
+
raise_azure_exception(ex, msg)
|
15
|
+
end
|
16
|
+
|
17
|
+
Fog::Logger.debug "Getting ACL of container #{container_name} successfully."
|
18
|
+
[container.public_access_level, signed_identifiers]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This class provides the mock implementation for unit tests.
|
23
|
+
class Mock
|
24
|
+
def get_container_acl(*)
|
25
|
+
['container', {}]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
def get_container_properties(name, options = {})
|
7
|
+
options[:request_id] = SecureRandom.uuid
|
8
|
+
msg = "Getting container properties: #{name}, options: #{options}."
|
9
|
+
Fog::Logger.debug msg
|
10
|
+
|
11
|
+
begin
|
12
|
+
container = @blob_client.get_container_properties(name, options)
|
13
|
+
rescue Azure::Core::Http::HTTPError => ex
|
14
|
+
raise 'NotFound' if ex.message.include?('(404)')
|
15
|
+
raise_azure_exception(ex, msg)
|
16
|
+
end
|
17
|
+
|
18
|
+
Fog::Logger.debug "Getting properties of container #{name} successfully."
|
19
|
+
container
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# This class provides the mock implementation for unit tests.
|
24
|
+
class Mock
|
25
|
+
def get_container_properties(*)
|
26
|
+
{
|
27
|
+
'name' => 'test_container',
|
28
|
+
'public_access_level' => nil,
|
29
|
+
'metadata' => {},
|
30
|
+
'properties' => {
|
31
|
+
'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
|
32
|
+
'etag' => '0x8D3A3B5F017F52D',
|
33
|
+
'lease_status' => 'unlocked',
|
34
|
+
'lease_state' => 'available'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Get a public container url from Azure storage container
|
7
|
+
#
|
8
|
+
# @param container_name [String] Name of container
|
9
|
+
#
|
10
|
+
# @return [String] - url for container
|
11
|
+
#
|
12
|
+
def get_container_url(container_name, options = {})
|
13
|
+
query = { 'comp' => 'list', 'restype' => 'container' }
|
14
|
+
uri = @blob_client.generate_uri(container_name, query)
|
15
|
+
|
16
|
+
if options[:scheme] == 'http'
|
17
|
+
uri.to_s.gsub('https:', 'http:')
|
18
|
+
else
|
19
|
+
uri.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This class provides the mock implementation for unit tests.
|
25
|
+
class Mock
|
26
|
+
def get_container_url(_container_name, options = {})
|
27
|
+
url = 'https://sa.blob.core.windows.net/test_container?comp=list&restype=container'
|
28
|
+
url.gsub!('https:', 'http:') if options[:scheme] == 'http'
|
29
|
+
url
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|