azure-storage 0.11.5.preview → 0.12.0.preview

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c064d9e707d08b6efa5c7c83f96e6cb8a5ddc6
4
- data.tar.gz: 5cc39f4003ae67bbb655fe8d30a5701d2404b736
3
+ metadata.gz: c54fd3d9800024a29cf5d43c6f867cb79f3ed46b
4
+ data.tar.gz: b8bab282f10b6c63768c992b3a6fa92b5e33f43b
5
5
  SHA512:
6
- metadata.gz: 0359aaaeca2ae969a7ec5ffd68a281fb679fe952bf12fcbdda6e1a9086b2221a8e6c33853e8c0f8df170b6906fc748b21f86011a20c4ed4280baea3b07dd5393
7
- data.tar.gz: a19f2f613d09b8da5305c0fc9d46395929be89d8640978af4123f1934147cae34fb6e5cbd230e20109e9eff7de041246c21699a28fcf944c4b289ba8b2c4f0a5
6
+ metadata.gz: 67212a5088a580dbb94f238ae3c3874fc56d49d7a664235f84eb96668a6061954175c2b8e0587a981cf3152fe02494f0c62bb6c74816faa5f8474ff2b628e83e
7
+ data.tar.gz: fa00cd1a38a04932c63ea34ef7c6599f1c100c1f726eb4bcfbba944aac19c4d3a89c09d81bdea7b265d6eb07a079c627e28bd4159098894d8b53da7334e0e3b1
@@ -65,5 +65,13 @@ module Azure
65
65
  autoload :Query, 'azure/storage/table/query'
66
66
  end
67
67
 
68
+ module File
69
+ autoload :FileService, 'azure/storage/file/file_service'
70
+ autoload :Share, 'azure/storage/file/share'
71
+ autoload :Directory, 'azure/storage/file/directory'
72
+ autoload :File, 'azure/storage/file/file'
73
+ autoload :Serialization, 'azure/storage/file/serialization'
74
+ end
75
+
68
76
  end
69
77
  end
@@ -96,6 +96,7 @@ module Azure::Storage
96
96
 
97
97
  result = Serialization.blob_from_headers(response.headers)
98
98
  result.name = blob
99
+ result.metadata = options[:metadata] if options[:metadata]
99
100
 
100
101
  result
101
102
  end
@@ -125,7 +125,7 @@ module Azure::Storage
125
125
  #
126
126
  # See http://msdn.microsoft.com/en-us/library/azure/dd179394.aspx
127
127
  #
128
- # Returns the blob properties
128
+ # Returns the blob properties with a Blob instance
129
129
  def get_blob_properties(container, blob, options={})
130
130
  query = { }
131
131
  StorageService.with_query query, 'snapshot', options[:snapshot]
@@ -620,13 +620,13 @@ module Azure::Storage
620
620
  response.headers['x-ms-snapshot']
621
621
  end
622
622
 
623
- # Public: Copies a source blob to a destination blob.
623
+ # Public: Copies a source blob or file to a destination blob.
624
624
  #
625
625
  # ==== Attributes
626
626
  #
627
- # * +source_container+ - String. The destination container name to copy to.
628
- # * +source_blob+ - String. The destination blob name to copy to.
629
- # * +source_blob_uri+ - String. The source blob URI to copy from.
627
+ # * +destination_container+ - String. The destination container name to copy to.
628
+ # * +destination_blob+ - String. The destination blob name to copy to.
629
+ # * +source_uri+ - String. The source blob or file URI to copy from.
630
630
  # * +options+ - Hash. Optional parameters.
631
631
  #
632
632
  # ==== Options
@@ -675,13 +675,13 @@ module Azure::Storage
675
675
  # "success" - The copy completed successfully.
676
676
  # "pending" - The copy is in progress.
677
677
  #
678
- def copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options={})
678
+ def copy_blob_from_uri(destination_container, destination_blob, source_uri, options={})
679
679
  query = { }
680
680
  StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
681
681
 
682
682
  uri = blob_uri(destination_container, destination_blob, query)
683
683
  headers = StorageService.common_headers
684
- StorageService.with_header headers, 'x-ms-copy-source', source_blob_uri
684
+ StorageService.with_header headers, 'x-ms-copy-source', source_uri
685
685
 
686
686
  unless options.empty?
687
687
  add_blob_conditional_headers options, headers
@@ -696,8 +696,8 @@ module Azure::Storage
696
696
  #
697
697
  # ==== Attributes
698
698
  #
699
- # * +source_container+ - String. The destination container name to copy to.
700
- # * +source_blob+ - String. The destination blob name to copy to.
699
+ # * +destination_container+ - String. The destination container name to copy to.
700
+ # * +destination_blob+ - String. The destination blob name to copy to.
701
701
  # * +source_container+ - String. The source container name to copy from.
702
702
  # * +source_blob+ - String. The source blob name to copy from.
703
703
  # * +options+ - Hash. Optional parameters.
@@ -40,7 +40,7 @@ module Azure::Storage
40
40
 
41
41
  def initialize(options = {}, &block)
42
42
  client_config = options[:client] || Azure::Storage
43
- signer = options[:signer] || Azure::Storage::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
43
+ signer = options[:signer] || client_config.signer || Azure::Storage::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
44
44
  super(signer, client_config.storage_account_name, options, &block)
45
45
  @host = client.storage_blob_host
46
46
  end
@@ -469,19 +469,9 @@ module Azure::Storage
469
469
  if container_name.nil? || container_name.empty?
470
470
  path = blob_name
471
471
  else
472
- path = File.join(container_name, blob_name)
472
+ path = ::File.join(container_name, blob_name)
473
473
  end
474
-
475
- path = CGI.escape(path.encode('UTF-8'))
476
-
477
- # Unencode the forward slashes to match what the server expects.
478
- path = path.gsub(/%2F/, '/')
479
- # Unencode the backward slashes to match what the server expects.
480
- path = path.gsub(/%5C/, '/')
481
- # Re-encode the spaces (encoded as space) to the % encoding.
482
- path = path.gsub(/\+/, '%20')
483
-
484
- generate_uri(path, query)
474
+ generate_uri(path, query, true)
485
475
  end
486
476
 
487
477
  # Adds conditional header with required condition
@@ -115,6 +115,7 @@ module Azure::Storage
115
115
 
116
116
  result = Serialization.blob_from_headers(response.headers)
117
117
  result.name = blob
118
+ result.metadata = options[:metadata] if options[:metadata]
118
119
 
119
120
  result
120
121
  end
@@ -106,7 +106,8 @@ module Azure::Storage
106
106
 
107
107
  result = Serialization.blob_from_headers(response.headers)
108
108
  result.name = blob
109
-
109
+ result.metadata = options[:metadata] if options[:metadata]
110
+
110
111
  result
111
112
  end
112
113
 
@@ -118,12 +119,14 @@ module Azure::Storage
118
119
  # * +blob+ - String. Name of blob
119
120
  # * +start_range+ - Integer. Position of first byte of first page
120
121
  # * +end_range+ - Integer. Position of last byte of of last page
121
- # * +content+ - IO or String. Content to write. Length in bytes should equal end_range - start_range
122
+ # * +content+ - IO or String. Content to write. Length in bytes should equal end_range - start_range + 1
122
123
  # * +options+ - Hash. A collection of options.
123
124
  #
124
125
  # ==== Options
125
126
  #
126
127
  # Accepted key/value pairs in options parameter are:
128
+ # * +:transactional_md5+ - String. An MD5 hash of the page content. This hash is used to verify the integrity of the page during transport.
129
+ # When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
127
130
  # * +:if_sequence_number_le+ - Integer. If the blob's sequence number is less than or equal to the specified value, the request proceeds;
128
131
  # otherwise it fails with the SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
129
132
  # * +:if_sequence_number_lt+ - Integer. If the blob's sequence number is less than the specified value, the request proceeds;
@@ -155,6 +158,7 @@ module Azure::Storage
155
158
 
156
159
  uri = blob_uri(container, blob, query)
157
160
  headers = StorageService.common_headers
161
+ StorageService.with_header headers, 'Content-MD5', options[:transactional_md5]
158
162
  StorageService.with_header headers, 'x-ms-range', "bytes=#{start_range}-#{end_range}"
159
163
  StorageService.with_header headers, 'x-ms-page-write', 'update'
160
164
 
@@ -31,6 +31,7 @@ require 'azure/storage/service/storage_service'
31
31
  require 'azure/storage/blob/blob_service'
32
32
  require 'azure/storage/table/table_service'
33
33
  require 'azure/storage/queue/queue_service'
34
+ require 'azure/storage/file/file_service'
34
35
 
35
36
  module Azure::Storage
36
37
  class Client
@@ -50,6 +51,7 @@ module Azure::Storage
50
51
  #
51
52
  # * +:use_development_storage+ - True. Whether to use storage emulator.
52
53
  # * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
54
+ # * +:storage_connection_string+ - String. The storage connection string.
53
55
  # * +:storage_account_name+ - String. The name of the storage account.
54
56
  # * +:storage_access_key+ - Base64 String. The access key of the storage account.
55
57
  # * +:storage_sas_token+ - String. The signed access signiture for the storage account or one of its service.
@@ -79,14 +81,9 @@ module Azure::Storage
79
81
  #
80
82
  # @return [Azure::Storage::Client]
81
83
  def initialize(options = {}, &block)
82
- if options.is_a?(Hash)
83
- options = setup_options if options.length == 0
84
- options = parse_connection_string(options[:storage_connection_string]) if options[:storage_connection_string]
85
-
86
- if options.has_key?(:user_agent_prefix)
87
- Azure::Storage::Service::StorageService.user_agent_prefix = options[:user_agent_prefix]
88
- options.delete :user_agent_prefix
89
- end
84
+ if options.is_a?(Hash) and options.has_key?(:user_agent_prefix)
85
+ Azure::Storage::Service::StorageService.user_agent_prefix = options[:user_agent_prefix]
86
+ options.delete :user_agent_prefix
90
87
  end
91
88
  Azure::Storage::Service::StorageService.register_request_callback &block if block_given?
92
89
  reset!(options)
@@ -110,6 +107,12 @@ module Azure::Storage
110
107
  @table_client ||= Azure::Storage::Table::TableService.new(default_client(options))
111
108
  end
112
109
 
110
+ # Azure File service client configured from this Azure Storage client instance
111
+ # @return [Azure::Storage::File::FileService]
112
+ def file_client(options = {})
113
+ @file_client ||= Azure::Storage::File::FileService.new(default_client(options))
114
+ end
115
+
113
116
  class << self
114
117
  # Public: Creates an instance of [Azure::Storage::Client]
115
118
  #
@@ -34,7 +34,7 @@ module Azure::Storage
34
34
  #
35
35
  # ==== Attributes
36
36
  #
37
- # * +options+ - Hash. Optional parameters.
37
+ # * +options+ - Hash | String. Optional parameters or storage connection string.
38
38
  #
39
39
  # ==== Options
40
40
  #
@@ -42,6 +42,7 @@ module Azure::Storage
42
42
  #
43
43
  # * +:use_development_storage+ - TrueClass. Whether to use storage emulator.
44
44
  # * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
45
+ # * +:storage_connection_string+ - String. The storage connection string.
45
46
  # * +:storage_account_name+ - String. The name of the storage account.
46
47
  # * +:storage_access_key+ - Base64 String. The access key of the storage account.
47
48
  # * +:storage_sas_token+ - String. The signed access signiture for the storage account or one of its service.
@@ -71,9 +72,16 @@ module Azure::Storage
71
72
  def reset!(options = {})
72
73
  if options.is_a? String
73
74
  options = parse_connection_string(options)
75
+ elsif options.is_a? Hash
76
+ # When the options are provided via singlton setup: Azure::Storage.setup()
77
+ options = setup_options if options.length == 0
78
+
79
+ options = parse_connection_string(options[:storage_connection_string]) if options[:storage_connection_string]
74
80
  end
75
-
81
+
82
+ # Load from environment when no valid input
76
83
  options = load_env if options.length == 0
84
+
77
85
  @ca_file = options.delete(:ca_file)
78
86
  @options = filter(options)
79
87
  self.send(:reset_config!, @options) if self.respond_to?(:reset_config!)
@@ -58,7 +58,10 @@ module Azure::Storage
58
58
 
59
59
  attr_writer :storage_table_host,
60
60
  :storage_blob_host,
61
- :storage_queue_host
61
+ :storage_queue_host,
62
+ :storage_file_host
63
+
64
+ attr_reader :signer
62
65
 
63
66
  class << self
64
67
  # List of configurable keys for {Azure::Client}
@@ -71,7 +74,8 @@ module Azure::Storage
71
74
  :storage_sas_token,
72
75
  :storage_table_host,
73
76
  :storage_blob_host,
74
- :storage_queue_host
77
+ :storage_queue_host,
78
+ :storage_file_host
75
79
  ]
76
80
  end
77
81
  end
@@ -81,6 +85,10 @@ module Azure::Storage
81
85
  yield self
82
86
  end
83
87
 
88
+ def config
89
+ self
90
+ end
91
+
84
92
  # Reset configuration options to default values
85
93
  def reset_config!(options = {})
86
94
  Azure::Storage::Configurable.keys.each do |key|
@@ -92,6 +100,7 @@ module Azure::Storage
92
100
  instance_variable_set(:"@#{key}", options.fetch(key, value))
93
101
  end
94
102
  self.send(:reset_agents!) if self.respond_to?(:reset_agents!)
103
+ setup_signer_for_service
95
104
  self
96
105
  end
97
106
 
@@ -121,10 +130,6 @@ module Azure::Storage
121
130
  @storage_file_host || default_host(:file)
122
131
  end
123
132
 
124
- def config
125
- self
126
- end
127
-
128
133
  private
129
134
 
130
135
  def default_host(service)
@@ -139,5 +144,36 @@ module Azure::Storage
139
144
  opts
140
145
  end
141
146
 
147
+ def account_name_from_endpoint endpoint
148
+ return nil if endpoint.nil?
149
+ uri = URI::parse endpoint
150
+ fields = uri.host.split '.'
151
+ fields[0]
152
+ end
153
+
154
+ def determine_account_name
155
+ if instance_variable_get(:@storage_account_name).nil?
156
+ hosts = [@storage_blob_host, @storage_table_host, @storage_queue_host, @storage_file_host]
157
+ account_name = nil;
158
+ hosts.each do |host|
159
+ parsed = account_name_from_endpoint host
160
+ if account_name.nil?
161
+ account_name = parsed
162
+ elsif !account_name.nil? and !parsed.nil? and (account_name <=> parsed) != 0
163
+ raise InvalidOptionsError, "Ambiguous account name in service hosts."
164
+ end
165
+ end
166
+ raise InvalidOptionsError, "Cannot identify account name." if account_name.nil?
167
+ @storage_account_name = account_name
168
+ end
169
+ end
170
+
171
+ def setup_signer_for_service
172
+ if @storage_sas_token
173
+ determine_account_name
174
+ @signer = Azure::Storage::Core::Auth::SharedAccessSignatureSigner.new @storage_account_name, @storage_sas_token
175
+ end
176
+ end
177
+
142
178
  end
143
179
  end
@@ -83,6 +83,15 @@ module Azure::Storage::Core
83
83
  endrk: :erk
84
84
  }
85
85
 
86
+ FILE_KEY_MAPPINGS = {
87
+ resource: :sr,
88
+ cache_control: :rscc,
89
+ content_disposition: :rscd,
90
+ content_encoding: :rsce,
91
+ content_language: :rscl,
92
+ content_type: :rsct
93
+ }
94
+
86
95
  SERVICE_OPTIONAL_QUERY_PARAMS = [:sp, :si, :sip, :spr, :rscc, :rscd, :rsce, :rscl, :rsct, :spk, :srk, :epk, :erk]
87
96
 
88
97
  ACCOUNT_OPTIONAL_QUERY_PARAMS = [:st, :sip, :spr]
@@ -151,6 +160,13 @@ module Azure::Storage::Core
151
160
  elsif service_type == Azure::Storage::ServiceType::TABLE
152
161
  options.merge!(table_name: path)
153
162
  valid_mappings.merge!(TABLE_KEY_MAPPINGS)
163
+ elsif service_type == Azure::Storage::ServiceType::FILE
164
+ if options[:resource]
165
+ options.merge!(resource: options[:resource])
166
+ else
167
+ options.merge!(resource: 'f')
168
+ end
169
+ valid_mappings.merge!(FILE_KEY_MAPPINGS)
154
170
  end
155
171
 
156
172
  invalid_options = options.reject { |k, _| valid_mappings.key?(k) }
@@ -188,7 +204,7 @@ module Azure::Storage::Core
188
204
  options[:content_encoding],
189
205
  options[:content_language],
190
206
  options[:content_type]
191
- ] if service_type == Azure::Storage::ServiceType::BLOB
207
+ ] if service_type == Azure::Storage::ServiceType::BLOB || service_type == Azure::Storage::ServiceType::FILE
192
208
 
193
209
  signable_fields.concat [
194
210
  options[:startpk],
@@ -42,13 +42,21 @@ module Azure::Storage::Core::Filter
42
42
  # response - HttpResponse. The response from the active request
43
43
  # retry_data - Hash. Stores stateful retry data
44
44
  def should_retry?(response, retry_data)
45
+ # Applies the logic when there is subclass overrides it
45
46
  apply_retry_policy retry_data
46
- retry_data[:retryable] = retry_data[:count] <= @retry_count
47
+
48
+ # Checks the result and count limit
49
+ if retry_data[:retryable].nil?
50
+ retry_data[:retryable] = true
51
+ else
52
+ retry_data[:retryable] &&= retry_data[:count] <= @retry_count
53
+ end
47
54
  return false unless retry_data[:retryable]
48
-
55
+
56
+ # Checks whether there is a local error
57
+ # Cannot retry immediately when it returns true, as it need check other errors
49
58
  should_retry_on_local_error? retry_data
50
- should_retry_on_error? response, retry_data
51
- return false unless retry_data[:retryable]
59
+ return false unless should_retry_on_error? response, retry_data
52
60
 
53
61
  adjust_retry_parameter retry_data
54
62
  end
@@ -167,6 +175,7 @@ module Azure::Storage::Core::Filter
167
175
  retry_data[:retryable] = false;
168
176
  end
169
177
  end
178
+ retry_data[:retryable]
170
179
  end
171
180
 
172
181
  # Adjust the retry parameter
@@ -0,0 +1,268 @@
1
+ #-------------------------------------------------------------------------
2
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
3
+ #
4
+ # The MIT License(MIT)
5
+
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files(the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions :
12
+
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ #--------------------------------------------------------------------------
24
+ require 'azure/storage/file/serialization'
25
+
26
+ module Azure::Storage::File
27
+ module Directory
28
+ include Azure::Storage::Service
29
+
30
+ class Directory
31
+ def initialize
32
+ @properties = {}
33
+ @metadata = {}
34
+ yield self if block_given?
35
+ end
36
+
37
+ attr_accessor :name
38
+ attr_accessor :properties
39
+ attr_accessor :metadata
40
+ end
41
+ end
42
+
43
+ # Public: Get a list of files or directories under the specified share or directory.
44
+ # It lists the contents only for a single level of the directory hierarchy.
45
+ #
46
+ # ==== Attributes
47
+ #
48
+ # * +share+ - String. The name of the file share.
49
+ # * +directory_path+ - String. The path to the directory.
50
+ # * +options+ - Hash. Optional parameters.
51
+ #
52
+ # ==== Options
53
+ #
54
+ # Accepted key/value pairs in options parameter are:
55
+ #
56
+ # * +:marker+ - String. An identifier the specifies the portion of the
57
+ # list to be returned. This value comes from the property
58
+ # Azure::Service::EnumerationResults.continuation_token when there
59
+ # are more shares available than were returned. The
60
+ # marker value may then be used here to request the next set
61
+ # of list items. (optional)
62
+ #
63
+ # * +:max_results+ - Integer. Specifies the maximum number of shares to return.
64
+ # If max_results is not specified, or is a value greater than
65
+ # 5,000, the server will return up to 5,000 items. If it is set
66
+ # to a value less than or equal to zero, the server will return
67
+ # status code 400 (Bad Request). (optional)
68
+ #
69
+ # * +:timeout+ - Integer. A timeout in seconds.
70
+ #
71
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
72
+ # in the analytics logs when storage analytics logging is enabled.
73
+ #
74
+ # See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-directories-and-files
75
+ #
76
+ # Returns an Azure::Service::EnumerationResults
77
+ #
78
+ def list_directories_and_files(share, directory_path, options={})
79
+ query = {'comp' => 'list'}
80
+ unless options.nil?
81
+ StorageService.with_query query, 'marker', options[:marker]
82
+ StorageService.with_query query, 'maxresults', options[:max_results].to_s if options[:max_results]
83
+ StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]
84
+ end
85
+
86
+ uri = directory_uri(share, directory_path, query)
87
+ response = call(:get, uri, nil, {}, options)
88
+
89
+ # Result
90
+ if response.success?
91
+ Serialization.directories_and_files_enumeration_results_from_xml(response.body)
92
+ else
93
+ response.exception
94
+ end
95
+ end
96
+
97
+ # Public: Create a new directory
98
+ #
99
+ # ==== Attributes
100
+ #
101
+ # * +share+ - String. The name of the file share.
102
+ # * +directory_path+ - String. The path to the directory.
103
+ # * +options+ - Hash. Optional parameters.
104
+ #
105
+ # ==== Options
106
+ #
107
+ # Accepted key/value pairs in options parameter are:
108
+ # * +:metadata+ - Hash. User defined metadata for the share (optional).
109
+ # * +:timeout+ - Integer. A timeout in seconds.
110
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
111
+ # in the analytics logs when storage analytics logging is enabled.
112
+ #
113
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/create-directory
114
+ #
115
+ # Returns a Directory
116
+ def create_directory(share, directory_path, options={})
117
+ # Query
118
+ query = { }
119
+ query['timeout'] = options[:timeout].to_s if options[:timeout]
120
+
121
+ # Scheme + path
122
+ uri = directory_uri(share, directory_path, query)
123
+
124
+ # Headers
125
+ headers = StorageService.common_headers
126
+ StorageService.add_metadata_to_headers(options[:metadata], headers) if options[:metadata]
127
+
128
+ # Call
129
+ response = call(:put, uri, nil, headers, options)
130
+
131
+ # result
132
+ directory = Serialization.directory_from_headers(response.headers)
133
+ directory.name = directory_path
134
+ directory.metadata = options[:metadata] if options[:metadata]
135
+ directory
136
+ end
137
+
138
+ # Public: Returns all system properties for the specified directory,
139
+ # and can also be used to check the existence of a directory.
140
+ # The data returned does not include the files in the directory or any subdirectories.
141
+ #
142
+ # ==== Attributes
143
+ #
144
+ # * +share+ - String. The name of the file share.
145
+ # * +directory_path+ - String. The path to the directory.
146
+ # * +options+ - Hash. Optional parameters.
147
+ #
148
+ # ==== Options
149
+ #
150
+ # Accepted key/value pairs in options parameter are:
151
+ # * +:timeout+ - Integer. A timeout in seconds.
152
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
153
+ # in the analytics logs when storage analytics logging is enabled.
154
+ #
155
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-directory-properties
156
+ #
157
+ # Returns a Directory
158
+ def get_directory_properties(share, directory_path, options={})
159
+ # Query
160
+ query = { }
161
+ query['timeout'] = options[:timeout].to_s if options[:timeout]
162
+
163
+ # Call
164
+ response = call(:get, directory_uri(share, directory_path, query), nil, {}, options)
165
+
166
+ # result
167
+ directory = Serialization.directory_from_headers(response.headers)
168
+ directory.name = directory_path
169
+ directory
170
+ end
171
+
172
+ # Public: Deletes a directory.
173
+ #
174
+ # ==== Attributes
175
+ #
176
+ # * +share+ - String. The name of the file share.
177
+ # * +directory_path+ - String. The path to the directory.
178
+ # * +options+ - Hash. Optional parameters.
179
+ #
180
+ # ==== Options
181
+ #
182
+ # Accepted key/value pairs in options parameter are:
183
+ # * +:timeout+ - Integer. A timeout in seconds.
184
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
185
+ # in the analytics logs when storage analytics logging is enabled.
186
+ #
187
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-directory
188
+ #
189
+ # Returns nil on success
190
+ def delete_directory(share, directory_path, options={})
191
+ # Query
192
+ query = { }
193
+ query['timeout'] = options[:timeout].to_s if options[:timeout]
194
+
195
+ # Call
196
+ call(:delete, directory_uri(share, directory_path, query), nil, {}, options)
197
+
198
+ # result
199
+ nil
200
+ end
201
+
202
+ # Public: Returns only user-defined metadata for the specified directory.
203
+ #
204
+ # ==== Attributes
205
+ #
206
+ # * +share+ - String. The name of the file share.
207
+ # * +directory_path+ - String. The path to the directory.
208
+ # * +options+ - Hash. Optional parameters.
209
+ #
210
+ # ==== Options
211
+ #
212
+ # Accepted key/value pairs in options parameter are:
213
+ # * +:timeout+ - Integer. A timeout in seconds.
214
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
215
+ # in the analytics logs when storage analytics logging is enabled.
216
+ #
217
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-directory-metadata
218
+ #
219
+ # Returns a Directory
220
+ def get_directory_metadata(share, directory_path, options={})
221
+ # Query
222
+ query = { 'comp' => 'metadata' }
223
+ query['timeout'] = options[:timeout].to_s if options[:timeout]
224
+
225
+ # Call
226
+ response = call(:get, directory_uri(share, directory_path, query), nil, {}, options)
227
+
228
+ # result
229
+ directory = Serialization.directory_from_headers(response.headers)
230
+ directory.name = directory_path
231
+ directory
232
+ end
233
+
234
+ # Public: Sets custom metadata for the directory.
235
+ #
236
+ # ==== Attributes
237
+ #
238
+ # * +share+ - String. The name of the file share.
239
+ # * +directory_path+ - String. The path to the directory.
240
+ # * +metadata+ - Hash. A Hash of the metadata values.
241
+ # * +options+ - Hash. Optional parameters.
242
+ #
243
+ # ==== Options
244
+ #
245
+ # Accepted key/value pairs in options parameter are:
246
+ # * +:timeout+ - Integer. A timeout in seconds.
247
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
248
+ # in the analytics logs when storage analytics logging is enabled.
249
+ #
250
+ # See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-directory-metadata
251
+ #
252
+ # Returns nil on success
253
+ def set_directory_metadata(share, directory_path, metadata, options={})
254
+ # Query
255
+ query = { 'comp' => 'metadata' }
256
+ query['timeout'] = options[:timeout].to_s if options[:timeout]
257
+
258
+ # Headers
259
+ headers = StorageService.common_headers
260
+ StorageService.add_metadata_to_headers(metadata, headers) if metadata
261
+
262
+ # Call
263
+ call(:put, directory_uri(share, directory_path, query), nil, headers, options)
264
+
265
+ # Result
266
+ nil
267
+ end
268
+ end