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,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
+ module MSS
14
+ module Core
15
+ class QueryClient < Core::Client
16
+
17
+ protected
18
+
19
+ def self.request_builder_for api_config, operation
20
+ QueryRequestBuilder.new(api_config[:api_version], operation)
21
+ end
22
+
23
+ def self.response_parser_for api_config, operation
24
+ QueryResponseParser.new(operation[:outputs])
25
+ end
26
+
27
+ def extract_error_details response
28
+ if
29
+ response.http_response.status >= 300 and
30
+ body = response.http_response.body and
31
+ error = errors_module::GRAMMAR.parse(body) and
32
+ error[:code]
33
+ then
34
+ [error[:code], error[:message]]
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
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
+
16
+ # @api private
17
+ module QueryErrorParser
18
+
19
+
20
+ end
21
+
22
+ end
23
+ 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
+ module MSS
14
+ module Core
15
+
16
+ # @api private
17
+ class QueryRequestBuilder
18
+
19
+ def initialize api_version, operation
20
+ @api_version = api_version
21
+ @operation_name = operation[:name]
22
+ @grammar = OptionGrammar.customize(operation[:inputs])
23
+ end
24
+
25
+ def populate_request request, options
26
+
27
+ now = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
28
+
29
+ request.headers['Content-Type'] =
30
+ "application/x-www-form-urlencoded; charset=utf-8"
31
+
32
+ request.add_param 'Timestamp', now
33
+ request.add_param 'Version', @api_version
34
+ request.add_param 'Action', @operation_name
35
+
36
+ @grammar.request_params(options).each do |param|
37
+ request.add_param(param)
38
+ end
39
+ request.body = request.url_encoded_params
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,34 @@
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
+
16
+ # @api private
17
+ class QueryResponseParser
18
+
19
+ def initialize parsing_rules
20
+ @parser = XML::Parser.new(parsing_rules)
21
+ end
22
+
23
+ def extract_data response
24
+ @parser.parse(response.http_response.body)
25
+ end
26
+
27
+ def simulate
28
+ @parser.simulate
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,84 @@
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
+
16
+ # Represents an MSS region. A region has a name and provides access
17
+ # to service interface objects.
18
+ #
19
+ # mss = MSS.regions['us-west-1']
20
+ #
21
+ # mss.dynamo_db.tables.map(&:name)
22
+ # mss.ec2.instances.map(&:id)
23
+ #
24
+ # Regions provide helper methods for each service.
25
+ #
26
+ # @attr_reader [AutoScaling] auto_scaling
27
+ # @attr_reader [CloudFormation] cloud_formation
28
+ # @attr_reader [CloudFront] cloud_front
29
+ # @attr_reader [CloudSearch] cloud_search
30
+ # @attr_reader [CloudTrail] cloud_trail
31
+ # @attr_reader [CloudWatch] cloud_watch
32
+ # @attr_reader [DataPipeline] data_pipeline
33
+ # @attr_reader [DirectConnect] direct_connect
34
+ # @attr_reader [DynamoDB] dynamo_db
35
+ # @attr_reader [EC2] ec2
36
+ # @attr_reader [ElasticBeanstalk] elastic_beanstalk
37
+ # @attr_reader [ElasticTranscoder] elastic_transcoder
38
+ # @attr_reader [ElastiCache] elasticache
39
+ # @attr_reader [ELB] elb
40
+ # @attr_reader [EMR] emr
41
+ # @attr_reader [Glacier] glacier
42
+ # @attr_reader [IAM] iam
43
+ # @attr_reader [ImportExport] import_export
44
+ # @attr_reader [Kinesis] kinesis
45
+ # @attr_reader [OpsWorks] ops_works
46
+ # @attr_reader [RDS] rds
47
+ # @attr_reader [Redshift] redshift
48
+ # @attr_reader [Route53] route_53
49
+ # @attr_reader [S3] s3
50
+ # @attr_reader [SimpleEmailService] ses
51
+ # @attr_reader [SimpleDB] simple_db
52
+ # @attr_reader [SNS] sns
53
+ # @attr_reader [SQS] sqs
54
+ # @attr_reader [StorageGateway] storage_gateway
55
+ # @attr_reader [STS] sts
56
+ # @attr_reader [Support] support
57
+ # @attr_reader [SimpleWorkflow] swf
58
+ #
59
+ class Region
60
+
61
+ # @param [String] name
62
+ # @option options [Configuration] :config (MSS.config)
63
+ def initialize name, options = {}
64
+ @name = name
65
+ @config = options[:config] || MSS.config
66
+ @config = @config.with(:region => name)
67
+ end
68
+
69
+ # @return [String] The name of this region (e.g. 'us-west-1').
70
+ attr_reader :name
71
+
72
+ # @return [Configuration]
73
+ attr_reader :config
74
+
75
+ MSS::SERVICES.values.each do |svc|
76
+ define_method(svc.method_name) do
77
+ MSS.const_get(svc.class_name).new(:config => config)
78
+ end
79
+ alias_method(svc.method_alias, svc.method_name) if svc.method_alias
80
+ end
81
+
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,79 @@
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 'uri'
14
+ require 'net/http'
15
+ require 'json'
16
+
17
+ module MSS
18
+ module Core
19
+
20
+ # Provides a mechnasim to discover available regions. This can useful if
21
+ # you want to perform an operation for a service in every region.
22
+ #
23
+ # # call the EC2 DescribeInstances operation in each region
24
+ # MSS.regions.each do |region|
25
+ # resp = region.ec2.client.describe_instances
26
+ # end
27
+ #
28
+ # You can also use this collection as a shortcut for creating
29
+ # a service interface with a given region.
30
+ #
31
+ # s3 = MSS.regions['us-west-1'].s3
32
+ #
33
+ # This collection enumerates and returns {Region} objects.
34
+ #
35
+ # @see Region
36
+ class RegionCollection
37
+
38
+ include Enumerable
39
+
40
+ # @option options [Configuration] :config (MSS.config)
41
+ # @option options [ServiceInterface] :service (nil)
42
+ # @api private
43
+ def initialize options = {}
44
+ @config = options[:config] || MSS.config
45
+ @service = options[:service]
46
+ end
47
+
48
+ # @return [Configuration]
49
+ attr_reader :config
50
+
51
+ # @param [String] name
52
+ # @return [Region] Returns a {Region} with the given name.
53
+ def [] name
54
+ Region.new(name, :config => config)
55
+ end
56
+
57
+ # Enumerates public regions (non US Gov regions).
58
+ # @yieldparam [region] Region
59
+ def each &block
60
+ public_regions.each do |region_name|
61
+ yield(self[region_name])
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ # @return [Array<String>] Returns an array of non-gov-cloud region names.
68
+ def public_regions
69
+ return ['us-east-1'] if @service and @service.global_endpoint?
70
+ data = Endpoints.endpoints
71
+ regions = @service ?
72
+ data['services'][@service.endpoint_prefix] :
73
+ data['regions'].keys
74
+ regions.reject{ |r| r =~ /us-gov/ }.reject{ |r| r =~ /^cn-/ }
75
+ end
76
+
77
+ end
78
+ end
79
+ end