icehouse-right_aws 1.11.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/History.txt +93 -15
  2. data/Manifest.txt +15 -1
  3. data/README.txt +0 -4
  4. data/Rakefile +34 -17
  5. data/lib/acf/right_acf_interface.rb +260 -124
  6. data/lib/acf/right_acf_invalidations.rb +144 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  8. data/lib/acf/right_acf_streaming_interface.rb +229 -0
  9. data/lib/acw/right_acw_interface.rb +4 -5
  10. data/lib/as/right_as_interface.rb +59 -51
  11. data/lib/awsbase/benchmark_fix.rb +0 -0
  12. data/lib/awsbase/right_awsbase.rb +351 -104
  13. data/lib/awsbase/support.rb +2 -82
  14. data/lib/awsbase/version.rb +9 -0
  15. data/lib/ec2/right_ec2.rb +97 -246
  16. data/lib/ec2/right_ec2_ebs.rb +88 -68
  17. data/lib/ec2/right_ec2_images.rb +90 -50
  18. data/lib/ec2/right_ec2_instances.rb +118 -89
  19. data/lib/ec2/right_ec2_placement_groups.rb +108 -0
  20. data/lib/ec2/right_ec2_reserved_instances.rb +51 -44
  21. data/lib/ec2/right_ec2_security_groups.rb +396 -0
  22. data/lib/ec2/right_ec2_spot_instances.rb +425 -0
  23. data/lib/ec2/right_ec2_tags.rb +139 -0
  24. data/lib/ec2/right_ec2_vpc.rb +152 -140
  25. data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
  26. data/lib/elb/right_elb_interface.rb +205 -39
  27. data/lib/iam/right_iam_access_keys.rb +71 -0
  28. data/lib/iam/right_iam_groups.rb +195 -0
  29. data/lib/iam/right_iam_interface.rb +341 -0
  30. data/lib/iam/right_iam_mfa_devices.rb +67 -0
  31. data/lib/iam/right_iam_users.rb +251 -0
  32. data/lib/rds/right_rds_interface.rb +591 -205
  33. data/lib/right_aws.rb +16 -12
  34. data/lib/route_53/right_route_53_interface.rb +640 -0
  35. data/lib/s3/right_s3.rb +34 -13
  36. data/lib/s3/right_s3_interface.rb +17 -14
  37. data/lib/sdb/active_sdb.rb +215 -38
  38. data/lib/sdb/right_sdb_interface.rb +93 -12
  39. data/lib/sqs/right_sqs.rb +1 -2
  40. data/lib/sqs/right_sqs_gen2.rb +0 -1
  41. data/lib/sqs/right_sqs_gen2_interface.rb +9 -9
  42. data/lib/sqs/right_sqs_interface.rb +6 -7
  43. data/right_aws.gemspec +91 -0
  44. data/test/README.mdown +39 -0
  45. data/test/acf/test_helper.rb +0 -0
  46. data/test/acf/test_right_acf.rb +10 -18
  47. data/test/awsbase/test_helper.rb +0 -0
  48. data/test/awsbase/test_right_awsbase.rb +0 -1
  49. data/test/ec2/test_helper.rb +0 -0
  50. data/test/ec2/test_right_ec2.rb +0 -1
  51. data/test/elb/test_helper.rb +2 -0
  52. data/test/elb/test_right_elb.rb +43 -0
  53. data/test/http_connection.rb +0 -0
  54. data/test/route_53/fixtures/a_record.xml +18 -0
  55. data/test/route_53/fixtures/alias_record.xml +18 -0
  56. data/test/route_53/test_helper.rb +2 -0
  57. data/test/route_53/test_right_route_53.rb +141 -0
  58. data/test/s3/test_helper.rb +0 -0
  59. data/test/s3/test_right_s3.rb +11 -9
  60. data/test/s3/test_right_s3_stubbed.rb +6 -4
  61. data/test/sdb/test_active_sdb.rb +71 -13
  62. data/test/sdb/test_batch_put_attributes.rb +54 -0
  63. data/test/sdb/test_helper.rb +0 -0
  64. data/test/sdb/test_right_sdb.rb +13 -7
  65. data/test/sqs/test_helper.rb +0 -0
  66. data/test/sqs/test_right_sqs.rb +0 -6
  67. data/test/sqs/test_right_sqs_gen2.rb +22 -34
  68. data/test/test_credentials.rb +0 -0
  69. data/test/ts_right_aws.rb +0 -0
  70. metadata +146 -16
  71. data/VERSION +0 -1
@@ -4,7 +4,7 @@ Initial release.
4
4
  == 1.2.0 2007-09-12
5
5
 
6
6
  * r1718, todd, 2007-09-12 15:34:37
7
- * # 458, Extensive documentation review, rework, and expansion. Also added
7
+ * # 458, Extensive documentation review, rework, and expansion. Also added
8
8
  coverage analysis to the test suite using RCov.
9
9
 
10
10
  * r1690, todd, 2007-09-07 15:23:11
@@ -39,7 +39,7 @@ Initial release.
39
39
  * # 487, # 488, Consolidate a lot of code that was repeated in three places.
40
40
  Fix error handling path when using streaming GET interfaces with S3.
41
41
  Also add a stub for RightHttpConnection which allows more control over the
42
- unit tests. Expand the unit tests and coverage tests.
42
+ unit tests. Expand the unit tests and coverage tests.
43
43
 
44
44
  * r1755, todd, 2007-09-19 14:29:19
45
45
  * # 487, RDoc fixes after code consolidation
@@ -59,13 +59,13 @@ Initial release.
59
59
  * # 524, blocks added to ec2_describe_xxx to support aws_cache
60
60
 
61
61
  * r1924, konstantin, 2007-10-12 11:35:06
62
- * # 536, user_data bug fix
62
+ * # 536, user_data bug fix
63
63
 
64
64
  * r1929, tve, 2007-10-15 00:00:11
65
65
  * Fix libxml/rexml selection bug
66
66
 
67
67
  * r1938, konstantin, 2007-10-16 10:53:56
68
- * instance type support is set to default
68
+ * instance type support is set to default
69
69
 
70
70
  == 1.4.3 2007-10-25
71
71
 
@@ -82,11 +82,11 @@ Initial release.
82
82
  * r2001, konstantin, 2007-11-01 12:03:13 +0300
83
83
  * Fixed multiple permissions assignment on Grantee#grant/revoke
84
84
  * Fixed new grantee permissions set ingnore (Grantee#apply)
85
- * S3::Grantee#exists? method added
85
+ * S3::Grantee#exists? method added
86
86
 
87
87
  * r2109, konstantin, 2007-11-12 21:49:36 +0300
88
88
  * RightAwsBaseInterface: caching implemented.
89
- (The Ec2 functions are being cached: describe_images, describe_instances,
89
+ (The Ec2 functions are being cached: describe_images, describe_instances,
90
90
  describe_security_groups and describe_key_pairs)
91
91
 
92
92
  == 1.4.5 - 1.4.6
@@ -107,7 +107,7 @@ Initial release.
107
107
  == 1.5.0
108
108
  * r 2688, konstantin, 02-30-08 15:42:00 +0300
109
109
  * SDB support added.
110
- * RightAws::S3::bucket and RightAws::S3::Bucket.create methods behaviour
110
+ * RightAws::S3::bucket and RightAws::S3::Bucket.create methods behaviour
111
111
  changed: param +create+ is set to +false+ by default.
112
112
 
113
113
  == 1.6.0
@@ -151,7 +151,7 @@ Initial release.
151
151
  == 1.7.2
152
152
 
153
153
  Release Notes:
154
-
154
+
155
155
  RightAws includes some new features, including:
156
156
  - Support in RightAws::S3 and RightAws::S3Interface for S3 key copy, move, and rename
157
157
  - Support for signature version 0 request authentication to EC2, SQS, and SDB
@@ -165,7 +165,7 @@ Initial release.
165
165
  We now reset the seek pointer of the streaming IO object to its initial position.
166
166
  - Removal of an accidental dependency on ActiveSupport in RightAws::S3Interface.get_link().
167
167
  - Monkey-patch of the Ruby File class on Windows platforms to correct a problem in lstat.
168
- The lstat bug was causing failure of very large file uploads on Windows [ Contributed by Benjamin Allfree ]
168
+ The lstat bug was causing failure of very large file uploads on Windows [ Contributed by Benjamin Allfree ]
169
169
  - Fixed parsing of the ETag field for S3 objects
170
170
 
171
171
  == 1.7.3
@@ -174,7 +174,7 @@ Initial release.
174
174
 
175
175
  - Removed the 1.7.2 monkey-patch of the Ruby File class on Windows. This patch broke Rails 2.0.
176
176
  The patch is now included in the README for anyone to use at their own risk.
177
-
177
+
178
178
  == 1.8.0
179
179
 
180
180
  Release Notes:
@@ -186,7 +186,7 @@ Initial release.
186
186
 
187
187
  Bug fixes include correction of RightAws::S3 copy's failure to url-encode
188
188
  the source key.
189
-
189
+
190
190
  == 1.8.1
191
191
 
192
192
  Release Notes:
@@ -197,7 +197,7 @@ the source key.
197
197
  result sorting and attributes auto loading
198
198
  - RightAws::ActiveSdb::Base#find_all_by_ and find_by_ helpers improved to support
199
199
  :order, :auto_load, :limit and :next_token options
200
- - RightAws::SdbInterface#delete_attributes bug fixed
200
+ - RightAws::SdbInterface#delete_attributes bug fixed
201
201
  - SdbInterface allows specification of a string value to use for
202
202
  representing Ruby nil in SDB.
203
203
  - Sdb tests fixed and improved
@@ -215,7 +215,7 @@ the source key.
215
215
  - Ec::cancel_bundle_task
216
216
 
217
217
  - Full Amazon CloudFront support added with RightAws::AcfInterface
218
- - Bug fixes to S3Interface::store_object_and_verify and
218
+ - Bug fixes to S3Interface::store_object_and_verify and
219
219
  S3Interface::retrieve_object_and_verify (thanks to numerous user reports)
220
220
  - Updates to caching for Ec2::describe_images_by methods
221
221
  - Ec2 now has Ec2::last_request_id
@@ -228,7 +228,7 @@ the source key.
228
228
  - CloudFront: docs fixes
229
229
  - SDB: added: SQL-like query, select and query_with_attributes support
230
230
  - SDB: fixed no method error when searching for id that doesn't exist
231
-
231
+
232
232
  === 1.11.0
233
233
 
234
234
  Release Notes:
@@ -236,4 +236,82 @@ the source key.
236
236
  - Boot from EBS support added
237
237
  - VPC support added
238
238
  - Latest EC2 API 2009-10-31 support added
239
- - Some of bugs fixed
239
+ - Some of bugs fixed
240
+
241
+ === 2.0.0
242
+
243
+ Release Notes:
244
+ - Added:
245
+ - Ruby 1.9 support
246
+ - Ec2:
247
+ - SpotInstances support
248
+ - m2.xlarge instances
249
+ - GetPasswordData API call (see get_password_data_v2)
250
+ - SecurityGroups support for Eucalyptus clouds
251
+ - EBS:
252
+ - :delete_on_termination field for volumes
253
+ - SimpleDB:
254
+ - BatchPutAttributes support
255
+ - ActiveSDB:
256
+ - Dynamic attribute accessors
257
+ - "Columns" support
258
+ - Simple Type Casting support
259
+ - ELB:
260
+ - API '2009-11-25' support (stickiness policies)
261
+ - ACF:
262
+ - API '2010-03-01' support (origin access policy and streaming distributions)
263
+ - Bunch of small issues were fixed
264
+ - Time objects were replaced by Strings (as Amazon returns them) to make the gem more consistent:
265
+ - :last_modified_time in:
266
+ RightAws::AcfInterface#incrementally_list_distributions,
267
+ RightAws::AcfInterface#create_distribution_by_config,
268
+ RightAws::AcfInterface#get_distribution,
269
+ RightAws::AcfInterface#get_distribution_config
270
+ - :timestamp in:
271
+ RightAws::AcwInterface#get_metric_statistics
272
+ - :aws_created_at in:
273
+ RightAws::Ec2#create_volume,
274
+ RightAws::Ec2#describe_volumes
275
+ - :aws_attached_at in:
276
+ RightAws::Ec2#attach_volume,
277
+ RightAws::Ec2#detach_volume,
278
+ RightAws::Ec2#describe_volumes
279
+ - :aws_started_at in:
280
+ RightAws::Ec2#describe_snapshots,
281
+ RightAws::Ec2#create_snapshot,
282
+ RightAws::Ec2#try_create_snapshot
283
+ - :created_time in:
284
+ RightAws::ElbInterface#describe_load_balancers
285
+
286
+ === 2.1.0
287
+ Release Notes:
288
+ - Added:
289
+ - Route 53: API '2010-10-01'
290
+ - ACF: API '2010-11-01'
291
+ - EC2:
292
+ - API '2010-08-31'
293
+ - Port based group permissions support
294
+ - HPC Support
295
+ - Tags Suport
296
+ - ClientToken support added on instance launch
297
+ - RDS: API "2010-07-28"
298
+ - ELB: API '2010-07-01' (SSL support)
299
+ - IAM: API '2010-05-08' (AWS Identity and Access Management interface)
300
+ - 301 Redirect support added
301
+ - Removed:
302
+ - ActiveSupport dependency
303
+ - SDB: uuid gem dependency
304
+ - this gem requires right_http_connection 0bc3343232133bdb38c237d8285525d74495d3f5 or later
305
+ - "Raise On Timeout On Action" feature added to avoid duplicate resources creation if a timeout error occures and a retry is performed
306
+
307
+ === next
308
+ Release Notes:
309
+ - Fixed:
310
+ - EC2: ClientToken (launch_instances, run_instances) is not used for Eucalyptus clouds
311
+ - RDS:
312
+ - RDS: API 2011-04-01
313
+ - Make :instance_class param more consistent: :db_instance_class --> :instance_class
314
+ - Issue 53: regression in latest master version of right_rds_interface
315
+ - Issue 73: Can't get list of instances with RdsInterface
316
+ - EBS: Issue 54: regression in right_ec2_ebs.rb
317
+ - Add the port number with server name in the v2 signature string if it is not the RFC standard number (author: unakatsuo).
@@ -2,16 +2,21 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ lib/awsbase/support.rb
5
6
  lib/awsbase/benchmark_fix.rb
6
7
  lib/awsbase/right_awsbase.rb
7
- lib/awsbase/support.rb
8
8
  lib/ec2/right_ec2.rb
9
9
  lib/ec2/right_ec2_images.rb
10
10
  lib/ec2/right_ec2_instances.rb
11
+ lib/ec2/right_ec2_security_groups.rb
12
+ lib/ec2/right_ec2_spot_instances.rb
11
13
  lib/ec2/right_ec2_ebs.rb
12
14
  lib/ec2/right_ec2_reserved_instances.rb
13
15
  lib/ec2/right_ec2_vpc.rb
14
16
  lib/ec2/right_ec2_monitoring.rb
17
+ lib/ec2/right_ec2_placement_groups.rb
18
+ lib/ec2/right_ec2_windows_mobility.rb
19
+ lib/ec2/right_ec2_tags.rb
15
20
  lib/right_aws.rb
16
21
  lib/s3/right_s3.rb
17
22
  lib/acw/right_acw_interface.rb
@@ -25,7 +30,16 @@ lib/sqs/right_sqs_gen2.rb
25
30
  lib/sqs/right_sqs_gen2_interface.rb
26
31
  lib/sqs/right_sqs_interface.rb
27
32
  lib/acf/right_acf_interface.rb
33
+ lib/acf/right_acf_streaming_interface.rb
34
+ lib/acf/right_acf_origin_access_identities.rb
35
+ lib/acf/right_acf_invalidations.rb
28
36
  lib/rds/right_rds_interface.rb
37
+ lib/iam/right_iam_interface.rb
38
+ lib/iam/right_iam_groups.rb
39
+ lib/iam/right_iam_users.rb
40
+ lib/iam/right_iam_access_keys.rb
41
+ lib/iam/right_iam_mfa_devices.rb
42
+ lib/route_53/right_route_53_interface.rb
29
43
  test/ec2/test_helper.rb
30
44
  test/ec2/test_right_ec2.rb
31
45
  test/http_connection.rb
data/README.txt CHANGED
@@ -68,10 +68,6 @@ concurrent requests to AWS. The way this plays out in practice is:
68
68
  Note that due to limitations in the I/O of the Ruby interpreter you
69
69
  may not get the degree of parallelism you may expect with the multi-threaded setting.
70
70
 
71
- By default, EC2/S3/SQS/SDB/ACF interface instances are created in single-threaded mode. Set
72
- "params[:multi_thread]" to "true" in the initialization arguments to use
73
- multithreaded mode.
74
-
75
71
  == GETTING STARTED:
76
72
 
77
73
  * For EC2 read RightAws::Ec2 and consult the Amazon EC2 API documentation at
data/Rakefile CHANGED
@@ -3,34 +3,37 @@
3
3
  require 'rubygems'
4
4
  require "rake/testtask"
5
5
  require 'rcov/rcovtask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/clean'
6
8
  $: << File.dirname(__FILE__)
7
- require 'lib/right_aws.rb'
8
-
9
9
  testglobs = ["test/ts_right_aws.rb"]
10
10
 
11
11
  begin
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- gem.name = "icehouse-right_aws"
15
- gem.summary = "Interface classes for the Amazon EC2, SQS, and S3 Web Services"
16
- gem.email = "support@rightscale.com"
17
- gem.homepage = "http://github.com/icehouse/right_aws"
18
- gem.authors = ["RightScale, Inc."]
19
- gem.files = Dir["[A-Z]*", "lib/**/*"]
20
-
21
- gem.add_dependency('right_http_connection', '>= 1.2.1')
22
- end
23
- Jeweler::GemcutterTasks.new
24
- rescue LoadError
25
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
12
+ require 'bundler'
13
+ rescue LoadError => e
14
+ STDERR.puts("Bundler is not available, some rake tasks will not be defined: #{e.message}")
15
+ else
16
+ Bundler::GemHelper.install_tasks :name => 'icehouse-right_aws'
17
+ end
18
+
19
+ # == Gem == #
20
+
21
+ gemtask = Rake::GemPackageTask.new(Gem::Specification.load("icehouse-right_aws.gemspec")) do |package|
22
+ package.package_dir = ENV['PACKAGE_DIR'] || 'pkg'
23
+ package.need_zip = true
24
+ package.need_tar = true
26
25
  end
27
26
 
27
+ directory gemtask.package_dir
28
+
29
+ CLEAN.include(gemtask.package_dir)
30
+
28
31
  desc "Analyze code coverage of the unit tests."
29
32
  Rcov::RcovTask.new do |t|
30
33
  t.test_files = FileList[testglobs]
31
34
  #t.verbose = true # uncomment to see the executed command
32
35
  end
33
-
36
+
34
37
  desc "Test just the SQS interface"
35
38
  task :testsqs do
36
39
  require 'test/test_credentials'
@@ -98,4 +101,18 @@ task :testrds do
98
101
  require 'test/rds/test_right_rds.rb'
99
102
  end
100
103
 
104
+ desc "Test Route 53 interface"
105
+ task :testroute53 do
106
+ require 'test/test_credentials'
107
+ TestCredentials.get_credentials
108
+ require 'test/route_53/test_right_route_53'
109
+ end
110
+
111
+ desc "Test ELB interface"
112
+ task :testelb do
113
+ require 'test/test_credentials'
114
+ TestCredentials.get_credentials
115
+ require 'test/elb/test_right_elb'
116
+ end
117
+
101
118
  # vim: syntax=Ruby
@@ -20,7 +20,6 @@
20
20
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #
23
-
24
23
  module RightAws
25
24
 
26
25
  # = RightAws::AcfInterface -- RightScale Amazon's CloudFront interface
@@ -39,24 +38,25 @@ module RightAws
39
38
  # [{:status => "Deployed",
40
39
  # :domain_name => "d74zzrxmpmygb.6hops.net",
41
40
  # :aws_id => "E4U91HCJHGXVC",
42
- # :origin => "my-bucket.s3.amazonaws.com",
41
+ # :s3_origin => {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
43
42
  # :cnames => ["x1.my-awesome-site.net", "x1.my-awesome-site.net"]
44
43
  # :comment => "My comments",
45
- # :last_modified_time => Wed Sep 10 17:00:04 UTC 2008 }, ..., {...} ]
44
+ # :last_modified_time => "2008-09-10T17:00:04.000Z" }, ..., {...} ]
46
45
  #
47
46
  # distibution = list.first
48
47
  #
49
48
  # info = acf.get_distribution(distibution[:aws_id]) #=>
50
- # {:enabled => true,
51
- # :caller_reference => "200809102100536497863003",
52
- # :e_tag => "E39OHHU1ON65SI",
53
- # :status => "Deployed",
54
- # :domain_name => "d3dxv71tbbt6cd.6hops.net",
55
- # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
56
- # :aws_id => "E2REJM3VUN5RSI",
57
- # :comment => "Woo-Hoo!",
58
- # :origin => "my-bucket.s3.amazonaws.com",
59
- # :last_modified_time => Wed Sep 10 17:00:54 UTC 2008 }
49
+ # {:last_modified_time=>"2010-05-19T18:54:38.242Z",
50
+ # :status=>"Deployed",
51
+ # :domain_name=>"dpzl38cuix402.cloudfront.net",
52
+ # :caller_reference=>"201005181943052207677116",
53
+ # :e_tag=>"EJSXFGM5JL8ER",
54
+ # :s3_origin=>
55
+ # {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
56
+ # :origin_access_identity=>
57
+ # "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
58
+ # :aws_id=>"E5P8HQ3ZAZIXD",
59
+ # :enabled=>false}
60
60
  #
61
61
  # config = acf.get_distribution_config(distibution[:aws_id]) #=>
62
62
  # {:enabled => true,
@@ -64,7 +64,7 @@ module RightAws
64
64
  # :e_tag => "E39OHHU1ON65SI",
65
65
  # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
66
66
  # :comment => "Woo-Hoo!",
67
- # :origin => "my-bucket.s3.amazonaws.com"}
67
+ # :s3_origin => {:dns_name => "my-bucket.s3.amazonaws.com"}}
68
68
  #
69
69
  # config[:comment] = 'Olah-lah!'
70
70
  # config[:enabled] = false
@@ -76,7 +76,7 @@ module RightAws
76
76
 
77
77
  include RightAwsBaseInterface
78
78
 
79
- API_VERSION = "2009-04-02"
79
+ API_VERSION = "2010-11-01"
80
80
  DEFAULT_HOST = 'cloudfront.amazonaws.com'
81
81
  DEFAULT_PORT = 443
82
82
  DEFAULT_PROTOCOL = 'https'
@@ -97,7 +97,6 @@ module RightAws
97
97
  # * <tt>:server</tt>: CloudFront service host, default: DEFAULT_HOST
98
98
  # * <tt>:port</tt>: CloudFront service port, default: DEFAULT_PORT
99
99
  # * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
100
- # * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
101
100
  # * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
102
101
  #
103
102
  # acf = RightAws::AcfInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX',
@@ -122,8 +121,8 @@ module RightAws
122
121
  # Generates request hash for REST API.
123
122
  def generate_request(method, path, params={}, body=nil, headers={}) # :nodoc:
124
123
  # Params
125
- params.delete_if{ |key, val| val.blank? }
126
- unless params.blank?
124
+ params.delete_if{ |key, val| val.right_blank? }
125
+ unless params.right_blank?
127
126
  path += "?" + params.to_a.collect{ |key,val| "#{AwsUtils::amz_escape(key)}=#{AwsUtils::amz_escape(val.to_s)}" }.join("&")
128
127
  end
129
128
  # Headers
@@ -134,7 +133,7 @@ module RightAws
134
133
  headers['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
135
134
  # Request
136
135
  path = "#{@params[:service]}#{@params[:api_version]}/#{path}"
137
- request = "Net::HTTP::#{method.capitalize}".constantize.new(path)
136
+ request = "Net::HTTP::#{method.capitalize}".right_constantize.new(path)
138
137
  request.body = body if body
139
138
  # Set request headers
140
139
  headers.each { |key, value| request[key.to_s] = value }
@@ -155,14 +154,6 @@ module RightAws
155
154
  # Helpers:
156
155
  #-----------------------------------------------------------------
157
156
 
158
- def self.escape(text) # :nodoc:
159
- REXML::Text::normalize(text)
160
- end
161
-
162
- def self.unescape(text) # :nodoc:
163
- REXML::Text::unnormalize(text)
164
- end
165
-
166
157
  def generate_call_reference # :nodoc:
167
158
  result = Time.now.strftime('%Y%m%d%H%M%S')
168
159
  10.times{ result << rand(10).to_s }
@@ -175,29 +166,84 @@ module RightAws
175
166
  hash
176
167
  end
177
168
 
178
- def config_to_xml(config) # :nodoc:
179
- cnames = ''
180
- unless config[:cnames].blank?
181
- config[:cnames].to_a.each { |cname| cnames += " <CNAME>#{cname}</CNAME>\n" }
169
+ def distribution_config_to_xml(config, xml_wrapper='DistributionConfig') # :nodoc:
170
+ cnames = logging = trusted_signers = s3_origin = custom_origin = default_root_object = ''
171
+ # CNAMES
172
+ unless config[:cnames].right_blank?
173
+ Array(config[:cnames]).each { |cname| cnames += " <CNAME>#{cname}</CNAME>\n" }
182
174
  end
183
- # logging
184
- logging = ''
185
- unless config[:logging].blank?
175
+ # Logging
176
+ unless config[:logging].right_blank?
186
177
  logging = " <Logging>\n" +
187
178
  " <Bucket>#{config[:logging][:bucket]}</Bucket>\n" +
188
179
  " <Prefix>#{config[:logging][:prefix]}</Prefix>\n" +
189
180
  " </Logging>\n"
190
181
  end
191
- # xml
192
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
193
- "<DistributionConfig xmlns=\"http://#{@params[:server]}/doc/#{API_VERSION}/\">\n" +
194
- " <Origin>#{config[:origin]}</Origin>\n" +
195
- " <CallerReference>#{config[:caller_reference]}</CallerReference>\n" +
196
- " <Comment>#{AcfInterface::escape(config[:comment].to_s)}</Comment>\n" +
182
+ unless config[:required_protocols].right_blank?
183
+ required_protocols = " <RequiredProtocols>\n" +
184
+ " <Protocol>#{config[:required_protocols]}</Protocol>\n" +
185
+ " </RequiredProtocols>\n"
186
+ else required_protocols = ""
187
+ end
188
+ # Default Root Object
189
+ unless config[:default_root_object].right_blank?
190
+ default_root_object = " <DefaultRootObject>#{config[:default_root_object]}</DefaultRootObject>\n" unless config[:default_root_object].right_blank?
191
+ end
192
+ # Trusted Signers
193
+ unless config[:trusted_signers].right_blank?
194
+ trusted_signers = " <TrustedSigners>\n"
195
+ Array(config[:trusted_signers]).each do |trusted_signer|
196
+ trusted_signers += if trusted_signer.to_s[/self/i]
197
+ " <Self/>\n"
198
+ else
199
+ " <AwsAccountNumber>#{trusted_signer}</AwsAccountNumber>\n"
200
+ end
201
+ end
202
+ trusted_signers += " </TrustedSigners>\n"
203
+ end
204
+ # S3Origin
205
+ unless config[:s3_origin].right_blank?
206
+ origin_access_identity = ''
207
+ # Origin Access Identity
208
+ unless config[:s3_origin][:origin_access_identity].right_blank?
209
+ origin_access_identity = config[:s3_origin][:origin_access_identity]
210
+ unless origin_access_identity[%r{^origin-access-identity}]
211
+ origin_access_identity = "origin-access-identity/cloudfront/#{origin_access_identity}"
212
+ end
213
+ origin_access_identity = " <OriginAccessIdentity>#{origin_access_identity}</OriginAccessIdentity>\n"
214
+ end
215
+ s3_origin = " <S3Origin>\n" +
216
+ " <DNSName>#{config[:s3_origin][:dns_name]}</DNSName>\n" +
217
+ "#{origin_access_identity}" +
218
+ " </S3Origin>\n"
219
+ end
220
+ # Custom Origin
221
+ unless config[:custom_origin].right_blank?
222
+ http_port = https_port = origin_protocol_policy = ''
223
+ http_port = " <HTTPPort>#{config[:custom_origin][:http_port]}</HTTPPort>\n" unless config[:custom_origin][:http_port].right_blank?
224
+ https_port = " <HTTPSPort>#{config[:custom_origin][:https_port]}</HTTPSPort>" unless config[:custom_origin][:https_port].right_blank?
225
+ origin_protocol_policy = " <OriginProtocolPolicy>#{config[:custom_origin][:origin_protocol_policy]}</OriginProtocolPolicy>\n" unless config[:custom_origin][:origin_protocol_policy].right_blank?
226
+ custom_origin = " <CustomOrigin>\n" +
227
+ " <DNSName>#{config[:custom_origin][:dns_name]}</DNSName>\n" +
228
+ "#{http_port}" +
229
+ "#{https_port}" +
230
+ "#{origin_protocol_policy}" +
231
+ " </CustomOrigin>\n"
232
+ end
233
+ # XML
234
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
235
+ "<#{xml_wrapper} xmlns=\"http://#{@params[:server]}/doc/#{API_VERSION}/\">\n" +
236
+ " <CallerReference>#{config[:caller_reference]}</CallerReference>\n" +
237
+ " <Comment>#{AwsUtils::xml_escape(config[:comment].to_s)}</Comment>\n" +
197
238
  " <Enabled>#{config[:enabled]}</Enabled>\n" +
198
- cnames +
199
- logging +
200
- "</DistributionConfig>"
239
+ s3_origin +
240
+ custom_origin +
241
+ default_root_object +
242
+ cnames +
243
+ logging +
244
+ required_protocols +
245
+ trusted_signers +
246
+ "</#{xml_wrapper}>"
201
247
  end
202
248
 
203
249
  #-----------------------------------------------------------------
@@ -208,13 +254,13 @@ module RightAws
208
254
  # Returns an array of distributions or RightAws::AwsError exception.
209
255
  #
210
256
  # acf.list_distributions #=>
211
- # [{:status => "Deployed",
212
- # :domain_name => "d74zzrxmpmygb.6hops.net",
213
- # :aws_id => "E4U91HCJHGXVC",
214
- # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
215
- # :origin => "my-bucket.s3.amazonaws.com",
216
- # :comment => "My comments",
217
- # :last_modified_time => Wed Sep 10 17:00:04 UTC 2008 }, ..., {...} ]
257
+ # [{:status=>"Deployed",
258
+ # :domain_name=>"dgmde.6os.net",
259
+ # :comment=>"ONE LINE OF COMMENT",
260
+ # :last_modified_time=>"2009-06-16T16:10:02.210Z",
261
+ # :s3_origin=>{:dns_name=>"example.s3.amazonaws.com"},
262
+ # :aws_id=>"12Q05OOMFN7SYL",
263
+ # :enabled=>true}, ... ]
218
264
  #
219
265
  def list_distributions
220
266
  result = []
@@ -234,11 +280,10 @@ module RightAws
234
280
  # {:distributions=>
235
281
  # [{:status=>"Deployed",
236
282
  # :aws_id=>"E2Q0AOOMFNPSYL",
237
- # :logging=>{},
238
- # :origin=>"my-bucket.s3.amazonaws.com",
283
+ # :s3_origin=>{:dns_name=>"example.s3.amazonaws.com"},
239
284
  # :domain_name=>"d1s5gmdtmafnre.6hops.net",
240
285
  # :comment=>"ONE LINE OF COMMENT",
241
- # :last_modified_time=>Wed Oct 22 19:31:23 UTC 2008,
286
+ # :last_modified_time=>"2008-10-22T19:31:23.000Z",
242
287
  # :enabled=>true,
243
288
  # :cnames=>[]}],
244
289
  # :is_truncated=>true,
@@ -252,7 +297,7 @@ module RightAws
252
297
  # # list distributions by 10
253
298
  # incrementally_list_distributions(:max_items => 10) do |response|
254
299
  # puts response.inspect # a list of 10 distributions
255
- # false # return false if the listing should be broken otherwise use true
300
+ # true # return false if the listing should be broken otherwise use true
256
301
  # end
257
302
  #
258
303
  def incrementally_list_distributions(params={}, &block)
@@ -264,7 +309,7 @@ module RightAws
264
309
  link = generate_request('GET', 'distribution', opts)
265
310
  last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
266
311
  opts['Marker'] = last_response[:next_marker]
267
- break unless block && block.call(last_response) && !last_response[:next_marker].blank?
312
+ break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
268
313
  end
269
314
  last_response
270
315
  end
@@ -272,51 +317,101 @@ module RightAws
272
317
  # Create a new distribution.
273
318
  # Returns the just created distribution or RightAws::AwsError exception.
274
319
  #
275
- # acf.create_distribution('my-bucket.s3.amazonaws.com', 'Woo-Hoo!', true, ['web1.my-awesome-site.net'],
276
- # { :prefix=>"log/", :bucket=>"my-logs.s3.amazonaws.com" } ) #=>
277
- # {:comment => "Woo-Hoo!",
278
- # :enabled => true,
279
- # :location => "https://cloudfront.amazonaws.com/2008-06-30/distribution/E2REJM3VUN5RSI",
280
- # :status => "InProgress",
281
- # :aws_id => "E2REJM3VUN5RSI",
282
- # :domain_name => "d3dxv71tbbt6cd.6hops.net",
283
- # :origin => "my-bucket.s3.amazonaws.com",
284
- # :cnames => ["web1.my-awesome-site.net"],
285
- # :logging => { :prefix => "log/",
286
- # :bucket => "my-logs.s3.amazonaws.com"},
287
- # :last_modified_time => Wed Sep 10 17:00:54 UTC 2008,
288
- # :caller_reference => "200809102100536497863003"}
320
+ # # S3 Origin
289
321
  #
290
- def create_distribution(origin, comment='', enabled=true, cnames=[], caller_reference=nil, logging={})
291
- config = { :origin => origin,
292
- :comment => comment,
293
- :enabled => enabled,
294
- :cnames => cnames.to_a,
295
- :caller_reference => caller_reference }
296
- config[:logging] = logging unless logging.blank?
297
- create_distribution_by_config(config)
298
- end
299
-
300
- def create_distribution_by_config(config)
322
+ # config = { :comment => "kd: delete me please",
323
+ # :s3_origin => { :dns_name => "devs-us-east.s3.amazonaws.com",
324
+ # :origin_access_identity => "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
325
+ # :enabled => true,
326
+ # :logging => { :prefix => "kd/log/",
327
+ # :bucket => "devs-us-west.s3.amazonaws.com"}}
328
+ # acf.create_distribution(config) #=>
329
+ # { :status=>"InProgress",
330
+ # :enabled=>true,
331
+ # :caller_reference=>"201012071910051044304704",
332
+ # :logging=>{:prefix=>"kd/log/", :bucket=>"devs-us-west.s3.amazonaws.com"},
333
+ # :e_tag=>"ESCTG5WJCFWJK",
334
+ # :location=> "https://cloudfront.amazonaws.com/2010-11-01/distribution/E3KUBANZ7N1B2",
335
+ # :comment=>"kd: delete me please",
336
+ # :domain_name=>"d3stykk6upgs20.cloudfront.net",
337
+ # :aws_id=>"E3KUBANZ7N1B2",
338
+ # :s3_origin=>
339
+ # {:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
340
+ # :dns_name=>"devs-us-east.s3.amazonaws.com"},
341
+ # :last_modified_time=>"2010-12-07T16:10:07.087Z",
342
+ # :in_progress_invalidation_batches=>0}
343
+ #
344
+ # # Custom Origin
345
+ #
346
+ # custom_config = { :comment => "kd: delete me please",
347
+ # :custom_origin => { :dns_name => "custom_origin.my-site.com",
348
+ # :http_port => 80,
349
+ # :https_port => 443,
350
+ # :origin_protocol_policy => 'match-viewer' },
351
+ # :enabled => true,
352
+ # :logging => { :prefix => "kd/log/",
353
+ # :bucket => "my-bucket.s3.amazonaws.com"}} #=>
354
+ # { :last_modified_time=>"2010-12-08T14:23:43.522Z",
355
+ # :status=>"InProgress",
356
+ # :custom_origin=>
357
+ # {:http_port=>"80",
358
+ # :https_port=>"443",
359
+ # :origin_protocol_policy=>"match-viewer",
360
+ # :dns_name=>"custom_origin.my-site.com"},
361
+ # :enabled=>true,
362
+ # :caller_reference=>"201012081723428499167245",
363
+ # :in_progress_invalidation_batches=>0,
364
+ # :e_tag=>"E1ZCJ8N5E52KO6",
365
+ # :location=>
366
+ # "https://cloudfront.amazonaws.com/2010-11-01/distribution/EK0AJ4RMNIF2P",
367
+ # :logging=>{:prefix=>"kd/log/", :bucket=>"my-bucket.s3.amazonaws.com"},
368
+ # :domain_name=>"do36k7s2wxklg.cloudfront.net",
369
+ # :comment=>"kd: delete me please",
370
+ # :aws_id=>"EK0AJ4RMNIF2P"}
371
+ #
372
+ def create_distribution(config)
301
373
  config[:caller_reference] ||= generate_call_reference
302
- link = generate_request('POST', 'distribution', {}, config_to_xml(config))
374
+ link = generate_request('POST', 'distribution', {}, distribution_config_to_xml(config))
303
375
  merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
304
376
  end
377
+ alias_method :create_distribution_by_config, :create_distribution
305
378
 
306
379
  # Get a distribution's information.
307
380
  # Returns a distribution's information or RightAws::AwsError exception.
308
381
  #
309
382
  # acf.get_distribution('E2REJM3VUN5RSI') #=>
310
- # {:enabled => true,
311
- # :caller_reference => "200809102100536497863003",
312
- # :e_tag => "E39OHHU1ON65SI",
313
- # :status => "Deployed",
314
- # :domain_name => "d3dxv71tbbt6cd.6hops.net",
315
- # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
316
- # :aws_id => "E2REJM3VUN5RSI",
317
- # :comment => "Woo-Hoo!",
318
- # :origin => "my-bucket.s3.amazonaws.com",
319
- # :last_modified_time => Wed Sep 10 17:00:54 UTC 2008 }
383
+ # {:last_modified_time=>"2010-05-19T18:54:38.242Z",
384
+ # :status=>"Deployed",
385
+ # :domain_name=>"dpzl38cuix402.cloudfront.net",
386
+ # :caller_reference=>"201005181943052207677116",
387
+ # :e_tag=>"EJSXFGM5JL8ER",
388
+ # :s3_origin=>
389
+ # {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
390
+ # :origin_access_identity=>
391
+ # "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
392
+ # :aws_id=>"E5P8HQ3ZAZIXD",
393
+ # :enabled=>false}
394
+ #
395
+ # acf.get_distribution('E2FNSBHNVVF11E') #=>
396
+ # {:e_tag=>"E1Q2DJEPTQOLJD",
397
+ # :status=>"InProgress",
398
+ # :last_modified_time=>"2010-04-17T17:24:25.000Z",
399
+ # :cnames=>["web1.my-awesome-site.net", "web2.my-awesome-site.net"],
400
+ # :aws_id=>"E2FNSBHNVVF11E",
401
+ # :logging=>{:prefix=>"xlog/", :bucket=>"my-bucket.s3.amazonaws.com"},
402
+ # :enabled=>true,
403
+ # :active_trusted_signers=>
404
+ # [{:aws_account_number=>"120288270000",
405
+ # :key_pair_ids=>["APKAJTD5OHNDX0000000", "APKAIK74BJWCL0000000"]},
406
+ # {:aws_account_number=>"self"},
407
+ # {:aws_account_number=>"648772220000"}],
408
+ # :caller_reference=>"201004171154450740700072",
409
+ # :domain_name=>"d1f6lpevremt5m.cloudfront.net",
410
+ # :s3_origin=>
411
+ # {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
412
+ # :origin_access_identity=>
413
+ # "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
414
+ # :trusted_signers=>["self", "648772220000", "120288270000"]}
320
415
  #
321
416
  def get_distribution(aws_id)
322
417
  link = generate_request('GET', "distribution/#{aws_id}")
@@ -327,12 +422,24 @@ module RightAws
327
422
  # Returns a distribution's configuration or RightAws::AwsError exception.
328
423
  #
329
424
  # acf.get_distribution_config('E2REJM3VUN5RSI') #=>
330
- # {:enabled => true,
331
- # :caller_reference => "200809102100536497863003",
332
- # :e_tag => "E39OHHU1ON65SI",
333
- # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
334
- # :comment => "Woo-Hoo!",
335
- # :origin => "my-bucket.s3.amazonaws.com"}
425
+ # {:caller_reference=>"201005181943052207677116",
426
+ # :e_tag=>"EJSXFGM5JL8ER",
427
+ # :s3_origin=>
428
+ # {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
429
+ # :origin_access_identity=>
430
+ # "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
431
+ # :enabled=>false}
432
+ #
433
+ # acf.get_distribution_config('E2FNSBHNVVF11E') #=>
434
+ # {:e_tag=>"E1Q2DJEPTQOLJD",
435
+ # :logging=>{:prefix=>"xlog/", :bucket=>"my-bucket.s3.amazonaws.com"},
436
+ # :enabled=>true,
437
+ # :caller_reference=>"201004171154450740700072",
438
+ # :trusted_signers=>["self", "648772220000", "120288270000"],
439
+ # :s3_origin=>
440
+ # {:dns_name=>"bucket-for-konstantin-eu.s3.amazonaws.com",
441
+ # :origin_access_identity=>
442
+ # "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"}}
336
443
  #
337
444
  def get_distribution_config(aws_id)
338
445
  link = generate_request('GET', "distribution/#{aws_id}/config")
@@ -340,7 +447,6 @@ module RightAws
340
447
  end
341
448
 
342
449
  # Set a distribution's configuration
343
- # (the :origin and the :caller_reference cannot be changed).
344
450
  # Returns +true+ on success or RightAws::AwsError exception.
345
451
  #
346
452
  # config = acf.get_distribution_config('E2REJM3VUN5RSI') #=>
@@ -349,13 +455,20 @@ module RightAws
349
455
  # :e_tag => "E39OHHU1ON65SI",
350
456
  # :cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
351
457
  # :comment => "Woo-Hoo!",
352
- # :origin => "my-bucket.s3.amazonaws.com"}
353
- # config[:comment] = 'Olah-lah!'
354
- # config[:enabled] = false
458
+ # :s3_origin => { :dns_name => "my-bucket.s3.amazonaws.com"}}
459
+ #
460
+ # config[:comment] = 'Olah-lah!'
461
+ # config[:enabled] = false
462
+ # config[:s3_origin][:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
463
+ # # or just
464
+ # # config[:s3_origin][:origin_access_identity] = "E3JPJZ80ZBX24G"
465
+ # config[:trusted_signers] = ['self', '648772220000', '120288270000']
466
+ # config[:logging] = { :bucket => 'my-bucket.s3.amazonaws.com', :prefix => 'xlog/' }
467
+ #
355
468
  # acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true
356
469
  #
357
470
  def set_distribution_config(aws_id, config)
358
- link = generate_request('PUT', "distribution/#{aws_id}/config", {}, config_to_xml(config),
471
+ link = generate_request('PUT', "distribution/#{aws_id}/config", {}, distribution_config_to_xml(config),
359
472
  'If-Match' => config[:e_tag])
360
473
  request_info(link, RightHttp2xxParser.new(:logger => @logger))
361
474
  end
@@ -380,32 +493,55 @@ module RightAws
380
493
  @result = { :distributions => [] }
381
494
  end
382
495
  def tagstart(name, attributes)
383
- if name == 'DistributionSummary' || name == 'Distribution' ||
384
- (name == 'DistributionConfig' && @xmlpath.blank?)
385
- @distribution = { :cnames => [], :logging => {} }
496
+ case full_tag_name
497
+ when %r{/Signer$}
498
+ @active_signer = {}
499
+ when %r{(Streaming)?DistributionSummary$},
500
+ %r{^(Streaming)?Distribution$},
501
+ %r{^(Streaming)?DistributionConfig$}
502
+ @distribution = { }
503
+ when %r{/S3Origin$} then @distribution[:s3_origin] = {}
504
+ when %r{/CustomOrigin$} then @distribution[:custom_origin] = {}
386
505
  end
387
506
  end
388
507
  def tagend(name)
389
508
  case name
390
- when 'Marker' then @result[:marker] = @text
391
- when 'NextMarker' then @result[:next_marker] = @text
392
- when 'MaxItems' then @result[:max_items] = @text.to_i
393
- when 'IsTruncated' then @result[:is_truncated] = @text == 'true' ? true : false
394
- when 'Id' then @distribution[:aws_id] = @text
395
- when 'Status' then @distribution[:status] = @text
396
- when 'LastModifiedTime' then @distribution[:last_modified_time] = Time.parse(@text)
397
- when 'DomainName' then @distribution[:domain_name] = @text
398
- when 'Origin' then @distribution[:origin] = @text
399
- when 'Comment' then @distribution[:comment] = AcfInterface::unescape(@text)
400
- when 'CallerReference' then @distribution[:caller_reference] = @text
401
- when 'CNAME' then @distribution[:cnames] << @text
402
- when 'Enabled' then @distribution[:enabled] = @text == 'true' ? true : false
403
- when 'Bucket' then @distribution[:logging][:bucket] = @text
404
- when 'Prefix' then @distribution[:logging][:prefix] = @text
405
- end
406
- if name == 'DistributionSummary' || name == 'Distribution' ||
407
- (name == 'DistributionConfig' && @xmlpath.blank?)
408
- @result[:distributions] << @distribution
509
+ when 'Marker' then @result[:marker] = @text
510
+ when 'NextMarker' then @result[:next_marker] = @text
511
+ when 'MaxItems' then @result[:max_items] = @text.to_i
512
+ when 'IsTruncated' then @result[:is_truncated] = (@text == 'true')
513
+ when 'Id' then @distribution[:aws_id] = @text
514
+ when 'Status' then @distribution[:status] = @text
515
+ when 'LastModifiedTime' then @distribution[:last_modified_time] = @text
516
+ when 'DomainName' then @distribution[:domain_name] = @text
517
+ when 'Comment' then @distribution[:comment] = AwsUtils::xml_unescape(@text)
518
+ when 'CallerReference' then @distribution[:caller_reference] = @text
519
+ when 'CNAME' then (@distribution[:cnames] ||= []) << @text
520
+ when 'Enabled' then @distribution[:enabled] = (@text == 'true')
521
+ when 'Bucket' then (@distribution[:logging] ||= {})[:bucket] = @text
522
+ when 'Prefix' then (@distribution[:logging] ||= {})[:prefix] = @text
523
+ when 'Protocol' then (@distribution[:required_protocols] ||= {})[:protocol] = @text
524
+ when 'InProgressInvalidationBatches' then @distribution[:in_progress_invalidation_batches] = @text.to_i
525
+ when 'DefaultRootObject' then @distribution[:default_root_object] = @text
526
+ else
527
+ case full_tag_name
528
+ when %r{/S3Origin/DNSName$} then @distribution[:s3_origin][:dns_name] = @text
529
+ when %r{/S3Origin/OriginAccessIdentity$} then @distribution[:s3_origin][:origin_access_identity] = @text
530
+ when %r{/CustomOrigin/DNSName$} then @distribution[:custom_origin][:dns_name] = @text
531
+ when %r{/CustomOrigin/HTTPPort} then @distribution[:custom_origin][:http_port] = @text
532
+ when %r{/CustomOrigin/HTTPSPort$} then @distribution[:custom_origin][:https_port] = @text
533
+ when %r{/CustomOrigin/OriginProtocolPolicy$} then @distribution[:custom_origin][:origin_protocol_policy] = @text
534
+ when %r{/TrustedSigners/Self$} then (@distribution[:trusted_signers] ||= []) << 'self'
535
+ when %r{/TrustedSigners/AwsAccountNumber$} then (@distribution[:trusted_signers] ||= []) << @text
536
+ when %r{/Signer/Self$} then @active_signer[:aws_account_number] = 'self'
537
+ when %r{/Signer/AwsAccountNumber$} then @active_signer[:aws_account_number] = @text
538
+ when %r{/Signer/KeyPairId$} then (@active_signer[:key_pair_ids] ||= []) << @text
539
+ when %r{/Signer$} then (@distribution[:active_trusted_signers] ||= []) << @active_signer
540
+ when %r{(Streaming)?DistributionSummary$},
541
+ %r{^(Streaming)?Distribution$},
542
+ %r{^(Streaming)?DistributionConfig$}
543
+ @result[:distributions] << @distribution
544
+ end
409
545
  end
410
546
  end
411
547
  end