gitlab-fog-azure-rm 1.9.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +3 -0
  4. data/gitlab-fog-azure-rm.gemspec +1 -3
  5. data/lib/fog/azurerm/models/storage/file.rb +1 -1
  6. data/lib/fog/azurerm/version.rb +1 -1
  7. data/vendor/azure-storage-ruby/.env_sample +8 -0
  8. data/vendor/azure-storage-ruby/.gitignore +35 -0
  9. data/vendor/azure-storage-ruby/.rubocop.yml +132 -0
  10. data/vendor/azure-storage-ruby/.travis.yml +23 -0
  11. data/vendor/azure-storage-ruby/BreakingChanges.md +34 -0
  12. data/vendor/azure-storage-ruby/CONTRIBUTING.md +74 -0
  13. data/vendor/azure-storage-ruby/ChangeLog.md +198 -0
  14. data/vendor/azure-storage-ruby/Gemfile +41 -0
  15. data/vendor/azure-storage-ruby/README.md +48 -0
  16. data/vendor/azure-storage-ruby/Rakefile +216 -0
  17. data/vendor/azure-storage-ruby/SECURITY.md +41 -0
  18. data/vendor/azure-storage-ruby/blob/BreakingChanges.md +10 -0
  19. data/vendor/azure-storage-ruby/blob/ChangeLog.md +33 -0
  20. data/vendor/azure-storage-ruby/blob/Gemfile +30 -0
  21. data/vendor/azure-storage-ruby/blob/LICENSE.txt +21 -0
  22. data/vendor/azure-storage-ruby/blob/README.md +188 -0
  23. data/vendor/azure-storage-ruby/blob/azure-storage-blob.gemspec +52 -0
  24. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/append.rb +244 -0
  25. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/autoload.rb +47 -0
  26. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/blob.rb +932 -0
  27. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/blob_service.rb +720 -0
  28. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/block.rb +530 -0
  29. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/container.rb +634 -0
  30. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/default.rb +171 -0
  31. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/page.rb +566 -0
  32. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/serialization.rb +351 -0
  33. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/version.rb +49 -0
  34. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob.rb +26 -0
  35. data/vendor/azure-storage-ruby/common/BreakingChanges.md +8 -0
  36. data/vendor/azure-storage-ruby/common/ChangeLog.md +41 -0
  37. data/vendor/azure-storage-ruby/common/Gemfile +30 -0
  38. data/vendor/azure-storage-ruby/common/LICENSE.txt +21 -0
  39. data/vendor/azure-storage-ruby/common/README.md +146 -0
  40. data/vendor/azure-storage-ruby/common/azure-storage-common.gemspec +57 -0
  41. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/authorizer.rb +36 -0
  42. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/shared_key.rb +125 -0
  43. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/shared_key_lite.rb +48 -0
  44. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/signer.rb +51 -0
  45. data/vendor/azure-storage-ruby/common/lib/azure/core/default.rb +23 -0
  46. data/vendor/azure-storage-ruby/common/lib/azure/core/error.rb +21 -0
  47. data/vendor/azure-storage-ruby/common/lib/azure/core/filtered_service.rb +45 -0
  48. data/vendor/azure-storage-ruby/common/lib/azure/core/http/debug_filter.rb +36 -0
  49. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_error.rb +135 -0
  50. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_filter.rb +53 -0
  51. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_request.rb +195 -0
  52. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_response.rb +102 -0
  53. data/vendor/azure-storage-ruby/common/lib/azure/core/http/retry_policy.rb +84 -0
  54. data/vendor/azure-storage-ruby/common/lib/azure/core/http/signer_filter.rb +33 -0
  55. data/vendor/azure-storage-ruby/common/lib/azure/core/service.rb +46 -0
  56. data/vendor/azure-storage-ruby/common/lib/azure/core/signed_service.rb +45 -0
  57. data/vendor/azure-storage-ruby/common/lib/azure/core/utility.rb +244 -0
  58. data/vendor/azure-storage-ruby/common/lib/azure/core/version.rb +33 -0
  59. data/vendor/azure-storage-ruby/common/lib/azure/core.rb +48 -0
  60. data/vendor/azure-storage-ruby/common/lib/azure/http_response_helper.rb +38 -0
  61. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/autoload.rb +62 -0
  62. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client.rb +162 -0
  63. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client_options.rb +363 -0
  64. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client_options_error.rb +41 -0
  65. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/configurable.rb +212 -0
  66. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/anonymous_signer.rb +43 -0
  67. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature.rb +30 -0
  68. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature_generator.rb +399 -0
  69. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature_signer.rb +57 -0
  70. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_key.rb +60 -0
  71. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/token_signer.rb +43 -0
  72. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/autoload.rb +53 -0
  73. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/error.rb +43 -0
  74. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/exponential_retry_filter.rb +64 -0
  75. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/linear_retry_filter.rb +55 -0
  76. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/retry_filter.rb +300 -0
  77. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/http_client.rb +82 -0
  78. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/sr.rb +85 -0
  79. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/token_credential.rb +64 -0
  80. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/utility.rb +261 -0
  81. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core.rb +35 -0
  82. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/default.rb +868 -0
  83. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/access_policy.rb +37 -0
  84. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/cors.rb +38 -0
  85. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/cors_rule.rb +48 -0
  86. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/enumeration_results.rb +32 -0
  87. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/geo_replication.rb +40 -0
  88. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/logging.rb +47 -0
  89. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/metrics.rb +45 -0
  90. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/retention_policy.rb +37 -0
  91. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/serialization.rb +335 -0
  92. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/signed_identifier.rb +40 -0
  93. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service.rb +322 -0
  94. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service_properties.rb +48 -0
  95. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service_stats.rb +39 -0
  96. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/user_delegation_key.rb +50 -0
  97. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/version.rb +49 -0
  98. data/vendor/azure-storage-ruby/common/lib/azure/storage/common.rb +26 -0
  99. metadata +95 -31
@@ -0,0 +1,351 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ require "base64"
27
+
28
+ module Azure::Storage
29
+ module Blob
30
+ module Serialization
31
+ include Azure::Storage::Common::Service::Serialization
32
+
33
+ def self.container_enumeration_results_from_xml(xml)
34
+ xml = slopify(xml)
35
+ expect_node("EnumerationResults", xml)
36
+
37
+ results = enumeration_results_from_xml(xml, Azure::Storage::Common::Service::EnumerationResults.new)
38
+
39
+ return results unless (xml > "Containers").any? && ((xml > "Containers") > "Container").any?
40
+
41
+ if xml.Containers.Container.count == 0
42
+ results.push(container_from_xml(xml.Containers.Container))
43
+ else
44
+ xml.Containers.Container.each { |container_node|
45
+ results.push(container_from_xml(container_node))
46
+ }
47
+ end
48
+
49
+ results
50
+ end
51
+
52
+ def self.key_info_to_xml(start, expiry)
53
+ builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
54
+ xml.KeyInfo {
55
+ xml.Start start.utc.iso8601
56
+ xml.Expiry expiry.utc.iso8601
57
+ }
58
+ end
59
+ builder.to_xml
60
+ end
61
+
62
+ def self.user_delegation_key_from_xml(xml)
63
+ xml = slopify(xml)
64
+ expect_node("UserDelegationKey", xml)
65
+
66
+ Azure::Storage::Common::Service::UserDelegationKey.new do |user_delegation_key|
67
+ user_delegation_key.signed_oid = xml.SignedOid.text if (xml > "SignedOid").any?
68
+ user_delegation_key.signed_tid = xml.SignedTid.text if (xml > "SignedTid").any?
69
+ user_delegation_key.signed_start = xml.SignedStart.text if (xml > "SignedStart").any?
70
+ user_delegation_key.signed_expiry = xml.SignedExpiry.text if (xml > "SignedExpiry").any?
71
+ user_delegation_key.signed_service = xml.SignedService.text if (xml > "SignedService").any?
72
+ user_delegation_key.signed_version = xml.SignedVersion.text if (xml > "SignedVersion").any?
73
+ user_delegation_key.value = xml.Value.text if (xml > "Value").any?
74
+ end
75
+ end
76
+
77
+ def self.container_from_xml(xml)
78
+ xml = slopify(xml)
79
+ expect_node("Container", xml)
80
+
81
+ Container::Container.new do |container|
82
+ container.name = xml.Name.text if (xml > "Name").any?
83
+ container.properties = container_properties_from_xml(xml.Properties) if (xml > "Properties").any?
84
+ container.metadata = metadata_from_xml(xml.Metadata) if (xml > "Metadata").any?
85
+ container.public_access_level = public_access_level_from_properties_xml(xml.Properties) if (xml > "Properties").any?
86
+ end
87
+ end
88
+
89
+ def self.container_from_headers(headers)
90
+ Container::Container.new do |container|
91
+ container.properties = container_properties_from_headers(headers)
92
+ container.public_access_level = public_access_level_from_headers(headers)
93
+ container.metadata = metadata_from_headers(headers)
94
+ end
95
+ end
96
+
97
+ def self.container_properties_from_xml(xml)
98
+ xml = slopify(xml)
99
+ expect_node("Properties", xml)
100
+
101
+ props = {}
102
+
103
+ props[:last_modified] = (xml > "Last-Modified").text if (xml > "Last-Modified").any?
104
+ props[:etag] = xml.Etag.text if (xml > "Etag").any?
105
+ props[:lease_status] = xml.LeaseStatus.text if (xml > "LeaseStatus").any?
106
+ props[:lease_state] = xml.LeaseState.text if (xml > "LeaseState").any?
107
+ props[:lease_duration] = xml.LeaseDuration.text if (xml > "LeaseDuration").any?
108
+
109
+ props
110
+ end
111
+
112
+ def self.container_properties_from_headers(headers)
113
+ props = {}
114
+
115
+ props[:last_modified] = headers["Last-Modified"]
116
+ props[:etag] = headers["Etag"]
117
+ props[:lease_status] = headers["x-ms-lease-status"]
118
+ props[:lease_state] = headers["x-ms-lease-state"]
119
+ props[:lease_duration] = headers["x-ms-lease-duration"]
120
+
121
+ props
122
+ end
123
+
124
+ def self.public_access_level_from_headers(headers)
125
+ headers["x-ms-blob-public-access"]
126
+ end
127
+
128
+ def self.public_access_level_from_properties_xml(xml)
129
+ (xml > "PublicAccess").any? ? xml.PublicAccess.text : nil
130
+ end
131
+
132
+ def self.blob_enumeration_results_from_xml(xml)
133
+ xml = slopify(xml)
134
+ expect_node("EnumerationResults", xml)
135
+
136
+ results = enumeration_results_from_xml(xml, Azure::Storage::Common::Service::EnumerationResults.new)
137
+
138
+ return results unless (xml > "Blobs").any?
139
+
140
+ if ((xml > "Blobs") > "Blob").any?
141
+ if xml.Blobs.Blob.count == 0
142
+ results.push(blob_from_xml(xml.Blobs.Blob))
143
+ else
144
+ xml.Blobs.Blob.each { |blob_node|
145
+ results.push(blob_from_xml(blob_node))
146
+ }
147
+ end
148
+ end
149
+
150
+ if ((xml > "Blobs") > "BlobPrefix").any?
151
+ if xml.Blobs.BlobPrefix.count == 0
152
+ results.push(blob_prefix_from_xml(xml.Blobs.BlobPrefix))
153
+ else
154
+ xml.Blobs.BlobPrefix.each { |blob_prefix|
155
+ results.push(blob_prefix_from_xml(blob_prefix))
156
+ }
157
+ end
158
+ end
159
+
160
+ results
161
+ end
162
+
163
+ def self.blob_prefix_from_xml(xml)
164
+ xml = slopify(xml)
165
+ expect_node("BlobPrefix", xml)
166
+
167
+ name = xml.Name.text if (xml > "Name").any?
168
+ name
169
+ end
170
+
171
+ def self.blob_from_xml(xml)
172
+ xml = slopify(xml)
173
+ expect_node("Blob", xml)
174
+
175
+ Blob.new do |blob|
176
+ blob.name = xml.Name.text if (xml > "Name").any?
177
+ blob.snapshot = xml.Snapshot.text if (xml > "Snapshot").any?
178
+
179
+ blob.metadata = metadata_from_xml(xml.Metadata) if (xml > "Metadata").any?
180
+ if (xml > "Properties").any?
181
+ blob.properties = blob_properties_from_xml(xml.Properties)
182
+ blob.encrypted = xml.Properties.ServerEncrypted.text == "true" if (xml.Properties > "ServerEncrypted").any?
183
+ end
184
+ end
185
+ end
186
+
187
+ def self.blob_from_headers(headers)
188
+ Blob.new do |blob|
189
+ blob.properties = blob_properties_from_headers(headers)
190
+ blob.metadata = metadata_from_headers(headers)
191
+ blob.encrypted = headers[Azure::Storage::Common::HeaderConstants::REQUEST_SERVER_ENCRYPTED] || headers[Azure::Storage::Common::HeaderConstants::SERVER_ENCRYPTED]
192
+ blob.encrypted = blob.encrypted.to_s == "true" unless blob.encrypted.nil?
193
+ end
194
+ end
195
+
196
+ def self.blob_properties_from_xml(xml)
197
+ xml = slopify(xml)
198
+ expect_node("Properties", xml)
199
+
200
+ props = {}
201
+
202
+ props[:access_tier] = (xml > "AccessTier").text if (xml > "AccessTier").any?
203
+ props[:access_tier_change_time] = (xml > "AccessTierChangeTime").text if (xml > "AccessTierChangeTime").any?
204
+ props[:creation_Time] = (xml > "Creation-Time").text if (xml > "Creation-Time").any?
205
+ props[:last_modified] = (xml > "Last-Modified").text if (xml > "Last-Modified").any?
206
+ props[:etag] = xml.Etag.text if (xml > "Etag").any?
207
+ props[:lease_status] = xml.LeaseStatus.text if (xml > "LeaseStatus").any?
208
+ props[:lease_state] = xml.LeaseState.text if (xml > "LeaseState").any?
209
+ props[:lease_duration] = xml.LeaseDuration.text if (xml > "LeaseDuration").any?
210
+ props[:content_length] = (xml > "Content-Length").text.to_i if (xml > "Content-Length").any?
211
+ props[:content_type] = (xml > "Content-Type").text if (xml > "Content-Type").any?
212
+ props[:content_encoding] = (xml > "Content-Encoding").text if (xml > "Content-Encoding").any?
213
+ props[:content_language] = (xml > "Content-Language").text if (xml > "Content-Language").any?
214
+ props[:content_md5] = (xml > "Content-MD5").text if (xml > "Content-MD5").any?
215
+
216
+ props[:cache_control] = (xml > "Cache-Control").text if (xml > "Cache-Control").any?
217
+ props[:sequence_number] = (xml > "x-ms-blob-sequence-number").text.to_i if (xml > "x-ms-blob-sequence-number").any?
218
+ props[:blob_type] = xml.BlobType.text if (xml > "BlobType").any?
219
+ props[:copy_id] = xml.CopyId.text if (xml > "CopyId").any?
220
+ props[:copy_status] = xml.CopyStatus.text if (xml > "CopyStatus").any?
221
+ props[:copy_source] = xml.CopySource.text if (xml > "CopySource").any?
222
+ props[:copy_progress] = xml.CopyProgress.text if (xml > "CopyProgress").any?
223
+ props[:copy_completion_time] = xml.CopyCompletionTime.text if (xml > "CopyCompletionTime").any?
224
+ props[:copy_status_description] = xml.CopyStatusDescription.text if (xml > "CopyStatusDescription").any?
225
+ props[:incremental_copy] = xml.IncrementalCopy.text == "true" if (xml > "IncrementalCopy").any?
226
+
227
+ props
228
+ end
229
+
230
+ def self.blob_properties_from_headers(headers)
231
+ props = {}
232
+
233
+ props[:last_modified] = headers["Last-Modified"]
234
+ props[:etag] = headers["Etag"]
235
+ props[:lease_status] = headers["x-ms-lease-status"]
236
+ props[:lease_state] = headers["x-ms-lease-state"]
237
+ props[:lease_duration] = headers["x-ms-lease-duration"]
238
+
239
+ props[:content_length] = headers["x-ms-blob-content-length"] || headers["Content-Length"]
240
+ props[:content_length] = props[:content_length].to_i if props[:content_length]
241
+
242
+ props[:content_type] = headers["x-ms-blob-content-type"] || headers["Content-Type"]
243
+ props[:content_encoding] = headers["x-ms-blob-content-encoding"] || headers["Content-Encoding"]
244
+ props[:content_language] = headers["x-ms-blob-content-language"] || headers["Content-Language"]
245
+ props[:content_disposition] = headers["x-ms-blob-content-disposition"] || headers["Content-Disposition"]
246
+ props[:content_md5] = headers["x-ms-blob-content-md5"] || headers["Content-MD5"]
247
+ props[:range_md5] = headers["Content-MD5"] if headers["x-ms-blob-content-md5"] && headers["Content-MD5"]
248
+
249
+ props[:cache_control] = headers["x-ms-blob-cache-control"] || headers["Cache-Control"]
250
+ props[:sequence_number] = headers["x-ms-blob-sequence-number"].to_i if headers["x-ms-blob-sequence-number"]
251
+ props[:blob_type] = headers["x-ms-blob-type"]
252
+
253
+ props[:copy_id] = headers["x-ms-copy-id"]
254
+ props[:copy_status] = headers["x-ms-copy-status"]
255
+ props[:copy_source] = headers["x-ms-copy-source"]
256
+ props[:copy_progress] = headers["x-ms-copy-progress"]
257
+ props[:copy_completion_time] = headers["x-ms-copy-completion-time"]
258
+ props[:copy_status_description] = headers["x-ms-copy-status-description"]
259
+
260
+ props[:accept_ranges] = headers["Accept-Ranges"].to_i if headers["Accept-Ranges"]
261
+
262
+ props[:append_offset] = headers["x-ms-blob-append-offset"].to_i if headers["x-ms-blob-append-offset"]
263
+ props[:committed_count] = headers["x-ms-blob-committed-block-count"].to_i if headers["x-ms-blob-committed-block-count"]
264
+ props[:incremental_copy] = headers["x-ms-incremental-copy"].to_s == "true" if headers["x-ms-incremental-copy"]
265
+
266
+ props
267
+ end
268
+
269
+ def self.block_list_to_xml(block_list)
270
+ builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
271
+ xml.BlockList {
272
+ block_list.each { |block|
273
+ encoded_id = Base64.strict_encode64(block[0])
274
+ case block[1]
275
+ when :uncommitted
276
+ xml.Uncommitted encoded_id
277
+ when :committed
278
+ xml.Committed encoded_id
279
+ else
280
+ xml.Latest encoded_id
281
+ end
282
+ }
283
+ }
284
+ end
285
+ builder.to_xml
286
+ end
287
+
288
+ def self.block_list_from_xml(xml)
289
+ xml = slopify(xml)
290
+ expect_node("BlockList", xml)
291
+
292
+ block_list = {
293
+ committed: [],
294
+ uncommitted: []
295
+ }
296
+
297
+ if ((xml > "CommittedBlocks") > "Block").any?
298
+ if xml.CommittedBlocks.Block.count == 0
299
+ add_block(:committed, xml.CommittedBlocks.Block, block_list)
300
+ else
301
+ xml.CommittedBlocks.Block.each { |block_node|
302
+ add_block(:committed, block_node, block_list)
303
+ }
304
+ end
305
+ end
306
+
307
+ return block_list unless (xml > "UncommittedBlocks")
308
+
309
+ if ((xml > "UncommittedBlocks") > "Block").any?
310
+ if xml.UncommittedBlocks.Block.count == 0
311
+ add_block(:uncommitted, xml.UncommittedBlocks.Block, block_list)
312
+ else
313
+ xml.UncommittedBlocks.Block.each { |block_node|
314
+ add_block(:uncommitted, block_node, block_list)
315
+ }
316
+ end
317
+ end
318
+
319
+ block_list
320
+ end
321
+
322
+ def self.add_block(type, block_node, block_list)
323
+ block = Block.new do |b|
324
+ b.name = Base64.strict_decode64(block_node.Name.text) if (block_node > "Name").any?
325
+ b.size = block_node.Size.text.to_i if (block_node > "Size").any?
326
+ b.type = type
327
+ end
328
+ block_list[type].push block
329
+ end
330
+
331
+ def self.page_list_from_xml(xml)
332
+ xml = slopify(xml)
333
+ expect_node("PageList", xml)
334
+
335
+ page_list = []
336
+
337
+ return page_list unless (xml > "PageRange").any?
338
+
339
+ if xml.PageRange.count == 0
340
+ page_list.push [xml.PageRange.Start.text.to_i, xml.PageRange.End.text.to_i]
341
+ else
342
+ xml.PageRange.each { |page_range|
343
+ page_list.push [page_range.Start.text.to_i, page_range.End.text.to_i]
344
+ }
345
+ end
346
+
347
+ page_list
348
+ end
349
+ end
350
+ end
351
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+
27
+ module Azure
28
+ module Storage
29
+ module Blob
30
+ class Version
31
+ # Fields represent the parts defined in http://semver.org/
32
+ MAJOR = 2 unless defined? MAJOR
33
+ MINOR = 0 unless defined? MINOR
34
+ UPDATE = 3 unless defined? UPDATE
35
+
36
+ class << self
37
+ # @return [String]
38
+ def to_s
39
+ [MAJOR, MINOR, UPDATE].compact.join(".")
40
+ end
41
+
42
+ def to_uas
43
+ [MAJOR, MINOR, UPDATE].join(".")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ require "azure/storage/blob/autoload"
@@ -0,0 +1,8 @@
1
+ Tracking Breaking Changes in 2.0.0
2
+
3
+ * This module now supports Ruby versions to 2.3 through 2.7
4
+
5
+ Tracking Breaking Changes in 1.0.0
6
+
7
+ * This module now consists of functionalities to support service client library modules.
8
+ * All namespaces in this module now begin with "Azure::Storage::Common" instead of "Azure::Storage".
@@ -0,0 +1,41 @@
1
+ 2021.12 - version 2.0.4
2
+ * Lifted Ruby-version-based restrictions on Nokogiri version.
3
+
4
+ 2021.10 - version 2.0.3
5
+ * Allowed to use any version 1.x of Nokogiri for Ruby version later than or equal to 2.5.0.
6
+ * Fixed handling of invalid connection strings
7
+
8
+ 2020.8 - version 2.0.2
9
+ * Bumped up Nokogiri version to 1.11.0.rc2 for Ruby version later than or equal to 2.4.0.
10
+ * Changed to use persistent HTTP client to speed up requests #168.
11
+ * Explicitly requiring `tempfile` to avoid runtime errors.
12
+
13
+ 2020.3 - version 2.0.1
14
+ * Resolved an issue where the rubygem 'azure-storage-common' cannot resolve 'faraday_middleware' version automatically.
15
+ * Resolved an issue where automation does not report error for sanity check failure.
16
+
17
+ 2020.3 - version 2.0.0
18
+ * This module now supports Ruby versions to 2.3 through 2.7
19
+ * Service version is upgraded to 2018-11-09.
20
+ * Add support for generating user delegation shared access signatures.
21
+ * This module now contains azure-core which was originally in azure-ruby-asm-core.
22
+ * The following dependency version was bumped up to the specified version for security update:
23
+ Nokogiri 1.10.4
24
+ Faraday 1.0.0
25
+ Rake 13.0
26
+ * Now reuses the HTTP Client on host level.
27
+
28
+ 2018.11 - version 1.1.0
29
+ * Added the support for sending a request with a bearer token.
30
+ * Added the configuration for SSL versions.
31
+ * Fixed the issue that the retry interval could be negative. [#121]
32
+ * Fixed the timeout issue when the resource doesn't exist. [#122]
33
+
34
+ 2018.1 - version 1.0.1
35
+ * Resolved an issue where user cannot use Gem package using `gem install`.
36
+
37
+ 2018.1 - version 1.0.0
38
+
39
+ * This module now consists of functionalities to support service client library modules.
40
+ * All namespaces in this module now begin with "Azure::Storage::Common" instead of "Azure::Storage".
41
+ * Resolved an issue where user tries to access `Azure::Storage::Common::Default::signer` would throw `undefined method 'signer' for Azure::Storage::Default:Module`.
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ source "https://rubygems.org"
27
+
28
+ gemspec name: "azure-storage-common"
29
+
30
+ gem "coveralls", require: false
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,146 @@
1
+ # Microsoft Azure Storage Common Client Library for Ruby
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/azure-storage-common.svg)](https://badge.fury.io/rb/azure-storage-common)
4
+ * Master: [![Master Build Status](https://travis-ci.org/Azure/azure-storage-ruby.svg?branch=master)](https://travis-ci.org/Azure/azure-storage-ruby/branches) [![Coverage Status](https://coveralls.io/repos/github/Azure/azure-storage-ruby/badge.svg?branch=master)](https://coveralls.io/github/Azure/azure-storage-ruby?branch=master)
5
+ * Dev: [![Dev Build Status](https://travis-ci.org/Azure/azure-storage-ruby.svg?branch=dev)](https://travis-ci.org/Azure/azure-storage-ruby/branches) [![Coverage Status](https://coveralls.io/repos/github/Azure/azure-storage-ruby/badge.svg?branch=dev)](https://coveralls.io/github/Azure/azure-storage-ruby?branch=dev)
6
+
7
+ This project provides a Ruby package that supports service client libraries.
8
+
9
+ # Supported Ruby Versions
10
+
11
+ * Ruby 2.3 to 2.7
12
+
13
+ Note:
14
+
15
+ * x64 Ruby for Windows is known to have some compatibility issues.
16
+ * azure-storage-common depends on gem nokogiri.
17
+
18
+ # Getting Started
19
+
20
+ ## Install the rubygem package
21
+
22
+ You can install the azure storage common rubygem package directly.
23
+
24
+ ```bash
25
+ gem install azure-storage-common
26
+ ```
27
+
28
+ ## Create client
29
+
30
+ You can use this module to create client that can be later shared by service modules, to avoid repeating code of creating storage client.
31
+
32
+ There are two ways you can create the client:
33
+
34
+ 1. [via code](#via-code)
35
+ 2. [via environment variables](#via-environment-variables)
36
+
37
+ <a name="via-code"></a>
38
+ ### Via Code
39
+ * Against Microsoft Azure Services in the cloud
40
+
41
+ ```ruby
42
+
43
+ require 'azure/storage/common'
44
+
45
+ # Setup a specific instance of an Azure::Storage::Common::Client
46
+ client = Azure::Storage::Common::Client.create(storage_account_name: <your account name>, storage_access_key: <your access key>)
47
+
48
+ # Configure a ca_cert.pem file if you are having issues with ssl peer verification
49
+ client.ca_file = './ca_file.pem'
50
+
51
+ ```
52
+
53
+ * Against local Emulator (Windows Only)
54
+
55
+ ```ruby
56
+
57
+ require 'azure/storage/common'
58
+ client = Azure::Storage::Common::Client.create_development
59
+
60
+ # Or create by options and provide your own proxy_uri
61
+ client = Azure::Storage::Common::Client.create(use_development_storage: true, development_storage_proxy_uri: <your proxy uri>)
62
+
63
+ ```
64
+
65
+ <a name="via-environment-variables"></a>
66
+ ### Via Environment Variables
67
+
68
+ * Against Microsoft Azure Storage Services in the cloud
69
+
70
+ ```bash
71
+ export AZURE_STORAGE_ACCOUNT = <your azure storage account name>
72
+ export AZURE_STORAGE_ACCESS_KEY = <your azure storage access key>
73
+ ```
74
+
75
+ * Against local Emulator (Windows Only)
76
+
77
+ ```bash
78
+ export EMULATED = true
79
+ ```
80
+
81
+ * [SSL Certificate File](https://gist.github.com/fnichol/867550) if having issues with ssl peer verification
82
+
83
+ ```bash
84
+ SSL_CERT_FILE=<path to *.pem>
85
+ ```
86
+
87
+ # Usage
88
+
89
+ <a name="sas"></a>
90
+ ## Shared Access Signature generation
91
+
92
+ ```ruby
93
+
94
+ require "azure/storage/common"
95
+
96
+ # Creating an instance of `Azure::Storage::Common::Core::Auth::SharedAccessSignature`
97
+ generator = Azure::Storage::Common::Core::Auth::SharedAccessSignature.new(your_account_name, your_access_key)
98
+
99
+ # The generator now can be used to create service SAS or account SAS.
100
+ generator.generate_service_sas_token(my_path_or_table_name, my_sas_options)
101
+ generator.generate_account_sas_token(my_account_sas_options)
102
+ # For details about the possible options, please reference the document of the class `Azure::Storage::Common::Core::Auth::SharedAccessSignature`
103
+
104
+ ```
105
+
106
+ <a name="token"></a>
107
+ ## Access Token
108
+
109
+ Please refer to the below links for obtaining an access token:
110
+ * [Authenticate with Azure Active Directory](https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-azure-active-directory)
111
+ * [Getting a MSI access token](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-linux-vm-access-storage#get-an-access-token-and-use-it-to-call-azure-storage)
112
+
113
+ ```ruby
114
+ require "azure/storage/common"
115
+
116
+ access_token = <your initial access token>
117
+
118
+ # Creating an instance of `Azure::Storage::Common::Core::TokenCredential`
119
+ token_credential = Azure::Storage::Common::Core::TokenCredential.new access_token
120
+ token_signer = Azure::Storage::Common::Core::Auth::TokenSigner.new token_credential
121
+ common_token_client = Azure::Storage::Common::Client.create.new(storage_account_name: <your_account_name>, signer: token_signer)
122
+
123
+ # Refresh internal is 50 minutes
124
+ refresh_interval = 50 * 60
125
+ # The user-defined thread that renews the access token
126
+ cancelled = false
127
+ renew_token = Thread.new do
128
+ Thread.stop
129
+ while !cancelled
130
+ sleep(refresh_interval)
131
+
132
+ # Renew the access token here
133
+
134
+ # Update the access token to the credential
135
+ token_credential.renew_token <new_access_token>
136
+ end
137
+ end
138
+ sleep 0.1 while renew_token.status != 'sleep'
139
+ renew_token.run
140
+
141
+ # Call client functions as usaual
142
+
143
+ ```
144
+
145
+ # Code of Conduct
146
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.