Module: Azure::Storage::File::Share

Includes:
Common::Service
Included in:
FileService
Defined in:
file/lib/azure/storage/file/share.rb

Defined Under Namespace

Classes: Share

Instance Method Summary collapse

Instance Method Details

#create_share(name, options = {}) ⇒ Object

Public: Create a new share

Attributes

  • name - String. The name of the share.

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :metadata - Hash. User defined metadata for the share (optional).

  • :quota - Integer. The maximum size of the share, in gigabytes.

    Must be greater than 0, and less than or equal to 5TB (5120). (optional).
  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/create-share

Returns a Share



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'file/lib/azure/storage/file/share.rb', line 66

def create_share(name, options = {})
  # Query
  query = {}
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Scheme + path
  uri = share_uri(name, query)

  # Headers
  headers = {}
  StorageService.(options[:metadata], headers) if options[:metadata]
  headers["x-ms-share-quota"] = options[:quota].to_s if options[:quota]

  # Call
  response = call(:put, uri, nil, headers, options)

  # result
  share = Serialization.share_from_headers(response.headers)
  share.name = name
  share.quota = options[:quota] if options[:quota]
  share. = options[:metadata] if options[:metadata]
  share
end

#delete_share(name, options = {}) ⇒ Object

Public: Deletes a share.

Attributes

  • name - String. The name of the share.

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-share

Returns nil on success



244
245
246
247
248
249
250
251
252
253
254
# File 'file/lib/azure/storage/file/share.rb', line 244

def delete_share(name, options = {})
  # Query
  query = {}
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Call
  call(:delete, share_uri(name, query), nil, {}, options)

  # result
  nil
end

#get_share_acl(name, options = {}) ⇒ Object

Public: Gets the information about stored access policies for the share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.
  • :location_mode - LocationMode. Specifies the location mode used to decide

    which location the request should be sent to.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-acl

Returns a tuple of (share, signed_identifiers)

share                       - A Azure::Storage::File::Share::Share instance
signed_identifiers          - A list of Azure::Storage::Service::SignedIdentifier instances


278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'file/lib/azure/storage/file/share.rb', line 278

def get_share_acl(name, options = {})
  # Query
  query = { "comp" => "acl" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Call
  options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
  response = call(:get, share_uri(name, query, options), nil, {}, options)

  # Result
  share = Serialization.share_from_headers(response.headers)
  share.name = name

  signed_identifiers = nil
  signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0

  return share, signed_identifiers
end

#get_share_metadata(name, options = {}) ⇒ Object

Public: Returns only user-defined metadata for the specified share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.
  • :location_mode - LocationMode. Specifies the location mode used to decide

    which location the request should be sent to.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-metadata

Returns a Share



178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'file/lib/azure/storage/file/share.rb', line 178

def (name, options = {})
  # Query
  query = { "comp" => "metadata" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Call
  options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
  response = call(:get, share_uri(name, query, options), nil, {}, options)

  # result
  share = Serialization.share_from_headers(response.headers)
  share.name = name
  share
end

#get_share_properties(name, options = {}) ⇒ Object

Public: Returns all properties and metadata on the share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.
  • :location_mode - LocationMode. Specifies the location mode used to decide

    which location the request should be sent to.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-properties

Returns a Share



109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'file/lib/azure/storage/file/share.rb', line 109

def get_share_properties(name, options = {})
  # Query
  query = {}
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Call
  options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
  response = call(:get, share_uri(name, query, options), nil, {}, options)

  # result
  share = Serialization.share_from_headers(response.headers)
  share.name = name
  share
end

#get_share_stats(name, options = {}) ⇒ Object

Public: Retrieves statistics related to the share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.
  • :location_mode - LocationMode. Specifies the location mode used to decide

    which location the request should be sent to.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-share-stats

Returns a Share



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'file/lib/azure/storage/file/share.rb', line 361

def get_share_stats(name, options = {})
  # Query
  query = { "comp" => "stats" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Call
  options[:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY
  response = call(:get, share_uri(name, query, options), nil, {}, options)

  # result
  share = Serialization.share_from_headers(response.headers)
  share.name = name
  share.usage = Serialization.share_stats_from_xml(response.body)
  share
end

#set_share_acl(name, options = {}) ⇒ Object

Public: Sets stored access policies the share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :signed_identifiers - Array. A list of Azure::Storage::Service::SignedIdentifier instances.

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-acl

Returns a tuple of (share, signed_identifiers)

  • share - A Azure::Storage::File::Share::Share instance

  • signed_identifiers - A list of Azure::Storage::Service::SignedIdentifier instances



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'file/lib/azure/storage/file/share.rb', line 318

def set_share_acl(name, options = {})
  # Query
  query = { "comp" => "acl" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Scheme + path
  uri = share_uri(name, query)

  # Headers + body
  headers = {}

  signed_identifiers = options[:signed_identifiers] ? options[:signed_identifiers] : nil
  body = signed_identifiers ? Serialization.signed_identifiers_to_xml(signed_identifiers) : nil

  # Call
  response = call(:put, uri, body, headers, options)

  # Result
  share = Serialization.share_from_headers(response.headers)
  share.name = name

  return share, signed_identifiers || []
end

#set_share_metadata(name, metadata, options = {}) ⇒ Object

Public: Sets custom metadata for the share.

Attributes

  • name - String. The name of the share

  • metadata - Hash. A Hash of the metadata values

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-metadata

Returns nil on success



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'file/lib/azure/storage/file/share.rb', line 211

def (name, , options = {})
  # Query
  query = { "comp" => "metadata" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Headers
  headers = {}
  StorageService.(, headers) if 

  # Call
  call(:put, share_uri(name, query), nil, headers, options)

  # Result
  nil
end

#set_share_properties(name, options = {}) ⇒ Object

Public: Sets service-defined properties for the share.

Attributes

  • name - String. The name of the share

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :quota - Integer. The maximum size of the share, in gigabytes.

    Must be greater than 0, and less than or equal to 5TB (5120). (optional).
  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.

See docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-share-properties

Returns nil on success



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'file/lib/azure/storage/file/share.rb', line 143

def set_share_properties(name, options = {})
  # Query
  query = { "comp" => "properties" }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  # Headers
  headers = {}
  headers["x-ms-share-quota"] = options[:quota].to_s if options[:quota]

  # Call
  call(:put, share_uri(name, query), nil, headers, options)

  # Result
  nil
end