azure-blob 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/azure_blob/client.rb +19 -4
- data/lib/azure_blob/http.rb +6 -2
- data/lib/azure_blob/tags.rb +35 -0
- data/lib/azure_blob/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6c4e076840dd6671c28c99b5fca03057782e81686c0c06890b42cedd3b83788
|
4
|
+
data.tar.gz: '00668582cecce526ad816a5c537469af7e646d6f64d7392655d1c7e60396393c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdd32b7f8547ac428bf0eb19d884860e94d1ab9471df0022356119c5ec28aca8589d1b1925d0085b2361c4c16d5898123a1fc18f57b5b2cb9ae7e53dbc4b4379
|
7
|
+
data.tar.gz: 44a4592046d5d33432762cfd4d3636500f9c13db00cf5c705fbc2f472b7c322bd37bc05d9765e03079e0966dcb44d0e5cc844db303906aaa18435c8db7ee422f
|
data/CHANGELOG.md
CHANGED
data/lib/azure_blob/client.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "block_list"
|
|
4
4
|
require_relative "blob_list"
|
5
5
|
require_relative "blob"
|
6
6
|
require_relative "container"
|
7
|
+
require_relative "tags"
|
7
8
|
require_relative "http"
|
8
9
|
require_relative "shared_key_signer"
|
9
10
|
require_relative "entra_id_signer"
|
@@ -28,7 +29,7 @@ module AzureBlob
|
|
28
29
|
)
|
29
30
|
end
|
30
31
|
@signer = using_managed_identities ?
|
31
|
-
AzureBlob::EntraIdSigner.new(account_name:, host:, principal_id:
|
32
|
+
AzureBlob::EntraIdSigner.new(account_name:, host:, principal_id:) :
|
32
33
|
AzureBlob::SharedKeySigner.new(account_name:, access_key:)
|
33
34
|
end
|
34
35
|
|
@@ -157,6 +158,20 @@ module AzureBlob
|
|
157
158
|
Blob.new(response)
|
158
159
|
end
|
159
160
|
|
161
|
+
# Returns the tags associated with a blob
|
162
|
+
#
|
163
|
+
# Calls to the {Get Blob Tags}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-tags] endpoint.
|
164
|
+
#
|
165
|
+
# Takes a key (path) of the blob.
|
166
|
+
#
|
167
|
+
# Returns a hash of the blob's tags.
|
168
|
+
def get_blob_tags(key)
|
169
|
+
uri = generate_uri("#{container}/#{key}?comp=tags")
|
170
|
+
response = Http.new(uri, signer:).get
|
171
|
+
|
172
|
+
Tags.from_response(response).to_h
|
173
|
+
end
|
174
|
+
|
160
175
|
# Returns a Container object.
|
161
176
|
#
|
162
177
|
# Calls to {Get Container Properties}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-container-properties]
|
@@ -230,7 +245,7 @@ module AzureBlob
|
|
230
245
|
"x-ms-blob-content-disposition": options[:content_disposition],
|
231
246
|
}
|
232
247
|
|
233
|
-
Http.new(uri, headers,
|
248
|
+
Http.new(uri, headers, signer:, **options.slice(:metadata, :tags)).put(nil)
|
234
249
|
end
|
235
250
|
|
236
251
|
# Append a block to an Append Blob
|
@@ -305,7 +320,7 @@ module AzureBlob
|
|
305
320
|
"x-ms-blob-content-disposition": options[:content_disposition],
|
306
321
|
}
|
307
322
|
|
308
|
-
Http.new(uri, headers,
|
323
|
+
Http.new(uri, headers, signer:, **options.slice(:metadata, :tags)).put(content)
|
309
324
|
end
|
310
325
|
|
311
326
|
private
|
@@ -337,7 +352,7 @@ module AzureBlob
|
|
337
352
|
"x-ms-blob-content-disposition": options[:content_disposition],
|
338
353
|
}
|
339
354
|
|
340
|
-
Http.new(uri, headers,
|
355
|
+
Http.new(uri, headers, signer:, **options.slice(:metadata, :tags)).put(content.read)
|
341
356
|
end
|
342
357
|
|
343
358
|
def host
|
data/lib/azure_blob/http.rb
CHANGED
@@ -24,12 +24,16 @@ module AzureBlob
|
|
24
24
|
|
25
25
|
include REXML
|
26
26
|
|
27
|
-
def initialize(uri, headers = {}, signer: nil, metadata: {}, debug: false, raise_on_error: true)
|
27
|
+
def initialize(uri, headers = {}, signer: nil, metadata: {}, tags: {}, debug: false, raise_on_error: true)
|
28
28
|
@raise_on_error = raise_on_error
|
29
29
|
@date = Time.now.httpdate
|
30
30
|
@uri = uri
|
31
31
|
@signer = signer
|
32
|
-
@headers = headers.merge(
|
32
|
+
@headers = headers.merge(
|
33
|
+
Metadata.new(metadata).headers,
|
34
|
+
Tags.new(tags).headers,
|
35
|
+
)
|
36
|
+
|
33
37
|
sanitize_headers
|
34
38
|
|
35
39
|
@http = Net::HTTP.new(uri.hostname, uri.port)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rexml/document"
|
2
|
+
|
3
|
+
module AzureBlob
|
4
|
+
class Tags # :nodoc:
|
5
|
+
def self.from_response(response)
|
6
|
+
document = REXML::Document.new(response)
|
7
|
+
tags = {}
|
8
|
+
document.elements.each("Tags/TagSet/Tag") do |tag|
|
9
|
+
key = tag.elements["Key"].text
|
10
|
+
value = tag.elements["Value"].text
|
11
|
+
tags[key] = value
|
12
|
+
end
|
13
|
+
new(tags)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(tags = nil)
|
17
|
+
@tags = tags || {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def headers
|
21
|
+
return {} if @tags.empty?
|
22
|
+
|
23
|
+
{
|
24
|
+
"x-ms-tags":
|
25
|
+
@tags.map do |key, value|
|
26
|
+
%(#{key}=#{value})
|
27
|
+
end.join("&"),
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_h
|
32
|
+
@tags
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/azure_blob/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-blob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joé Dupuis
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/azure_blob/identity_token.rb
|
52
52
|
- lib/azure_blob/metadata.rb
|
53
53
|
- lib/azure_blob/shared_key_signer.rb
|
54
|
+
- lib/azure_blob/tags.rb
|
54
55
|
- lib/azure_blob/user_delegation_key.rb
|
55
56
|
- lib/azure_blob/version.rb
|
56
57
|
homepage: https://github.com/testdouble/azure-blob
|