aws-sdk-core 2.7.11 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5ff1a53dfe920acfd2e2793475c6830c2668a8c
4
- data.tar.gz: b35f84a9076e22a30fb237cc61bbf5e155ac6acf
3
+ metadata.gz: 49fd678d04874002883367eef281b0a51ab8733c
4
+ data.tar.gz: 632c85e825d4bae5b595584116b35cb7306181c2
5
5
  SHA512:
6
- metadata.gz: a126a087e6c7f537b41ca7c425bf3ad0a35122a832606e8b0d7cae4a86b7a0b333160068664f11d2e9f1224b918fd2766a87a9ca8a5c79e15593a1ae28d00ed2
7
- data.tar.gz: bc2a0fe009755ef519716d01ff77b34adba5bda37fcfa3c11165f14e2465c29fcd33c022ba8e9427b1ff14c89a63b0e3a61d03f3bf3ba72143ca0638e3448071
6
+ metadata.gz: 451971284067ed6fed856141f710c98c54ff6f3abe9ec760ca7dd6f78c0d0550d79e4e57f29e2f7a46e57691ef419534f328af7a0f59b857947b447156232c52
7
+ data.tar.gz: 3744041eefa7ef6fe9a403c868add5e3c19735ff3ef1cefa509af8c0b5d09ac6d189abf09fb5140a14faefd7536da6f3cabd72df58440f30de49b654fb612008
@@ -2802,6 +2802,13 @@
2802
2802
  "modifying"
2803
2803
  ]
2804
2804
  },
2805
+ "BillingProductList":{
2806
+ "type":"list",
2807
+ "member":{
2808
+ "shape":"String",
2809
+ "locationName":"item"
2810
+ }
2811
+ },
2805
2812
  "Blob":{"type":"blob"},
2806
2813
  "BlobAttributeValue":{
2807
2814
  "type":"structure",
@@ -11385,6 +11392,10 @@
11385
11392
  "shape":"String",
11386
11393
  "locationName":"ramdiskId"
11387
11394
  },
11395
+ "BillingProducts":{
11396
+ "shape":"BillingProductList",
11397
+ "locationName":"BillingProduct"
11398
+ },
11388
11399
  "RootDeviceName":{
11389
11400
  "shape":"String",
11390
11401
  "locationName":"rootDeviceName"
@@ -50,8 +50,18 @@ module Aws
50
50
  # buckets: [{ name: 'my-bucket' }]
51
51
  # })
52
52
  #
53
- # client.list_buckets.buckets.map(&:name) #=> ['my-bucket']
54
- # #=> ['aws-sdk']
53
+ # client.list_buckets.buckets.map(&:name)
54
+ # #=> ['my-bucket']
55
+ #
56
+ # With a Resource class {#stub_responses} on the corresponding client:
57
+ #
58
+ # s3 = Aws::S3::Resource.new(stub_responses: true)
59
+ # s3.client.stub_responses(:list_buckets, {
60
+ # buckets: [{ name: 'my-bucket' }]
61
+ # })
62
+ #
63
+ # s3.buckets.map(&:name)
64
+ # #=> ['my-bucket']
55
65
  #
56
66
  # Lastly, default stubs can be configured via `Aws.config`:
57
67
  #
@@ -64,6 +74,9 @@ module Aws
64
74
  # Aws::S3::Client.new.list_buckets.buckets.map(&:name)
65
75
  # #=> ['my-bucket']
66
76
  #
77
+ # Aws::S3::Resource.new.buckets.map(&:name)
78
+ # #=> ['my-bucket']
79
+ #
67
80
  # ## Stubbing Errors
68
81
  #
69
82
  # When stubbing is enabled, the SDK will default to generate
@@ -9,7 +9,9 @@ Aws.add_service(:CloudFront, {
9
9
  module Aws
10
10
  module CloudFront
11
11
 
12
+ autoload :Signer, 'aws-sdk-core/cloudfront/signer.rb'
12
13
  autoload :UrlSigner, 'aws-sdk-core/cloudfront/url_signer.rb'
14
+ autoload :CookieSigner, 'aws-sdk-core/cloudfront/cookie_signer.rb'
13
15
 
14
16
  end
15
17
  end
@@ -0,0 +1,44 @@
1
+ require 'base64'
2
+ require 'uri'
3
+ require 'time'
4
+ require 'json'
5
+ require 'openssl'
6
+
7
+ module Aws
8
+ module CloudFront
9
+
10
+ # Allows you to create signed cookie for Amazon CloudFront resources
11
+ #
12
+ # signer = Aws::CloudFront::CookieSigner.new(
13
+ # key_pair_id: "cf-keypair-id",
14
+ # private_key_path: "./cf_private_key.pem"
15
+ # )
16
+ # cookies = signer.signed_cookie(url,
17
+ # policy: policy.to_json
18
+ # )
19
+ #
20
+ class CookieSigner
21
+ include Signer
22
+
23
+ # create a signed Amazon CloudFront URL
24
+ # @param [String] url
25
+ # @option params [Time, DateTime, Date, String, Integer<timestamp>] :expires
26
+ # @option params [String<JSON>] :policy
27
+ def signed_cookie(url, params = {})
28
+ scheme, uri = scheme_and_uri(url)
29
+ signed_content = signature(
30
+ resource: resource(scheme, uri),
31
+ expires: time(params[:expires]),
32
+ policy: params[:policy]
33
+ )
34
+
35
+ cookie_parameters = {}
36
+ signed_content.each { |k, v|
37
+ cookie_parameters["CloudFront-#{k}"] = v.to_s.gsub("\n", '')
38
+ }
39
+ cookie_parameters
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,141 @@
1
+ require 'base64'
2
+ require 'uri'
3
+ require 'time'
4
+ require 'json'
5
+ require 'openssl'
6
+
7
+ module Aws
8
+ module CloudFront
9
+
10
+ module Signer
11
+
12
+ # @option options [String] :key_pair_id
13
+ # @option options [String] :private_key
14
+ # @option options [String] :private_key_path
15
+ def initialize(options = {})
16
+ @key_pair_id = key_pair_id(options)
17
+ @private_key = private_key(options)
18
+ end
19
+
20
+ private
21
+
22
+ def scheme_and_uri(url)
23
+ url_sections = url.split('://')
24
+ if url_sections.length < 2
25
+ raise ArgumentError, "Invaild URL:#{url}"
26
+ end
27
+ scheme = url_sections[0].gsub('*', '')
28
+ uri = "#{scheme}://#{url_sections[1]}"
29
+ [scheme, uri]
30
+ end
31
+
32
+ def time(expires)
33
+ case expires
34
+ when Time then expires.to_i
35
+ when DateTime, Date then expires.to_time.to_i
36
+ when String then Time.parse(expires).to_i
37
+ when Integer, NIL then expires
38
+ else
39
+ msg = "expected a time value for :expires, got `#{expires.class}'"
40
+ raise ArgumentError, msg
41
+ end
42
+ end
43
+
44
+ # create a relative signed URL for RTMP distribution
45
+ def rtmp_url(uri)
46
+ result = uri.path.gsub(' ', '/')
47
+ result[0] = ''
48
+ if uri.query
49
+ "#{result}?#{uri.query}"
50
+ else
51
+ result
52
+ end
53
+ end
54
+
55
+ # prepare resource for signing
56
+ def resource(scheme, url)
57
+ case scheme
58
+ when 'http', 'http*', 'https' then url
59
+ when 'rtmp'
60
+ url_info = URI.parse(url)
61
+ path = url_info.path
62
+ path[0] = ''
63
+ resource_content = "#{File.dirname(path)}/#{File.basename(path)}".gsub(' ', '/')
64
+ if url_info.query
65
+ "#{resource_content}?#{uri.query}"
66
+ else
67
+ resource_content
68
+ end
69
+ else
70
+ msg = "Invaild URI scheme:#{scheme}.Scheme must be one of: http, https or rtmp."
71
+ raise ArgumentError, msg
72
+ end
73
+ end
74
+
75
+ # create signed values that used to construct signed URLs or Set-Cookie parameters
76
+ # @option param [String] :resource
77
+ # @option param [Integer<timestamp>] :expires
78
+ # @option param [String<JSON>] :policy
79
+ def signature(params = {})
80
+ signature_content = {}
81
+ if params[:policy]
82
+ policy = params[:policy].gsub('/\s/s', '')
83
+ signature_content['Policy'] = encode(policy)
84
+ elsif params[:resource] && params[:expires]
85
+ policy = canned_policy(params[:resource], params[:expires])
86
+ signature_content['Expires'] = params[:expires]
87
+ else
88
+ msg = "Either a policy or a resource with an expiration time must be provided."
89
+ raise ArgumentError, msg
90
+ end
91
+
92
+ signature_content['Signature'] = encode(sign_policy(policy))
93
+ signature_content['Key-Pair-Id'] = @key_pair_id
94
+ signature_content
95
+ end
96
+
97
+ # create the signature string with policy signed
98
+ def sign_policy(policy)
99
+ key = OpenSSL::PKey::RSA.new(@private_key)
100
+ key.sign(OpenSSL::Digest::SHA1.new, policy)
101
+ end
102
+
103
+ # create canned policy that used for signing
104
+ def canned_policy(resource, expires)
105
+ json_hash = {
106
+ 'Statement' => [
107
+ 'Resource' => resource,
108
+ 'Condition' => {
109
+ 'DateLessThan' => {'AWS:EpochTime' => expires}
110
+ }
111
+ ]
112
+ }
113
+ JSON.dump(json_hash)
114
+ end
115
+
116
+ def encode(policy)
117
+ Base64.encode64(policy).gsub(/[+=\/]/, '+' => '-', '=' => '_', '/' => '~')
118
+ end
119
+
120
+ def key_pair_id(options)
121
+ if options[:key_pair_id].nil? or options[:key_pair_id] == ''
122
+ raise ArgumentError, ":key_pair_id must not be blank"
123
+ else
124
+ options[:key_pair_id]
125
+ end
126
+ end
127
+
128
+ def private_key(options)
129
+ if options[:private_key]
130
+ options[:private_key]
131
+ elsif options[:private_key_path]
132
+ File.open(options[:private_key_path], 'rb') { |f| f.read }
133
+ else
134
+ msg = ":private_key or :private_key_path should be provided"
135
+ raise ArgumentError, msg
136
+ end
137
+ end
138
+
139
+ end
140
+ end
141
+ end
@@ -18,35 +18,23 @@ module Aws
18
18
  # )
19
19
  #
20
20
  class UrlSigner
21
-
22
- # @option options [String] :key_pair_id
23
- # @option options [String] :private_key
24
- # @option options [String] :private_key_path
25
- def initialize(options = {})
26
- @key_pair_id = key_pair_id(options)
27
- @private_key = private_key(options)
28
- end
21
+ include Signer
29
22
 
30
23
  # create a signed Amazon CloudFront URL
31
24
  # @param [String] url
32
25
  # @option params [Time, DateTime, Date, String, Integer<timestamp>] :expires
33
26
  # @option params [String<JSON>] :policy
34
27
  def signed_url(url, params = {})
35
- url_sections = url.split('://')
36
- if url_sections.length < 2
37
- raise ArgumentError, "Invaild URL:#{url}"
38
- end
39
- # removing wildcard character to get real scheme
40
- scheme = url_sections[0].gsub('*', '')
41
- uri = "#{scheme}://#{url_sections[1]}"
28
+ scheme, uri = scheme_and_uri(url)
42
29
  signed_content = signature(
43
- :resource => resource(scheme, uri),
44
- :expires => time(params[:expires]),
45
- :policy => params[:policy]
30
+ resource: resource(scheme, uri),
31
+ expires: time(params[:expires]),
32
+ policy: params[:policy]
46
33
  )
47
34
 
48
35
  start_flag = URI.parse(uri).query ? '&' : '?'
49
- uri = "#{uri}#{start_flag}#{signed_content}"
36
+ signature = signed_content.map{ |k, v| "#{k}=#{v}" }.join('&').gsub("\n", '')
37
+ uri = "#{uri}#{start_flag}#{signature}"
50
38
 
51
39
  if scheme == 'rtmp'
52
40
  rtmp_url(URI(uri))
@@ -55,115 +43,6 @@ module Aws
55
43
  end
56
44
  end
57
45
 
58
- private
59
-
60
- def time(expires)
61
- case expires
62
- when Time then expires.to_i
63
- when DateTime, Date then expires.to_time.to_i
64
- when String then Time.parse(expires).to_i
65
- when Integer, NIL then expires
66
- else
67
- msg = "expected a time value for :expires, got `#{expires.class}'"
68
- raise ArgumentError, msg
69
- end
70
- end
71
-
72
- # create a relative signed URL for RTMP distribution
73
- def rtmp_url(uri)
74
- result = uri.path.gsub(' ', '/')
75
- result[0] = ''
76
- if uri.query
77
- "#{result}?#{uri.query}"
78
- else
79
- result
80
- end
81
- end
82
-
83
- # prepare resource for signing
84
- def resource(scheme, url)
85
- case scheme
86
- when 'http', 'http*', 'https' then url
87
- when 'rtmp'
88
- url_info = URI.parse(url)
89
- path = url_info.path
90
- path[0] = ''
91
- resource_content = "#{File.dirname(path)}/#{File.basename(path)}".gsub(' ', '/')
92
- if url_info.query
93
- "#{resource_content}?#{uri.query}"
94
- else
95
- resource_content
96
- end
97
- else
98
- msg = "Invaild URI scheme:#{scheme}.Scheme must be one of: http, https or rtmp."
99
- raise ArgumentError, msg
100
- end
101
- end
102
-
103
- # create signed values that used to construct signed URLs
104
- # @option param [String] :resource
105
- # @option param [Integer<timestamp>] :expires
106
- # @option param [String<JSON>] :policy
107
- def signature(params = {})
108
- signature_content = []
109
- if params[:policy]
110
- policy = params[:policy].gsub('/\s/s', '')
111
- signature_content << "Policy=#{encode(policy)}"
112
- elsif params[:resource] && params[:expires]
113
- policy = canned_policy(params[:resource], params[:expires])
114
- signature_content << "Expires=#{params[:expires]}"
115
- else
116
- msg = "Either a policy or a resource with an expiration time must be provided."
117
- raise ArgumentError, msg
118
- end
119
-
120
- signature_content << "Signature=#{encode(sign_policy(policy))}"
121
- signature_content << "Key-Pair-Id=#{@key_pair_id}"
122
- signature_content.join('&').gsub("\n", '')
123
- end
124
-
125
- # create the signature string with policy signed
126
- def sign_policy(policy)
127
- key = OpenSSL::PKey::RSA.new(@private_key)
128
- key.sign(OpenSSL::Digest::SHA1.new, policy)
129
- end
130
-
131
- # create canned policy that used for signing
132
- def canned_policy(resource, expires)
133
- json_hash = {
134
- 'Statement' => [
135
- 'Resource' => resource,
136
- 'Condition' => {
137
- 'DateLessThan' => {'AWS:EpochTime' => expires}
138
- }
139
- ]
140
- }
141
- JSON.dump(json_hash)
142
- end
143
-
144
- def encode(policy)
145
- Base64.encode64(policy).gsub(/[+=\/]/, '+' => '-', '=' => '_', '/' => '~')
146
- end
147
-
148
- def key_pair_id(options)
149
- if options[:key_pair_id].nil? or options[:key_pair_id] == ''
150
- raise ArgumentError, ":key_pair_id must not be blank"
151
- else
152
- options[:key_pair_id]
153
- end
154
- end
155
-
156
- def private_key(options)
157
- if options[:private_key]
158
- options[:private_key]
159
- elsif options[:private_key_path]
160
- File.open(options[:private_key_path], 'rb') { |f| f.read }
161
- else
162
- msg = ":private_key or :private_key_path should be provided"
163
- raise ArgumentError, msg
164
- end
165
- end
166
-
167
46
  end
168
47
  end
169
48
  end
@@ -40,7 +40,9 @@ module Aws
40
40
 
41
41
  def build_body(api, operation, data)
42
42
  rules = operation.output
43
- if streaming?(rules)
43
+ if head_operation(operation)
44
+ ""
45
+ elsif streaming?(rules)
44
46
  data[rules[:payload]]
45
47
  elsif rules[:payload]
46
48
  body_for(api, operation, rules[:payload_member], data[rules[:payload]])
@@ -68,6 +70,10 @@ module Aws
68
70
  end
69
71
  end
70
72
 
73
+ def head_operation(operation)
74
+ operation.http_method == "HEAD"
75
+ end
76
+
71
77
  end
72
78
  end
73
79
  end
@@ -1,3 +1,3 @@
1
1
  module Aws
2
- VERSION = '2.7.11'
2
+ VERSION = '2.7.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.11
4
+ version: 2.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath
@@ -399,6 +399,8 @@ files:
399
399
  - lib/aws-sdk-core/clouddirectory.rb
400
400
  - lib/aws-sdk-core/cloudformation.rb
401
401
  - lib/aws-sdk-core/cloudfront.rb
402
+ - lib/aws-sdk-core/cloudfront/cookie_signer.rb
403
+ - lib/aws-sdk-core/cloudfront/signer.rb
402
404
  - lib/aws-sdk-core/cloudfront/url_signer.rb
403
405
  - lib/aws-sdk-core/cloudhsm.rb
404
406
  - lib/aws-sdk-core/cloudsearch.rb