azure-storage-common 1.1.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/lib/azure/core.rb +47 -0
  3. data/lib/azure/core/auth/authorizer.rb +36 -0
  4. data/lib/azure/core/auth/shared_key.rb +125 -0
  5. data/lib/azure/core/auth/shared_key_lite.rb +48 -0
  6. data/lib/azure/core/auth/signer.rb +51 -0
  7. data/lib/azure/core/default.rb +23 -0
  8. data/lib/azure/core/error.rb +21 -0
  9. data/lib/azure/core/filtered_service.rb +45 -0
  10. data/lib/azure/core/http/debug_filter.rb +36 -0
  11. data/lib/azure/core/http/http_error.rb +135 -0
  12. data/lib/azure/core/http/http_filter.rb +53 -0
  13. data/lib/azure/core/http/http_request.rb +194 -0
  14. data/lib/azure/core/http/http_response.rb +102 -0
  15. data/lib/azure/core/http/retry_policy.rb +84 -0
  16. data/lib/azure/core/http/signer_filter.rb +33 -0
  17. data/lib/azure/core/service.rb +46 -0
  18. data/lib/azure/core/signed_service.rb +45 -0
  19. data/lib/azure/core/utility.rb +244 -0
  20. data/lib/azure/core/version.rb +33 -0
  21. data/lib/azure/http_response_helper.rb +38 -0
  22. data/lib/azure/storage/common.rb +26 -26
  23. data/lib/azure/storage/common/autoload.rb +62 -61
  24. data/lib/azure/storage/common/client.rb +162 -162
  25. data/lib/azure/storage/common/client_options.rb +363 -363
  26. data/lib/azure/storage/common/client_options_error.rb +41 -41
  27. data/lib/azure/storage/common/configurable.rb +212 -212
  28. data/lib/azure/storage/common/core.rb +35 -35
  29. data/lib/azure/storage/common/core/auth/anonymous_signer.rb +43 -43
  30. data/lib/azure/storage/common/core/auth/shared_access_signature.rb +30 -30
  31. data/lib/azure/storage/common/core/auth/shared_access_signature_generator.rb +399 -352
  32. data/lib/azure/storage/common/core/auth/shared_access_signature_signer.rb +57 -57
  33. data/lib/azure/storage/common/core/auth/shared_key.rb +60 -60
  34. data/lib/azure/storage/common/core/auth/token_signer.rb +43 -43
  35. data/lib/azure/storage/common/core/autoload.rb +53 -53
  36. data/lib/azure/storage/common/core/error.rb +43 -43
  37. data/lib/azure/storage/common/core/filter/exponential_retry_filter.rb +64 -64
  38. data/lib/azure/storage/common/core/filter/linear_retry_filter.rb +55 -55
  39. data/lib/azure/storage/common/core/filter/retry_filter.rb +300 -300
  40. data/lib/azure/storage/common/core/http_client.rb +79 -69
  41. data/lib/azure/storage/common/core/sr.rb +85 -85
  42. data/lib/azure/storage/common/core/token_credential.rb +64 -64
  43. data/lib/azure/storage/common/core/utility.rb +255 -255
  44. data/lib/azure/storage/common/default.rb +868 -868
  45. data/lib/azure/storage/common/service/access_policy.rb +37 -37
  46. data/lib/azure/storage/common/service/cors.rb +38 -38
  47. data/lib/azure/storage/common/service/cors_rule.rb +48 -48
  48. data/lib/azure/storage/common/service/enumeration_results.rb +32 -32
  49. data/lib/azure/storage/common/service/geo_replication.rb +40 -40
  50. data/lib/azure/storage/common/service/logging.rb +47 -47
  51. data/lib/azure/storage/common/service/metrics.rb +45 -45
  52. data/lib/azure/storage/common/service/retention_policy.rb +37 -37
  53. data/lib/azure/storage/common/service/serialization.rb +335 -335
  54. data/lib/azure/storage/common/service/signed_identifier.rb +40 -40
  55. data/lib/azure/storage/common/service/storage_service.rb +322 -322
  56. data/lib/azure/storage/common/service/storage_service_properties.rb +48 -48
  57. data/lib/azure/storage/common/service/storage_service_stats.rb +39 -39
  58. data/lib/azure/storage/common/service/user_delegation_key.rb +50 -0
  59. data/lib/azure/storage/common/version.rb +49 -49
  60. metadata +60 -18
@@ -1,69 +1,79 @@
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::Storage::Common::Core
28
- module HttpClient
29
- # Returns the http agent based on uri
30
- # @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint
31
- # @return [Net::HTTP] http agent for a given uri
32
- def agents(uri)
33
- key = uri.to_s
34
- @agents ||= {}
35
- unless @agents.key?(key)
36
- @agents[key] = build_http(uri)
37
- end
38
- @agents[key]
39
- end
40
-
41
- # Empties all the http agents
42
- def reset_agents!
43
- @agents = nil
44
- end
45
-
46
- private
47
-
48
- def build_http(uri)
49
- ssl_options = {}
50
- if uri.is_a?(URI) && uri.scheme.downcase == "https"
51
- ssl_options[:version] = self.ssl_version if self.ssl_version
52
- # min_version and max_version only supported in ruby 2.5
53
- ssl_options[:min_version] = self.ssl_min_version if self.ssl_min_version
54
- ssl_options[:max_version] = self.ssl_max_version if self.ssl_max_version
55
- ssl_options[:ca_file] = self.ca_file if self.ca_file
56
- ssl_options[:verify] = true
57
- end
58
- proxy_options = if ENV["HTTP_PROXY"]
59
- URI::parse(ENV["HTTP_PROXY"])
60
- elsif ENV["HTTPS_PROXY"]
61
- URI::parse(ENV["HTTPS_PROXY"])
62
- end || nil
63
- Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
64
- conn.use FaradayMiddleware::FollowRedirects
65
- conn.adapter Faraday.default_adapter
66
- end
67
- end
68
- end
69
- end
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::Storage::Common::Core
28
+ module HttpClient
29
+ # Returns the http agent based on uri
30
+ # @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint
31
+ # @return [Net::HTTP] http agent for a given uri
32
+ def agents(uri)
33
+ uri = URI(uri) unless uri.is_a? URI
34
+ key = uri.host
35
+
36
+ @agents ||= {}
37
+ unless @agents.key?(key)
38
+ @agents[key] = build_http(uri)
39
+ else
40
+ reuse_agent!(@agents[key])
41
+ end
42
+ @agents[key]
43
+ end
44
+
45
+ # Empties all the http agents
46
+ def reset_agents!
47
+ @agents = nil
48
+ end
49
+
50
+ private
51
+
52
+ # Empties all information that cannot be reused.
53
+ def reuse_agent!(agent)
54
+ agent.params.clear
55
+ agent.headers.clear
56
+ end
57
+
58
+ def build_http(uri)
59
+ ssl_options = {}
60
+ if uri.is_a?(URI) && uri.scheme.downcase == "https"
61
+ ssl_options[:version] = self.ssl_version if self.ssl_version
62
+ # min_version and max_version only supported in ruby 2.5
63
+ ssl_options[:min_version] = self.ssl_min_version if self.ssl_min_version
64
+ ssl_options[:max_version] = self.ssl_max_version if self.ssl_max_version
65
+ ssl_options[:ca_file] = self.ca_file if self.ca_file
66
+ ssl_options[:verify] = true
67
+ end
68
+ proxy_options = if ENV["HTTP_PROXY"]
69
+ URI::parse(ENV["HTTP_PROXY"])
70
+ elsif ENV["HTTPS_PROXY"]
71
+ URI::parse(ENV["HTTPS_PROXY"])
72
+ end || nil
73
+ Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
74
+ conn.use FaradayMiddleware::FollowRedirects
75
+ conn.adapter Faraday.default_adapter
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,85 +1,85 @@
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
-
28
- module Azure::Storage::Common::Core
29
- module SR
30
- ANONYMOUS_ACCESS_BLOBSERVICE_ONLY = "Anonymous access is only valid for the BlobService."
31
- ARGUMENT_NULL_OR_EMPTY = "The argument must not be null or an empty string. Argument name: %s."
32
- ARGUMENT_NULL_OR_UNDEFINED = "The argument must not be null or undefined. Argument name: %s."
33
- ARGUMENT_OUT_OF_RANGE_ERROR = "The argument is out of range. Argument name: %s, Value passed: %s."
34
- BATCH_ONE_PARTITION_KEY = "All entities in the batch must have the same PartitionKey value."
35
- BATCH_ONE_RETRIEVE = "If a retrieve operation is part of a batch, it must be the only operation in the batch."
36
- BATCH_TOO_LARGE = "Batches must not contain more than 100 operations."
37
- BLOB_INVALID_SEQUENCE_NUMBER = "The sequence number may not be specified for an increment operation."
38
- BLOB_TYPE_MISMATCH = 'Blob type of the blob reference doesn\'t match blob type of the blob.'
39
- CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY = "Cannot create Shared Access Signature unless the Account Name and Key are used to create the ServiceClient."
40
- CONTENT_LENGTH_MISMATCH = "An incorrect number of bytes was read from the connection. The connection may have been closed."
41
- CONTENT_TYPE_MISSING = "Content-Type response header is missing or invalid."
42
- EMPTY_BATCH = "Batch must not be empty."
43
- EXCEEDED_SIZE_LIMITATION = "Upload exceeds the size limitation. Max size is %s but the current size is %s"
44
- HASH_MISMATCH = "Hash mismatch (integrity check failed), Expected value is %s, retrieved %s."
45
- INCORRECT_ENTITY_KEYS = "PartitionKey and RowKey must be specified as strings in the entity object."
46
- INVALID_BLOB_LENGTH = "createBlockBlobFromText requires the size of text to be less than 64MB. Please use createBlockBlobFromLocalFile or createBlockBlobFromStream to upload large blobs."
47
- INVALID_CONNECTION_STRING = 'Connection strings must be of the form "key1=value1;key2=value2".'
48
- INVALID_CONNECTION_STRING_BAD_KEY = 'Connection string contains unrecognized key: "%s"'
49
- INVALID_CONNECTION_STRING_DUPLICATE_KEY = 'Connection string contains duplicate key: "%s"'
50
- INVALID_CONNECTION_STRING_EMPTY_KEY = "Connection strings must not contain empty keys."
51
- INVALID_CLIENT_OPTIONS = "Storage client options are invalid"
52
- INVALID_DELETE_SNAPSHOT_OPTION = "The deleteSnapshots option cannot be included when deleting a specific snapshot using the snapshotId option."
53
- INVALID_EDM_TYPE = 'The value \'%s\' does not match the type \'%s\'.'
54
- INVALID_FILE_LENGTH = "createFileFromText requires the size of text to be less than 4MB. Please use createFileFromLocalFile or createFileFromStream to upload large files."
55
- INVALID_FILE_RANGE_FOR_UPDATE = "Range size should be less than 4MB for a file range update operation."
56
- INVALID_HEADERS = "Headers are not supported in the 2012-02-12 version."
57
- INVALID_MESSAGE_ID = "Message ID cannot be null or undefined for deleteMessage and updateMessage operations."
58
- INVALID_PAGE_BLOB_LENGTH = "Page blob length must be multiple of 512."
59
- INVALID_PAGE_END_OFFSET = "Page end offset must be multiple of 512."
60
- INVALID_PAGE_RANGE_FOR_UPDATE = "Page range size should be less than 4MB for a page update operation."
61
- INVALID_PAGE_START_OFFSET = "Page start offset must be multiple of 512."
62
- INVALID_POP_RECEIPT = "Pop Receipt cannot be null or undefined for deleteMessage and updateMessage operations."
63
- INVALID_PROPERTY_RESOLVER = "The specified property resolver returned an invalid type. %s:{_:%s,$:%s }"
64
- INVALID_RANGE_FOR_MD5 = "The requested range should be less than 4MB when contentMD5 is expected from the server"
65
- INVALID_SAS_VERSION = "SAS Version ? is invalid. Valid versions include: ?."
66
- INVALID_SAS_TOKEN = "The SAS token should not contain api-version."
67
- INVALID_SIGNED_IDENTIFIERS = "Signed identifiers need to be an array."
68
- INVALID_STREAM_LENGTH = "The length of the provided stream is invalid."
69
- INVALID_STRING_ERROR = "Invalid string error."
70
- INVALID_TABLE_OPERATION = "Operation not found: %s"
71
- INVALID_TEXT_LENGTH = "The length of the provided text is invalid."
72
- MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION = "The client could not finish the operation within specified maximum execution timeout."
73
- MD5_NOT_PRESENT_ERROR = "MD5 does not exist. If you do not want to force validation, please disable useTransactionalMD5."
74
- METADATA_KEY_INVALID = "The key for one of the metadata key-value pairs is null, empty, or whitespace."
75
- METADATA_VALUE_INVALID = "The value for one of the metadata key-value pairs is null, empty, or whitespace."
76
- NO_CREDENTIALS_PROVIDED = "Credentials must be provided when creating a service client."
77
- PRIMARY_ONLY_COMMAND = "This operation can only be executed against the primary storage location."
78
- QUERY_OPERATOR_REQUIRES_WHERE = "%s operator needs to be used after where."
79
- SECONDARY_ONLY_COMMAND = "This operation can only be executed against the secondary storage location."
80
- STORAGE_HOST_LOCATION_REQUIRED = "The host for the storage service must be specified."
81
- STORAGE_HOST_MISSING_LOCATION = 'The host for the target storage location is not specified. Please consider changing the request\'s location mode.'
82
- TYPE_NOT_SUPPORTED = "Type not supported when sending data to the service: "
83
- MAX_BLOB_SIZE_CONDITION_NOT_MEET = "The max blob size condition specified was not met."
84
- end
85
- end
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
+
28
+ module Azure::Storage::Common::Core
29
+ module SR
30
+ ANONYMOUS_ACCESS_BLOBSERVICE_ONLY = "Anonymous access is only valid for the BlobService."
31
+ ARGUMENT_NULL_OR_EMPTY = "The argument must not be null or an empty string. Argument name: %s."
32
+ ARGUMENT_NULL_OR_UNDEFINED = "The argument must not be null or undefined. Argument name: %s."
33
+ ARGUMENT_OUT_OF_RANGE_ERROR = "The argument is out of range. Argument name: %s, Value passed: %s."
34
+ BATCH_ONE_PARTITION_KEY = "All entities in the batch must have the same PartitionKey value."
35
+ BATCH_ONE_RETRIEVE = "If a retrieve operation is part of a batch, it must be the only operation in the batch."
36
+ BATCH_TOO_LARGE = "Batches must not contain more than 100 operations."
37
+ BLOB_INVALID_SEQUENCE_NUMBER = "The sequence number may not be specified for an increment operation."
38
+ BLOB_TYPE_MISMATCH = 'Blob type of the blob reference doesn\'t match blob type of the blob.'
39
+ CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY = "Cannot create Shared Access Signature unless the Account Name and Key are used to create the ServiceClient."
40
+ CONTENT_LENGTH_MISMATCH = "An incorrect number of bytes was read from the connection. The connection may have been closed."
41
+ CONTENT_TYPE_MISSING = "Content-Type response header is missing or invalid."
42
+ EMPTY_BATCH = "Batch must not be empty."
43
+ EXCEEDED_SIZE_LIMITATION = "Upload exceeds the size limitation. Max size is %s but the current size is %s"
44
+ HASH_MISMATCH = "Hash mismatch (integrity check failed), Expected value is %s, retrieved %s."
45
+ INCORRECT_ENTITY_KEYS = "PartitionKey and RowKey must be specified as strings in the entity object."
46
+ INVALID_BLOB_LENGTH = "createBlockBlobFromText requires the size of text to be less than 64MB. Please use createBlockBlobFromLocalFile or createBlockBlobFromStream to upload large blobs."
47
+ INVALID_CONNECTION_STRING = 'Connection strings must be of the form "key1=value1;key2=value2".'
48
+ INVALID_CONNECTION_STRING_BAD_KEY = 'Connection string contains unrecognized key: "%s"'
49
+ INVALID_CONNECTION_STRING_DUPLICATE_KEY = 'Connection string contains duplicate key: "%s"'
50
+ INVALID_CONNECTION_STRING_EMPTY_KEY = "Connection strings must not contain empty keys."
51
+ INVALID_CLIENT_OPTIONS = "Storage client options are invalid"
52
+ INVALID_DELETE_SNAPSHOT_OPTION = "The deleteSnapshots option cannot be included when deleting a specific snapshot using the snapshotId option."
53
+ INVALID_EDM_TYPE = 'The value \'%s\' does not match the type \'%s\'.'
54
+ INVALID_FILE_LENGTH = "createFileFromText requires the size of text to be less than 4MB. Please use createFileFromLocalFile or createFileFromStream to upload large files."
55
+ INVALID_FILE_RANGE_FOR_UPDATE = "Range size should be less than 4MB for a file range update operation."
56
+ INVALID_HEADERS = "Headers are not supported in the 2012-02-12 version."
57
+ INVALID_MESSAGE_ID = "Message ID cannot be null or undefined for deleteMessage and updateMessage operations."
58
+ INVALID_PAGE_BLOB_LENGTH = "Page blob length must be multiple of 512."
59
+ INVALID_PAGE_END_OFFSET = "Page end offset must be multiple of 512."
60
+ INVALID_PAGE_RANGE_FOR_UPDATE = "Page range size should be less than 4MB for a page update operation."
61
+ INVALID_PAGE_START_OFFSET = "Page start offset must be multiple of 512."
62
+ INVALID_POP_RECEIPT = "Pop Receipt cannot be null or undefined for deleteMessage and updateMessage operations."
63
+ INVALID_PROPERTY_RESOLVER = "The specified property resolver returned an invalid type. %s:{_:%s,$:%s }"
64
+ INVALID_RANGE_FOR_MD5 = "The requested range should be less than 4MB when contentMD5 is expected from the server"
65
+ INVALID_SAS_VERSION = "SAS Version ? is invalid. Valid versions include: ?."
66
+ INVALID_SAS_TOKEN = "The SAS token should not contain api-version."
67
+ INVALID_SIGNED_IDENTIFIERS = "Signed identifiers need to be an array."
68
+ INVALID_STREAM_LENGTH = "The length of the provided stream is invalid."
69
+ INVALID_STRING_ERROR = "Invalid string error."
70
+ INVALID_TABLE_OPERATION = "Operation not found: %s"
71
+ INVALID_TEXT_LENGTH = "The length of the provided text is invalid."
72
+ MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION = "The client could not finish the operation within specified maximum execution timeout."
73
+ MD5_NOT_PRESENT_ERROR = "MD5 does not exist. If you do not want to force validation, please disable useTransactionalMD5."
74
+ METADATA_KEY_INVALID = "The key for one of the metadata key-value pairs is null, empty, or whitespace."
75
+ METADATA_VALUE_INVALID = "The value for one of the metadata key-value pairs is null, empty, or whitespace."
76
+ NO_CREDENTIALS_PROVIDED = "Credentials must be provided when creating a service client."
77
+ PRIMARY_ONLY_COMMAND = "This operation can only be executed against the primary storage location."
78
+ QUERY_OPERATOR_REQUIRES_WHERE = "%s operator needs to be used after where."
79
+ SECONDARY_ONLY_COMMAND = "This operation can only be executed against the secondary storage location."
80
+ STORAGE_HOST_LOCATION_REQUIRED = "The host for the storage service must be specified."
81
+ STORAGE_HOST_MISSING_LOCATION = 'The host for the target storage location is not specified. Please consider changing the request\'s location mode.'
82
+ TYPE_NOT_SUPPORTED = "Type not supported when sending data to the service: "
83
+ MAX_BLOB_SIZE_CONDITION_NOT_MEET = "The max blob size condition specified was not met."
84
+ end
85
+ end
@@ -1,64 +1,64 @@
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/core"
27
-
28
- module Azure::Storage::Common::Core
29
- class TokenCredential
30
-
31
- # Public: Initializes an instance of [Azure::Storage::Common::Core::TokenCredential]
32
- #
33
- # ==== Attributes
34
- #
35
- # * +token+ - String. The initial access token.
36
- #
37
- def initialize(token)
38
- @token = token
39
- @mutex = Mutex.new
40
- end
41
-
42
- # Public: Gets the access token
43
- #
44
- # Note: Providing this getter under the protect of a mutex
45
- #
46
- def token
47
- @mutex.synchronize do
48
- @token
49
- end
50
- end
51
-
52
- # Public: Renews the access token
53
- #
54
- # ==== Attributes
55
- #
56
- # * +new_token+ - String. The new access token.
57
- #
58
- def renew_token(new_token)
59
- @mutex.synchronize do
60
- @token = new_token
61
- end
62
- end
63
- end
64
- end
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/core"
27
+
28
+ module Azure::Storage::Common::Core
29
+ class TokenCredential
30
+
31
+ # Public: Initializes an instance of [Azure::Storage::Common::Core::TokenCredential]
32
+ #
33
+ # ==== Attributes
34
+ #
35
+ # * +token+ - String. The initial access token.
36
+ #
37
+ def initialize(token)
38
+ @token = token
39
+ @mutex = Mutex.new
40
+ end
41
+
42
+ # Public: Gets the access token
43
+ #
44
+ # Note: Providing this getter under the protect of a mutex
45
+ #
46
+ def token
47
+ @mutex.synchronize do
48
+ @token
49
+ end
50
+ end
51
+
52
+ # Public: Renews the access token
53
+ #
54
+ # ==== Attributes
55
+ #
56
+ # * +new_token+ - String. The new access token.
57
+ #
58
+ def renew_token(new_token)
59
+ @mutex.synchronize do
60
+ @token = new_token
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,255 +1,255 @@
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
- require "ipaddr"
28
- require "azure/storage/common/core/error"
29
-
30
- if RUBY_VERSION.to_f < 2.0
31
- begin
32
- require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32|mingw32/
33
- rescue LoadError
34
- puts "WARNING: Output will look weird on Windows unless"\
35
- ' you install the "win32console" gem.'
36
- end
37
- end
38
-
39
- module Azure::Storage::Common
40
- module Error
41
- # Azure Error
42
- class Error < Azure::Core::Error
43
- attr_reader :description
44
- attr_reader :status_code
45
- attr_reader :type
46
-
47
- def initialize(type, status, description)
48
- @type = type
49
- @status_code = status
50
- @description = description
51
- super("#{type} (#{status_code}): #{description}")
52
- end
53
- end
54
- end
55
-
56
- module Core
57
- module Utility
58
- def random_string(str = "azure", no_of_char = 5)
59
- str + (0...no_of_char).map { ("a".."z").to_a[rand(26)] }.join
60
- end
61
-
62
- def xml_content(xml, key, default = "")
63
- content = default
64
- node = xml.at_css(key)
65
- content = node.text if node
66
- content
67
- end
68
-
69
- def locate_file(name)
70
- if File.exist? name
71
- name
72
- elsif File.exist?(File.join(ENV["HOME"], name))
73
- File.join(ENV["HOME"], name)
74
- else
75
- Azure::Loggerx.error_with_exit "Unable to find #{name} file "
76
- end
77
- end
78
-
79
- def export_der(cert, key, pass = nil, name = nil)
80
- pkcs12 = OpenSSL::PKCS12.create(pass, name, key, cert)
81
- Base64.encode64(pkcs12.to_der)
82
- rescue Exception => e
83
- puts e.message
84
- abort
85
- end
86
-
87
- def export_fingerprint(certificate)
88
- Digest::SHA1.hexdigest(certificate.to_der)
89
- end
90
-
91
- def enable_winrm?(winrm_transport)
92
- (!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase == "http" || x.downcase == "https" }.size > 0))
93
- end
94
-
95
- def get_certificate(private_key_file)
96
- rsa = OpenSSL::PKey.read File.read(private_key_file)
97
- cert = OpenSSL::X509::Certificate.new
98
- cert.version = 2
99
- cert.serial = 0
100
- name = OpenSSL::X509::Name.new([["CN", "Azure Management Certificate"]])
101
- cert.subject = cert.issuer = name
102
- cert.not_before = Time.now
103
- cert.not_after = cert.not_before + (60 * 60 * 24 * 365)
104
- cert.public_key = rsa.public_key
105
- cert.sign(rsa, OpenSSL::Digest::SHA1.new)
106
- cert
107
- end
108
-
109
- def initialize_external_logger(logger)
110
- Loggerx.initialize_external_logger(logger)
111
- end
112
-
113
- def parse_charset_from_content_type(content_type)
114
- if (content_type && content_type.length > 0)
115
- charset = content_type.split(";").delete_if { |attribute| !attribute.lstrip.start_with?("charset=") }.map { |x| x.lstrip }[0]
116
- charset["charset=".length...charset.length] if charset
117
- end
118
- end
119
- end
120
-
121
- # Logger
122
- module Logger
123
- class << self
124
- attr_accessor :logger
125
-
126
- def info(msg)
127
- if logger.nil?
128
- puts msg.bold.white
129
- else
130
- logger.info(msg)
131
- end
132
- end
133
-
134
- def error_with_exit(msg)
135
- if logger.nil?
136
- puts msg.bold.red
137
- else
138
- logger.error(msg)
139
- end
140
-
141
- raise msg.bold.red
142
- end
143
-
144
- def warn(msg)
145
- if logger.nil?
146
- puts msg.yellow
147
- else
148
- logger.warn(msg)
149
- end
150
-
151
- msg
152
- end
153
-
154
- def error(msg)
155
- if logger.nil?
156
- puts msg.bold.red
157
- else
158
- logger.error(msg)
159
- end
160
-
161
- msg
162
- end
163
-
164
- def exception_message(msg)
165
- if logger.nil?
166
- puts msg.bold.red
167
- else
168
- logger.warn(msg)
169
- end
170
-
171
- raise msg.bold.red
172
- end
173
-
174
- def success(msg)
175
- msg_with_new_line = msg + "\n"
176
- if logger.nil?
177
- print msg_with_new_line.green
178
- else
179
- logger.info(msg)
180
- end
181
- end
182
-
183
- def initialize_external_logger(logger)
184
- @logger = logger
185
- end
186
- end
187
- end
188
- end
189
- end
190
-
191
- class String
192
- { reset: 0,
193
- bold: 1,
194
- dark: 2,
195
- underline: 4,
196
- blink: 5,
197
- orange: 6,
198
- negative: 7,
199
- black: 30,
200
- red: 31,
201
- green: 32,
202
- yellow: 33,
203
- blue: 34,
204
- magenta: 35,
205
- cyan: 36,
206
- white: 37,
207
- }.each do |key, value|
208
- define_method key do
209
- "\e[#{value}m" + self + "\e[0m"
210
- end
211
- end
212
- end
213
-
214
- # Code validate private/public IP acceptable ranges.
215
- class IPAddr
216
- def private?
217
- return false unless self.ipv4?
218
- PRIVATE_RANGES.each do |ipr|
219
- return true if ipr.include?(self)
220
- end
221
- false
222
- end
223
-
224
- def public?
225
- !private?
226
- end
227
-
228
- class << self
229
- def validate_ip_and_prefix(ip, cidr)
230
- if cidr.to_s.empty?
231
- raise "Cidr is missing for IP '#{ip}'."
232
- elsif valid?(ip)
233
- raise "Ip address '#{ip}' is invalid."
234
- elsif !IPAddr.new(ip).private?
235
- raise "Ip Address #{ip} must be private."
236
- end
237
- end
238
-
239
- def validate_address_space(ip)
240
- if ip.split("/").size != 2
241
- raise "Cidr is invalid for IP #{ip}."
242
- elsif valid?(ip)
243
- raise "Address space '#{ip}' is invalid."
244
- end
245
- end
246
-
247
- def address_prefix(ip, cidr)
248
- ip + "/" + cidr.to_s
249
- end
250
-
251
- def valid?(ip)
252
- (IPAddr.new(ip) rescue nil).nil?
253
- end
254
- end
255
- end
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
+ require "ipaddr"
28
+ require "azure/storage/common/core/error"
29
+
30
+ if RUBY_VERSION.to_f < 2.0
31
+ begin
32
+ require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32|mingw32/
33
+ rescue LoadError
34
+ puts "WARNING: Output will look weird on Windows unless"\
35
+ ' you install the "win32console" gem.'
36
+ end
37
+ end
38
+
39
+ module Azure::Storage::Common
40
+ module Error
41
+ # Azure Error
42
+ class Error < Azure::Core::Error
43
+ attr_reader :description
44
+ attr_reader :status_code
45
+ attr_reader :type
46
+
47
+ def initialize(type, status, description)
48
+ @type = type
49
+ @status_code = status
50
+ @description = description
51
+ super("#{type} (#{status_code}): #{description}")
52
+ end
53
+ end
54
+ end
55
+
56
+ module Core
57
+ module Utility
58
+ def random_string(str = "azure", no_of_char = 5)
59
+ str + (0...no_of_char).map { ("a".."z").to_a[rand(26)] }.join
60
+ end
61
+
62
+ def xml_content(xml, key, default = "")
63
+ content = default
64
+ node = xml.at_css(key)
65
+ content = node.text if node
66
+ content
67
+ end
68
+
69
+ def locate_file(name)
70
+ if File.exist? name
71
+ name
72
+ elsif File.exist?(File.join(ENV["HOME"], name))
73
+ File.join(ENV["HOME"], name)
74
+ else
75
+ Azure::Loggerx.error_with_exit "Unable to find #{name} file "
76
+ end
77
+ end
78
+
79
+ def export_der(cert, key, pass = nil, name = nil)
80
+ pkcs12 = OpenSSL::PKCS12.create(pass, name, key, cert)
81
+ Base64.encode64(pkcs12.to_der)
82
+ rescue Exception => e
83
+ puts e.message
84
+ abort
85
+ end
86
+
87
+ def export_fingerprint(certificate)
88
+ Digest::SHA1.hexdigest(certificate.to_der)
89
+ end
90
+
91
+ def enable_winrm?(winrm_transport)
92
+ (!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase == "http" || x.downcase == "https" }.size > 0))
93
+ end
94
+
95
+ def get_certificate(private_key_file)
96
+ rsa = OpenSSL::PKey.read File.read(private_key_file)
97
+ cert = OpenSSL::X509::Certificate.new
98
+ cert.version = 2
99
+ cert.serial = 0
100
+ name = OpenSSL::X509::Name.new([["CN", "Azure Management Certificate"]])
101
+ cert.subject = cert.issuer = name
102
+ cert.not_before = Time.now
103
+ cert.not_after = cert.not_before + (60 * 60 * 24 * 365)
104
+ cert.public_key = rsa.public_key
105
+ cert.sign(rsa, OpenSSL::Digest::SHA1.new)
106
+ cert
107
+ end
108
+
109
+ def initialize_external_logger(logger)
110
+ Loggerx.initialize_external_logger(logger)
111
+ end
112
+
113
+ def parse_charset_from_content_type(content_type)
114
+ if (content_type && content_type.length > 0)
115
+ charset = content_type.split(";").delete_if { |attribute| !attribute.lstrip.start_with?("charset=") }.map { |x| x.lstrip }[0]
116
+ charset["charset=".length...charset.length] if charset
117
+ end
118
+ end
119
+ end
120
+
121
+ # Logger
122
+ module Logger
123
+ class << self
124
+ attr_accessor :logger
125
+
126
+ def info(msg)
127
+ if logger.nil?
128
+ puts msg.bold.white
129
+ else
130
+ logger.info(msg)
131
+ end
132
+ end
133
+
134
+ def error_with_exit(msg)
135
+ if logger.nil?
136
+ puts msg.bold.red
137
+ else
138
+ logger.error(msg)
139
+ end
140
+
141
+ raise msg.bold.red
142
+ end
143
+
144
+ def warn(msg)
145
+ if logger.nil?
146
+ puts msg.yellow
147
+ else
148
+ logger.warn(msg)
149
+ end
150
+
151
+ msg
152
+ end
153
+
154
+ def error(msg)
155
+ if logger.nil?
156
+ puts msg.bold.red
157
+ else
158
+ logger.error(msg)
159
+ end
160
+
161
+ msg
162
+ end
163
+
164
+ def exception_message(msg)
165
+ if logger.nil?
166
+ puts msg.bold.red
167
+ else
168
+ logger.warn(msg)
169
+ end
170
+
171
+ raise msg.bold.red
172
+ end
173
+
174
+ def success(msg)
175
+ msg_with_new_line = msg + "\n"
176
+ if logger.nil?
177
+ print msg_with_new_line.green
178
+ else
179
+ logger.info(msg)
180
+ end
181
+ end
182
+
183
+ def initialize_external_logger(logger)
184
+ @logger = logger
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
190
+
191
+ class String
192
+ { reset: 0,
193
+ bold: 1,
194
+ dark: 2,
195
+ underline: 4,
196
+ blink: 5,
197
+ orange: 6,
198
+ negative: 7,
199
+ black: 30,
200
+ red: 31,
201
+ green: 32,
202
+ yellow: 33,
203
+ blue: 34,
204
+ magenta: 35,
205
+ cyan: 36,
206
+ white: 37,
207
+ }.each do |key, value|
208
+ define_method key do
209
+ "\e[#{value}m" + self + "\e[0m"
210
+ end
211
+ end
212
+ end
213
+
214
+ # Code validate private/public IP acceptable ranges.
215
+ class IPAddr
216
+ def private?
217
+ return false unless self.ipv4?
218
+ PRIVATE_RANGES.each do |ipr|
219
+ return true if ipr.include?(self)
220
+ end
221
+ false
222
+ end
223
+
224
+ def public?
225
+ !private?
226
+ end
227
+
228
+ class << self
229
+ def validate_ip_and_prefix(ip, cidr)
230
+ if cidr.to_s.empty?
231
+ raise "Cidr is missing for IP '#{ip}'."
232
+ elsif valid?(ip)
233
+ raise "Ip address '#{ip}' is invalid."
234
+ elsif !IPAddr.new(ip).private?
235
+ raise "Ip Address #{ip} must be private."
236
+ end
237
+ end
238
+
239
+ def validate_address_space(ip)
240
+ if ip.split("/").size != 2
241
+ raise "Cidr is invalid for IP #{ip}."
242
+ elsif valid?(ip)
243
+ raise "Address space '#{ip}' is invalid."
244
+ end
245
+ end
246
+
247
+ def address_prefix(ip, cidr)
248
+ ip + "/" + cidr.to_s
249
+ end
250
+
251
+ def valid?(ip)
252
+ (IPAddr.new(ip) rescue nil).nil?
253
+ end
254
+ end
255
+ end