azure-storage 0.10.0.preview → 0.10.1.preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/azure/storage/autoload.rb +2 -4
  3. data/lib/azure/storage/blob/blob_service.rb +2 -5
  4. data/lib/azure/storage/blob/container.rb +5 -1
  5. data/lib/azure/storage/client.rb +4 -4
  6. data/lib/azure/storage/{core/client_options.rb → client_options.rb} +1 -2
  7. data/lib/azure/storage/{core/client_options_error.rb → client_options_error.rb} +2 -2
  8. data/lib/azure/storage/core.rb +1 -1
  9. data/lib/azure/storage/core/auth/shared_access_signature.rb +3 -2
  10. data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +31 -18
  11. data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +1 -1
  12. data/lib/azure/storage/core/auth/shared_key.rb +4 -72
  13. data/lib/azure/storage/core/autoload.rb +17 -8
  14. data/lib/azure/storage/core/error.rb +2 -8
  15. data/lib/azure/storage/core/filter/exponential_retry_filter.rb +62 -0
  16. data/lib/azure/storage/core/{auth/shared_key_lite.rb → filter/linear_retry_filter.rb} +27 -29
  17. data/lib/azure/storage/core/filter/retry_filter.rb +172 -0
  18. data/lib/azure/storage/core/http_client.rb +1 -1
  19. data/lib/azure/storage/core/utility.rb +2 -10
  20. data/lib/azure/storage/{core/constants.rb → default.rb} +0 -0
  21. data/lib/azure/storage/service/storage_service.rb +7 -2
  22. data/lib/azure/storage/table/auth/shared_key.rb +2 -2
  23. data/lib/azure/storage/table/batch.rb +1 -1
  24. data/lib/azure/storage/table/table_service.rb +11 -11
  25. data/lib/azure/storage/version.rb +1 -1
  26. metadata +24 -18
  27. data/lib/azure/storage/core/auth/signer.rb +0 -60
  28. data/lib/azure/storage/core/filtered_service.rb +0 -54
  29. data/lib/azure/storage/core/http/debug_filter.rb +0 -45
  30. data/lib/azure/storage/core/http/http_error.rb +0 -95
  31. data/lib/azure/storage/core/http/http_filter.rb +0 -62
  32. data/lib/azure/storage/core/http/http_request.rb +0 -182
  33. data/lib/azure/storage/core/http/http_response.rb +0 -105
  34. data/lib/azure/storage/core/http/retry_policy.rb +0 -83
  35. data/lib/azure/storage/core/http/signer_filter.rb +0 -42
  36. data/lib/azure/storage/core/service.rb +0 -55
  37. data/lib/azure/storage/core/signed_service.rb +0 -54
@@ -1,105 +0,0 @@
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/core/http/http_error'
25
-
26
- module Azure
27
- module Core
28
- module Http
29
- # A small proxy to clean up the API of Net::HTTPResponse.
30
- class HttpResponse
31
-
32
- # Public: Initialize a new response.
33
- #
34
- # http_response - A Net::HTTPResponse.
35
- def initialize(http_response, uri='')
36
- @http_response = http_response
37
- @uri = uri
38
- end
39
-
40
- attr_accessor :uri
41
-
42
- # Public: Get the response body.
43
- #
44
- # Returns a String.
45
- def body
46
- @http_response.body
47
- end
48
-
49
- # Public: Get the response status code.
50
- #
51
- # Returns a Fixnum.
52
- def status_code
53
- @http_response.status
54
- end
55
-
56
- # Public: Check if this response was successful. A request is considered
57
- # successful if the response is in the 200 - 399 range.
58
- #
59
- # Returns nil|false.
60
- def success?
61
- @http_response.success?
62
- end
63
-
64
- # Public: Get all the response headers as a Hash.
65
- #
66
- # Returns a Hash.
67
- def headers
68
- @http_response.headers
69
- end
70
-
71
- # Public: Get an error that wraps this HTTP response, as long as this
72
- # response was unsuccessful. This method will return nil if the
73
- # response was successful.
74
- #
75
- # Returns an Azure::Core::Http::HTTPError.
76
- def exception
77
- HTTPError.new(self) unless success?
78
- end
79
-
80
- alias_method :error, :exception
81
-
82
- # TODO: This needs to be deleted and HttpError needs to be refactored to not rely on HttpResponse.
83
- # The dependency on knowing the internal structure of HttpResponse breaks good design principles.
84
- # The only reason this class exists is because the HttpError parses the HttpResponse to produce an error msg.
85
- class MockResponse
86
- def initialize(code, body, headers)
87
- @status = code
88
- @body = body
89
- @headers = headers
90
- @headers.each { |k,v|
91
- @headers[k] = [v] unless v.respond_to? first
92
- }
93
- end
94
- attr_accessor :status
95
- attr_accessor :body
96
- attr_accessor :headers
97
-
98
- def to_hash
99
- @headers
100
- end
101
- end
102
- end
103
- end
104
- end
105
- end
@@ -1,83 +0,0 @@
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/core/http/http_filter"
25
-
26
- module Azure
27
- module Core
28
- module Http
29
-
30
- # A HttpFilter implementation that handles retrying based on a
31
- # specific policy when HTTP layer errors occur
32
- class RetryPolicy < HttpFilter
33
-
34
- def initialize(&block)
35
- @block = block
36
- end
37
-
38
- attr_accessor :retry_data
39
-
40
- # Overrides the base class implementation of call to implement
41
- # a retry loop that uses should_retry? to determine when to
42
- # break the loop
43
- #
44
- # req - HttpRequest. The HTTP request
45
- # _next - HttpFilter. The next filter in the pipeline
46
- def call(req, _next)
47
- retry_data = {}
48
- response = nil
49
- begin
50
- response = _next.call
51
- rescue
52
- retry_data[:error] = $!
53
- end while should_retry?(response, retry_data)
54
- if retry_data.has_key?(:error)
55
- raise retry_data[:error]
56
- else
57
- response
58
- end
59
- end
60
-
61
- # Determines if the HTTP request should continue retrying
62
- #
63
- # response - HttpResponse. The response from the active request
64
- # retry_data - Hash. Stores stateful retry data
65
- #
66
- # The retry_data is a Hash which can be used to store
67
- # stateful data about the request execution context (such as an
68
- # incrementing counter, timestamp, etc). The retry_data object
69
- # will be the same instance throughout the lifetime of the request.
70
- #
71
- # If an inline block was passed to the constructor, that block
72
- # will be used here and should return true to retry the job, or
73
- # false to stop exit. If an inline block was not passed to the
74
- # constructor the method returns false.
75
- #
76
- # Alternatively, a subclass could override this method.
77
- def should_retry?(response, retry_data)
78
- @block ? @block.call(response, retry_data) : false
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,42 +0,0 @@
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/core/http/http_filter'
25
-
26
- module Azure
27
- module Core
28
- module Http
29
- # A HttpFilter implementation that creates a authorization signature which is added to the request headers
30
- class SignerFilter < HttpFilter
31
- def initialize(signer)
32
- @signer = signer
33
- end
34
-
35
- def call(req, _next)
36
- @signer.sign_request(req)
37
- _next.call
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,55 +0,0 @@
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/core/http/http_request'
25
-
26
- module Azure
27
- module Core
28
- # A base class for Service implementations
29
- class Service
30
-
31
- # Create a new instance of the Service
32
- #
33
- # @param host [String] The hostname. (optional, Default empty)
34
- # @param options [Hash] options including {:client} (optional, Default {})
35
- def initialize(host='', options = {})
36
- @host = host
37
- @client = options[:client] || Azure::Storage
38
- end
39
-
40
- attr_accessor :host, :client
41
-
42
- def call(method, uri, body=nil, headers={})
43
- request = Core::Http::HttpRequest.new(method, uri, body: body, headers: headers, client: @client)
44
- yield request if block_given?
45
- request.call
46
- end
47
-
48
- def generate_uri(path='', query={})
49
- uri = URI.parse(File.join(host, path))
50
- uri.query = URI.encode_www_form(query) unless query == nil or query.empty?
51
- uri
52
- end
53
- end
54
- end
55
- end
@@ -1,54 +0,0 @@
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/core/filtered_service'
25
- require 'azure/storage/core/http/signer_filter'
26
- require 'azure/storage/core/auth/shared_key'
27
-
28
- module Azure
29
- module Core
30
- # A base class for Service implementations
31
- class SignedService < FilteredService
32
-
33
- # Create a new instance of the SignedService
34
- #
35
- # @param signer [Azure::Core::Auth::Signer]. An implementation of Signer used for signing requests. (optional, Default=Azure::Storage::Auth::SharedKey.new)
36
- # @param account_name [String] The account name (optional, Default=Azure::Storage.config.storage_account_name)
37
- # @param options [Hash] options
38
- def initialize(signer=nil, account_name=nil, options={})
39
- super('', options)
40
- signer ||= Azure::Storage::Auth::SharedKey.new(client.storage_account_name, client.storage_access_key)
41
- @account_name = account_name || client.storage_account_name
42
- @signer = signer
43
- filters.unshift Core::Http::SignerFilter.new(signer) if signer
44
- end
45
-
46
- attr_accessor :account_name
47
- attr_accessor :signer
48
-
49
- def call(method, uri, body=nil, headers=nil)
50
- super(method, uri, body, headers)
51
- end
52
- end
53
- end
54
- end