mss-sdk 1.0.0

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.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/LICENSE.txt +0 -0
  4. data/README.md +192 -0
  5. data/bin/mss-rb +178 -0
  6. data/ca-bundle.crt +3554 -0
  7. data/lib/mss/core/async_handle.rb +89 -0
  8. data/lib/mss/core/cacheable.rb +76 -0
  9. data/lib/mss/core/client.rb +786 -0
  10. data/lib/mss/core/collection/simple.rb +81 -0
  11. data/lib/mss/core/collection/with_limit_and_next_token.rb +70 -0
  12. data/lib/mss/core/collection/with_next_token.rb +96 -0
  13. data/lib/mss/core/collection.rb +262 -0
  14. data/lib/mss/core/configuration.rb +527 -0
  15. data/lib/mss/core/credential_providers.rb +653 -0
  16. data/lib/mss/core/data.rb +251 -0
  17. data/lib/mss/core/deprecations.rb +83 -0
  18. data/lib/mss/core/endpoints.rb +36 -0
  19. data/lib/mss/core/http/connection_pool.rb +374 -0
  20. data/lib/mss/core/http/curb_handler.rb +150 -0
  21. data/lib/mss/core/http/handler.rb +88 -0
  22. data/lib/mss/core/http/net_http_handler.rb +144 -0
  23. data/lib/mss/core/http/patch.rb +98 -0
  24. data/lib/mss/core/http/request.rb +258 -0
  25. data/lib/mss/core/http/response.rb +80 -0
  26. data/lib/mss/core/indifferent_hash.rb +87 -0
  27. data/lib/mss/core/inflection.rb +55 -0
  28. data/lib/mss/core/ini_parser.rb +41 -0
  29. data/lib/mss/core/json_client.rb +46 -0
  30. data/lib/mss/core/json_parser.rb +75 -0
  31. data/lib/mss/core/json_request_builder.rb +34 -0
  32. data/lib/mss/core/json_response_parser.rb +78 -0
  33. data/lib/mss/core/lazy_error_classes.rb +107 -0
  34. data/lib/mss/core/log_formatter.rb +426 -0
  35. data/lib/mss/core/managed_file.rb +31 -0
  36. data/lib/mss/core/meta_utils.rb +44 -0
  37. data/lib/mss/core/model.rb +61 -0
  38. data/lib/mss/core/naming.rb +29 -0
  39. data/lib/mss/core/option_grammar.rb +737 -0
  40. data/lib/mss/core/options/json_serializer.rb +81 -0
  41. data/lib/mss/core/options/validator.rb +154 -0
  42. data/lib/mss/core/options/xml_serializer.rb +117 -0
  43. data/lib/mss/core/page_result.rb +74 -0
  44. data/lib/mss/core/policy.rb +938 -0
  45. data/lib/mss/core/query_client.rb +40 -0
  46. data/lib/mss/core/query_error_parser.rb +23 -0
  47. data/lib/mss/core/query_request_builder.rb +46 -0
  48. data/lib/mss/core/query_response_parser.rb +34 -0
  49. data/lib/mss/core/region.rb +84 -0
  50. data/lib/mss/core/region_collection.rb +79 -0
  51. data/lib/mss/core/resource.rb +412 -0
  52. data/lib/mss/core/resource_cache.rb +39 -0
  53. data/lib/mss/core/response.rb +214 -0
  54. data/lib/mss/core/response_cache.rb +49 -0
  55. data/lib/mss/core/rest_error_parser.rb +23 -0
  56. data/lib/mss/core/rest_json_client.rb +39 -0
  57. data/lib/mss/core/rest_request_builder.rb +153 -0
  58. data/lib/mss/core/rest_response_parser.rb +65 -0
  59. data/lib/mss/core/rest_xml_client.rb +46 -0
  60. data/lib/mss/core/service_interface.rb +82 -0
  61. data/lib/mss/core/signers/base.rb +45 -0
  62. data/lib/mss/core/signers/cloud_front.rb +55 -0
  63. data/lib/mss/core/signers/s3.rb +158 -0
  64. data/lib/mss/core/signers/version_2.rb +71 -0
  65. data/lib/mss/core/signers/version_3.rb +85 -0
  66. data/lib/mss/core/signers/version_3_https.rb +60 -0
  67. data/lib/mss/core/signers/version_4/chunk_signed_stream.rb +190 -0
  68. data/lib/mss/core/signers/version_4.rb +227 -0
  69. data/lib/mss/core/uri_escape.rb +43 -0
  70. data/lib/mss/core/xml/frame.rb +245 -0
  71. data/lib/mss/core/xml/frame_stack.rb +84 -0
  72. data/lib/mss/core/xml/grammar.rb +306 -0
  73. data/lib/mss/core/xml/parser.rb +69 -0
  74. data/lib/mss/core/xml/root_frame.rb +64 -0
  75. data/lib/mss/core/xml/sax_handlers/libxml.rb +46 -0
  76. data/lib/mss/core/xml/sax_handlers/nokogiri.rb +55 -0
  77. data/lib/mss/core/xml/sax_handlers/ox.rb +40 -0
  78. data/lib/mss/core/xml/sax_handlers/rexml.rb +46 -0
  79. data/lib/mss/core/xml/stub.rb +122 -0
  80. data/lib/mss/core.rb +602 -0
  81. data/lib/mss/errors.rb +161 -0
  82. data/lib/mss/rails.rb +194 -0
  83. data/lib/mss/s3/access_control_list.rb +262 -0
  84. data/lib/mss/s3/acl_object.rb +263 -0
  85. data/lib/mss/s3/acl_options.rb +200 -0
  86. data/lib/mss/s3/bucket.rb +757 -0
  87. data/lib/mss/s3/bucket_collection.rb +161 -0
  88. data/lib/mss/s3/bucket_lifecycle_configuration.rb +472 -0
  89. data/lib/mss/s3/bucket_region_cache.rb +51 -0
  90. data/lib/mss/s3/bucket_tag_collection.rb +110 -0
  91. data/lib/mss/s3/bucket_version_collection.rb +78 -0
  92. data/lib/mss/s3/cipher_io.rb +119 -0
  93. data/lib/mss/s3/client/xml.rb +265 -0
  94. data/lib/mss/s3/client.rb +2076 -0
  95. data/lib/mss/s3/config.rb +60 -0
  96. data/lib/mss/s3/cors_rule.rb +107 -0
  97. data/lib/mss/s3/cors_rule_collection.rb +193 -0
  98. data/lib/mss/s3/data_options.rb +190 -0
  99. data/lib/mss/s3/encryption_utils.rb +145 -0
  100. data/lib/mss/s3/errors.rb +93 -0
  101. data/lib/mss/s3/multipart_upload.rb +353 -0
  102. data/lib/mss/s3/multipart_upload_collection.rb +75 -0
  103. data/lib/mss/s3/object_collection.rb +355 -0
  104. data/lib/mss/s3/object_metadata.rb +102 -0
  105. data/lib/mss/s3/object_upload_collection.rb +76 -0
  106. data/lib/mss/s3/object_version.rb +153 -0
  107. data/lib/mss/s3/object_version_collection.rb +88 -0
  108. data/lib/mss/s3/paginated_collection.rb +74 -0
  109. data/lib/mss/s3/policy.rb +73 -0
  110. data/lib/mss/s3/prefix_and_delimiter_collection.rb +46 -0
  111. data/lib/mss/s3/prefixed_collection.rb +84 -0
  112. data/lib/mss/s3/presign_v4.rb +135 -0
  113. data/lib/mss/s3/presigned_post.rb +574 -0
  114. data/lib/mss/s3/region_detection.rb +75 -0
  115. data/lib/mss/s3/request.rb +61 -0
  116. data/lib/mss/s3/s3_object.rb +1795 -0
  117. data/lib/mss/s3/tree/branch_node.rb +67 -0
  118. data/lib/mss/s3/tree/child_collection.rb +103 -0
  119. data/lib/mss/s3/tree/leaf_node.rb +93 -0
  120. data/lib/mss/s3/tree/node.rb +21 -0
  121. data/lib/mss/s3/tree/parent.rb +86 -0
  122. data/lib/mss/s3/tree.rb +115 -0
  123. data/lib/mss/s3/uploaded_part.rb +81 -0
  124. data/lib/mss/s3/uploaded_part_collection.rb +83 -0
  125. data/lib/mss/s3/website_configuration.rb +101 -0
  126. data/lib/mss/s3.rb +161 -0
  127. data/lib/mss/version.rb +16 -0
  128. data/lib/mss-sdk.rb +2 -0
  129. data/lib/mss.rb +14 -0
  130. data/rails/init.rb +14 -0
  131. metadata +201 -0
@@ -0,0 +1,64 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ module MSS
14
+ module Core
15
+ module XML
16
+
17
+ class RootFrame < Frame
18
+
19
+ def initialize rules
20
+ @inflected = {}
21
+ @indexes = {}
22
+ setup_indexes(rules)
23
+ super(self, nil, 'XML', rules)
24
+ end
25
+
26
+ def build_child_frame element_name
27
+ Frame.new(self, self, element_name, rules)
28
+ end
29
+
30
+ def value
31
+ value = @data.values.find{|v| v.is_a?(Hash) }
32
+ value ||= {}
33
+ value.merge(@indexes)
34
+ end
35
+
36
+ def add_to_index index_name, key, value
37
+ @indexes[index_name] ||= {}
38
+ @indexes[index_name][key] = value
39
+ end
40
+
41
+ # The root frame maintains a cache of inflected element names.
42
+ def inflect element_name
43
+ @inflected[element_name] ||= Inflection.ruby_name(element_name).to_sym
44
+ end
45
+
46
+ protected
47
+
48
+ # recursively crawls the parser rules and looks for elements
49
+ # that index values. Adds an empty index for each of these.
50
+ def setup_indexes rules
51
+ if rules[:children]
52
+ rules[:children].each_pair do |child_name,child_rules|
53
+ if index = child_rules[:index]
54
+ @indexes[index[:name]] = {}
55
+ end
56
+ setup_indexes(child_rules)
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ require 'libxml'
14
+
15
+ module MSS
16
+ module Core
17
+ module XML
18
+ module SaxHandlers
19
+ class LibXML
20
+
21
+ include FrameStack
22
+ include ::LibXML::XML::SaxParser::Callbacks
23
+
24
+ def sax_parse xml
25
+ sax_parser = ::LibXML::XML::SaxParser.string(xml)
26
+ sax_parser.callbacks = self
27
+ sax_parser.parse
28
+ end
29
+
30
+ def on_start_element_ns element_name, attributes, *ignore
31
+ start_element(element_name, attributes)
32
+ end
33
+
34
+ def on_end_element_ns *ignore
35
+ end_element
36
+ end
37
+
38
+ def on_characters chars
39
+ text(chars)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ require 'nokogiri'
14
+
15
+ module MSS
16
+ module Core
17
+ module XML
18
+ module SaxHandlers
19
+ class Nokogiri
20
+
21
+ include FrameStack
22
+
23
+ def sax_parse xml
24
+ ::Nokogiri::XML::SAX::Parser.new(self).parse(xml)
25
+ end
26
+
27
+ def xmldecl(*args); end
28
+ def start_document; end
29
+ def end_document; end
30
+ def error(*args); end
31
+ def comment(*args); end
32
+
33
+ def start_element_namespace element_name, attributes = [], *ignore
34
+
35
+ attributes = attributes.map.inject({}) do |hash,attr|
36
+ hash.merge(attr.localname => attr.value)
37
+ end
38
+
39
+ start_element(element_name, attributes)
40
+
41
+ end
42
+
43
+ def end_element_namespace *ignore
44
+ end_element
45
+ end
46
+
47
+ def characters chars
48
+ set_text(chars)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ require 'stringio'
14
+ require 'ox'
15
+
16
+ module MSS
17
+ module Core
18
+ module XML
19
+ module SaxHandlers
20
+ class Ox
21
+
22
+ include FrameStack
23
+
24
+ def sax_parse xml
25
+ ::Ox.sax_parse(self, StringIO.new(xml))
26
+ end
27
+
28
+ def start_element name
29
+ super(name.to_s)
30
+ end
31
+
32
+ def attr name, value
33
+ attributes(name.to_s => value)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ require 'rexml/document'
14
+ require 'rexml/streamlistener'
15
+
16
+ module MSS
17
+ module Core
18
+ module XML
19
+ module SaxHandlers
20
+ class REXML
21
+
22
+ include FrameStack
23
+ include ::REXML::StreamListener
24
+
25
+ def sax_parse xml
26
+ source = ::REXML::Source.new(xml)
27
+ ::REXML::Parsers::StreamParser.new(source, self).parse
28
+ end
29
+
30
+ def tag_start name, attrs
31
+ start_element(name, attrs)
32
+ end
33
+
34
+ def tag_end name
35
+ end_element
36
+ end
37
+
38
+ def text(chars)
39
+ set_text(chars)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,122 @@
1
+ # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ #
8
+ # or in the "license" file accompanying this file. This file is
9
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10
+ # ANY KIND, either express or implied. See the License for the specific
11
+ # language governing permissions and limitations under the License.
12
+
13
+ module MSS
14
+ module Core
15
+ module XML
16
+
17
+ # This class takes the rules from an XML parser and then
18
+ # returns a stubbed reponse. This response has placeholder
19
+ # values based on the grammar, e.g.
20
+ #
21
+ # * Lists are stubbed with empty arrays
22
+ # * Indexes become empty hashes
23
+ # * Numeric types are returned as 0
24
+ # * etc
25
+ #
26
+ # This is used primarily to help with the MSS.stub! utility.
27
+ #
28
+ class Stub
29
+
30
+ # @param [Hash] rules
31
+ def initialize rules
32
+ @rules = rules
33
+ end
34
+
35
+ # @return [Hash]
36
+ attr_reader :rules
37
+
38
+ # Returns a hash with stubbed values as if it had parsed
39
+ # an empty xml document.
40
+ # @return [Hash]
41
+ def simulate
42
+ if rules[:children]
43
+ data = stub_data_for(rules)
44
+ apply_empty_indexes(rules, data)
45
+ data
46
+ else
47
+ {}
48
+ end
49
+ end
50
+
51
+ # Returns a hash with stubbed values as if it had parsed
52
+ # an empty xml document.
53
+ # @param [Hash] rules An XML::Parser rule set.
54
+ # @return [Hash]
55
+ def self.simulate rules
56
+ stub = Stub.new(rules)
57
+ stub.simulate
58
+ end
59
+
60
+ protected
61
+ def stub_data_for rules, data = {}
62
+ rules[:children].each_pair do |name,child_rules|
63
+
64
+ # skip ignored elements
65
+ if child_rules[:ignore]
66
+ stub_data_for(child_rules, data) if child_rules[:children]
67
+ next
68
+ end
69
+
70
+ orig_data = data
71
+ if wrapper = child_rules[:wrap]
72
+ data[wrapper] ||= {}
73
+ data = data[wrapper]
74
+ end
75
+
76
+ ruby_name = child_rules[:rename] ||
77
+ Inflection.ruby_name(name.to_s).to_sym
78
+
79
+ if child_rules[:list]
80
+ data[ruby_name] = []
81
+ elsif child_rules[:map]
82
+ data[ruby_name] = {}
83
+ elsif child_rules[:children] and !child_rules[:children].empty?
84
+ data[ruby_name] = stub_data_for(child_rules)
85
+ else
86
+ data[ruby_name] = case child_rules[:type]
87
+ when :integer then 0
88
+ when :float then 0.0
89
+ when :time then Time.now
90
+ when :datetime then Date.parse(Time.now.to_s)
91
+ when :boolean then false
92
+ else nil
93
+ end
94
+ end
95
+
96
+ # restore data incase it was redirected for wrapping
97
+ data = orig_data
98
+
99
+ end
100
+
101
+ data
102
+
103
+ end
104
+
105
+ protected
106
+ def apply_empty_indexes rules, data
107
+
108
+ return unless rules[:children]
109
+
110
+ rules[:children].each_pair do |name,child_rules|
111
+ if index = child_rules[:index]
112
+ data[index[:name]] = {}
113
+ end
114
+ apply_empty_indexes(child_rules, data)
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+ end
121
+ end
122
+ end