azure-storage 0.10.0.preview
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/lib/azure/storage.rb +58 -0
- data/lib/azure/storage/autoload.rb +71 -0
- data/lib/azure/storage/blob/append.rb +154 -0
- data/lib/azure/storage/blob/blob.rb +821 -0
- data/lib/azure/storage/blob/blob_service.rb +510 -0
- data/lib/azure/storage/blob/block.rb +264 -0
- data/lib/azure/storage/blob/container.rb +552 -0
- data/lib/azure/storage/blob/page.rb +380 -0
- data/lib/azure/storage/blob/serialization.rb +297 -0
- data/lib/azure/storage/client.rb +185 -0
- data/lib/azure/storage/configurable.rb +137 -0
- data/lib/azure/storage/core.rb +33 -0
- data/lib/azure/storage/core/auth/shared_access_signature.rb +27 -0
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +194 -0
- data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +49 -0
- data/lib/azure/storage/core/auth/shared_key.rb +125 -0
- data/lib/azure/storage/core/auth/shared_key_lite.rb +55 -0
- data/lib/azure/storage/core/auth/signer.rb +60 -0
- data/lib/azure/storage/core/autoload.rb +35 -0
- data/lib/azure/storage/core/client_options.rb +334 -0
- data/lib/azure/storage/core/client_options_error.rb +39 -0
- data/lib/azure/storage/core/constants.rb +1077 -0
- data/lib/azure/storage/core/error.rb +47 -0
- data/lib/azure/storage/core/filtered_service.rb +54 -0
- data/lib/azure/storage/core/http/debug_filter.rb +45 -0
- data/lib/azure/storage/core/http/http_error.rb +95 -0
- data/lib/azure/storage/core/http/http_filter.rb +62 -0
- data/lib/azure/storage/core/http/http_request.rb +182 -0
- data/lib/azure/storage/core/http/http_response.rb +105 -0
- data/lib/azure/storage/core/http/retry_policy.rb +83 -0
- data/lib/azure/storage/core/http/signer_filter.rb +42 -0
- data/lib/azure/storage/core/http_client.rb +63 -0
- data/lib/azure/storage/core/service.rb +55 -0
- data/lib/azure/storage/core/signed_service.rb +54 -0
- data/lib/azure/storage/core/sr.rb +83 -0
- data/lib/azure/storage/core/utility.rb +254 -0
- data/lib/azure/storage/queue/message.rb +39 -0
- data/lib/azure/storage/queue/queue.rb +37 -0
- data/lib/azure/storage/queue/queue_service.rb +580 -0
- data/lib/azure/storage/queue/serialization.rb +113 -0
- data/lib/azure/storage/service/access_policy.rb +35 -0
- data/lib/azure/storage/service/cors.rb +36 -0
- data/lib/azure/storage/service/cors_rule.rb +46 -0
- data/lib/azure/storage/service/enumeration_results.rb +30 -0
- data/lib/azure/storage/service/logging.rb +45 -0
- data/lib/azure/storage/service/metrics.rb +43 -0
- data/lib/azure/storage/service/retention_policy.rb +35 -0
- data/lib/azure/storage/service/serialization.rb +308 -0
- data/lib/azure/storage/service/signed_identifier.rb +39 -0
- data/lib/azure/storage/service/storage_service.rb +131 -0
- data/lib/azure/storage/service/storage_service_properties.rb +46 -0
- data/lib/azure/storage/table/auth/shared_key.rb +68 -0
- data/lib/azure/storage/table/auth/shared_key_lite.rb +53 -0
- data/lib/azure/storage/table/batch.rb +339 -0
- data/lib/azure/storage/table/batch_response.rb +127 -0
- data/lib/azure/storage/table/edmtype.rb +136 -0
- data/lib/azure/storage/table/entity.rb +40 -0
- data/lib/azure/storage/table/guid.rb +33 -0
- data/lib/azure/storage/table/query.rb +121 -0
- data/lib/azure/storage/table/serialization.rb +117 -0
- data/lib/azure/storage/table/table_service.rb +571 -0
- data/lib/azure/storage/version.rb +46 -0
- metadata +329 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81d51da25ec4fc5a5f0bf93a3c071b255f94e3e2
|
4
|
+
data.tar.gz: e4f064f2875bc72613c86c92ae31cfe18e534bec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c44444db774de77bf408448be653708a0e678d2fd57a2610a44204c185c0a38878c467c6f9a5831e4852322c57dbe8745b231e6c3890fa847a24d98851117478
|
7
|
+
data.tar.gz: afddf25b3f04414d2842fcb718efa05af2bd270ea137dafc6bdb4470c8894f2e60eba17442cf688ced49ad3ad2ac7cb5b3ff6ebf26b72579a3c8f33c0e5c380d
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'nokogiri'
|
27
|
+
require 'base64'
|
28
|
+
require 'openssl'
|
29
|
+
require 'uri'
|
30
|
+
require 'rexml/document'
|
31
|
+
require 'addressable/uri'
|
32
|
+
require 'faraday'
|
33
|
+
require 'faraday_middleware'
|
34
|
+
|
35
|
+
require 'azure/storage/autoload'
|
36
|
+
|
37
|
+
module Azure
|
38
|
+
module Storage
|
39
|
+
class << self
|
40
|
+
include Azure::Storage::Configurable
|
41
|
+
|
42
|
+
def client(options={})
|
43
|
+
@client = Azure::Storage::Client.new(options)
|
44
|
+
@client
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def method_missing(method_name, *args, &block)
|
50
|
+
return super unless client.respond_to?(method_name)
|
51
|
+
client.send(method_name, *args, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Azure::Storage.setup
|
58
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
|
25
|
+
require 'azure/storage/core/autoload'
|
26
|
+
|
27
|
+
module Azure
|
28
|
+
|
29
|
+
autoload :Storage, 'azure/storage/core'
|
30
|
+
|
31
|
+
module Storage
|
32
|
+
autoload :Default, 'azure/storage/core/constants'
|
33
|
+
autoload :Configurable, 'azure/storage/configurable'
|
34
|
+
autoload :Client, 'azure/storage/client'
|
35
|
+
autoload :ClientOptions, 'azure/storage/core/client_options'
|
36
|
+
|
37
|
+
module Auth
|
38
|
+
autoload :SharedAccessSignature, 'azure/storage/core/auth/shared_access_signature'
|
39
|
+
autoload :SharedKey, 'azure/storage/core/auth/shared_key'
|
40
|
+
autoload :SharedKeyLite, 'azure/storage/core/auth/shared_key_lite'
|
41
|
+
end
|
42
|
+
|
43
|
+
module Service
|
44
|
+
autoload :Serialization, 'azure/storage/service/serialization'
|
45
|
+
autoload :StorageService, 'azure/storage/service/storage_service'
|
46
|
+
end
|
47
|
+
|
48
|
+
module Blob
|
49
|
+
autoload :Blob, 'azure/storage/blob/blob'
|
50
|
+
autoload :Block, 'azure/storage/blob/block'
|
51
|
+
autoload :Page, 'azure/storage/blob/page'
|
52
|
+
autoload :Append, 'azure/storage/blob/append'
|
53
|
+
autoload :Container, 'azure/storage/blob/container'
|
54
|
+
autoload :Serialization, 'azure/storage/blob/serialization'
|
55
|
+
autoload :BlobService, 'azure/storage/blob/blob_service'
|
56
|
+
end
|
57
|
+
|
58
|
+
module Queue
|
59
|
+
autoload :QueueService, 'azure/storage/queue/queue_service'
|
60
|
+
autoload :Message, 'azure/storage/queue/message'
|
61
|
+
autoload :Queue, 'azure/storage/queue/queue'
|
62
|
+
end
|
63
|
+
|
64
|
+
module Table
|
65
|
+
autoload :TableService, 'azure/storage/table/table_service'
|
66
|
+
autoload :Batch, 'azure/storage/table/batch'
|
67
|
+
autoload :Query, 'azure/storage/table/query'
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
module Azure::Storage
|
25
|
+
module Blob
|
26
|
+
# Public: Creates a new append blob. Note that calling create_append_blob to create an append
|
27
|
+
# blob only initializes the blob. To add content to an append blob, call append_blob_blocks method.
|
28
|
+
#
|
29
|
+
# ==== Attributes
|
30
|
+
#
|
31
|
+
# * +container+ - String. The container name.
|
32
|
+
# * +blob+ - String. The blob name.
|
33
|
+
# * +options+ - Hash. Optional parameters.
|
34
|
+
#
|
35
|
+
# ==== Options
|
36
|
+
#
|
37
|
+
# Accepted key/value pairs in options parameter are:
|
38
|
+
# * +:transactional_md5+ - String. An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during transport.
|
39
|
+
# When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
|
40
|
+
# If the two hashes do not match, the operation will fail with error code 400 (Bad Request).
|
41
|
+
# * +:content_type+ - String. Content type for the blob. Will be saved with blob.
|
42
|
+
# * +:content_encoding+ - String. Content encoding for the blob. Will be saved with blob.
|
43
|
+
# * +:content_language+ - String. Content language for the blob. Will be saved with blob.
|
44
|
+
# * +:content_md5+ - String. Content MD5 for the blob. Will be saved with blob.
|
45
|
+
# * +:cache_control+ - String. Cache control for the blob. Will be saved with blob.
|
46
|
+
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
47
|
+
# and also can be used to attach additional metadata
|
48
|
+
# * +:metadata+ - Hash. Custom metadata values to store with the blob.
|
49
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
50
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
|
51
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
52
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
53
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
|
54
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
55
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
56
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
|
57
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
58
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
59
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
|
60
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
61
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
62
|
+
#
|
63
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
|
64
|
+
#
|
65
|
+
# Returns a Blob
|
66
|
+
def create_append_blob(container, blob, options={})
|
67
|
+
query = { }
|
68
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
69
|
+
|
70
|
+
uri = blob_uri(container, blob, query)
|
71
|
+
|
72
|
+
headers = StorageService.service_properties_headers
|
73
|
+
|
74
|
+
# set x-ms-blob-type to AppendBlob
|
75
|
+
StorageService.with_header headers, 'x-ms-blob-type', 'AppendBlob'
|
76
|
+
|
77
|
+
# ensure content-length is 0
|
78
|
+
StorageService.with_header headers, 'Content-Length', 0.to_s
|
79
|
+
|
80
|
+
# set the rest of the optional headers
|
81
|
+
StorageService.with_header headers, 'Content-MD5', options[:transactional_md5]
|
82
|
+
StorageService.with_header headers, 'x-ms-blob-content-type', options[:content_type]
|
83
|
+
StorageService.with_header headers, 'x-ms-blob-content-encoding', options[:content_encoding]
|
84
|
+
StorageService.with_header headers, 'x-ms-blob-content-language', options[:content_language]
|
85
|
+
StorageService.with_header headers, 'x-ms-blob-content-md5', options[:content_md5]
|
86
|
+
StorageService.with_header headers, 'x-ms-blob-cache-control', options[:cache_control]
|
87
|
+
StorageService.with_header headers, 'x-ms-blob-content-disposition', options[:content_disposition]
|
88
|
+
|
89
|
+
StorageService.add_metadata_to_headers options[:metadata], headers
|
90
|
+
add_blob_conditional_headers options, headers
|
91
|
+
|
92
|
+
# call PutBlob with empty body
|
93
|
+
response = call(:put, uri, nil, headers)
|
94
|
+
|
95
|
+
result = Serialization.blob_from_headers(response.headers)
|
96
|
+
result.name = blob
|
97
|
+
|
98
|
+
result
|
99
|
+
end
|
100
|
+
|
101
|
+
# Public: Commits a new block of data to the end of an existing append blob.
|
102
|
+
# This operation is permitted only on blobs created with the create_append_blob API.
|
103
|
+
#
|
104
|
+
# ==== Attributes
|
105
|
+
#
|
106
|
+
# * +container+ - String. The container name.
|
107
|
+
# * +blob+ - String. The blob name.
|
108
|
+
# * +content+ - IO or String. The content of the blob.
|
109
|
+
# * +options+ - Hash. Optional parameters.
|
110
|
+
#
|
111
|
+
# ==== Options
|
112
|
+
#
|
113
|
+
# Accepted key/value pairs in options parameter are:
|
114
|
+
# * +:content_md5+ - String. Content MD5 for the request contents.
|
115
|
+
# * +:lease_id+ - String. The lease id if the blob has an active lease
|
116
|
+
# * +:max_size+ - Integer. The max length in bytes permitted for the append blob
|
117
|
+
# * +:append_position+ - Integer. A number indicating the byte offset to compare. It will succeed only if the append position is equal to this number
|
118
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
119
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to append a block only if
|
120
|
+
# the blob has been modified since the specified date/time. If the blob has not been modified,
|
121
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
122
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to append a block only if
|
123
|
+
# the blob has not been modified since the specified date/time. If the blob has been modified,
|
124
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
125
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to append a block only if
|
126
|
+
# the blob's ETag value matches the value specified. If the values do not match,
|
127
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
128
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to append a block only if
|
129
|
+
# the blob's ETag value does not match the value specified. If the values are identical,
|
130
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
131
|
+
#
|
132
|
+
# See http://msdn.microsoft.com/en-us/library/azure/mt427365.aspx
|
133
|
+
#
|
134
|
+
# Returns a Blob
|
135
|
+
def append_blob_block(container, blob, content, options={})
|
136
|
+
query = { 'comp' => 'appendblock' }
|
137
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
138
|
+
|
139
|
+
uri = blob_uri(container, blob, query)
|
140
|
+
|
141
|
+
headers = StorageService.service_properties_headers
|
142
|
+
StorageService.with_header headers, 'Content-MD5', options[:content_md5]
|
143
|
+
StorageService.with_header headers, 'x-ms-lease-id', options[:lease_id]
|
144
|
+
|
145
|
+
add_blob_conditional_headers options, headers
|
146
|
+
|
147
|
+
response = call(:put, uri, content, headers)
|
148
|
+
result = Serialization.blob_from_headers(response.headers)
|
149
|
+
result.name = blob
|
150
|
+
|
151
|
+
result
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,821 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
module Azure::Storage
|
25
|
+
module Blob
|
26
|
+
include Azure::Storage::Service
|
27
|
+
|
28
|
+
class Blob
|
29
|
+
def initialize
|
30
|
+
@properties = {}
|
31
|
+
@metadata = {}
|
32
|
+
yield self if block_given?
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_accessor :name
|
36
|
+
attr_accessor :snapshot
|
37
|
+
attr_accessor :properties
|
38
|
+
attr_accessor :metadata
|
39
|
+
end
|
40
|
+
|
41
|
+
# Public: Reads or downloads a blob from the system, including its metadata and properties.
|
42
|
+
#
|
43
|
+
# ==== Attributes
|
44
|
+
#
|
45
|
+
# * +container+ - String. The container name.
|
46
|
+
# * +blob+ - String. The blob name.
|
47
|
+
# * +options+ - Hash. Optional parameters.
|
48
|
+
#
|
49
|
+
# ==== Options
|
50
|
+
#
|
51
|
+
# Accepted key/value pairs in options parameter are:
|
52
|
+
# * +:start_range+ - Integer. Position of first byte of first page. (optional)
|
53
|
+
# * +:end_range+ - Integer. Position of last byte of of last page. (optional)
|
54
|
+
# * +:snapshot+ - String. An opaque DateTime value that specifies the blob snapshot to
|
55
|
+
# retrieve information from. (optional)
|
56
|
+
# * +:get_content_md5+ - Boolean. Return the MD5 hash for the range. This option only valid if
|
57
|
+
# start_range and end_range are specified. (optional)
|
58
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
59
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to get the blob
|
60
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
61
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
62
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to get the blob
|
63
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
64
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
65
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob
|
66
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
67
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
68
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob
|
69
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
70
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
71
|
+
#
|
72
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179440.aspx
|
73
|
+
#
|
74
|
+
# Returns a blob and the blob body
|
75
|
+
def get_blob(container, blob, options={})
|
76
|
+
query = { }
|
77
|
+
StorageService.with_query query, 'snapshot', options[:snapshot]
|
78
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
79
|
+
uri = blob_uri(container, blob, query)
|
80
|
+
|
81
|
+
headers = StorageService.service_properties_headers
|
82
|
+
options[:start_range] = 0 if options[:end_range] and not options[:start_range]
|
83
|
+
if options[:start_range]
|
84
|
+
StorageService.with_header headers, 'x-ms-range', "bytes=#{options[:start_range]}-#{options[:end_range]}"
|
85
|
+
StorageService.with_header headers, 'x-ms-range-get-content-md5', true if options[:get_content_md5]
|
86
|
+
end
|
87
|
+
add_blob_conditional_headers options, headers
|
88
|
+
|
89
|
+
response = call(:get, uri, nil, headers)
|
90
|
+
result = Serialization.blob_from_headers(response.headers)
|
91
|
+
result.name = blob unless result.name
|
92
|
+
return result, response.body
|
93
|
+
end
|
94
|
+
|
95
|
+
# Public: Returns all properties and metadata on the blob.
|
96
|
+
#
|
97
|
+
# ==== Attributes
|
98
|
+
#
|
99
|
+
# * +container+ - String. The container name.
|
100
|
+
# * +blob+ - String. The blob name.
|
101
|
+
# * +options+ - Hash. Optional parameters.
|
102
|
+
#
|
103
|
+
# ==== Options
|
104
|
+
#
|
105
|
+
# Accepted key/value pairs in options parameter are:
|
106
|
+
# * +:snapshot+ - String. An opaque DateTime value that specifies the blob snapshot to
|
107
|
+
# retrieve information from.
|
108
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
109
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to get the blob properties
|
110
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
111
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
112
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to get the blob properties
|
113
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
114
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
115
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob properties
|
116
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
117
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
118
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob properties
|
119
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
120
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
121
|
+
#
|
122
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179394.aspx
|
123
|
+
#
|
124
|
+
# Returns a Blob
|
125
|
+
def get_blob_properties(container, blob, options={})
|
126
|
+
query = { }
|
127
|
+
StorageService.with_query query, 'snapshot', options[:snapshot]
|
128
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
129
|
+
|
130
|
+
headers = StorageService.service_properties_headers
|
131
|
+
unless options.empty?
|
132
|
+
add_blob_conditional_headers options, headers
|
133
|
+
end
|
134
|
+
|
135
|
+
uri = blob_uri(container, blob, query)
|
136
|
+
|
137
|
+
response = call(:head, uri, nil, headers)
|
138
|
+
|
139
|
+
result = Serialization.blob_from_headers(response.headers)
|
140
|
+
|
141
|
+
result.name = blob
|
142
|
+
result.snapshot = options[:snapshot]
|
143
|
+
|
144
|
+
result
|
145
|
+
end
|
146
|
+
|
147
|
+
# Public: Sets system properties defined for a blob.
|
148
|
+
#
|
149
|
+
# ==== Attributes
|
150
|
+
#
|
151
|
+
# * +container+ - String. The container name.
|
152
|
+
# * +blob+ - String. The blob name.
|
153
|
+
# * +options+ - Hash. Optional parameters.
|
154
|
+
#
|
155
|
+
# ==== Options
|
156
|
+
#
|
157
|
+
# Accepted key/value pairs in options parameter are:
|
158
|
+
# * +:content_type+ - String. Content type for the blob. Will be saved with blob.
|
159
|
+
# * +:content_encoding+ - String. Content encoding for the blob. Will be saved with blob.
|
160
|
+
# * +:content_language+ - String. Content language for the blob. Will be saved with blob.
|
161
|
+
# * +:content_md5+ - String. Content MD5 for the blob. Will be saved with blob.
|
162
|
+
# * +:cache_control+ - String. Cache control for the blob. Will be saved with blob.
|
163
|
+
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
164
|
+
# and also can be used to attach additional metadata
|
165
|
+
# * +:content_length+ - Integer. Resizes a page blob to the specified size. If the specified
|
166
|
+
# value is less than the current size of the blob, then all pages above
|
167
|
+
# the specified value are cleared. This property cannot be used to change
|
168
|
+
# the size of a block blob. Setting this property for a block blob returns
|
169
|
+
# status code 400 (Bad Request).
|
170
|
+
# * +:sequence_number_action+ - Symbol. This property indicates how the service should modify the sequence
|
171
|
+
# number for the blob. Required if :sequence_number is used. This property
|
172
|
+
# applies to page blobs only.
|
173
|
+
#
|
174
|
+
# Specify one of the following options for this property:
|
175
|
+
#
|
176
|
+
# * +:max+ - Sets the sequence number to be the higher of the value included with
|
177
|
+
# the request and the value currently stored for the blob.
|
178
|
+
# * +:update+ - Sets the sequence number to the value included with the request.
|
179
|
+
# * +:increment+ - Increments the value of the sequence number by 1. If specifying this
|
180
|
+
# option, do not include the sequence_number option; doing so will return
|
181
|
+
# status code 400 (Bad Request).
|
182
|
+
#
|
183
|
+
# * +:sequence_number+ - Integer. This property sets the blob's sequence number. The sequence number is a
|
184
|
+
# user-controlled property that you can use to track requests and manage concurrency
|
185
|
+
# issues. Required if the :sequence_number_action option is set to :max or :update.
|
186
|
+
# This property applies to page blobs only.
|
187
|
+
#
|
188
|
+
# Use this together with the :sequence_number_action to update the blob's sequence
|
189
|
+
# number, either to the specified value or to the higher of the values specified with
|
190
|
+
# the request or currently stored with the blob.
|
191
|
+
#
|
192
|
+
# This header should not be specified if :sequence_number_action is set to :increment;
|
193
|
+
# in this case the service automatically increments the sequence number by one.
|
194
|
+
#
|
195
|
+
# To set the sequence number to a value of your choosing, this property must be specified
|
196
|
+
# together with :sequence_number_action
|
197
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
198
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
|
199
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
200
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
201
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
|
202
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
203
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
204
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
|
205
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
206
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
207
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
|
208
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
209
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
210
|
+
#
|
211
|
+
# Remarks:
|
212
|
+
#
|
213
|
+
# The semantics for updating a blob's properties are as follows:
|
214
|
+
#
|
215
|
+
# * A page blob's sequence number is updated only if the request meets either of the following conditions:
|
216
|
+
#
|
217
|
+
# * The :sequence_number_action property is set to :max or :update, and a value for :sequence_number is also set.
|
218
|
+
# * The :sequence_number_action property is set to :increment, indicating that the service should increment
|
219
|
+
# the sequence number by one.
|
220
|
+
#
|
221
|
+
# * The size of the page blob is modified only if a value for :content_length is specified.
|
222
|
+
#
|
223
|
+
# * If :sequence_number and/or :content_length are the only properties specified, then the other properties of the blob
|
224
|
+
# will NOT be modified.
|
225
|
+
#
|
226
|
+
# * If any one or more of the following properties are set, then all of these properties are set together. If a value is
|
227
|
+
# not provided for a given property when at least one of the properties listed below is set, then that property will be
|
228
|
+
# cleared for the blob.
|
229
|
+
#
|
230
|
+
# * :cache_control
|
231
|
+
# * :content_type
|
232
|
+
# * :content_md5
|
233
|
+
# * :content_encoding
|
234
|
+
# * :content_language
|
235
|
+
#
|
236
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691966.aspx
|
237
|
+
#
|
238
|
+
# Returns nil on success.
|
239
|
+
def set_blob_properties(container, blob, options={})
|
240
|
+
query = {'comp' => 'properties'}
|
241
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
242
|
+
uri = blob_uri(container, blob, query)
|
243
|
+
|
244
|
+
headers = StorageService.service_properties_headers
|
245
|
+
|
246
|
+
unless options.empty?
|
247
|
+
StorageService.with_header headers, 'x-ms-blob-content-type', options[:content_type]
|
248
|
+
StorageService.with_header headers, 'x-ms-blob-content-encoding', options[:content_encoding]
|
249
|
+
StorageService.with_header headers, 'x-ms-blob-content-language', options[:content_language]
|
250
|
+
StorageService.with_header headers, 'x-ms-blob-content-md5', options[:content_md5]
|
251
|
+
StorageService.with_header headers, 'x-ms-blob-cache-control', options[:cache_control]
|
252
|
+
StorageService.with_header headers, 'x-ms-blob-content-length', options[:content_length].to_s if options[:content_length]
|
253
|
+
StorageService.with_header headers, 'x-ms-blob-content-disposition', options[:content_disposition]
|
254
|
+
|
255
|
+
if options[:sequence_number_action]
|
256
|
+
StorageService.with_header headers, 'x-ms-blob-sequence-number-action', options[:sequence_number_action].to_s
|
257
|
+
|
258
|
+
if options[:sequence_number_action] != :increment
|
259
|
+
StorageService.with_header headers, 'x-ms-blob-sequence-number', options[:sequence_number].to_s if options[:sequence_number]
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
add_blob_conditional_headers options, headers
|
264
|
+
end
|
265
|
+
|
266
|
+
call(:put, uri, nil, headers)
|
267
|
+
nil
|
268
|
+
end
|
269
|
+
|
270
|
+
# Public: Returns metadata on the blob.
|
271
|
+
#
|
272
|
+
# ==== Attributes
|
273
|
+
#
|
274
|
+
# * +container+ - String. The container name.
|
275
|
+
# * +blob+ - String. The blob name.
|
276
|
+
# * +options+ - Hash. Optional parameters.
|
277
|
+
#
|
278
|
+
# ==== Options
|
279
|
+
#
|
280
|
+
# Accepted key/value pairs in options parameter are:
|
281
|
+
# * +:snapshot+ - String. An opaque DateTime value that specifies the blob snapshot to
|
282
|
+
# retrieve information from.
|
283
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
284
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to get the blob metadata
|
285
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
286
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
287
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to get the blob metadata
|
288
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
289
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
290
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob metadata
|
291
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
292
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
293
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to get the blob metadata
|
294
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
295
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
296
|
+
#
|
297
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179350.aspx
|
298
|
+
#
|
299
|
+
# Returns a Blob
|
300
|
+
def get_blob_metadata(container, blob, options={})
|
301
|
+
query = {'comp' => 'metadata'}
|
302
|
+
StorageService.with_query query, 'snapshot', options[:snapshot]
|
303
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
304
|
+
|
305
|
+
headers = StorageService.service_properties_headers
|
306
|
+
unless options.empty?
|
307
|
+
add_blob_conditional_headers options, headers
|
308
|
+
end
|
309
|
+
|
310
|
+
uri = blob_uri(container, blob, query)
|
311
|
+
response = call(:get, uri, nil, headers)
|
312
|
+
result = Serialization.blob_from_headers(response.headers)
|
313
|
+
|
314
|
+
result.name = blob
|
315
|
+
result.snapshot = options[:snapshot]
|
316
|
+
|
317
|
+
result
|
318
|
+
end
|
319
|
+
|
320
|
+
# Public: Sets metadata headers on the blob.
|
321
|
+
#
|
322
|
+
# ==== Attributes
|
323
|
+
#
|
324
|
+
# * +container+ - String. The container name.
|
325
|
+
# * +blob+ - String. The blob name.
|
326
|
+
# * +metadata+ - Hash. The custom metadata.
|
327
|
+
# * +options+ - Hash. Optional parameters.
|
328
|
+
#
|
329
|
+
# ==== Options
|
330
|
+
#
|
331
|
+
# Accepted key/value pairs in options parameter are:
|
332
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
333
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to set the blob metadata
|
334
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
335
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
336
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to set the blob metadata
|
337
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
338
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
339
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob metadata
|
340
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
341
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
342
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob metadata
|
343
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
344
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
345
|
+
#
|
346
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179414.aspx
|
347
|
+
#
|
348
|
+
# Returns nil on success.
|
349
|
+
def set_blob_metadata(container, blob, metadata, options={})
|
350
|
+
query = {'comp' => 'metadata'}
|
351
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
352
|
+
|
353
|
+
uri = blob_uri(container, blob, query)
|
354
|
+
|
355
|
+
headers = StorageService.service_properties_headers
|
356
|
+
StorageService.add_metadata_to_headers metadata, headers
|
357
|
+
unless options.empty?
|
358
|
+
add_blob_conditional_headers options, headers
|
359
|
+
end
|
360
|
+
|
361
|
+
call(:put, uri, nil, headers)
|
362
|
+
nil
|
363
|
+
end
|
364
|
+
|
365
|
+
# Public: Establishes an exclusive write lock on a blob. The lock duration can be 15 to 60 seconds, or can be infinite.
|
366
|
+
# To write to a locked blob, a client must provide a lease ID.
|
367
|
+
#
|
368
|
+
# ==== Attributes
|
369
|
+
#
|
370
|
+
# * +container+ - String. The container name.
|
371
|
+
# * +blob+ - String. The blob name.
|
372
|
+
# * +options+ - Hash. Optional parameters.
|
373
|
+
#
|
374
|
+
# ==== Options
|
375
|
+
#
|
376
|
+
# Accepted key/value pairs in options parameter are:
|
377
|
+
# * +:duration+ - Integer. Default -1. Specifies the duration of the lease, in seconds, or negative one (-1)
|
378
|
+
# for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. (optional)
|
379
|
+
# * +:proposed_lease_id+ - String. Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request)
|
380
|
+
# if the proposed lease ID is not in the correct format. (optional)
|
381
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
382
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to acquire the lease
|
383
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
384
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
385
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to acquire the lease
|
386
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
387
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
388
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to acquire the lease
|
389
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
390
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
391
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to acquire the lease
|
392
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
393
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
394
|
+
#
|
395
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
|
396
|
+
#
|
397
|
+
# Returns a String of the new unique lease id. While the lease is active, you must include the lease ID with any request
|
398
|
+
# to write to the blob, or to renew, change, or release the lease.
|
399
|
+
#
|
400
|
+
def acquire_blob_lease(container, blob, options={})
|
401
|
+
acquire_lease container, blob, options
|
402
|
+
end
|
403
|
+
|
404
|
+
# Public: Renews the lease. The lease can be renewed if the lease ID specified on the request matches that
|
405
|
+
# associated with the blob. Note that the lease may be renewed even if it has expired as long as the blob
|
406
|
+
# has not been modified or leased again since the expiration of that lease. When you renew a lease, the
|
407
|
+
# lease duration clock resets.
|
408
|
+
#
|
409
|
+
# ==== Attributes
|
410
|
+
#
|
411
|
+
# * +container+ - String. The container name.
|
412
|
+
# * +blob+ - String. The blob name.
|
413
|
+
# * +lease+ - String. The lease id
|
414
|
+
# * +options+ - Hash. Optional parameters.
|
415
|
+
#
|
416
|
+
# ==== Options
|
417
|
+
#
|
418
|
+
# Accepted key/value pairs in options parameter are:
|
419
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
420
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to renew the lease
|
421
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
422
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
423
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to renew the lease
|
424
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
425
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
426
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to renew the lease
|
427
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
428
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
429
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to renew the lease
|
430
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
431
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
432
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
|
433
|
+
#
|
434
|
+
# Returns the renewed lease id
|
435
|
+
def renew_blob_lease(container, blob, lease, options={})
|
436
|
+
renew_lease container, blob, lease, options
|
437
|
+
end
|
438
|
+
|
439
|
+
# Public: Change the lease ID.
|
440
|
+
#
|
441
|
+
# ==== Attributes
|
442
|
+
#
|
443
|
+
# * +container+ - String. The container name.
|
444
|
+
# * +blob+ - String. The blob name.
|
445
|
+
# * +lease+ - String. The existing lease id.
|
446
|
+
# * +proposed_lease+ - String. Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request)
|
447
|
+
# if the proposed lease ID is not in the correct format. (optional).
|
448
|
+
# * +options+ - Hash. Optional parameters.
|
449
|
+
#
|
450
|
+
# ==== Options
|
451
|
+
#
|
452
|
+
# Accepted key/value pairs in options parameter are:
|
453
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
454
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to change the lease
|
455
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
456
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
457
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to change the lease
|
458
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
459
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
460
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to change the lease
|
461
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
462
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
463
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to change the lease
|
464
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
465
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
466
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
|
467
|
+
#
|
468
|
+
# Returns the changed lease id
|
469
|
+
def change_blob_lease(container, blob, lease, proposed_lease, options={})
|
470
|
+
change_lease container, blob, lease, proposed_lease, options
|
471
|
+
end
|
472
|
+
|
473
|
+
# Public: Releases the lease. The lease may be released if the lease ID specified on the request matches that
|
474
|
+
# associated with the blob. Releasing the lease allows another client to immediately acquire the lease for
|
475
|
+
# the blob as soon as the release is complete.
|
476
|
+
#
|
477
|
+
# ==== Attributes
|
478
|
+
#
|
479
|
+
# * +container+ - String. The container name.
|
480
|
+
# * +blob+ - String. The blob name.
|
481
|
+
# * +lease+ - String. The lease id.
|
482
|
+
# * +options+ - Hash. Optional parameters.
|
483
|
+
#
|
484
|
+
# ==== Options
|
485
|
+
#
|
486
|
+
# Accepted key/value pairs in options parameter are:
|
487
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
488
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to release the lease
|
489
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
490
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
491
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to release the lease
|
492
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
493
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
494
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to release the lease
|
495
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
496
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
497
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to release the lease
|
498
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
499
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
500
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
|
501
|
+
#
|
502
|
+
# Returns nil on success
|
503
|
+
def release_blob_lease(container, blob, lease, options={})
|
504
|
+
release_lease container, blob, lease, options
|
505
|
+
end
|
506
|
+
|
507
|
+
# Public: Breaks the lease, if the blob has an active lease. Once a lease is broken, it cannot be renewed. Any
|
508
|
+
# authorized request can break the lease; the request is not required to specify a matching lease ID. When a
|
509
|
+
# lease is broken, the lease break period is allowed to elapse, during which time no lease operation except
|
510
|
+
# break and release can be performed on the blob. When a lease is successfully broken, the response indicates
|
511
|
+
# the interval in seconds until a new lease can be acquired.
|
512
|
+
#
|
513
|
+
# A lease that has been broken can also be released, in which case another client may immediately acquire the
|
514
|
+
# lease on the blob.
|
515
|
+
#
|
516
|
+
# ==== Attributes
|
517
|
+
#
|
518
|
+
# * +container+ - String. The container name.
|
519
|
+
# * +blob+ - String. The blob name.
|
520
|
+
# * +options+ - Hash. Optional parameters.
|
521
|
+
#
|
522
|
+
# ==== Options
|
523
|
+
#
|
524
|
+
# Accepted key/value pairs in options parameter are:
|
525
|
+
# * +:break_period+ - Integer. The proposed duration of seconds that the lease should continue before it is
|
526
|
+
# broken, between 0 and 60 seconds. This break period is only used if it is shorter than
|
527
|
+
# the time remaining on the lease. If longer, the time remaining on the lease is used. A
|
528
|
+
# new lease will not be available before the break period has expired, but the lease may
|
529
|
+
# be held for longer than the break period.
|
530
|
+
#
|
531
|
+
# If this option is not used, a fixed-duration lease breaks after the remaining lease
|
532
|
+
# period elapses, and an infinite lease breaks immediately.
|
533
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
534
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to break the lease
|
535
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
536
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
537
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to break the lease
|
538
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
539
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
540
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to break the lease
|
541
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
542
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
543
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to break the lease
|
544
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
545
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
546
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
|
547
|
+
#
|
548
|
+
# Returns an Integer of the remaining lease time. This value is the approximate time remaining in the lease
|
549
|
+
# period, in seconds. This header is returned only for a successful request to break the lease. If the break
|
550
|
+
# is immediate, 0 is returned.
|
551
|
+
def break_blob_lease(container, blob, options={})
|
552
|
+
break_lease container, blob, options
|
553
|
+
end
|
554
|
+
|
555
|
+
# Public: Creates a snapshot of a blob.
|
556
|
+
#
|
557
|
+
# ==== Attributes
|
558
|
+
#
|
559
|
+
# * +container+ - String. The container name.
|
560
|
+
# * +blob+ - String. The blob name.
|
561
|
+
# * +options+ - Hash. Optional parameters.
|
562
|
+
#
|
563
|
+
# ==== Options
|
564
|
+
#
|
565
|
+
# Accepted key/value pairs in options parameter are:
|
566
|
+
# * +:metadata+ - Hash. Custom metadata values to store with the blob snapshot.
|
567
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
568
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to create the blob snapshot
|
569
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
570
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
571
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to create the blob snapshot
|
572
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
573
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
574
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to create the blob snapshot
|
575
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
576
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
577
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to create the blob snapshot
|
578
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
579
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
580
|
+
#
|
581
|
+
# See http://msdn.microsoft.com/en-us/library/azure/ee691971.aspx
|
582
|
+
#
|
583
|
+
# Returns the snapshot DateTime value
|
584
|
+
def create_blob_snapshot(container, blob, options={})
|
585
|
+
query = { 'comp' => 'snapshot'}
|
586
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
587
|
+
|
588
|
+
uri = blob_uri(container, blob, query)
|
589
|
+
|
590
|
+
headers = StorageService.service_properties_headers
|
591
|
+
unless options.empty?
|
592
|
+
StorageService.add_metadata_to_headers(options[:metadata], headers)
|
593
|
+
add_blob_conditional_headers(options, headers)
|
594
|
+
end
|
595
|
+
|
596
|
+
response = call(:put, uri, nil, headers)
|
597
|
+
|
598
|
+
response.headers['x-ms-snapshot']
|
599
|
+
end
|
600
|
+
|
601
|
+
# Public: Copies a source blob to a destination blob.
|
602
|
+
#
|
603
|
+
# ==== Attributes
|
604
|
+
#
|
605
|
+
# * +source_container+ - String. The destination container name to copy to.
|
606
|
+
# * +source_blob+ - String. The destination blob name to copy to.
|
607
|
+
# * +source_blob_uri+ - String. The source blob URI to copy from.
|
608
|
+
# * +options+ - Hash. Optional parameters.
|
609
|
+
#
|
610
|
+
# ==== Options
|
611
|
+
#
|
612
|
+
# Accepted key/value pairs in options parameter are:
|
613
|
+
# * +:source_snapshot+ - String. A snapshot id for the source blob
|
614
|
+
# * +:metadata+ - Hash. Custom metadata values to store with the copy. If this parameter is not
|
615
|
+
# specified, the operation will copy the source blob metadata to the destination
|
616
|
+
# blob. If this parameter is specified, the destination blob is created with the
|
617
|
+
# specified metadata, and metadata is not copied from the source blob.
|
618
|
+
# * +:source_if_modified_since+ - String. A DateTime value. Specify this option to write the page only if the source blob
|
619
|
+
# has been modified since the specified date/time. If the blob has not been
|
620
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
621
|
+
# * +:source_if_unmodified_since+ - String. A DateTime value. Specify this option to write the page only if the source blob
|
622
|
+
# has not been modified since the specified date/time. If the blob has been
|
623
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
624
|
+
# * +:source_if_match+ - String. An ETag value. Specify an ETag value to write the page only if the source blob's
|
625
|
+
# ETag value matches the value specified. If the values do not match, the Blob
|
626
|
+
# service returns status code 412 (Precondition Failed).
|
627
|
+
# * +:source_if_none_match+ - String. An ETag value. Specify an ETag value to write the page only if the source blob's
|
628
|
+
# ETag value does not match the value specified. If the values are identical, the
|
629
|
+
# Blob service returns status code 412 (Precondition Failed).
|
630
|
+
# * +:dest_if_modified_since+ - String. A DateTime value. Specify this option to write the page only if the destination
|
631
|
+
# blob has been modified since the specified date/time. If the blob has not been
|
632
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
633
|
+
# * +:dest_if_unmodified_since+ - String. A DateTime value. Specify this option to write the page only if the destination
|
634
|
+
# blob has not been modified since the specified date/time. If the blob has been
|
635
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
636
|
+
# * +:dest_if_match+ - String. An ETag value. Specify an ETag value to write the page only if the destination
|
637
|
+
# blob's ETag value matches the value specified. If the values do not match, the
|
638
|
+
# Blob service returns status code 412 (Precondition Failed).
|
639
|
+
# * +:dest_if_none_match+ - String. An ETag value. Specify an ETag value to write the page only if the destination
|
640
|
+
# blob's ETag value does not match the value specified. If the values are
|
641
|
+
# identical, the Blob service returns status code 412 (Precondition Failed).
|
642
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
643
|
+
#
|
644
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd894037.aspx
|
645
|
+
#
|
646
|
+
# Returns a tuple of (copy_id, copy_status).
|
647
|
+
#
|
648
|
+
# * +copy_id+ - String identifier for this copy operation. Use with get_blob or get_blob_properties to check
|
649
|
+
# the status of this copy operation, or pass to abort_copy_blob to abort a pending copy.
|
650
|
+
# * +copy_status+ - String. The state of the copy operation, with these values:
|
651
|
+
# "success" - The copy completed successfully.
|
652
|
+
# "pending" - The copy is in progress.
|
653
|
+
#
|
654
|
+
def copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options={})
|
655
|
+
query = { }
|
656
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
657
|
+
|
658
|
+
uri = blob_uri(destination_container, destination_blob, query)
|
659
|
+
headers = StorageService.service_properties_headers
|
660
|
+
StorageService.with_header headers, 'x-ms-copy-source', source_blob_uri
|
661
|
+
|
662
|
+
unless options.empty?
|
663
|
+
add_blob_conditional_headers options, headers
|
664
|
+
StorageService.add_metadata_to_headers options[:metadata], headers
|
665
|
+
end
|
666
|
+
|
667
|
+
response = call(:put, uri, nil, headers)
|
668
|
+
return response.headers['x-ms-copy-id'], response.headers['x-ms-copy-status']
|
669
|
+
end
|
670
|
+
|
671
|
+
# Public: Copies a source blob to a destination blob within the same storage account.
|
672
|
+
#
|
673
|
+
# ==== Attributes
|
674
|
+
#
|
675
|
+
# * +source_container+ - String. The destination container name to copy to.
|
676
|
+
# * +source_blob+ - String. The destination blob name to copy to.
|
677
|
+
# * +source_container+ - String. The source container name to copy from.
|
678
|
+
# * +source_blob+ - String. The source blob name to copy from.
|
679
|
+
# * +options+ - Hash. Optional parameters.
|
680
|
+
#
|
681
|
+
# ==== Options
|
682
|
+
#
|
683
|
+
# Accepted key/value pairs in options parameter are:
|
684
|
+
# * +:source_snapshot+ - String. A snapshot id for the source blob
|
685
|
+
# * +:metadata+ - Hash. Custom metadata values to store with the copy. If this parameter is not
|
686
|
+
# specified, the operation will copy the source blob metadata to the destination
|
687
|
+
# blob. If this parameter is specified, the destination blob is created with the
|
688
|
+
# specified metadata, and metadata is not copied from the source blob.
|
689
|
+
# * +:source_if_modified_since+ - String. A DateTime value. Specify this option to write the page only if the source blob
|
690
|
+
# has been modified since the specified date/time. If the blob has not been
|
691
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
692
|
+
# * +:source_if_unmodified_since+ - String. A DateTime value. Specify this option to write the page only if the source blob
|
693
|
+
# has not been modified since the specified date/time. If the blob has been
|
694
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
695
|
+
# * +:source_if_match+ - String. An ETag value. Specify an ETag value to write the page only if the source blob's
|
696
|
+
# ETag value matches the value specified. If the values do not match, the Blob
|
697
|
+
# service returns status code 412 (Precondition Failed).
|
698
|
+
# * +:source_if_none_match+ - String. An ETag value. Specify an ETag value to write the page only if the source blob's
|
699
|
+
# ETag value does not match the value specified. If the values are identical, the
|
700
|
+
# Blob service returns status code 412 (Precondition Failed).
|
701
|
+
# * +:dest_if_modified_since+ - String. A DateTime value. Specify this option to write the page only if the destination
|
702
|
+
# blob has been modified since the specified date/time. If the blob has not been
|
703
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
704
|
+
# * +:dest_if_unmodified_since+ - String. A DateTime value. Specify this option to write the page only if the destination
|
705
|
+
# blob has not been modified since the specified date/time. If the blob has been
|
706
|
+
# modified, the Blob service returns status code 412 (Precondition Failed).
|
707
|
+
# * +:dest_if_match+ - String. An ETag value. Specify an ETag value to write the page only if the destination
|
708
|
+
# blob's ETag value matches the value specified. If the values do not match, the
|
709
|
+
# Blob service returns status code 412 (Precondition Failed).
|
710
|
+
# * +:dest_if_none_match+ - String. An ETag value. Specify an ETag value to write the page only if the destination
|
711
|
+
# blob's ETag value does not match the value specified. If the values are
|
712
|
+
# identical, the Blob service returns status code 412 (Precondition Failed).
|
713
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
714
|
+
#
|
715
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd894037.aspx
|
716
|
+
#
|
717
|
+
# Returns a tuple of (copy_id, copy_status).
|
718
|
+
#
|
719
|
+
# * +copy_id+ - String identifier for this copy operation. Use with get_blob or get_blob_properties to check
|
720
|
+
# the status of this copy operation, or pass to abort_copy_blob to abort a pending copy.
|
721
|
+
# * +copy_status+ - String. The state of the copy operation, with these values:
|
722
|
+
# "success" - The copy completed successfully.
|
723
|
+
# "pending" - The copy is in progress.
|
724
|
+
#
|
725
|
+
def copy_blob(destination_container, destination_blob, source_container, source_blob, options={})
|
726
|
+
source_blob_uri = blob_uri(source_container, source_blob, options[:source_snapshot] ? { 'snapshot' => options[:source_snapshot] } : {}).to_s
|
727
|
+
|
728
|
+
return copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options)
|
729
|
+
end
|
730
|
+
|
731
|
+
# Public: Aborts a pending Copy Blob operation and leaves a destination blob with zero length and full metadata.
|
732
|
+
#
|
733
|
+
# ==== Attributes
|
734
|
+
#
|
735
|
+
# * +container+ - String. The destination container name.
|
736
|
+
# * +blob+ - String. The destination blob name.
|
737
|
+
# * +copy_id+ - String. The copy identifier returned in the copy blob operation.
|
738
|
+
# * +options+ - Hash. Optional parameters.
|
739
|
+
#
|
740
|
+
# ==== Options
|
741
|
+
#
|
742
|
+
# Accepted key/value pairs in options parameter are:
|
743
|
+
# * +:lease_id+ - String. The lease id if the destination blob has an active infinite lease
|
744
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
745
|
+
#
|
746
|
+
# See https://msdn.microsoft.com/en-us/library/azure/jj159098.aspx
|
747
|
+
#
|
748
|
+
# Returns nil on success
|
749
|
+
def abort_copy_blob(container, blob, copy_id, options={})
|
750
|
+
query = { 'comp' => 'copy'}
|
751
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
752
|
+
StorageService.with_query query, 'copyid', copy_id
|
753
|
+
|
754
|
+
uri = blob_uri(container, blob, query);
|
755
|
+
headers = StorageService.service_properties_headers
|
756
|
+
StorageService.with_header headers, 'x-ms-copy-action', 'abort';
|
757
|
+
|
758
|
+
unless options.empty?
|
759
|
+
StorageService.with_header headers, 'x-ms-lease-id', options[:lease_id]
|
760
|
+
end
|
761
|
+
|
762
|
+
response = call(:put, uri, nil, headers)
|
763
|
+
nil
|
764
|
+
end
|
765
|
+
|
766
|
+
# Public: Deletes a blob or blob snapshot.
|
767
|
+
#
|
768
|
+
# ==== Attributes
|
769
|
+
#
|
770
|
+
# * +container+ - String. The container name.
|
771
|
+
# * +blob+ - String. The blob name.
|
772
|
+
# * +options+ - Hash. Optional parameters.
|
773
|
+
#
|
774
|
+
# ==== Options
|
775
|
+
#
|
776
|
+
# Accepted key/value pairs in options parameter are:
|
777
|
+
# * +:snapshot+ - String. An opaque DateTime value that specifies the blob snapshot to
|
778
|
+
# retrieve information from. (optional)
|
779
|
+
# * +:delete_snapshots+ - Symbol. Used to specify the scope of the delete operation for snapshots.
|
780
|
+
# This parameter is ignored if a blob does not have snapshots, or if a
|
781
|
+
# snapshot is specified in the snapshot parameter. (optional)
|
782
|
+
#
|
783
|
+
# Possible values include:
|
784
|
+
# * +:only+ - Deletes only the snapshots for the blob, but leaves the blob
|
785
|
+
# * +:include+ - Deletes the blob and all of the snapshots for the blob
|
786
|
+
# * +:timeout+ - Integer. A timeout in seconds.
|
787
|
+
# * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to create the blob snapshot
|
788
|
+
# only if the blob has been modified since the specified date/time. If the blob has not been modified,
|
789
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
790
|
+
# * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to create the blob snapshot
|
791
|
+
# only if the blob has not been modified since the specified date/time. If the blob has been modified,
|
792
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
793
|
+
# * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to create the blob snapshot
|
794
|
+
# only if the blob's ETag value matches the value specified. If the values do not match,
|
795
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
796
|
+
# * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to create the blob snapshot
|
797
|
+
# only if the blob's ETag value does not match the value specified. If the values are identical,
|
798
|
+
# the Blob service returns status code 412 (Precondition Failed).
|
799
|
+
#
|
800
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179440.aspx
|
801
|
+
#
|
802
|
+
# Returns nil on success
|
803
|
+
def delete_blob(container, blob, options={})
|
804
|
+
query = { }
|
805
|
+
StorageService.with_query query, 'snapshot', options[:snapshot]
|
806
|
+
StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
|
807
|
+
|
808
|
+
uri = blob_uri(container, blob, query)
|
809
|
+
|
810
|
+
options[:delete_snapshots] = :include unless options[:delete_snapshots]
|
811
|
+
|
812
|
+
headers = StorageService.service_properties_headers
|
813
|
+
StorageService.with_header headers, 'x-ms-delete-snapshots', options[:delete_snapshots].to_s if options[:delete_snapshots] && options[:snapshot] == nil
|
814
|
+
add_blob_conditional_headers options, headers
|
815
|
+
|
816
|
+
call(:delete, uri, nil, headers)
|
817
|
+
nil
|
818
|
+
end
|
819
|
+
|
820
|
+
end
|
821
|
+
end
|