azure-storage-file2 2.0.8 → 2.0.9

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.
@@ -0,0 +1,377 @@
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/file/serialization"
27
+
28
+ module Azure::Storage::File
29
+ module Share
30
+ include Azure::Storage::Common::Service
31
+
32
+ class Share
33
+ def initialize
34
+ @properties = {}
35
+ @metadata = {}
36
+ yield self if block_given?
37
+ end
38
+
39
+ attr_accessor :name
40
+ attr_accessor :properties
41
+ attr_accessor :metadata
42
+ attr_accessor :quota
43
+ attr_accessor :usage
44
+ end
45
+
46
+ # Public: Create a new share
47
+ #
48
+ # ==== Attributes
49
+ #
50
+ # * +name+ - String. The name of the share.
51
+ # * +options+ - Hash. Optional parameters.
52
+ #
53
+ # ==== Options
54
+ #
55
+ # Accepted key/value pairs in options parameter are:
56
+ # * +:metadata+ - Hash. User defined metadata for the share (optional).
57
+ # * +:quota+ - Integer. The maximum size of the share, in gigabytes.
58
+ # Must be greater than 0, and less than or equal to 5TB (5120). (optional).
59
+ # * +:timeout+ - Integer. A timeout in seconds.
60
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
61
+ # in the analytics logs when storage analytics logging is enabled.
62
+ #
63
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/create-share
64
+ #
65
+ # Returns a Share
66
+ def create_share(name, options = {})
67
+ # Query
68
+ query = {}
69
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
70
+
71
+ # Scheme + path
72
+ uri = share_uri(name, query)
73
+
74
+ # Headers
75
+ headers = {}
76
+ StorageService.add_metadata_to_headers(options[:metadata], headers) if options[:metadata]
77
+ headers["x-ms-share-quota"] = options[:quota].to_s if options[:quota]
78
+
79
+ # Call
80
+ response = call(:put, uri, nil, headers, options)
81
+
82
+ # result
83
+ share = Serialization.share_from_headers(response.headers)
84
+ share.name = name
85
+ share.quota = options[:quota] if options[:quota]
86
+ share.metadata = options[:metadata] if options[:metadata]
87
+ share
88
+ end
89
+
90
+ # Public: Returns all properties and metadata on the share.
91
+ #
92
+ # ==== Attributes
93
+ #
94
+ # * +name+ - String. The name of the share
95
+ # * +options+ - Hash. Optional parameters.
96
+ #
97
+ # ==== Options
98
+ #
99
+ # Accepted key/value pairs in options parameter are:
100
+ # * +:timeout+ - Integer. A timeout in seconds.
101
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
102
+ # in the analytics logs when storage analytics logging is enabled.
103
+ # * +:location_mode+ - LocationMode. Specifies the location mode used to decide
104
+ # which location the request should be sent to.
105
+ #
106
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-properties
107
+ #
108
+ # Returns a Share
109
+ def get_share_properties(name, options = {})
110
+ # Query
111
+ query = {}
112
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
113
+
114
+ # Call
115
+ options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
116
+ response = call(:get, share_uri(name, query, options), nil, {}, options)
117
+
118
+ # result
119
+ share = Serialization.share_from_headers(response.headers)
120
+ share.name = name
121
+ share
122
+ end
123
+
124
+ # Public: Sets service-defined properties for the share.
125
+ #
126
+ # ==== Attributes
127
+ #
128
+ # * +name+ - String. The name of the share
129
+ # * +options+ - Hash. Optional parameters.
130
+ #
131
+ # ==== Options
132
+ #
133
+ # Accepted key/value pairs in options parameter are:
134
+ # * +:quota+ - Integer. The maximum size of the share, in gigabytes.
135
+ # Must be greater than 0, and less than or equal to 5TB (5120). (optional).
136
+ # * +:timeout+ - Integer. A timeout in seconds.
137
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
138
+ # in the analytics logs when storage analytics logging is enabled.
139
+ #
140
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-properties
141
+ #
142
+ # Returns nil on success
143
+ def set_share_properties(name, options = {})
144
+ # Query
145
+ query = { "comp" => "properties" }
146
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
147
+
148
+ # Headers
149
+ headers = {}
150
+ headers["x-ms-share-quota"] = options[:quota].to_s if options[:quota]
151
+
152
+ # Call
153
+ call(:put, share_uri(name, query), nil, headers, options)
154
+
155
+ # Result
156
+ nil
157
+ end
158
+
159
+ # Public: Returns only user-defined metadata for the specified share.
160
+ #
161
+ # ==== Attributes
162
+ #
163
+ # * +name+ - String. The name of the share
164
+ # * +options+ - Hash. Optional parameters.
165
+ #
166
+ # ==== Options
167
+ #
168
+ # Accepted key/value pairs in options parameter are:
169
+ # * +:timeout+ - Integer. A timeout in seconds.
170
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
171
+ # in the analytics logs when storage analytics logging is enabled.
172
+ # * +:location_mode+ - LocationMode. Specifies the location mode used to decide
173
+ # which location the request should be sent to.
174
+ #
175
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-metadata
176
+ #
177
+ # Returns a Share
178
+ def get_share_metadata(name, options = {})
179
+ # Query
180
+ query = { "comp" => "metadata" }
181
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
182
+
183
+ # Call
184
+ options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
185
+ response = call(:get, share_uri(name, query, options), nil, {}, options)
186
+
187
+ # result
188
+ share = Serialization.share_from_headers(response.headers)
189
+ share.name = name
190
+ share
191
+ end
192
+
193
+ # Public: Sets custom metadata for the share.
194
+ #
195
+ # ==== Attributes
196
+ #
197
+ # * +name+ - String. The name of the share
198
+ # * +metadata+ - Hash. A Hash of the metadata values
199
+ # * +options+ - Hash. Optional parameters.
200
+ #
201
+ # ==== Options
202
+ #
203
+ # Accepted key/value pairs in options parameter are:
204
+ # * +:timeout+ - Integer. A timeout in seconds.
205
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
206
+ # in the analytics logs when storage analytics logging is enabled.
207
+ #
208
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-metadata
209
+ #
210
+ # Returns nil on success
211
+ def set_share_metadata(name, metadata, options = {})
212
+ # Query
213
+ query = { "comp" => "metadata" }
214
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
215
+
216
+ # Headers
217
+ headers = {}
218
+ StorageService.add_metadata_to_headers(metadata, headers) if metadata
219
+
220
+ # Call
221
+ call(:put, share_uri(name, query), nil, headers, options)
222
+
223
+ # Result
224
+ nil
225
+ end
226
+
227
+ # Public: Deletes a share.
228
+ #
229
+ # ==== Attributes
230
+ #
231
+ # * +name+ - String. The name of the share.
232
+ # * +options+ - Hash. Optional parameters.
233
+ #
234
+ # ==== Options
235
+ #
236
+ # Accepted key/value pairs in options parameter are:
237
+ # * +:timeout+ - Integer. A timeout in seconds.
238
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
239
+ # in the analytics logs when storage analytics logging is enabled.
240
+ #
241
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-share
242
+ #
243
+ # Returns nil on success
244
+ def delete_share(name, options = {})
245
+ # Query
246
+ query = {}
247
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
248
+
249
+ # Call
250
+ call(:delete, share_uri(name, query), nil, {}, options)
251
+
252
+ # result
253
+ nil
254
+ end
255
+
256
+ # Public: Gets the information about stored access policies for the share.
257
+ #
258
+ # ==== Attributes
259
+ #
260
+ # * +name+ - String. The name of the share
261
+ # * +options+ - Hash. Optional parameters.
262
+ #
263
+ # ==== Options
264
+ #
265
+ # Accepted key/value pairs in options parameter are:
266
+ # * +:timeout+ - Integer. A timeout in seconds.
267
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
268
+ # in the analytics logs when storage analytics logging is enabled.
269
+ # * +:location_mode+ - LocationMode. Specifies the location mode used to decide
270
+ # which location the request should be sent to.
271
+ #
272
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-acl
273
+ #
274
+ # Returns a tuple of (share, signed_identifiers)
275
+ # share - A Azure::Storage::File::Share::Share instance
276
+ # signed_identifiers - A list of Azure::Storage::Service::SignedIdentifier instances
277
+ #
278
+ def get_share_acl(name, options = {})
279
+ # Query
280
+ query = { "comp" => "acl" }
281
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
282
+
283
+ # Call
284
+ options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
285
+ response = call(:get, share_uri(name, query, options), nil, {}, options)
286
+
287
+ # Result
288
+ share = Serialization.share_from_headers(response.headers)
289
+ share.name = name
290
+
291
+ signed_identifiers = nil
292
+ signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0
293
+
294
+ return share, signed_identifiers
295
+ end
296
+
297
+ # Public: Sets stored access policies the share.
298
+ #
299
+ # ==== Attributes
300
+ #
301
+ # * +name+ - String. The name of the share
302
+ # * +options+ - Hash. Optional parameters.
303
+ #
304
+ # ==== Options
305
+ #
306
+ # Accepted key/value pairs in options parameter are:
307
+ # * +:signed_identifiers+ - Array. A list of Azure::Storage::Service::SignedIdentifier instances.
308
+ # * +:timeout+ - Integer. A timeout in seconds.
309
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
310
+ # in the analytics logs when storage analytics logging is enabled.
311
+ #
312
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-acl
313
+ #
314
+ # Returns a tuple of (share, signed_identifiers)
315
+ # * +share+ - A Azure::Storage::File::Share::Share instance
316
+ # * +signed_identifiers+ - A list of Azure::Storage::Service::SignedIdentifier instances
317
+ #
318
+ def set_share_acl(name, options = {})
319
+ # Query
320
+ query = { "comp" => "acl" }
321
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
322
+
323
+ # Scheme + path
324
+ uri = share_uri(name, query)
325
+
326
+ # Headers + body
327
+ headers = {}
328
+
329
+ signed_identifiers = options[:signed_identifiers] ? options[:signed_identifiers] : nil
330
+ body = signed_identifiers ? Serialization.signed_identifiers_to_xml(signed_identifiers) : nil
331
+
332
+ # Call
333
+ response = call(:put, uri, body, headers, options)
334
+
335
+ # Result
336
+ share = Serialization.share_from_headers(response.headers)
337
+ share.name = name
338
+
339
+ return share, signed_identifiers || []
340
+ end
341
+
342
+ # Public: Retrieves statistics related to the share.
343
+ #
344
+ # ==== Attributes
345
+ #
346
+ # * +name+ - String. The name of the share
347
+ # * +options+ - Hash. Optional parameters.
348
+ #
349
+ # ==== Options
350
+ #
351
+ # Accepted key/value pairs in options parameter are:
352
+ # * +:timeout+ - Integer. A timeout in seconds.
353
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
354
+ # in the analytics logs when storage analytics logging is enabled.
355
+ # * +:location_mode+ - LocationMode. Specifies the location mode used to decide
356
+ # which location the request should be sent to.
357
+ #
358
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-stats
359
+ #
360
+ # Returns a Share
361
+ def get_share_stats(name, options = {})
362
+ # Query
363
+ query = { "comp" => "stats" }
364
+ query["timeout"] = options[:timeout].to_s if options[:timeout]
365
+
366
+ # Call
367
+ options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
368
+ response = call(:get, share_uri(name, query, options), nil, {}, options)
369
+
370
+ # result
371
+ share = Serialization.share_from_headers(response.headers)
372
+ share.name = name
373
+ share.usage = Serialization.share_stats_from_xml(response.body)
374
+ share
375
+ end
376
+ end
377
+ 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 File
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 = 9 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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-storage-file2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
@@ -155,6 +155,14 @@ extensions: []
155
155
  extra_rdoc_files: []
156
156
  files:
157
157
  - "./lib/azure/storage/file.rb"
158
+ - lib/azure/storage/file/autoload.rb
159
+ - lib/azure/storage/file/default.rb
160
+ - lib/azure/storage/file/directory.rb
161
+ - lib/azure/storage/file/file.rb
162
+ - lib/azure/storage/file/file_service.rb
163
+ - lib/azure/storage/file/serialization.rb
164
+ - lib/azure/storage/file/share.rb
165
+ - lib/azure/storage/file/version.rb
158
166
  homepage: http://github.com/azure/azure-storage-ruby
159
167
  licenses:
160
168
  - MIT
@@ -174,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
182
  - !ruby/object:Gem::Version
175
183
  version: '0'
176
184
  requirements: []
177
- rubygems_version: 3.1.4
185
+ rubygems_version: 3.3.7
178
186
  signing_key:
179
187
  specification_version: 4
180
188
  summary: Official Ruby client library to consume Azure Storage File service