gitlab-fog-azure-rm 1.9.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +3 -0
  4. data/gitlab-fog-azure-rm.gemspec +1 -3
  5. data/lib/fog/azurerm/version.rb +1 -1
  6. data/vendor/azure-storage-ruby/.env_sample +8 -0
  7. data/vendor/azure-storage-ruby/.gitignore +35 -0
  8. data/vendor/azure-storage-ruby/.rubocop.yml +132 -0
  9. data/vendor/azure-storage-ruby/.travis.yml +23 -0
  10. data/vendor/azure-storage-ruby/BreakingChanges.md +34 -0
  11. data/vendor/azure-storage-ruby/CONTRIBUTING.md +74 -0
  12. data/vendor/azure-storage-ruby/ChangeLog.md +198 -0
  13. data/vendor/azure-storage-ruby/Gemfile +41 -0
  14. data/vendor/azure-storage-ruby/README.md +48 -0
  15. data/vendor/azure-storage-ruby/Rakefile +216 -0
  16. data/vendor/azure-storage-ruby/SECURITY.md +41 -0
  17. data/vendor/azure-storage-ruby/blob/BreakingChanges.md +10 -0
  18. data/vendor/azure-storage-ruby/blob/ChangeLog.md +33 -0
  19. data/vendor/azure-storage-ruby/blob/Gemfile +30 -0
  20. data/vendor/azure-storage-ruby/blob/LICENSE.txt +21 -0
  21. data/vendor/azure-storage-ruby/blob/README.md +188 -0
  22. data/vendor/azure-storage-ruby/blob/azure-storage-blob.gemspec +52 -0
  23. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/append.rb +244 -0
  24. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/autoload.rb +47 -0
  25. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/blob.rb +932 -0
  26. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/blob_service.rb +720 -0
  27. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/block.rb +530 -0
  28. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/container.rb +634 -0
  29. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/default.rb +171 -0
  30. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/page.rb +566 -0
  31. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/serialization.rb +351 -0
  32. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob/version.rb +49 -0
  33. data/vendor/azure-storage-ruby/blob/lib/azure/storage/blob.rb +26 -0
  34. data/vendor/azure-storage-ruby/common/BreakingChanges.md +8 -0
  35. data/vendor/azure-storage-ruby/common/ChangeLog.md +41 -0
  36. data/vendor/azure-storage-ruby/common/Gemfile +30 -0
  37. data/vendor/azure-storage-ruby/common/LICENSE.txt +21 -0
  38. data/vendor/azure-storage-ruby/common/README.md +146 -0
  39. data/vendor/azure-storage-ruby/common/azure-storage-common.gemspec +57 -0
  40. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/authorizer.rb +36 -0
  41. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/shared_key.rb +125 -0
  42. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/shared_key_lite.rb +48 -0
  43. data/vendor/azure-storage-ruby/common/lib/azure/core/auth/signer.rb +51 -0
  44. data/vendor/azure-storage-ruby/common/lib/azure/core/default.rb +23 -0
  45. data/vendor/azure-storage-ruby/common/lib/azure/core/error.rb +21 -0
  46. data/vendor/azure-storage-ruby/common/lib/azure/core/filtered_service.rb +45 -0
  47. data/vendor/azure-storage-ruby/common/lib/azure/core/http/debug_filter.rb +36 -0
  48. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_error.rb +135 -0
  49. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_filter.rb +53 -0
  50. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_request.rb +195 -0
  51. data/vendor/azure-storage-ruby/common/lib/azure/core/http/http_response.rb +102 -0
  52. data/vendor/azure-storage-ruby/common/lib/azure/core/http/retry_policy.rb +84 -0
  53. data/vendor/azure-storage-ruby/common/lib/azure/core/http/signer_filter.rb +33 -0
  54. data/vendor/azure-storage-ruby/common/lib/azure/core/service.rb +46 -0
  55. data/vendor/azure-storage-ruby/common/lib/azure/core/signed_service.rb +45 -0
  56. data/vendor/azure-storage-ruby/common/lib/azure/core/utility.rb +244 -0
  57. data/vendor/azure-storage-ruby/common/lib/azure/core/version.rb +33 -0
  58. data/vendor/azure-storage-ruby/common/lib/azure/core.rb +48 -0
  59. data/vendor/azure-storage-ruby/common/lib/azure/http_response_helper.rb +38 -0
  60. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/autoload.rb +62 -0
  61. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client.rb +162 -0
  62. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client_options.rb +363 -0
  63. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/client_options_error.rb +41 -0
  64. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/configurable.rb +212 -0
  65. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/anonymous_signer.rb +43 -0
  66. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature.rb +30 -0
  67. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature_generator.rb +399 -0
  68. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_access_signature_signer.rb +57 -0
  69. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/shared_key.rb +60 -0
  70. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/auth/token_signer.rb +43 -0
  71. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/autoload.rb +53 -0
  72. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/error.rb +43 -0
  73. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/exponential_retry_filter.rb +64 -0
  74. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/linear_retry_filter.rb +55 -0
  75. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/filter/retry_filter.rb +300 -0
  76. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/http_client.rb +82 -0
  77. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/sr.rb +85 -0
  78. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/token_credential.rb +64 -0
  79. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core/utility.rb +261 -0
  80. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/core.rb +35 -0
  81. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/default.rb +868 -0
  82. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/access_policy.rb +37 -0
  83. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/cors.rb +38 -0
  84. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/cors_rule.rb +48 -0
  85. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/enumeration_results.rb +32 -0
  86. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/geo_replication.rb +40 -0
  87. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/logging.rb +47 -0
  88. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/metrics.rb +45 -0
  89. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/retention_policy.rb +37 -0
  90. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/serialization.rb +335 -0
  91. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/signed_identifier.rb +40 -0
  92. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service.rb +322 -0
  93. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service_properties.rb +48 -0
  94. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/storage_service_stats.rb +39 -0
  95. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/service/user_delegation_key.rb +50 -0
  96. data/vendor/azure-storage-ruby/common/lib/azure/storage/common/version.rb +49 -0
  97. data/vendor/azure-storage-ruby/common/lib/azure/storage/common.rb +26 -0
  98. metadata +95 -31
@@ -0,0 +1,37 @@
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
+ module Azure::Storage::Common
27
+ module Service
28
+ class AccessPolicy
29
+ def initialize
30
+ yield self if block_given?
31
+ end
32
+ attr_accessor :start
33
+ attr_accessor :expiry
34
+ attr_accessor :permission
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
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
28
+ module Service
29
+ class Cors
30
+ def initialize
31
+ @cors_rules = []
32
+ yield self if block_given?
33
+ end
34
+
35
+ attr_accessor :cors_rules
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,48 @@
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
28
+ module Service
29
+ class CorsRule
30
+ def initialize
31
+ # All CORS rule elements are required if the CorsRule element is specified.
32
+ # The request will fail with error code 400 (Bad Request) if any element is missing.
33
+ @allowed_origins = []
34
+ @allowed_methods = []
35
+ @exposed_headers = []
36
+ @allowed_headers = []
37
+ @max_age_in_seconds = 0
38
+ yield self if block_given?
39
+ end
40
+
41
+ attr_accessor :allowed_origins
42
+ attr_accessor :allowed_methods
43
+ attr_accessor :max_age_in_seconds
44
+ attr_accessor :exposed_headers
45
+ attr_accessor :allowed_headers
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,32 @@
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
+ module Azure::Storage::Common
27
+ module Service
28
+ class EnumerationResults < Array
29
+ attr_accessor :continuation_token
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,40 @@
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
28
+ module Service
29
+ class GeoReplication
30
+ def initialize
31
+ @status = nil
32
+ @last_sync_time = nil
33
+ yield self if block_given?
34
+ end
35
+
36
+ attr_accessor :status
37
+ attr_accessor :last_sync_time
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ require "azure/storage/common/service/retention_policy"
27
+
28
+ module Azure::Storage::Common
29
+ module Service
30
+ class Logging
31
+ def initialize
32
+ @version = "1.0"
33
+ @delete = false
34
+ @read = false
35
+ @write = false
36
+ @retention_policy = RetentionPolicy.new
37
+ yield self if block_given?
38
+ end
39
+
40
+ attr_accessor :version
41
+ attr_accessor :delete
42
+ attr_accessor :read
43
+ attr_accessor :write
44
+ attr_accessor :retention_policy
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ require "azure/storage/common/service/retention_policy"
27
+
28
+ module Azure::Storage::Common
29
+ module Service
30
+ class Metrics
31
+ def initialize
32
+ @version = "1.0"
33
+ @enabled = false
34
+ @include_apis = false
35
+ @retention_policy = RetentionPolicy.new
36
+ yield self if block_given?
37
+ end
38
+
39
+ attr_accessor :version
40
+ attr_accessor :enabled
41
+ attr_accessor :include_apis
42
+ attr_accessor :retention_policy
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,37 @@
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
+ module Azure::Storage::Common
27
+ module Service
28
+ class RetentionPolicy
29
+ def initialize
30
+ @enabled = false
31
+ yield self if block_given?
32
+ end
33
+ attr_accessor :enabled
34
+ attr_accessor :days
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,335 @@
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 "nokogiri"
27
+ require "time"
28
+
29
+ require "azure/storage/common/service/enumeration_results"
30
+ require "azure/storage/common/service/signed_identifier"
31
+ require "azure/storage/common/service/access_policy"
32
+ require "azure/storage/common/service/storage_service_properties"
33
+ require "azure/storage/common/service/logging"
34
+ require "azure/storage/common/service/metrics"
35
+ require "azure/storage/common/service/retention_policy"
36
+ require "azure/storage/common/service/cors"
37
+ require "azure/storage/common/service/cors_rule"
38
+ require "azure/storage/common/service/storage_service_stats"
39
+
40
+ module Azure::Storage::Common
41
+ module Service
42
+ module Serialization
43
+ module ClassMethods
44
+ def signed_identifiers_from_xml(xml)
45
+ xml = slopify(xml)
46
+ expect_node("SignedIdentifiers", xml)
47
+
48
+ identifiers = []
49
+ return identifiers unless (xml > "SignedIdentifier").any?
50
+
51
+ if xml.SignedIdentifier.count == 0
52
+ identifiers.push(signed_identifier_from_xml(xml.SignedIdentifier))
53
+ else
54
+ xml.SignedIdentifier.each { |identifier_node|
55
+ identifiers.push(signed_identifier_from_xml(identifier_node))
56
+ }
57
+ end
58
+
59
+ identifiers
60
+ end
61
+
62
+ def signed_identifiers_to_xml(signed_identifiers)
63
+ builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
64
+ xml.SignedIdentifiers {
65
+ signed_identifiers.each do |identifier|
66
+ xml.SignedIdentifier {
67
+ xml.Id identifier.id
68
+ xml.AccessPolicy {
69
+ xml.Start identifier.access_policy.start
70
+ xml.Expiry identifier.access_policy.expiry
71
+ xml.Permission identifier.access_policy.permission
72
+ }
73
+ }
74
+ end
75
+ }
76
+ end
77
+ builder.to_xml
78
+ end
79
+
80
+ def signed_identifier_from_xml(xml)
81
+ xml = slopify(xml)
82
+ expect_node("SignedIdentifier", xml)
83
+
84
+ SignedIdentifier.new do |identifier|
85
+ identifier.id = xml.Id.text if (xml > "Id").any?
86
+ identifier.access_policy = access_policy_from_xml(xml.AccessPolicy) if (xml > "AccessPolicy").any?
87
+ end
88
+ end
89
+
90
+ def access_policy_from_xml(xml)
91
+ xml = slopify(xml)
92
+ expect_node("AccessPolicy", xml)
93
+
94
+ AccessPolicy.new do |policy|
95
+ policy.start = xml.Start.text if (xml > "Start").any?
96
+ policy.expiry = xml.Expiry.text if (xml > "Expiry").any?
97
+ policy.permission = xml.Permission.text if (xml > "Permission").any?
98
+ end
99
+ end
100
+
101
+ def enumeration_results_from_xml(xml, results)
102
+ xml = slopify(xml)
103
+ expect_node("EnumerationResults", xml)
104
+
105
+ results = results || Service::EnumerationResults.new;
106
+
107
+ results.continuation_token = xml.NextMarker.text if (xml > "NextMarker").any?
108
+ results
109
+ end
110
+
111
+ def metadata_from_xml(xml)
112
+ xml = slopify(xml)
113
+ expect_node("Metadata", xml)
114
+
115
+ metadata = {}
116
+
117
+ xml.children.each { |meta_node|
118
+
119
+ key = meta_node.name.downcase
120
+ if metadata.has_key? key
121
+ metadata[key] = [metadata[key]] unless metadata[key].respond_to? :push
122
+ metadata[key].push(meta_node.text)
123
+ else
124
+ metadata[key] = meta_node.text
125
+ end
126
+ }
127
+ metadata
128
+ end
129
+
130
+ def metadata_from_headers(headers)
131
+ metadata = {}
132
+
133
+ headers.each { |k, v|
134
+ if key = k[/^x-ms-meta-(.*)/, 1]
135
+ if metadata.has_key? key
136
+ metadata[key] = [metadata[key]] unless metadata[key].respond_to? :push
137
+ metadata[key].push(v)
138
+ else
139
+ metadata[key] = v
140
+ end
141
+ end
142
+ }
143
+
144
+ metadata
145
+ end
146
+
147
+ def retention_policy_to_xml(retention_policy, xml)
148
+ xml.RetentionPolicy {
149
+ xml.Enabled retention_policy.enabled
150
+ xml.Days retention_policy.days if retention_policy.enabled && retention_policy.days
151
+ } if retention_policy
152
+ end
153
+
154
+ def retention_policy_from_xml(xml)
155
+ xml = slopify(xml)
156
+ expect_node("RetentionPolicy", xml)
157
+
158
+ RetentionPolicy.new do |policy|
159
+ policy.enabled = to_bool(xml.Enabled.text) if (xml > "Enabled").any?
160
+ policy.days = xml.Days.text.to_i if (xml > "Days").any?
161
+ end
162
+ end
163
+
164
+ def metrics_to_xml_children(metrics, xml)
165
+ return unless metrics
166
+ xml.Version metrics.version
167
+ xml.Enabled metrics.enabled
168
+ xml.IncludeAPIs metrics.include_apis if metrics.enabled
169
+ retention_policy_to_xml(metrics.retention_policy, xml) if metrics.retention_policy
170
+ end
171
+
172
+ def hour_metrics_to_xml(metrics, xml)
173
+ xml.HourMetrics {
174
+ metrics_to_xml_children(metrics, xml)
175
+ } if metrics
176
+ end
177
+
178
+ def minute_metrics_to_xml(metrics, xml)
179
+ xml.MinuteMetrics {
180
+ metrics_to_xml_children(metrics, xml)
181
+ } if metrics
182
+ end
183
+
184
+ def metrics_from_xml(xml)
185
+ xml = slopify(xml)
186
+
187
+ Metrics.new do |metrics|
188
+ metrics.version = xml.Version.text if (xml > "Version").any?
189
+ metrics.enabled = to_bool(xml.Enabled.text) if (xml > "Enabled").any?
190
+ metrics.include_apis = to_bool(xml.IncludeAPIs.text) if (xml > "IncludeAPIs").any?
191
+ metrics.retention_policy = retention_policy_from_xml(xml.RetentionPolicy)
192
+ end
193
+ end
194
+
195
+ def logging_to_xml(logging, xml)
196
+ xml.Logging {
197
+ xml.Version logging.version
198
+ xml.Delete logging.delete
199
+ xml.Read logging.read
200
+ xml.Write logging.write
201
+ retention_policy_to_xml(logging.retention_policy, xml)
202
+ } if logging
203
+ end
204
+
205
+ def logging_from_xml(xml)
206
+ xml = slopify(xml)
207
+ expect_node("Logging", xml)
208
+
209
+ Logging.new do |logging|
210
+ logging.version = xml.Version.text if (xml > "Version").any?
211
+ logging.delete = to_bool(xml.Delete.text) if (xml > "Delete").any?
212
+ logging.read = to_bool(xml.Read.text) if (xml > "Read").any?
213
+ logging.write = to_bool(xml.Write.text) if (xml > "Write").any?
214
+ logging.retention_policy = retention_policy_from_xml(xml.RetentionPolicy)
215
+ end
216
+ end
217
+
218
+ def cors_to_xml(cors, xml)
219
+ xml.Cors {
220
+ cors.cors_rules.to_a.each do |cors_rule|
221
+ cors_rule_to_xml(cors_rule, xml)
222
+ end
223
+ }
224
+ end
225
+
226
+ def cors_rule_to_xml(cors_rule, xml)
227
+ xml.CorsRule {
228
+ xml.AllowedOrigins cors_rule.allowed_origins.join(",") if cors_rule.allowed_origins
229
+ xml.AllowedMethods cors_rule.allowed_methods.join(",") if cors_rule.allowed_methods
230
+ xml.MaxAgeInSeconds cors_rule.max_age_in_seconds if cors_rule.max_age_in_seconds
231
+ xml.ExposedHeaders cors_rule.exposed_headers.join(",") if cors_rule.exposed_headers
232
+ xml.AllowedHeaders cors_rule.allowed_headers.join(",") if cors_rule.allowed_headers
233
+ }
234
+ end
235
+
236
+ def cors_from_xml(xml)
237
+ xml = slopify(xml)
238
+ expect_node("Cors", xml)
239
+
240
+ Cors.new do |cors|
241
+ cors.cors_rules = xml.children.to_a.map { |child| cors_rule_from_xml(child) }
242
+ end
243
+ end
244
+
245
+ def cors_rule_from_xml(xml)
246
+ xml = slopify(xml)
247
+ expect_node("CorsRule", xml)
248
+
249
+ CorsRule.new do |cors_rule|
250
+ cors_rule.allowed_origins = ary_from_node(xml.AllowedOrigins) if (xml > "AllowedOrigins").any?
251
+ cors_rule.allowed_methods = ary_from_node(xml.AllowedMethods) if (xml > "AllowedMethods").any?
252
+ cors_rule.max_age_in_seconds = xml.MaxAgeInSeconds.text.to_i if (xml > "MaxAgeInSeconds").any?
253
+ cors_rule.exposed_headers = ary_from_node(xml.ExposedHeaders) if (xml > "ExposedHeaders").any?
254
+ cors_rule.allowed_headers = ary_from_node(xml.AllowedHeaders) if (xml > "AllowedHeaders").any?
255
+ end
256
+ end
257
+
258
+ def geo_replication_from_xml(xml)
259
+ xml = slopify(xml)
260
+ expect_node("GeoReplication", xml)
261
+
262
+ GeoReplication.new do |geo_replication|
263
+ geo_replication.status = xml.Status.text if (xml > "Status").any?
264
+ geo_replication.last_sync_time =
265
+ begin
266
+ Time.parse(xml.LastSyncTime.text) if (xml > "LastSyncTime").any?
267
+ rescue
268
+ nil
269
+ end
270
+ end
271
+ end
272
+
273
+ def ary_from_node(node)
274
+ node.text.split(",").map { |s| s.strip }
275
+ end
276
+
277
+ def service_properties_to_xml(properties)
278
+ builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
279
+ xml.StorageServiceProperties {
280
+ xml.DefaultServiceVersion(properties.default_service_version) if properties.default_service_version
281
+ logging_to_xml(properties.logging, xml) if properties.logging
282
+ hour_metrics_to_xml(properties.hour_metrics, xml) if properties.hour_metrics
283
+ minute_metrics_to_xml(properties.minute_metrics, xml) if properties.minute_metrics
284
+ cors_to_xml(properties.cors, xml) if properties.cors
285
+ }
286
+ end
287
+ builder.to_xml
288
+ end
289
+
290
+ def service_properties_from_xml(xml)
291
+ xml = slopify(xml)
292
+ expect_node("StorageServiceProperties", xml)
293
+
294
+ StorageServiceProperties.new do |props|
295
+ props.default_service_version = xml.DefaultServiceVersion.text if (xml > "DefaultServiceVersion").any?
296
+ props.logging = logging_from_xml(xml.Logging) if (xml > "Logging").any?
297
+ props.hour_metrics = metrics_from_xml(xml.HourMetrics) if (xml > "HourMetrics").any?
298
+ props.minute_metrics = metrics_from_xml(xml.MinuteMetrics) if (xml > "MinuteMetrics").any?
299
+ props.cors = cors_from_xml(xml.Cors) if (xml > "Cors").any?
300
+ end
301
+ end
302
+
303
+ def service_stats_from_xml(xml)
304
+ xml = slopify(xml)
305
+ expect_node("StorageServiceStats", xml)
306
+
307
+ StorageServiceStats.new do |stats|
308
+ stats.geo_replication = geo_replication_from_xml(xml.GeoReplication)
309
+ end
310
+ end
311
+
312
+ def to_bool(s)
313
+ (s || "").downcase == "true"
314
+ end
315
+
316
+ def slopify(xml)
317
+ node = (xml.is_a? String) ? Nokogiri.Slop(xml).root : xml
318
+ node.slop! if node.is_a? Nokogiri::XML::Document unless node.respond_to? :method_missing
319
+ node = node.root if node.is_a? Nokogiri::XML::Document
320
+ node
321
+ end
322
+
323
+ def expect_node(node_name, xml)
324
+ raise "Xml is not a #{node_name} node. xml:\n#{xml}" unless xml.name == node_name
325
+ end
326
+ end
327
+
328
+ extend ClassMethods
329
+
330
+ def self.included(other)
331
+ other.extend(ClassMethods)
332
+ end
333
+ end
334
+ end
335
+ end