aws-sdk 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +1 -0
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +1 -0
- data/lib/aws/api_config/CloudFront-2012-05-05.yml +2137 -0
- data/lib/aws/api_config/CloudWatch-2010-08-01.yml +9 -0
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +616 -0
- data/lib/aws/api_config/EC2-2012-07-20.yml +1 -0
- data/lib/aws/api_config/ELB-2012-06-01.yml +1 -0
- data/lib/aws/api_config/EMR-2009-03-31.yml +1 -0
- data/lib/aws/api_config/IAM-2010-05-08.yml +1 -0
- data/lib/aws/api_config/Route53-2012-02-29.yml +350 -349
- data/lib/aws/api_config/SNS-2010-03-31.yml +1 -0
- data/lib/aws/api_config/SQS-2011-10-01.yml +1 -0
- data/lib/aws/api_config/STS-2011-06-15.yml +1 -0
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +1 -0
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +62 -0
- data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +1637 -0
- data/lib/aws/auto_scaling/client.rb +2 -37
- data/lib/aws/cloud_formation/client.rb +2 -17
- data/lib/aws/cloud_watch/client.rb +2 -15
- data/lib/aws/core.rb +24 -4
- data/lib/aws/core/client.rb +115 -46
- data/lib/aws/core/configuration.rb +6 -0
- data/lib/aws/core/credential_providers.rb +1 -0
- data/lib/aws/core/http/curb_handler.rb +3 -3
- data/lib/aws/core/http/httparty_handler.rb +15 -15
- data/lib/aws/core/json_client.rb +19 -77
- data/lib/aws/core/json_error_parser.rb +25 -0
- data/lib/aws/core/json_request_builder.rb +34 -0
- data/lib/aws/core/json_response_parser.rb +81 -0
- data/lib/aws/core/log_formatter.rb +25 -25
- data/lib/aws/core/option_grammar.rb +123 -115
- data/lib/aws/core/options/xml_serializer.rb +13 -9
- data/lib/aws/core/query_client.rb +13 -104
- data/lib/aws/core/query_error_parser.rb +24 -0
- data/lib/aws/core/query_request_builder.rb +47 -0
- data/lib/aws/core/query_response_parser.rb +35 -0
- data/lib/aws/core/rest_client.rb +13 -62
- data/lib/aws/core/rest_error_parser.rb +24 -0
- data/lib/aws/core/rest_request_builder.rb +124 -0
- data/lib/aws/core/rest_response_parser.rb +48 -0
- data/lib/aws/core/xml/parser.rb +2 -2
- data/lib/aws/core/xml/root_frame.rb +1 -1
- data/lib/aws/dynamo_db.rb +10 -9
- data/lib/aws/dynamo_db/binary.rb +35 -0
- data/lib/aws/dynamo_db/client.rb +103 -20
- data/lib/aws/dynamo_db/config.rb +2 -0
- data/lib/aws/dynamo_db/item.rb +3 -0
- data/lib/aws/dynamo_db/primary_key_element.rb +2 -1
- data/lib/aws/dynamo_db/table.rb +32 -36
- data/lib/aws/dynamo_db/table_collection.rb +13 -13
- data/lib/aws/dynamo_db/types.rb +34 -9
- data/lib/aws/ec2/client.rb +884 -344
- data/lib/aws/ec2/filtered_collection.rb +2 -3
- data/lib/aws/elb/client.rb +59 -45
- data/lib/aws/emr/client.rb +2 -11
- data/lib/aws/iam/client.rb +9 -80
- data/lib/aws/record/hash_model/attributes.rb +28 -13
- data/lib/aws/route_53/client.rb +6 -16
- data/lib/aws/s3/client.rb +2 -1
- data/lib/aws/s3/encryption_utils.rb +2 -7
- data/lib/aws/s3/s3_object.rb +5 -0
- data/lib/aws/simple_db/client.rb +2 -14
- data/lib/aws/simple_email_service/client.rb +35 -19
- data/lib/aws/simple_email_service/identity.rb +49 -10
- data/lib/aws/simple_email_service/identity_collection.rb +4 -4
- data/lib/aws/simple_workflow/client.rb +2 -38
- data/lib/aws/sns/client.rb +2 -19
- data/lib/aws/sqs/client.rb +2 -19
- data/lib/aws/sqs/errors.rb +5 -5
- data/lib/aws/sts/client.rb +2 -6
- metadata +14 -5
- data/lib/aws/core/rest_client/input_handler.rb +0 -145
- data/lib/aws/core/rest_client/output_handler.rb +0 -53
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright 2011-2012 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
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
module Core
|
16
|
+
|
17
|
+
# @private
|
18
|
+
module JSONErrorParser
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright 2011-2012 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
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
module Core
|
16
|
+
|
17
|
+
# @private
|
18
|
+
class JSONRequestBuilder
|
19
|
+
|
20
|
+
def initialize target_prefix, operation
|
21
|
+
@x_amz_target = target_prefix + operation[:name]
|
22
|
+
@grammar = OptionGrammar.customize(operation[:inputs])
|
23
|
+
end
|
24
|
+
|
25
|
+
def populate_request request, options
|
26
|
+
request.headers["content-type"] = "application/x-amz-json-1.0"
|
27
|
+
request.headers["x-amz-target"] = @x_amz_target
|
28
|
+
request.body = @grammar.to_json(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright 2011-2012 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
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'json'
|
15
|
+
require 'time'
|
16
|
+
require 'bigdecimal'
|
17
|
+
require 'base64'
|
18
|
+
|
19
|
+
module AWS
|
20
|
+
module Core
|
21
|
+
|
22
|
+
# @private
|
23
|
+
class JSONResponseParser
|
24
|
+
|
25
|
+
def initialize rules
|
26
|
+
@rules = rules
|
27
|
+
end
|
28
|
+
|
29
|
+
def extract_data response
|
30
|
+
body = response.http_response.body
|
31
|
+
body = "{}" if [nil, ''].include?(body)
|
32
|
+
translate(JSON.load(body))
|
33
|
+
end
|
34
|
+
|
35
|
+
def simulate
|
36
|
+
{}
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
# @param [Hash] values
|
42
|
+
# @param [Hash] rules
|
43
|
+
# @return [Hash]
|
44
|
+
def translate values, rules = @rules
|
45
|
+
rules.inject({}) do |data,(key,rule)|
|
46
|
+
if values.key?(key)
|
47
|
+
#data.merge(rule[:symbol] => translate_value(values[key], rule))
|
48
|
+
data.merge(key => translate_value(values[key], rule))
|
49
|
+
else
|
50
|
+
data
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def translate_hash values, rules
|
56
|
+
translate(values, rules[:members])
|
57
|
+
end
|
58
|
+
|
59
|
+
def translate_map values, rules
|
60
|
+
values.inject({}) do |data,(key,value)|
|
61
|
+
data.merge(key => translate_value(value, rules[:members]))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def translate_value value, rule
|
66
|
+
case
|
67
|
+
when value.is_a?(Array) then value.map{|v| translate_value(v, rule) }
|
68
|
+
#when rule[:list] then value.map{|v| translate_value(v, rule) }
|
69
|
+
when rule[:type] == :hash then translate_hash(value, rule)
|
70
|
+
when rule[:type] == :map then translate_map(value, rule)
|
71
|
+
when rule[:type] == :blob then Base64.decode64(value)
|
72
|
+
when rule[:type] == :time then Time.at(value)
|
73
|
+
when rule[:type] == :big_decimal then BigDecimal.new(value)
|
74
|
+
else value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -51,8 +51,8 @@ module AWS
|
|
51
51
|
# * {LogFormatter.colored}
|
52
52
|
#
|
53
53
|
# = Pattern Substitutions
|
54
|
-
#
|
55
|
-
# You can put any of these placeholders into you pattern.
|
54
|
+
#
|
55
|
+
# You can put any of these placeholders into you pattern.
|
56
56
|
#
|
57
57
|
# [+:service+]
|
58
58
|
# The AWS service name (e.g. 'S3', 'EC2', 'SimpleDB', etc)
|
@@ -61,32 +61,32 @@ module AWS
|
|
61
61
|
# The AWS region name (e.g. 'us-east-1', 'us-west-1', etc)
|
62
62
|
#
|
63
63
|
# [+:operation+]
|
64
|
-
# The name of the client request method. This maps to the name of
|
64
|
+
# The name of the client request method. This maps to the name of
|
65
65
|
# the serivce API operation (e.g. :describe_instances).
|
66
66
|
#
|
67
|
-
# [+:options+]
|
67
|
+
# [+:options+]
|
68
68
|
# The hash of options passed to the client request method.
|
69
69
|
# Long strings are truncated/summarized if they excede the log
|
70
70
|
# formatters {#max_string_size}. Other objects are inspected.
|
71
|
-
#
|
72
|
-
# [+:retry_count+]
|
71
|
+
#
|
72
|
+
# [+:retry_count+]
|
73
73
|
# The number of times a client request was retried.
|
74
74
|
# Throttlings and service errors trigger the automatic retry logic.
|
75
75
|
# This value indicates how many extra attempts were made before
|
76
76
|
# getting a successful response or giving up.
|
77
77
|
#
|
78
|
-
# [+:duration+]
|
78
|
+
# [+:duration+]
|
79
79
|
# The time it took to generate a response, expressed
|
80
80
|
# in decimal seconds. This time includes everything from
|
81
81
|
# calling the client request method, until that method returns
|
82
82
|
# a value (event retries and retry delays).
|
83
83
|
#
|
84
|
-
# [+:error_class+]
|
85
|
-
# The class name of the error returned by the
|
84
|
+
# [+:error_class+]
|
85
|
+
# The class name of the error returned by the
|
86
86
|
# service. If no error was returned, this will be replcaed by
|
87
87
|
# an empty string.
|
88
88
|
#
|
89
|
-
# [+:error_message+]
|
89
|
+
# [+:error_message+]
|
90
90
|
# The message of the error returned. If
|
91
91
|
# no error was returned by the service, this will be an empty
|
92
92
|
# string.
|
@@ -94,17 +94,17 @@ module AWS
|
|
94
94
|
# [+:http_request_method+]
|
95
95
|
# The HTTP request verb (e.g. 'POST', 'PUT', 'GET', etc).
|
96
96
|
#
|
97
|
-
# [+:http_request_protocol+]
|
97
|
+
# [+:http_request_protocol+]
|
98
98
|
# This is replaced by 'http' or 'https'.
|
99
99
|
#
|
100
|
-
# [+:http_request_host+]
|
100
|
+
# [+:http_request_host+]
|
101
101
|
# The host name of the http request endpoint (e.g. 's3.amazon.com').
|
102
102
|
#
|
103
|
-
# [+:http_request_port+]
|
103
|
+
# [+:http_request_port+]
|
104
104
|
# The port number (e.g. '443' or '80').
|
105
105
|
#
|
106
106
|
# [+:http_request_uri+]
|
107
|
-
# The http request uri folling the host (e.g.
|
107
|
+
# The http request uri folling the host (e.g.
|
108
108
|
# '/bucket_name/objects/key?versions').
|
109
109
|
#
|
110
110
|
# [+:http_request_body+]
|
@@ -124,7 +124,7 @@ module AWS
|
|
124
124
|
#
|
125
125
|
# [+:http_response_body+]
|
126
126
|
# The http response body contents.
|
127
|
-
#
|
127
|
+
#
|
128
128
|
class LogFormatter
|
129
129
|
|
130
130
|
# @param [String] pattern The log format pattern should be a string
|
@@ -272,7 +272,7 @@ module AWS
|
|
272
272
|
# @return [String]
|
273
273
|
def summarize_hash hash
|
274
274
|
hash.map do |key,v|
|
275
|
-
"
|
275
|
+
"#{key.inspect}=>#{summarize_value(v)}"
|
276
276
|
end.sort.join(",")
|
277
277
|
end
|
278
278
|
|
@@ -288,7 +288,7 @@ module AWS
|
|
288
288
|
else value.inspect
|
289
289
|
end
|
290
290
|
end
|
291
|
-
|
291
|
+
|
292
292
|
# @param [String] str
|
293
293
|
# @return [String]
|
294
294
|
def summarize_string str
|
@@ -307,7 +307,7 @@ module AWS
|
|
307
307
|
def summarize_file path
|
308
308
|
"#<File:#{path} (#{File.size(path)} bytes)>"
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
311
|
# @param [Array] array
|
312
312
|
# @return [String]
|
313
313
|
def summarize_array array
|
@@ -315,13 +315,13 @@ module AWS
|
|
315
315
|
end
|
316
316
|
|
317
317
|
class << self
|
318
|
-
|
318
|
+
|
319
319
|
# The default log format.
|
320
320
|
#
|
321
321
|
# @example A sample of the default format.
|
322
322
|
#
|
323
323
|
# [AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
|
324
|
-
#
|
324
|
+
#
|
325
325
|
# @return [LogFormatter]
|
326
326
|
#
|
327
327
|
def default
|
@@ -346,7 +346,7 @@ module AWS
|
|
346
346
|
# @example A sample of the short format
|
347
347
|
#
|
348
348
|
# [AWS SimpleEmailService 200 0.494532] list_verified_email_addresses
|
349
|
-
#
|
349
|
+
#
|
350
350
|
# @return [LogFormatter]
|
351
351
|
#
|
352
352
|
def short
|
@@ -375,7 +375,7 @@ module AWS
|
|
375
375
|
# +-------------------------------------------------------------------------------
|
376
376
|
# | METHOD: POST
|
377
377
|
# | URL: https://email.us-east-1.amazonaws.com::443:/
|
378
|
-
# | HEADERS: {"content-type"=>"application/x-www-form-urlencoded" ...
|
378
|
+
# | HEADERS: {"content-type"=>"application/x-www-form-urlencoded" ...
|
379
379
|
# | BODY: Action=ListVerifiedEmailAddresses&Timestamp= ...
|
380
380
|
# +-------------------------------------------------------------------------------
|
381
381
|
# | RESPONSE
|
@@ -383,7 +383,7 @@ module AWS
|
|
383
383
|
# | STATUS: 200
|
384
384
|
# | HEADERS: {"x-amzn-requestid"=>["..."], ...
|
385
385
|
# | BODY: <ListVerifiedEmailAddressesResponse ...
|
386
|
-
#
|
386
|
+
#
|
387
387
|
# @return [LogFormatter]
|
388
388
|
#
|
389
389
|
def debug
|
@@ -404,7 +404,7 @@ module AWS
|
|
404
404
|
uri_pattern << ':'
|
405
405
|
uri_pattern << ':http_request_uri'
|
406
406
|
|
407
|
-
line = "+" + '-' * 79
|
407
|
+
line = "+" + '-' * 79
|
408
408
|
|
409
409
|
pattern = []
|
410
410
|
pattern << line
|
@@ -432,7 +432,7 @@ module AWS
|
|
432
432
|
# @example A sample of the colored format (sans the ansi colors).
|
433
433
|
#
|
434
434
|
# [AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
|
435
|
-
#
|
435
|
+
#
|
436
436
|
# @return [LogFormatter]
|
437
437
|
#
|
438
438
|
def colored
|
@@ -20,44 +20,44 @@ module AWS
|
|
20
20
|
|
21
21
|
# @private
|
22
22
|
class OptionGrammar
|
23
|
-
|
23
|
+
|
24
24
|
# @private
|
25
25
|
class DefaultOption; end
|
26
|
-
|
26
|
+
|
27
27
|
# @private
|
28
28
|
class FormatError < ArgumentError
|
29
29
|
attr_accessor :expectation
|
30
30
|
attr_accessor :context_description
|
31
|
-
|
31
|
+
|
32
32
|
def initialize(expectation, context)
|
33
33
|
@expectation = expectation
|
34
34
|
@context_description = context
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def to_s
|
38
38
|
"expected #{expectation} for #{context_description}"
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
# @private
|
43
43
|
module Descriptors
|
44
|
-
|
44
|
+
|
45
45
|
# @private
|
46
46
|
module NoArgs
|
47
47
|
def apply(option)
|
48
48
|
option.extend self
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
module Timestamp
|
53
|
-
|
53
|
+
|
54
54
|
extend NoArgs
|
55
|
-
|
55
|
+
|
56
56
|
def validate(value, context = nil)
|
57
57
|
true
|
58
58
|
# raise format_error("timestamp value", context) unless
|
59
59
|
# case value
|
60
|
-
# when String
|
60
|
+
# when String
|
61
61
|
# value =~ /^\d+$/ or value =~ /^\d{4}-\d{2}-d{2}T\d{2}:\d{2}:\d{2}Z$/
|
62
62
|
# when String then value =~ /^2009-12-04T20:56:05.000Z\d+$/
|
63
63
|
# when Integer then true
|
@@ -69,13 +69,13 @@ module AWS
|
|
69
69
|
# end
|
70
70
|
# value.respond_to? :to_str
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def encode_value(value)
|
74
74
|
value.to_s
|
75
75
|
# value.to_s
|
76
76
|
# case value
|
77
77
|
# when Integer
|
78
|
-
# when
|
78
|
+
# when
|
79
79
|
# case value
|
80
80
|
# when nil, '' then nil
|
81
81
|
# when DateTime then raw
|
@@ -84,98 +84,106 @@ module AWS
|
|
84
84
|
# end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
# @private
|
89
89
|
module String
|
90
|
-
|
90
|
+
|
91
91
|
extend NoArgs
|
92
|
-
|
92
|
+
|
93
93
|
def validate(value, context = nil)
|
94
94
|
raise format_error("string value", context) unless
|
95
95
|
value.respond_to? :to_str
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
def encode_value(value)
|
99
99
|
value.to_s
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
# @private
|
105
105
|
module Blob
|
106
|
-
|
106
|
+
|
107
107
|
extend NoArgs
|
108
|
-
|
108
|
+
|
109
109
|
def validate(value, context = nil)
|
110
110
|
raise format_error("string value", context) unless
|
111
111
|
value.respond_to? :to_str
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
def encode_value(value)
|
115
115
|
Base64.encode64(value.to_s)
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
|
+
def hash_format(value)
|
119
|
+
Base64.encode64(value.to_s).strip
|
120
|
+
end
|
121
|
+
|
118
122
|
end
|
119
|
-
|
123
|
+
|
120
124
|
# @private
|
121
125
|
module Integer
|
122
|
-
|
126
|
+
|
123
127
|
extend NoArgs
|
124
|
-
|
128
|
+
|
125
129
|
def validate(value, context = nil)
|
126
130
|
raise format_error("integer value", context) unless
|
127
131
|
value.respond_to? :to_int
|
128
132
|
end
|
129
|
-
|
133
|
+
|
130
134
|
def encode_value(value)
|
131
135
|
value.to_s
|
132
136
|
end
|
133
|
-
|
137
|
+
|
134
138
|
end
|
135
139
|
|
136
140
|
Long = Integer
|
137
|
-
|
141
|
+
|
138
142
|
# @private
|
139
143
|
module Boolean
|
140
|
-
|
144
|
+
|
141
145
|
extend NoArgs
|
142
|
-
|
146
|
+
|
143
147
|
def validate(value, context = nil)
|
144
148
|
raise format_error("boolean value", context) unless
|
145
149
|
value == true || value == false
|
146
150
|
end
|
147
|
-
|
151
|
+
|
148
152
|
def encode_value(value)
|
149
153
|
value.to_s
|
150
154
|
end
|
151
|
-
|
155
|
+
|
152
156
|
end
|
153
|
-
|
157
|
+
|
154
158
|
# @private
|
155
159
|
module Required
|
156
160
|
extend NoArgs
|
157
161
|
def required?; true; end
|
158
162
|
end
|
159
|
-
|
163
|
+
|
164
|
+
module Position
|
165
|
+
def self.apply *args; end
|
166
|
+
end
|
167
|
+
|
160
168
|
# @private
|
161
169
|
module Float
|
162
|
-
|
170
|
+
|
163
171
|
extend NoArgs
|
164
|
-
|
172
|
+
|
165
173
|
def validate(value, context = nil)
|
166
174
|
raise format_error("float value", context) unless
|
167
175
|
value.kind_of?(Numeric) or
|
168
176
|
value.respond_to? :to_f
|
169
177
|
end
|
170
|
-
|
178
|
+
|
171
179
|
def encode_value(value)
|
172
180
|
value.to_f.to_s
|
173
181
|
end
|
174
|
-
|
182
|
+
|
175
183
|
end
|
176
184
|
|
177
185
|
Double = Float
|
178
|
-
|
186
|
+
|
179
187
|
# @private
|
180
188
|
module Rename
|
181
189
|
def self.apply(option, new_name)
|
@@ -183,31 +191,31 @@ module AWS
|
|
183
191
|
MetaUtils.extend_method(option, :ruby_name) { new_name }
|
184
192
|
end
|
185
193
|
end
|
186
|
-
|
194
|
+
|
187
195
|
# @private
|
188
196
|
module Pattern
|
189
|
-
|
197
|
+
|
190
198
|
# def validate value, context = nil
|
191
199
|
# unless value =~ regex
|
192
200
|
# raise format_error("value to match #{regex}", context)
|
193
201
|
# end
|
194
202
|
# end
|
195
|
-
#
|
203
|
+
#
|
196
204
|
# def self.apply option, regex
|
197
205
|
# option.extend(self)
|
198
206
|
# MetaUtils.extend_method(option, :regex) { regex }
|
199
207
|
# end
|
200
|
-
|
208
|
+
|
201
209
|
def self.apply *args
|
202
210
|
end
|
203
|
-
|
211
|
+
|
204
212
|
end
|
205
|
-
|
213
|
+
|
206
214
|
# @private
|
207
215
|
module ListMethods
|
208
|
-
|
216
|
+
|
209
217
|
module ClassMethods
|
210
|
-
|
218
|
+
|
211
219
|
def apply(option, member_descriptors)
|
212
220
|
super(option)
|
213
221
|
member_option = option.member_option if option.respond_to?(:member_option)
|
@@ -224,11 +232,11 @@ module AWS
|
|
224
232
|
member_option = member_option.extend_with_config(*descriptors)
|
225
233
|
MetaUtils.extend_method(option, :member_option) { member_option }
|
226
234
|
end
|
227
|
-
|
235
|
+
|
228
236
|
end
|
229
|
-
|
237
|
+
|
230
238
|
module InstanceMethods
|
231
|
-
|
239
|
+
|
232
240
|
def validate(value, context = nil)
|
233
241
|
raise format_error("enumerable value", context) unless
|
234
242
|
value.respond_to? :each
|
@@ -239,7 +247,7 @@ module AWS
|
|
239
247
|
"member #{i} of #{context_description(context)}")
|
240
248
|
end
|
241
249
|
end
|
242
|
-
|
250
|
+
|
243
251
|
def request_params(value, prefix = nil)
|
244
252
|
params = []
|
245
253
|
value.each do |v|
|
@@ -259,64 +267,64 @@ module AWS
|
|
259
267
|
def join
|
260
268
|
'.'
|
261
269
|
end
|
262
|
-
|
270
|
+
|
263
271
|
end
|
264
|
-
|
272
|
+
|
265
273
|
end
|
266
|
-
|
274
|
+
|
267
275
|
module List
|
268
|
-
|
276
|
+
|
269
277
|
extend NoArgs
|
270
278
|
extend ListMethods::ClassMethods
|
271
279
|
include ListMethods::InstanceMethods
|
272
|
-
|
280
|
+
|
273
281
|
end
|
274
|
-
|
282
|
+
|
275
283
|
module MemberedList
|
276
|
-
|
284
|
+
|
277
285
|
extend NoArgs
|
278
286
|
extend ListMethods::ClassMethods
|
279
287
|
include ListMethods::InstanceMethods
|
280
|
-
|
288
|
+
|
281
289
|
def join
|
282
290
|
'.member.'
|
283
291
|
end
|
284
|
-
|
292
|
+
|
285
293
|
end
|
286
|
-
|
294
|
+
|
287
295
|
class ListMember < DefaultOption
|
288
|
-
|
296
|
+
|
289
297
|
def initialize options = {}
|
290
298
|
super("##list-member##")
|
291
299
|
@prefix = options[:prefix] || ''
|
292
300
|
end
|
293
|
-
|
301
|
+
|
294
302
|
def prefixed_name(prefix)
|
295
303
|
"#{prefix}#{@prefix}"
|
296
304
|
end
|
297
|
-
|
305
|
+
|
298
306
|
end
|
299
|
-
|
307
|
+
|
300
308
|
# @private
|
301
309
|
module Structure
|
302
|
-
|
310
|
+
|
303
311
|
extend NoArgs
|
304
|
-
|
312
|
+
|
305
313
|
def self.apply(option, members)
|
306
314
|
options = {}
|
307
315
|
options = option.member_options.inject({}) do |memo, member_option|
|
308
316
|
memo[member_option.name] = member_option
|
309
317
|
memo
|
310
318
|
end if option.respond_to?(:member_options)
|
311
|
-
|
319
|
+
|
312
320
|
super(option)
|
313
|
-
|
321
|
+
|
314
322
|
members.each do |(name, descriptors)|
|
315
323
|
member_option = options[name] || DefaultOption.new(name)
|
316
324
|
member_option = member_option.extend_with_config(*descriptors)
|
317
325
|
options[name] = member_option
|
318
326
|
end
|
319
|
-
|
327
|
+
|
320
328
|
MetaUtils.extend_method(option, :member_options) { options.values }
|
321
329
|
by_ruby_name = options.values.inject({}) do |memo, member_option|
|
322
330
|
memo[member_option.ruby_name] = member_option
|
@@ -325,20 +333,20 @@ module AWS
|
|
325
333
|
end
|
326
334
|
MetaUtils.extend_method(option, :member_option) { |n| by_ruby_name[n] }
|
327
335
|
end
|
328
|
-
|
336
|
+
|
329
337
|
def validate(value, context = nil)
|
330
338
|
raise format_error("hash value", context) unless
|
331
339
|
value.respond_to?(:to_hash)
|
332
|
-
|
340
|
+
|
333
341
|
context = context_description(context)
|
334
|
-
|
342
|
+
|
335
343
|
value.each do |name, v|
|
336
344
|
name = name.to_s
|
337
345
|
raise ArgumentError.new("unexpected key #{name} for #{context}") unless
|
338
346
|
member_option(name)
|
339
347
|
member_option(name).validate(v, "key #{name} of #{context}")
|
340
348
|
end
|
341
|
-
|
349
|
+
|
342
350
|
member_options.each do |option|
|
343
351
|
raise ArgumentError.new("missing required key #{option.ruby_name} for #{context}") if
|
344
352
|
option.required? and
|
@@ -347,7 +355,7 @@ module AWS
|
|
347
355
|
!value.has_key?(option.name)
|
348
356
|
end
|
349
357
|
end
|
350
|
-
|
358
|
+
|
351
359
|
def request_params(values, prefix = nil)
|
352
360
|
values.map do |name, value|
|
353
361
|
name = name.to_s
|
@@ -416,7 +424,7 @@ module AWS
|
|
416
424
|
|
417
425
|
end
|
418
426
|
end
|
419
|
-
|
427
|
+
|
420
428
|
|
421
429
|
def hash_format(value)
|
422
430
|
value.inject({}) do |hash, (key, value)|
|
@@ -451,26 +459,26 @@ module AWS
|
|
451
459
|
end
|
452
460
|
|
453
461
|
end
|
454
|
-
|
462
|
+
|
455
463
|
# @private
|
456
464
|
module Boolean
|
457
465
|
extend NoArgs
|
458
466
|
end
|
459
|
-
|
467
|
+
|
460
468
|
end
|
461
|
-
|
469
|
+
|
462
470
|
class DefaultOption
|
463
|
-
|
471
|
+
|
464
472
|
attr_reader :name
|
465
|
-
|
473
|
+
|
466
474
|
def initialize(name)
|
467
475
|
@name = name
|
468
476
|
end
|
469
|
-
|
477
|
+
|
470
478
|
def ruby_name
|
471
479
|
Inflection.ruby_name(name)
|
472
480
|
end
|
473
|
-
|
481
|
+
|
474
482
|
def request_params(value, prefix = nil)
|
475
483
|
[Http::Request::Param.new(prefixed_name(prefix), encode_value(value))]
|
476
484
|
end
|
@@ -483,24 +491,24 @@ module AWS
|
|
483
491
|
return "#{prefix}.#{name}" if prefix
|
484
492
|
name
|
485
493
|
end
|
486
|
-
|
494
|
+
|
487
495
|
def encode_value(value)
|
488
496
|
value
|
489
497
|
end
|
490
|
-
|
498
|
+
|
491
499
|
def required?
|
492
500
|
false
|
493
501
|
end
|
494
|
-
|
502
|
+
|
495
503
|
def format_error(expected, context = nil)
|
496
504
|
context = context_description(context)
|
497
505
|
FormatError.new(expected, context)
|
498
506
|
end
|
499
|
-
|
507
|
+
|
500
508
|
def context_description(context)
|
501
509
|
context or "option #{ruby_name}"
|
502
510
|
end
|
503
|
-
|
511
|
+
|
504
512
|
def extend_with_config(*descriptors)
|
505
513
|
option = clone
|
506
514
|
descriptors.each do |desc|
|
@@ -521,16 +529,16 @@ module AWS
|
|
521
529
|
end
|
522
530
|
option
|
523
531
|
end
|
524
|
-
|
532
|
+
|
525
533
|
include Descriptors::String
|
526
|
-
|
534
|
+
|
527
535
|
end
|
528
|
-
|
536
|
+
|
529
537
|
# @private
|
530
538
|
module ModuleMethods
|
531
|
-
|
539
|
+
|
532
540
|
include Inflection
|
533
|
-
|
541
|
+
|
534
542
|
def customize(config = [])
|
535
543
|
m = Class.new(self)
|
536
544
|
supported_options = m.supported_options.inject({}) do |memo, opt|
|
@@ -547,7 +555,7 @@ module AWS
|
|
547
555
|
option = option.extend_with_config(*value_desc)
|
548
556
|
supported_options[option.name] = option
|
549
557
|
end
|
550
|
-
|
558
|
+
|
551
559
|
supported_ary = supported_options.values
|
552
560
|
MetaUtils.extend_method(m, :supported_options) { supported_ary }
|
553
561
|
supported_ruby_names = supported_ary.inject({}) do |memo, opt|
|
@@ -560,18 +568,18 @@ module AWS
|
|
560
568
|
opt.validate(value)
|
561
569
|
end
|
562
570
|
end
|
563
|
-
|
571
|
+
|
564
572
|
m
|
565
573
|
end
|
566
|
-
|
574
|
+
|
567
575
|
def option(name)
|
568
576
|
nil
|
569
577
|
end
|
570
|
-
|
578
|
+
|
571
579
|
def supported_options
|
572
580
|
[]
|
573
581
|
end
|
574
|
-
|
582
|
+
|
575
583
|
def validate(options)
|
576
584
|
options.each do |name, value|
|
577
585
|
name = name.to_s
|
@@ -614,20 +622,20 @@ module AWS
|
|
614
622
|
def included(m)
|
615
623
|
m.extend(self::ModuleMethods)
|
616
624
|
end
|
617
|
-
|
625
|
+
|
618
626
|
protected
|
619
627
|
def parse_option(option)
|
620
628
|
value_desc = nil
|
621
629
|
if option.kind_of? Hash
|
622
630
|
raise ArgumentError.new("passed empty hash where an option was expected") if
|
623
631
|
option.empty?
|
624
|
-
|
632
|
+
|
625
633
|
raise ArgumentError.new("too many entries in option description") if
|
626
634
|
option.size > 1
|
627
|
-
|
635
|
+
|
628
636
|
(name, value_desc) = option.to_a.first
|
629
637
|
name = name.to_s
|
630
|
-
|
638
|
+
|
631
639
|
raise ArgumentError.new("expected an array for "+
|
632
640
|
"value description of option #{name},"+
|
633
641
|
"got #{value_desc.inspect}") unless
|
@@ -635,12 +643,12 @@ module AWS
|
|
635
643
|
else
|
636
644
|
name = option
|
637
645
|
end
|
638
|
-
|
646
|
+
|
639
647
|
value_desc ||= []
|
640
|
-
|
648
|
+
|
641
649
|
[name, value_desc]
|
642
650
|
end
|
643
|
-
|
651
|
+
|
644
652
|
protected
|
645
653
|
def apply_required_descriptor(m, name)
|
646
654
|
name = ruby_name(name)
|
@@ -649,7 +657,7 @@ module AWS
|
|
649
657
|
opts.key? name or opts.key? name.to_sym
|
650
658
|
end
|
651
659
|
end
|
652
|
-
|
660
|
+
|
653
661
|
protected
|
654
662
|
def apply_integer_descriptor(m, name)
|
655
663
|
MetaUtils.extend_method(m, "validate_#{ruby_name(name)}") do |value|
|
@@ -657,7 +665,7 @@ module AWS
|
|
657
665
|
value.respond_to? :to_int
|
658
666
|
end
|
659
667
|
end
|
660
|
-
|
668
|
+
|
661
669
|
protected
|
662
670
|
def apply_string_descriptor(m, name)
|
663
671
|
MetaUtils.extend_method(m, "validate_#{ruby_name(name)}") do |value|
|
@@ -665,7 +673,7 @@ module AWS
|
|
665
673
|
value.respond_to? :to_str
|
666
674
|
end
|
667
675
|
end
|
668
|
-
|
676
|
+
|
669
677
|
protected
|
670
678
|
def apply_list_descriptor(m, name, arg)
|
671
679
|
MetaUtils.extend_method(m, "validate_#{ruby_name(name)}") do |value|
|
@@ -687,14 +695,14 @@ module AWS
|
|
687
695
|
end
|
688
696
|
end
|
689
697
|
end
|
690
|
-
|
698
|
+
|
691
699
|
protected
|
692
700
|
def apply_rename_descriptor(m, name, new_name)
|
693
701
|
name = ruby_name(name)
|
694
702
|
MetaUtils.extend_method(m, :validate) do |opts|
|
695
703
|
raise ArgumentError.new("unexpected option foo") if
|
696
704
|
opts.key?(name) or opts.key?(name.to_sym)
|
697
|
-
|
705
|
+
|
698
706
|
opts = opts.dup
|
699
707
|
opts[name] = opts[new_name] if opts.key?(new_name)
|
700
708
|
opts[name.to_sym] = opts[new_name.to_sym] if opts.key?(new_name.to_sym)
|
@@ -702,27 +710,27 @@ module AWS
|
|
702
710
|
opts.delete(new_name.to_sym)
|
703
711
|
super(opts)
|
704
712
|
end
|
705
|
-
|
713
|
+
|
706
714
|
# couldn't find a better way to alias a class method
|
707
715
|
method = m.method("params_for_#{name}")
|
708
716
|
MetaUtils.extend_method(m, "params_for_#{new_name}") do |value|
|
709
717
|
method.call(value)
|
710
718
|
end
|
711
719
|
end
|
712
|
-
|
720
|
+
|
713
721
|
end
|
714
722
|
|
715
723
|
class MapOption < DefaultOption
|
716
724
|
def param_name
|
717
|
-
@param_name || name
|
725
|
+
@param_name || name
|
718
726
|
end
|
719
727
|
def param_name= name
|
720
728
|
@param_name = name
|
721
729
|
end
|
722
730
|
end
|
723
|
-
|
731
|
+
|
724
732
|
extend ModuleMethods
|
725
|
-
|
733
|
+
|
726
734
|
end
|
727
735
|
end
|
728
736
|
end
|