azure-storage 0.13.0.preview → 0.14.0.preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/azure/storage.rb +14 -13
  3. data/lib/azure/storage/autoload.rb +31 -31
  4. data/lib/azure/storage/blob/append.rb +43 -41
  5. data/lib/azure/storage/blob/blob.rb +150 -147
  6. data/lib/azure/storage/blob/blob_service.rb +186 -184
  7. data/lib/azure/storage/blob/block.rb +56 -56
  8. data/lib/azure/storage/blob/container.rb +93 -92
  9. data/lib/azure/storage/blob/page.rb +187 -104
  10. data/lib/azure/storage/blob/serialization.rb +32 -18
  11. data/lib/azure/storage/client.rb +18 -17
  12. data/lib/azure/storage/client_options.rb +192 -193
  13. data/lib/azure/storage/client_options_error.rb +5 -5
  14. data/lib/azure/storage/configurable.rb +39 -39
  15. data/lib/azure/storage/core.rb +6 -4
  16. data/lib/azure/storage/core/auth/shared_access_signature.rb +5 -3
  17. data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +34 -33
  18. data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +5 -5
  19. data/lib/azure/storage/core/auth/shared_key.rb +17 -15
  20. data/lib/azure/storage/core/autoload.rb +15 -13
  21. data/lib/azure/storage/core/error.rb +3 -1
  22. data/lib/azure/storage/core/filter/exponential_retry_filter.rb +13 -11
  23. data/lib/azure/storage/core/filter/linear_retry_filter.rb +10 -8
  24. data/lib/azure/storage/core/filter/retry_filter.rb +30 -29
  25. data/lib/azure/storage/core/http_client.rb +18 -16
  26. data/lib/azure/storage/core/sr.rb +50 -48
  27. data/lib/azure/storage/core/utility.rb +19 -17
  28. data/lib/azure/storage/default.rb +371 -361
  29. data/lib/azure/storage/file/directory.rb +36 -31
  30. data/lib/azure/storage/file/file.rb +103 -100
  31. data/lib/azure/storage/file/file_service.rb +42 -40
  32. data/lib/azure/storage/file/serialization.rb +9 -6
  33. data/lib/azure/storage/file/share.rb +48 -46
  34. data/lib/azure/storage/queue/message.rb +3 -1
  35. data/lib/azure/storage/queue/queue.rb +3 -2
  36. data/lib/azure/storage/queue/queue_service.rb +152 -151
  37. data/lib/azure/storage/queue/serialization.rb +7 -5
  38. data/lib/azure/storage/service/access_policy.rb +3 -1
  39. data/lib/azure/storage/service/cors.rb +4 -2
  40. data/lib/azure/storage/service/cors_rule.rb +3 -1
  41. data/lib/azure/storage/service/enumeration_results.rb +3 -1
  42. data/lib/azure/storage/service/logging.rb +5 -3
  43. data/lib/azure/storage/service/metrics.rb +5 -3
  44. data/lib/azure/storage/service/retention_policy.rb +3 -1
  45. data/lib/azure/storage/service/serialization.rb +31 -30
  46. data/lib/azure/storage/service/signed_identifier.rb +5 -4
  47. data/lib/azure/storage/service/storage_service.rb +33 -32
  48. data/lib/azure/storage/service/storage_service_properties.rb +6 -4
  49. data/lib/azure/storage/table/auth/shared_key.rb +9 -8
  50. data/lib/azure/storage/table/batch.rb +55 -55
  51. data/lib/azure/storage/table/batch_response.rb +17 -17
  52. data/lib/azure/storage/table/edmtype.rb +9 -7
  53. data/lib/azure/storage/table/entity.rb +4 -3
  54. data/lib/azure/storage/table/guid.rb +3 -1
  55. data/lib/azure/storage/table/query.rb +17 -19
  56. data/lib/azure/storage/table/serialization.rb +14 -12
  57. data/lib/azure/storage/table/table_service.rb +79 -80
  58. data/lib/azure/storage/version.rb +7 -5
  59. metadata +2 -2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #-------------------------------------------------------------------------
2
4
  # # Copyright (c) Microsoft and contributors. All rights reserved.
3
5
  #
@@ -21,7 +23,7 @@
21
23
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
24
  # THE SOFTWARE.
23
25
  #--------------------------------------------------------------------------
24
- require 'azure/storage/blob/blob'
26
+ require "azure/storage/blob/blob"
25
27
 
26
28
  module Azure::Storage
27
29
  module Blob
@@ -32,71 +34,71 @@ module Azure::Storage
32
34
  #
33
35
  # * +container+ - String. The container name.
34
36
  # * +blob+ - String. The blob name.
35
- # * +length+ - Integer. Specifies the maximum size for the page blob, up to 1 TB.
37
+ # * +length+ - Integer. Specifies the maximum size for the page blob, up to 1 TB.
36
38
  # The page blob size must be aligned to a 512-byte boundary.
37
39
  # * +options+ - Hash. Optional parameters.
38
40
  #
39
41
  # ==== Options
40
42
  #
41
43
  # Accepted key/value pairs in options parameter are:
42
- # * +:transactional_md5+ - String. An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during transport.
43
- # When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
44
+ # * +:transactional_md5+ - String. An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during transport.
45
+ # When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
44
46
  # If the two hashes do not match, the operation will fail with error code 400 (Bad Request).
45
47
  # * +:content_type+ - String. Content type for the blob. Will be saved with blob.
46
48
  # * +:content_encoding+ - String. Content encoding for the blob. Will be saved with blob.
47
49
  # * +:content_language+ - String. Content language for the blob. Will be saved with blob.
48
50
  # * +:content_md5+ - String. Content MD5 for the blob. Will be saved with blob.
49
51
  # * +:cache_control+ - String. Cache control for the blob. Will be saved with blob.
50
- # * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
52
+ # * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
51
53
  # and also can be used to attach additional metadata
52
54
  # * +:metadata+ - Hash. Custom metadata values to store with the blob.
53
- # * +:sequence_number+ - Integer. The sequence number is a user-controlled value that you can use to track requests.
55
+ # * +:sequence_number+ - Integer. The sequence number is a user-controlled value that you can use to track requests.
54
56
  # The value of the sequence number must be between 0 and 2^63 - 1.The default value is 0.
55
57
  # * +:timeout+ - Integer. A timeout in seconds.
56
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
58
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
57
59
  # in the analytics logs when storage analytics logging is enabled.
58
- # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
59
- # only if the blob has been modified since the specified date/time. If the blob has not been modified,
60
+ # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
61
+ # only if the blob has been modified since the specified date/time. If the blob has not been modified,
60
62
  # the Blob service returns status code 412 (Precondition Failed).
61
- # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
62
- # only if the blob has not been modified since the specified date/time. If the blob has been modified,
63
+ # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to create a new blob
64
+ # only if the blob has not been modified since the specified date/time. If the blob has been modified,
63
65
  # the Blob service returns status code 412 (Precondition Failed).
64
- # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
65
- # only if the blob's ETag value matches the value specified. If the values do not match,
66
+ # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
67
+ # only if the blob's ETag value matches the value specified. If the values do not match,
66
68
  # the Blob service returns status code 412 (Precondition Failed).
67
- # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
68
- # only if the blob's ETag value does not match the value specified. If the values are identical,
69
+ # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to create a new blob
70
+ # only if the blob's ETag value does not match the value specified. If the values are identical,
69
71
  # the Blob service returns status code 412 (Precondition Failed).
70
72
  #
71
73
  # See http://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
72
74
  #
73
75
  # Returns a Blob
74
- def create_page_blob(container, blob, length, options={})
75
- query = { }
76
- StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
76
+ def create_page_blob(container, blob, length, options = {})
77
+ query = {}
78
+ StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
77
79
 
78
80
  uri = blob_uri(container, blob, query)
79
81
 
80
82
  headers = StorageService.common_headers
81
83
 
82
84
  # set x-ms-blob-type to PageBlob
83
- StorageService.with_header headers, 'x-ms-blob-type', 'PageBlob'
85
+ StorageService.with_header headers, "x-ms-blob-type", "PageBlob"
84
86
 
85
87
  # ensure content-length is 0 and x-ms-blob-content-length is the blob length
86
- StorageService.with_header headers, 'Content-Length', 0.to_s
87
- StorageService.with_header headers, 'x-ms-blob-content-length', length.to_s
88
+ StorageService.with_header headers, "Content-Length", 0.to_s
89
+ StorageService.with_header headers, "x-ms-blob-content-length", length.to_s
88
90
 
89
91
  # set x-ms-sequence-number from options (or default to 0)
90
- StorageService.with_header headers, 'x-ms-sequence-number', (options[:sequence_number] || 0).to_s
92
+ StorageService.with_header headers, "x-ms-sequence-number", (options[:sequence_number] || 0).to_s
91
93
 
92
94
  # set the rest of the optional headers
93
- StorageService.with_header headers, 'Content-MD5', options[:transactional_md5]
94
- StorageService.with_header headers, 'x-ms-blob-content-type', options[:content_type]
95
- StorageService.with_header headers, 'x-ms-blob-content-encoding', options[:content_encoding]
96
- StorageService.with_header headers, 'x-ms-blob-content-language', options[:content_language]
97
- StorageService.with_header headers, 'x-ms-blob-content-md5', options[:content_md5]
98
- StorageService.with_header headers, 'x-ms-blob-cache-control', options[:cache_control]
99
- StorageService.with_header headers, 'x-ms-blob-content-disposition', options[:content_disposition]
95
+ StorageService.with_header headers, "Content-MD5", options[:transactional_md5]
96
+ StorageService.with_header headers, "x-ms-blob-content-type", options[:content_type]
97
+ StorageService.with_header headers, "x-ms-blob-content-encoding", options[:content_encoding]
98
+ StorageService.with_header headers, "x-ms-blob-content-language", options[:content_language]
99
+ StorageService.with_header headers, "x-ms-blob-content-md5", options[:content_md5]
100
+ StorageService.with_header headers, "x-ms-blob-cache-control", options[:cache_control]
101
+ StorageService.with_header headers, "x-ms-blob-content-disposition", options[:content_disposition]
100
102
 
101
103
  StorageService.add_metadata_to_headers options[:metadata], headers
102
104
  add_blob_conditional_headers options, headers
@@ -107,10 +109,10 @@ module Azure::Storage
107
109
  result = Serialization.blob_from_headers(response.headers)
108
110
  result.name = blob
109
111
  result.metadata = options[:metadata] if options[:metadata]
110
-
112
+
111
113
  result
112
114
  end
113
-
115
+
114
116
  # Public: Creates a range of pages in a page blob.
115
117
  #
116
118
  # ==== Attributes
@@ -127,43 +129,43 @@ module Azure::Storage
127
129
  # Accepted key/value pairs in options parameter are:
128
130
  # * +:transactional_md5+ - String. An MD5 hash of the page content. This hash is used to verify the integrity of the page during transport.
129
131
  # When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
130
- # * +:if_sequence_number_le+ - Integer. If the blob's sequence number is less than or equal to the specified value, the request proceeds;
132
+ # * +:if_sequence_number_le+ - Integer. If the blob's sequence number is less than or equal to the specified value, the request proceeds;
131
133
  # otherwise it fails with the SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
132
- # * +:if_sequence_number_lt+ - Integer. If the blob's sequence number is less than the specified value, the request proceeds;
134
+ # * +:if_sequence_number_lt+ - Integer. If the blob's sequence number is less than the specified value, the request proceeds;
133
135
  # otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
134
- # * +:if_sequence_number_eq+ - Integer. If the blob's sequence number is equal to the specified value, the request proceeds;
136
+ # * +:if_sequence_number_eq+ - Integer. If the blob's sequence number is equal to the specified value, the request proceeds;
135
137
  # otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
136
- # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to write the page only if
137
- # the blob has been modified since the specified date/time. If the blob has not been modified,
138
+ # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to write the page only if
139
+ # the blob has been modified since the specified date/time. If the blob has not been modified,
138
140
  # the Blob service returns status code 412 (Precondition Failed).
139
- # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to write the page only if
140
- # the blob has not been modified since the specified date/time. If the blob has been modified,
141
+ # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to write the page only if
142
+ # the blob has not been modified since the specified date/time. If the blob has been modified,
141
143
  # the Blob service returns status code 412 (Precondition Failed).
142
- # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to write the page only if
143
- # the blob's ETag value matches the value specified. If the values do not match,
144
+ # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to write the page only if
145
+ # the blob's ETag value matches the value specified. If the values do not match,
144
146
  # the Blob service returns status code 412 (Precondition Failed).
145
- # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to write the page only if
146
- # the blob's ETag value does not match the value specified. If the values are identical,
147
+ # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to write the page only if
148
+ # the blob's ETag value does not match the value specified. If the values are identical,
147
149
  # the Blob service returns status code 412 (Precondition Failed).
148
150
  # * +:timeout+ - Integer. A timeout in seconds.
149
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
151
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
150
152
  # in the analytics logs when storage analytics logging is enabled.
151
- #
153
+ #
152
154
  # See http://msdn.microsoft.com/en-us/library/azure/ee691975.aspx
153
155
  #
154
156
  # Returns Blob
155
- def put_blob_pages(container, blob, start_range, end_range, content, options={})
156
- query = { 'comp' => 'page' }
157
- StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
157
+ def put_blob_pages(container, blob, start_range, end_range, content, options = {})
158
+ query = { "comp" => "page" }
159
+ StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
158
160
 
159
161
  uri = blob_uri(container, blob, query)
160
162
  headers = StorageService.common_headers
161
- StorageService.with_header headers, 'Content-MD5', options[:transactional_md5]
162
- StorageService.with_header headers, 'x-ms-range', "bytes=#{start_range}-#{end_range}"
163
- StorageService.with_header headers, 'x-ms-page-write', 'update'
163
+ StorageService.with_header headers, "Content-MD5", options[:transactional_md5]
164
+ StorageService.with_header headers, "x-ms-range", "bytes=#{start_range}-#{end_range}"
165
+ StorageService.with_header headers, "x-ms-page-write", "update"
164
166
 
165
167
  # clear default content type
166
- StorageService.with_header headers, 'Content-Type', ''
168
+ StorageService.with_header headers, "Content-Type", ""
167
169
 
168
170
  # set optional headers
169
171
  unless options.empty?
@@ -192,37 +194,37 @@ module Azure::Storage
192
194
  #
193
195
  # Accepted key/value pairs in options parameter are:
194
196
  # * +:timeout+ - Integer. A timeout in seconds.
195
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
197
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
196
198
  # in the analytics logs when storage analytics logging is enabled.
197
- # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to clear the page only if
198
- # the blob has been modified since the specified date/time. If the blob has not been modified,
199
+ # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to clear the page only if
200
+ # the blob has been modified since the specified date/time. If the blob has not been modified,
199
201
  # the Blob service returns status code 412 (Precondition Failed).
200
- # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to clear the page only if
201
- # the blob has not been modified since the specified date/time. If the blob has been modified,
202
+ # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to clear the page only if
203
+ # the blob has not been modified since the specified date/time. If the blob has been modified,
202
204
  # the Blob service returns status code 412 (Precondition Failed).
203
- # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to clear the page only if
204
- # the blob's ETag value matches the value specified. If the values do not match,
205
+ # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to clear the page only if
206
+ # the blob's ETag value matches the value specified. If the values do not match,
205
207
  # the Blob service returns status code 412 (Precondition Failed).
206
- # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to clear the page only if
207
- # the blob's ETag value does not match the value specified. If the values are identical,
208
+ # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to clear the page only if
209
+ # the blob's ETag value does not match the value specified. If the values are identical,
208
210
  # the Blob service returns status code 412 (Precondition Failed).
209
211
  #
210
212
  # See http://msdn.microsoft.com/en-us/library/azure/ee691975.aspx
211
213
  #
212
214
  # Returns Blob
213
- def clear_blob_pages(container, blob, start_range, end_range, options={})
214
- query = { 'comp' => 'page' }
215
- StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
215
+ def clear_blob_pages(container, blob, start_range, end_range, options = {})
216
+ query = { "comp" => "page" }
217
+ StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
216
218
 
217
219
  uri = blob_uri(container, blob, query)
218
220
 
219
221
  headers = StorageService.common_headers
220
- StorageService.with_header headers, 'x-ms-range', "bytes=#{start_range}-#{end_range}"
221
- StorageService.with_header headers, 'x-ms-page-write', 'clear'
222
+ StorageService.with_header headers, "x-ms-range", "bytes=#{start_range}-#{end_range}"
223
+ StorageService.with_header headers, "x-ms-page-write", "clear"
222
224
 
223
225
  # clear default content type
224
- StorageService.with_header headers, 'Content-Type', ''
225
-
226
+ StorageService.with_header headers, "Content-Type", ""
227
+
226
228
  # set optional headers
227
229
  unless options.empty?
228
230
  add_blob_conditional_headers options, headers
@@ -235,7 +237,7 @@ module Azure::Storage
235
237
 
236
238
  result
237
239
  end
238
-
240
+
239
241
  # Public: Returns a list of active page ranges for a page blob. Active page ranges are
240
242
  # those that have been populated with data.
241
243
  #
@@ -253,54 +255,59 @@ module Azure::Storage
253
255
  # * +:snapshot+ - String. An opaque DateTime value that specifies the blob snapshot to
254
256
  # retrieve information from. (optional)
255
257
  # * +:timeout+ - Integer. A timeout in seconds.
256
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
258
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
257
259
  # in the analytics logs when storage analytics logging is enabled.
258
- # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to list the pages only if
259
- # the blob has been modified since the specified date/time. If the blob has not been modified,
260
+ # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to list the pages only if
261
+ # the blob has been modified since the specified date/time. If the blob has not been modified,
260
262
  # the Blob service returns status code 412 (Precondition Failed).
261
- # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to list the pages only if
262
- # the blob has not been modified since the specified date/time. If the blob has been modified,
263
+ # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to list the pages only if
264
+ # the blob has not been modified since the specified date/time. If the blob has been modified,
263
265
  # the Blob service returns status code 412 (Precondition Failed).
264
- # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to list the pages only if
265
- # the blob's ETag value matches the value specified. If the values do not match,
266
+ # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to list the pages only if
267
+ # the blob's ETag value matches the value specified. If the values do not match,
266
268
  # the Blob service returns status code 412 (Precondition Failed).
267
- # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to list the pages only if
268
- # the blob's ETag value does not match the value specified. If the values are identical,
269
+ # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to list the pages only if
270
+ # the blob's ETag value does not match the value specified. If the values are identical,
269
271
  # the Blob service returns status code 412 (Precondition Failed).
272
+ # * +:previous_snapshot+ - String. An opaque DateTime value that specifies that the response will contain only pages that
273
+ # were changed between target blob and previous snapshot. Changed pages include both updated and
274
+ # cleared pages. The target blob may be a snapshot, as long as the snapshot specified by this
275
+ # is the older of the two.
270
276
  #
271
277
  # See http://msdn.microsoft.com/en-us/library/azure/ee691973.aspx
272
278
  #
273
279
  # Returns a list of page ranges in the format [ [start, end], [start, end], ... ]
274
280
  #
275
- # eg. [ [0, 511], [512, 1024], ... ]
281
+ # e.g. [ [0, 511], [512, 1024], ... ]
276
282
  #
277
- def list_page_blob_ranges(container, blob, options={})
278
- query = {'comp' => 'pagelist'}
279
- query.update({'snapshot' => options[:snapshot]}) if options[:snapshot]
280
- StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
283
+ def list_page_blob_ranges(container, blob, options = {})
284
+ query = { "comp" => "pagelist" }
285
+ query.update("snapshot" => options[:snapshot]) if options[:snapshot]
286
+ query.update("prevsnapshot" => options[:previous_snapshot]) if options[:previous_snapshot]
287
+ StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
281
288
 
282
289
  uri = blob_uri(container, blob, query)
283
290
 
284
- options[:start_range] = 0 if options[:end_range] and not options[:start_range]
291
+ options[:start_range] = 0 if options[:end_range] && (not options[:start_range])
285
292
 
286
293
  headers = StorageService.common_headers
287
- StorageService.with_header headers, 'x-ms-range', "bytes=#{options[:start_range]}-#{options[:end_range]}" if options[:start_range]
294
+ StorageService.with_header headers, "x-ms-range", "bytes=#{options[:start_range]}-#{options[:end_range]}" if options[:start_range]
288
295
  add_blob_conditional_headers options, headers
289
-
296
+
290
297
  response = call(:get, uri, nil, headers, options)
291
298
 
292
299
  pagelist = Serialization.page_list_from_xml(response.body)
293
300
  pagelist
294
301
  end
295
-
302
+
296
303
  # Public: Resizes a page blob to the specified size.
297
304
  #
298
305
  # ==== Attributes
299
306
  #
300
307
  # * +container+ - String. The container name.
301
308
  # * +blob+ - String. The blob name.
302
- # * +size+ - String. The blob size. Resizes a page blob to the specified size.
303
- # If the specified value is less than the current size of the blob,
309
+ # * +size+ - String. The blob size. Resizes a page blob to the specified size.
310
+ # If the specified value is less than the current size of the blob,
304
311
  # then all pages above the specified value are cleared.
305
312
  # * +options+ - Hash. Optional parameters.
306
313
  #
@@ -308,29 +315,105 @@ module Azure::Storage
308
315
  #
309
316
  # Accepted key/value pairs in options parameter are:
310
317
  # * +:timeout+ - Integer. A timeout in seconds.
311
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
318
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
312
319
  # in the analytics logs when storage analytics logging is enabled.
313
320
  # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
314
- # only if the blob has been modified since the specified date/time. If the blob has not been modified,
321
+ # only if the blob has been modified since the specified date/time. If the blob has not been modified,
315
322
  # the Blob service returns status code 412 (Precondition Failed).
316
323
  # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
317
- # only if the blob has not been modified since the specified date/time. If the blob has been modified,
324
+ # only if the blob has not been modified since the specified date/time. If the blob has been modified,
318
325
  # the Blob service returns status code 412 (Precondition Failed).
319
326
  # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
320
- # only if the blob's ETag value matches the value specified. If the values do not match,
327
+ # only if the blob's ETag value matches the value specified. If the values do not match,
321
328
  # the Blob service returns status code 412 (Precondition Failed).
322
329
  # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
323
- # only if the blob's ETag value does not match the value specified. If the values are identical,
330
+ # only if the blob's ETag value does not match the value specified. If the values are identical,
324
331
  # the Blob service returns status code 412 (Precondition Failed).
325
332
  #
326
333
  # See http://msdn.microsoft.com/en-us/library/azure/ee691966.aspx
327
334
  #
328
335
  # Returns nil on success.
329
- def resize_page_blob(container, blob, size, options={})
330
- options = { :content_length => size }.merge(options)
336
+ def resize_page_blob(container, blob, size, options = {})
337
+ options = { content_length: size }.merge(options)
331
338
  set_blob_properties container, blob, options
332
339
  end
333
-
340
+
341
+ # Public: Copies a snapshot of the source page blob to a destination page blob. The snapshot is copied such that only
342
+ # the differential changes between the previously copied snapshot are transferred to the destination. The copied snapshots
343
+ # are complete copies of the original snapshot and can be read or copied from as usual.The destination of an incremental copy
344
+ # must either not exist, or must have been created with a previous incremental copy from the same source blob. Once created,
345
+ # the destination blob is permanently associated with the source and may only be used for incremental copies. The Get Blob
346
+ # Properties and List Blobs APIs indicate whether the blob is an incremental copy blob created in this way. Incremental
347
+ # copy blobs may not be downloaded directly. The only supported operations are Get Blob Properties, Incremental Copy Blob,
348
+ # and Delete Blob. The copied snapshots may be read and deleted as usual.
349
+ #
350
+ # ==== Attributes
351
+ #
352
+ # * +destination_container+ - String. The destination container name to copy to.
353
+ # * +destination_blob+ - String. The destination blob name to copy to.
354
+ # * +source_uri+ - String. Specifies the URI of the source page blob snapshot.
355
+ # This value is a URL of up to 2 KB in length that specifies a page blob snapshot. The
356
+ # value should be URL-encoded as it would appear in a request URI. The source blob must
357
+ # either be public or must be authenticated via a shared access signature. Here is an
358
+ # example of a source blob URL:
359
+ # https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=<DateTime>
360
+ # * +options+ - Hash. Optional parameters.
361
+ #
362
+ # ==== Options
363
+ #
364
+ # Accepted key/value pairs in options parameter are:
365
+ # * +:metadata+ - Hash. Custom metadata values to store with the copy. If this parameter is not
366
+ # specified, the operation will copy the source blob metadata to the destination
367
+ # blob. If this parameter is specified, the destination blob is created with the
368
+ # specified metadata, and metadata is not copied from the source blob.
369
+ # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to copy the blob only if the
370
+ # destination blob has been modified since the specified date/time. If the destination blob
371
+ # has not been modified, the Blob service returns status code 412 (Precondition Failed).
372
+ # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to copy the blob only if the
373
+ # destination blob has not been modified since the specified date/time. If the destination
374
+ # blob has been modified, the Blob service returns status code 412 (Precondition Failed).
375
+ # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to copy the blob
376
+ # only if the specified ETag value matches the ETag value for an existing destination blob.
377
+ # If the ETag for the destination blob does not match the ETag specified for If-Match,
378
+ # the Blob service returns status code 412 (Precondition Failed).
379
+ # * +:if_none_match+ - String. An ETag value, or the wildcard character (*). Specify an ETag value for this
380
+ # conditional header to copy the blob only if the specified ETag value does not match the
381
+ # ETag value for the destination blob. Specify the wildcard character (*) to perform the
382
+ # operation only if the destination blob does not exist. If the specified condition isn't met,
383
+ # the Blob service returns status code 412 (Precondition Failed).
384
+ # * +:timeout+ - Integer. A timeout in seconds.
385
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
386
+ # in the analytics logs when storage analytics logging is enabled.
387
+ #
388
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/incremental-copy-blob
389
+ #
390
+ # Returns a tuple of (copy_id, copy_status).
391
+ #
392
+ # * +copy_id+ - String. String identifier for this copy operation. Use with Get Blob Properties to check
393
+ # the status of this copy operation, or pass to Abort Copy Blob to abort a pending copy.
394
+ # * +copy_status+ - String. State of the copy operation. This is always pending to indicate that the copy has
395
+ # started and is in progress.
396
+ #
397
+ def incremental_copy_blob(destination_container, destination_blob, source_uri, options = {})
398
+ # query parameters
399
+ query = { QueryStringConstants::COMP => QueryStringConstants::INCREMENTAL_COPY }
400
+ StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
401
+
402
+ # URI
403
+ uri = blob_uri(destination_container, destination_blob, query)
404
+
405
+ # headers
406
+ headers = StorageService.common_headers
407
+ StorageService.with_header headers, "x-ms-copy-source", source_uri
408
+ unless options.empty?
409
+ add_blob_conditional_headers options, headers
410
+ StorageService.add_metadata_to_headers options[:metadata], headers
411
+ end
412
+
413
+ response = call(:put, uri, nil, headers, options)
414
+ return response.headers["x-ms-copy-id"], response.headers["x-ms-copy-status"]
415
+ end
416
+
334
417
  # Public: Sets a page blob's sequence number.
335
418
  #
336
419
  # ==== Attributes
@@ -370,27 +453,27 @@ module Azure::Storage
370
453
  #
371
454
  # Accepted key/value pairs in options parameter are:
372
455
  # * +:timeout+ - Integer. A timeout in seconds.
373
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
456
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
374
457
  # in the analytics logs when storage analytics logging is enabled.
375
458
  # * +:if_modified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
376
- # only if the blob has been modified since the specified date/time. If the blob has not been modified,
459
+ # only if the blob has been modified since the specified date/time. If the blob has not been modified,
377
460
  # the Blob service returns status code 412 (Precondition Failed).
378
461
  # * +:if_unmodified_since+ - String. A DateTime value. Specify this conditional header to set the blob properties
379
- # only if the blob has not been modified since the specified date/time. If the blob has been modified,
462
+ # only if the blob has not been modified since the specified date/time. If the blob has been modified,
380
463
  # the Blob service returns status code 412 (Precondition Failed).
381
464
  # * +:if_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
382
- # only if the blob's ETag value matches the value specified. If the values do not match,
465
+ # only if the blob's ETag value matches the value specified. If the values do not match,
383
466
  # the Blob service returns status code 412 (Precondition Failed).
384
467
  # * +:if_none_match+ - String. An ETag value. Specify an ETag value for this conditional header to set the blob properties
385
- # only if the blob's ETag value does not match the value specified. If the values are identical,
468
+ # only if the blob's ETag value does not match the value specified. If the values are identical,
386
469
  # the Blob service returns status code 412 (Precondition Failed).
387
470
  #
388
471
  # See http://msdn.microsoft.com/en-us/library/azure/ee691966.aspx
389
472
  #
390
473
  # Returns nil on success.
391
- def set_sequence_number(container, blob, action, number, options={})
392
- options = { :sequence_number_action => action, :sequence_number => number }.merge(options)
474
+ def set_sequence_number(container, blob, action, number, options = {})
475
+ options = { sequence_number_action: action, sequence_number: number }.merge(options)
393
476
  set_blob_properties container, blob, options
394
477
  end
395
478
  end
396
- end
479
+ end