aboisvert_aws 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +329 -0
- data/Manifest.txt +61 -0
- data/README.txt +163 -0
- data/Rakefile +130 -0
- data/lib/acf/right_acf_interface.rb +549 -0
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +229 -0
- data/lib/acw/right_acw_interface.rb +248 -0
- data/lib/as/right_as_interface.rb +698 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +1343 -0
- data/lib/awsbase/support.rb +35 -0
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +541 -0
- data/lib/ec2/right_ec2_ebs.rb +481 -0
- data/lib/ec2/right_ec2_images.rb +444 -0
- data/lib/ec2/right_ec2_instances.rb +788 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +184 -0
- data/lib/ec2/right_ec2_security_groups.rb +491 -0
- data/lib/ec2/right_ec2_spot_instances.rb +422 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +590 -0
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +573 -0
- data/lib/emr/right_emr_interface.rb +727 -0
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +1384 -0
- data/lib/right_aws.rb +86 -0
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +1138 -0
- data/lib/s3/right_s3_interface.rb +1278 -0
- data/lib/sdb/active_sdb.rb +1107 -0
- data/lib/sdb/right_sdb_interface.rb +762 -0
- data/lib/sns/right_sns_interface.rb +286 -0
- data/lib/sqs/right_sqs.rb +387 -0
- data/lib/sqs/right_sqs_gen2.rb +342 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
- data/lib/sqs/right_sqs_interface.rb +593 -0
- data/right_aws.gemspec +90 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +138 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +11 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +107 -0
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +87 -0
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_helper.rb +2 -0
- data/test/s3/test_right_s3.rb +528 -0
- data/test/s3/test_right_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +357 -0
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +253 -0
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +285 -0
- data/test/sqs/test_right_sqs_gen2.rb +264 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +15 -0
- metadata +257 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2010 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
module RightAws
|
24
|
+
|
25
|
+
class AcfInterface
|
26
|
+
|
27
|
+
# List Invalidations
|
28
|
+
#
|
29
|
+
# acf.list_invalidations('E3LTBMK4EAQS7D') #=>
|
30
|
+
# [{:status=>"InProgress", :aws_id=>"I3AW9PPQS0CBKV"},
|
31
|
+
# {:status=>"InProgress", :aws_id=>"I1HV23N5KD3XH9"}]
|
32
|
+
#
|
33
|
+
def list_invalidations(distribution_aws_id)
|
34
|
+
result = []
|
35
|
+
incrementally_list_invalidations(distribution_aws_id) do |response|
|
36
|
+
result += response[:invalidations]
|
37
|
+
true
|
38
|
+
end
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
# Incrementally list Invalidations.
|
43
|
+
# Optional params: +:marker+ and +:max_items+.
|
44
|
+
#
|
45
|
+
def incrementally_list_invalidations(distribution_aws_id, params={}, &block)
|
46
|
+
opts = {}
|
47
|
+
opts['MaxItems'] = params[:max_items] if params[:max_items]
|
48
|
+
opts['Marker'] = params[:marker] if params[:marker]
|
49
|
+
last_response = nil
|
50
|
+
loop do
|
51
|
+
link = generate_request('GET', "distribution/#{distribution_aws_id}/invalidation", opts)
|
52
|
+
last_response = request_info(link, AcfInvalidationsListParser.new(:logger => @logger))
|
53
|
+
opts['Marker'] = last_response[:next_marker]
|
54
|
+
break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
|
55
|
+
end
|
56
|
+
last_response
|
57
|
+
end
|
58
|
+
|
59
|
+
#-----------------------------------------------------------------
|
60
|
+
# Origin Access Identity
|
61
|
+
#-----------------------------------------------------------------
|
62
|
+
|
63
|
+
# Create a new Invalidation batch.
|
64
|
+
#
|
65
|
+
# acf.create_invalidation('E3LTBMK4EAQS7D', :path => ['/boot.jpg', '/kd/boot.public.1.jpg']) #=>
|
66
|
+
# {:status=>"InProgress",
|
67
|
+
# :create_time=>"2010-12-08T14:03:38.449Z",
|
68
|
+
# :location=> "https://cloudfront.amazonaws.com/2010-11-01/distribution/E3LTBMK4EAQS7D/invalidation/I3AW9PPQS0CBKV",
|
69
|
+
# :aws_id=>"I3AW9PPQS0CBKV",
|
70
|
+
# :invalidation_batch=>
|
71
|
+
# {:caller_reference=>"201012081703372555972012",
|
72
|
+
# :path=>["/boot.jpg", "/kd/boot.public.1.jpg"]}}
|
73
|
+
#
|
74
|
+
def create_invalidation(distribution_aws_id, invalidation_batch)
|
75
|
+
invalidation_batch[:caller_reference] ||= generate_call_reference
|
76
|
+
link = generate_request('POST', "/distribution/#{distribution_aws_id}/invalidation", {}, invalidation_batch_to_xml(invalidation_batch))
|
77
|
+
merge_headers(request_info(link, AcfInvalidationsListParser.new(:logger => @logger))[:invalidations].first)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Get Invalidation
|
81
|
+
#
|
82
|
+
# acf.get_invalidation('E3LTBMK4EAQS7D', 'I3AW9PPQS0CBKV') #=>
|
83
|
+
# {:create_time=>"2010-12-08T14:03:38.449Z",
|
84
|
+
# :status=>"InProgress",
|
85
|
+
# :aws_id=>"I3AW9PPQS0CBKV",
|
86
|
+
# :invalidation_batch=>
|
87
|
+
# {:caller_reference=>"201012081703372555972012",
|
88
|
+
# :path=>["/boot.jpg", "/kd/boot.public.1.jpg"]}}
|
89
|
+
#
|
90
|
+
def get_invalidation(distribution_aws_id, aws_id)
|
91
|
+
link = generate_request('GET', "distribution/#{distribution_aws_id}/invalidation/#{aws_id}")
|
92
|
+
merge_headers(request_info(link, AcfInvalidationsListParser.new(:logger => @logger))[:invalidations].first)
|
93
|
+
end
|
94
|
+
|
95
|
+
#-----------------------------------------------------------------
|
96
|
+
# Batch
|
97
|
+
#-----------------------------------------------------------------
|
98
|
+
|
99
|
+
def invalidation_batch_to_xml(invalidation_batch) # :nodoc:
|
100
|
+
paths = ''
|
101
|
+
Array(invalidation_batch[:path]).each do |path|
|
102
|
+
paths << " <Path>#{AwsUtils::xml_escape(path)}</Path>\n"
|
103
|
+
end
|
104
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
105
|
+
"<InvalidationBatch xmlns=\"http://#{@params[:server]}/doc/#{API_VERSION}/\">\n" +
|
106
|
+
" <CallerReference>#{invalidation_batch[:caller_reference]}</CallerReference>\n" +
|
107
|
+
paths +
|
108
|
+
"</InvalidationBatch>"
|
109
|
+
end
|
110
|
+
|
111
|
+
#-----------------------------------------------------------------
|
112
|
+
# PARSERS:
|
113
|
+
#-----------------------------------------------------------------
|
114
|
+
|
115
|
+
class AcfInvalidationsListParser < RightAWSParser # :nodoc:
|
116
|
+
def reset
|
117
|
+
@result = { :invalidations => [] }
|
118
|
+
end
|
119
|
+
def tagstart(name, attributes)
|
120
|
+
case name
|
121
|
+
when %r{(InvalidationSummary|Invalidation)$} then @item = {}
|
122
|
+
when %r{InvalidationBatch} then @item[:invalidation_batch] = {}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
def tagend(name)
|
126
|
+
case name
|
127
|
+
when 'Marker' then @result[:marker] = @text
|
128
|
+
when 'NextMarker' then @result[:next_marker] = @text
|
129
|
+
when 'MaxItems' then @result[:max_items] = @text.to_i
|
130
|
+
when 'IsTruncated' then @result[:is_truncated] = (@text == 'true')
|
131
|
+
when 'Id' then @item[:aws_id] = @text
|
132
|
+
when 'Status' then @item[:status] = @text
|
133
|
+
when 'CreateTime' then @item[:create_time] = @text
|
134
|
+
when 'Path' then (@item[:invalidation_batch][:path] ||= []) << @text
|
135
|
+
when 'CallerReference' then @item[:invalidation_batch][:caller_reference] = @text
|
136
|
+
when %r{(InvalidationSummary|Invalidation)$}
|
137
|
+
@item[:invalidation_batch][:path].sort! if @item[:invalidation_batch] && !@item[:invalidation_batch][:path].right_blank?
|
138
|
+
@result[:invalidations] << @item
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2010 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
module RightAws
|
24
|
+
|
25
|
+
class AcfInterface
|
26
|
+
|
27
|
+
# List Origin Access Identities.
|
28
|
+
#
|
29
|
+
# acf.list_origin_access_identities #=>
|
30
|
+
# [{:comment=>"kd: TEST",
|
31
|
+
# :s3_canonical_user_id=>
|
32
|
+
# "c7ca36f6c5d384e60aeca02032ac748bae3c458c5322a2e279382935f1f71b16d9ac251f7f71f1ea91c37d3c214645b8",
|
33
|
+
# :aws_id=>"E3TL4XWF5KTGH"},
|
34
|
+
# {:comment=>"kd: TEST-2",
|
35
|
+
# :s3_canonical_user_id=>
|
36
|
+
# "9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
|
37
|
+
# :aws_id=>"E3HJ7V8C3324VF"},
|
38
|
+
# {:comment=>"MyTestAccessIdentity",
|
39
|
+
# :s3_canonical_user_id=>
|
40
|
+
# "de4361b33dbaf499d3d77159bfa1571d3451eaec25a2b16553de5e534da8089bb8c31a4898d73d1a658155d0e48872a7",
|
41
|
+
# :aws_id=>"E3JPJZ80ZBX24G"}]
|
42
|
+
#
|
43
|
+
def list_origin_access_identities
|
44
|
+
result = []
|
45
|
+
incrementally_list_origin_access_identities do |response|
|
46
|
+
result += response[:origin_access_identities]
|
47
|
+
true
|
48
|
+
end
|
49
|
+
result
|
50
|
+
end
|
51
|
+
|
52
|
+
# Incrementally list Origin Access Identities.
|
53
|
+
# Optional params: +:marker+ and +:max_items+.
|
54
|
+
#
|
55
|
+
# acf.incrementally_list_origin_access_identities(:max_items => 2) #=>
|
56
|
+
# {:origin_access_identities=>
|
57
|
+
# [{:comment=>"kd: TEST",
|
58
|
+
# :s3_canonical_user_id=>
|
59
|
+
# "c7ca36f6c5d384e60aeca02032ac748bae3c458c5322a2e279382935f1f71b16d9ac251f7f71f1ea91c37d3c214645b8",
|
60
|
+
# :aws_id=>"E3TL4XWF5KTGH"},
|
61
|
+
# {:comment=>"kd: TEST-2",
|
62
|
+
# :s3_canonical_user_id=>
|
63
|
+
# "9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
|
64
|
+
# :aws_id=>"E3HJ7V8C3324VF"}],
|
65
|
+
# :is_truncated=>true,
|
66
|
+
# :max_items=>2,
|
67
|
+
# :marker=>"",
|
68
|
+
# :next_marker=>"E3HJ7V8C3324VF"}
|
69
|
+
#
|
70
|
+
# # get max 100 origin access identities (the list will be restricted by a default MaxItems value ==100 )
|
71
|
+
# incrementally_list_origin_access_identities
|
72
|
+
#
|
73
|
+
# # list origin access identities by 10
|
74
|
+
# acf.incrementally_list_origin_access_identities(:max_items => 10) do |response|
|
75
|
+
# puts response.inspect # a list of 10 distributions
|
76
|
+
# true # return false if the listing should be broken otherwise use true
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
def incrementally_list_origin_access_identities(params={}, &block)
|
80
|
+
opts = {}
|
81
|
+
opts['MaxItems'] = params[:max_items] if params[:max_items]
|
82
|
+
opts['Marker'] = params[:marker] if params[:marker]
|
83
|
+
last_response = nil
|
84
|
+
loop do
|
85
|
+
link = generate_request('GET', 'origin-access-identity/cloudfront', opts)
|
86
|
+
last_response = request_info(link, AcfOriginAccesIdentitiesListParser.new(:logger => @logger))
|
87
|
+
opts['Marker'] = last_response[:next_marker]
|
88
|
+
break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
|
89
|
+
end
|
90
|
+
last_response
|
91
|
+
end
|
92
|
+
|
93
|
+
#-----------------------------------------------------------------
|
94
|
+
# Origin Access Identity
|
95
|
+
#-----------------------------------------------------------------
|
96
|
+
|
97
|
+
# Create a new CloudFront Origin Access Identity.
|
98
|
+
#
|
99
|
+
# acf.create_origin_access_identity('MyTestAccessIdentity') #=>
|
100
|
+
# {:e_tag=>"E2QOKZEXCUWHJX",
|
101
|
+
# :comment=>"MyTestAccessIdentity",
|
102
|
+
# :location=>
|
103
|
+
# "https://cloudfront.amazonaws.com/origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
|
104
|
+
# :caller_reference=>"201004161657467493031273",
|
105
|
+
# :s3_canonical_user_id=>
|
106
|
+
# "de4361b33dbaf499d3d77159bfa1571d3451eaec25a2b16553de5e534da8089bb8c31a4898d73d1a658155d0e48872a7",
|
107
|
+
# :aws_id=>"E3JPJZ80ZBX24G"}
|
108
|
+
#
|
109
|
+
def create_origin_access_identity(comment='', caller_reference=nil)
|
110
|
+
config = { :comment => comment,
|
111
|
+
:caller_reference => caller_reference }
|
112
|
+
create_origin_access_identity_by_config(config)
|
113
|
+
end
|
114
|
+
|
115
|
+
def create_origin_access_identity_by_config(config)
|
116
|
+
config[:caller_reference] ||= generate_call_reference
|
117
|
+
link = generate_request('POST', 'origin-access-identity/cloudfront', {}, origin_access_identity_config_to_xml(config))
|
118
|
+
merge_headers(request_info(link, AcfOriginAccesIdentitiesListParser.new(:logger => @logger))[:origin_access_identities].first)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Get Origin Access Identity
|
122
|
+
#
|
123
|
+
# acf.get_origin_access_identity('E3HJ7V8C3324VF') #=>
|
124
|
+
# {:comment=>"kd: TEST-2",
|
125
|
+
# :caller_reference=>"201004161655035372351604",
|
126
|
+
# :aws_id=>"E3HJ7V8C3324VF",
|
127
|
+
# :s3_canonical_user_id=>
|
128
|
+
# "9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
|
129
|
+
# :e_tag=>"E309Q4IM450498"}
|
130
|
+
#
|
131
|
+
def get_origin_access_identity(aws_id)
|
132
|
+
link = generate_request('GET', "origin-access-identity/cloudfront/#{aws_id}")
|
133
|
+
merge_headers(request_info(link, AcfOriginAccesIdentitiesListParser.new(:logger => @logger))[:origin_access_identities].first)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Get Origin Access Identity
|
137
|
+
#
|
138
|
+
# acf.get_origin_access_identity('E3HJ7V8C3324VF') #=>
|
139
|
+
# {:comment=>"kd: TEST-2",
|
140
|
+
# :caller_reference=>"201004161655035372351604",
|
141
|
+
# :aws_id=>"E3HJ7V8C3324VF",
|
142
|
+
# :s3_canonical_user_id=>
|
143
|
+
# "9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
|
144
|
+
# :e_tag=>"E309Q4IM450498"}
|
145
|
+
#
|
146
|
+
# acf.delete_origin_access_identity("E3HJ7V8C3324VF","E309Q4IM450498") #=> true
|
147
|
+
#
|
148
|
+
def delete_origin_access_identity(aws_id, e_tag)
|
149
|
+
link = generate_request('DELETE', "origin-access-identity/cloudfront/#{aws_id}", {}, nil,
|
150
|
+
'If-Match' => e_tag)
|
151
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
152
|
+
end
|
153
|
+
|
154
|
+
#-----------------------------------------------------------------
|
155
|
+
# Config
|
156
|
+
#-----------------------------------------------------------------
|
157
|
+
|
158
|
+
def origin_access_identity_config_to_xml(config) # :nodoc:
|
159
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
160
|
+
"<CloudFrontOriginAccessIdentityConfig xmlns=\"http://#{@params[:server]}/doc/#{API_VERSION}/\">\n" +
|
161
|
+
" <CallerReference>#{config[:caller_reference]}</CallerReference>\n" +
|
162
|
+
" <Comment>#{AwsUtils::xml_escape(config[:comment].to_s)}</Comment>\n" +
|
163
|
+
"</CloudFrontOriginAccessIdentityConfig>"
|
164
|
+
end
|
165
|
+
|
166
|
+
# Get Origin Access Identity config
|
167
|
+
#
|
168
|
+
# acf.get_origin_access_identity_config("E3JPJZ80ZBX24G") #=>
|
169
|
+
# {:comment=>"MyTestAccessIdentity",
|
170
|
+
# :caller_reference=>"201004161657467493031273",
|
171
|
+
# :e_tag=>"E2QOKZEXCUWHJX"}
|
172
|
+
#
|
173
|
+
def get_origin_access_identity_config(aws_id)
|
174
|
+
link = generate_request('GET', "origin-access-identity/cloudfront/#{aws_id}/config")
|
175
|
+
merge_headers(request_info(link, AcfOriginAccesIdentitiesListParser.new(:logger => @logger))[:origin_access_identities].first)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Set Origin Access Identity config
|
179
|
+
#
|
180
|
+
#
|
181
|
+
# acf.set_origin_access_identity_config("E2QOKZEXCUWHJX",
|
182
|
+
# :comment => "MyBestOriginAccessConfig",
|
183
|
+
# :caller_reference => '01234567890',
|
184
|
+
# :e_tag=>"E2QOKZEXCUWHJX") #=> true
|
185
|
+
#
|
186
|
+
# P.S. This guy is not tested yet: http://developer.amazonwebservices.com/connect/thread.jspa?threadID=45256
|
187
|
+
def set_origin_access_identity_config(aws_id, config)
|
188
|
+
link = generate_request('PUT', "origin-access-identity/cloudfront/#{aws_id}/config", {}, origin_access_identity_config_to_xml(config),
|
189
|
+
'If-Match' => config[:e_tag])
|
190
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
191
|
+
end
|
192
|
+
|
193
|
+
#-----------------------------------------------------------------
|
194
|
+
# PARSERS:
|
195
|
+
#-----------------------------------------------------------------
|
196
|
+
|
197
|
+
class AcfOriginAccesIdentitiesListParser < RightAWSParser # :nodoc:
|
198
|
+
def reset
|
199
|
+
@result = { :origin_access_identities => [] }
|
200
|
+
end
|
201
|
+
def tagstart(name, attributes)
|
202
|
+
case full_tag_name
|
203
|
+
when %r{CloudFrontOriginAccessIdentitySummary$},
|
204
|
+
%r{^CloudFrontOriginAccessIdentity$},
|
205
|
+
%r{^CloudFrontOriginAccessIdentityConfig$}
|
206
|
+
@item = {}
|
207
|
+
end
|
208
|
+
end
|
209
|
+
def tagend(name)
|
210
|
+
case name
|
211
|
+
when 'Marker' then @result[:marker] = @text
|
212
|
+
when 'NextMarker' then @result[:next_marker] = @text
|
213
|
+
when 'MaxItems' then @result[:max_items] = @text.to_i
|
214
|
+
when 'IsTruncated' then @result[:is_truncated] = (@text == 'true')
|
215
|
+
when 'Id' then @item[:aws_id] = @text
|
216
|
+
when 'S3CanonicalUserId' then @item[:s3_canonical_user_id] = @text
|
217
|
+
when 'CallerReference' then @item[:caller_reference] = @text
|
218
|
+
when 'Comment' then @item[:comment] = AwsUtils::xml_unescape(@text)
|
219
|
+
end
|
220
|
+
case full_tag_name
|
221
|
+
when %r{CloudFrontOriginAccessIdentitySummary$},
|
222
|
+
%r{^CloudFrontOriginAccessIdentity$},
|
223
|
+
%r{^CloudFrontOriginAccessIdentityConfig$}
|
224
|
+
@result[:origin_access_identities] << @item
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2008 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#
|
23
|
+
module RightAws
|
24
|
+
|
25
|
+
class AcfInterface
|
26
|
+
|
27
|
+
def streaming_distribution_config_to_xml(config) # :nodoc:
|
28
|
+
distribution_config_to_xml(config, 'StreamingDistributionConfig')
|
29
|
+
end
|
30
|
+
|
31
|
+
#-----------------------------------------------------------------
|
32
|
+
# API Calls:
|
33
|
+
#-----------------------------------------------------------------
|
34
|
+
|
35
|
+
# List all streaming distributions.
|
36
|
+
# Returns an array of distributions or RightAws::AwsError exception.
|
37
|
+
#
|
38
|
+
# acf.list_streaming_distributions #=>
|
39
|
+
# [{:status=>"Deployed",
|
40
|
+
# :aws_id=>"E3CWE2Z9USOS6B",
|
41
|
+
# :enabled=>true,
|
42
|
+
# :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
|
43
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
44
|
+
# :last_modified_time=>"2010-04-19T08:53:32.574Z",
|
45
|
+
# :comment=>"Woo-Hoo!",
|
46
|
+
# :cnames=>["stream.web.my-awesome-site.net"]},
|
47
|
+
# ...
|
48
|
+
# {:status=>"Deployed",
|
49
|
+
# :aws_id=>"E3NPQZY4LKAYQ8",
|
50
|
+
# :enabled=>true,
|
51
|
+
# :domain_name=>"sw9nrsq9pudk3.cloudfront.net",
|
52
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
53
|
+
# :last_modified_time=>"2010-04-19T08:59:09.600Z",
|
54
|
+
# :comment=>"Woo-Hoo!",
|
55
|
+
# :cnames=>["stream-6.web.my-awesome-site.net"]}]
|
56
|
+
#
|
57
|
+
def list_streaming_distributions
|
58
|
+
result = []
|
59
|
+
incrementally_list_streaming_distributions do |response|
|
60
|
+
result += response[:distributions]
|
61
|
+
true
|
62
|
+
end
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
# Incrementally list streaming distributions.
|
67
|
+
#
|
68
|
+
# Optional params: +:marker+ and +:max_items+.
|
69
|
+
#
|
70
|
+
# # get first streaming distribution
|
71
|
+
# incrementally_list_distributions(:max_items => 1) #=>
|
72
|
+
# {:marker=>"",
|
73
|
+
# :next_marker=>"E3CWE2Z9USOS6B",
|
74
|
+
# :distributions=>
|
75
|
+
# [{:status=>"Deployed",
|
76
|
+
# :cnames=>["stream.web.my-awesome-site.net"],
|
77
|
+
# :aws_id=>"E3CWE2Z9USOS6B",
|
78
|
+
# :enabled=>true,
|
79
|
+
# :last_modified_time=>"2010-04-19T08:53:32.574Z",
|
80
|
+
# :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
|
81
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
82
|
+
# :comment=>"Woo-Hoo!"}],
|
83
|
+
# :max_items=>1,
|
84
|
+
# :is_truncated=>true}
|
85
|
+
#
|
86
|
+
# # get max 100 streaming distributions (the list will be restricted by a default MaxItems value ==100 )
|
87
|
+
# incrementally_list_streaming_distributions
|
88
|
+
#
|
89
|
+
# # list streaming distributions by 10
|
90
|
+
# incrementally_list_streaming_distributions(:max_items => 10) do |response|
|
91
|
+
# puts response.inspect # a list of 10 distributions
|
92
|
+
# true # return false if the listing should be broken otherwise use true
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
def incrementally_list_streaming_distributions(params={}, &block)
|
96
|
+
opts = {}
|
97
|
+
opts['MaxItems'] = params[:max_items] if params[:max_items]
|
98
|
+
opts['Marker'] = params[:marker] if params[:marker]
|
99
|
+
last_response = nil
|
100
|
+
loop do
|
101
|
+
link = generate_request('GET', 'streaming-distribution', opts)
|
102
|
+
last_response = request_info(link, AcfDistributionListParser.new(:logger => @logger))
|
103
|
+
opts['Marker'] = last_response[:next_marker]
|
104
|
+
break unless block && block.call(last_response) && !last_response[:next_marker].right_blank?
|
105
|
+
end
|
106
|
+
last_response
|
107
|
+
end
|
108
|
+
|
109
|
+
# Create a new streaming distribution.
|
110
|
+
# Returns the just created distribution or RightAws::AwsError exception.
|
111
|
+
#
|
112
|
+
# acf.create_streaming_distribution('bucket-for-konstantin-00.s3.amazonaws.com', 'Woo-Hoo!', true,
|
113
|
+
# ['stream-1.web.my-awesome-site.net']) #=>
|
114
|
+
# {:status=>"InProgress",
|
115
|
+
# :caller_reference=>"201004191254412191173215",
|
116
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
117
|
+
# :aws_id=>"E1M5LERJLU636F",
|
118
|
+
# :e_tag=>"E2588L5QL4BLXH",
|
119
|
+
# :enabled=>true,
|
120
|
+
# :domain_name=>"s1di8imd85wgld.cloudfront.net",
|
121
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
122
|
+
# :last_modified_time=>Mon Apr 19 08:54:42 UTC 2010,
|
123
|
+
# :location=>
|
124
|
+
# "https://cloudfront.amazonaws.com/streaming-distribution/E1M5LERJLU636F",
|
125
|
+
# :comment=>"Woo-Hoo!"}
|
126
|
+
#
|
127
|
+
def create_streaming_distribution(config)
|
128
|
+
config[:caller_reference] ||= generate_call_reference
|
129
|
+
link = generate_request('POST', 'streaming-distribution', {}, streaming_distribution_config_to_xml(config))
|
130
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
131
|
+
end
|
132
|
+
alias_method :create_streaming_distribution_by_config, :create_streaming_distribution
|
133
|
+
|
134
|
+
# Get a streaming distribution's information.
|
135
|
+
# Returns a distribution's information or RightAws::AwsError exception.
|
136
|
+
#
|
137
|
+
# acf.get_streaming_distribution('E3CWE2Z9USOS6B') #=>
|
138
|
+
# {:status=>"Deployed",
|
139
|
+
# :e_tag=>"EXTZ2SXAQT39K",
|
140
|
+
# :cnames=>["stream.web.my-awesome-site.net"],
|
141
|
+
# :aws_id=>"E3CWE2Z9USOS6B",
|
142
|
+
# :enabled=>true,
|
143
|
+
# :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
|
144
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
145
|
+
# :last_modified_time=>"2010-04-19T08:53:32.574Z",
|
146
|
+
# :comment=>"Woo-Hoo!",
|
147
|
+
# :caller_reference=>"201004191253311625537161"}
|
148
|
+
#
|
149
|
+
# acf.get_streaming_distribution('E1M5LERJLU636F') #=>
|
150
|
+
# {:trusted_signers=>["self", "648772220000", "120288270000"],
|
151
|
+
# :status=>"InProgress",
|
152
|
+
# :e_tag=>"E2K6XD13RCJQ6E",
|
153
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
154
|
+
# :active_trusted_signers=>
|
155
|
+
# [{:key_pair_ids=>["APKAIK74BJWCLXZUMEJA"],
|
156
|
+
# :aws_account_number=>"120288270000"},
|
157
|
+
# {:aws_account_number=>"self"},
|
158
|
+
# {:aws_account_number=>"648772220000"}],
|
159
|
+
# :aws_id=>"E1M5LERJLU636F",
|
160
|
+
# :enabled=>false,
|
161
|
+
# :domain_name=>"s1di8imd85wgld.cloudfront.net",
|
162
|
+
# :s3_origin=> {
|
163
|
+
# :dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
164
|
+
# :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G"},
|
165
|
+
# :last_modified_time=>"2010-04-19T09:14:07.160Z",
|
166
|
+
# :comment=>"Olah-lah!",
|
167
|
+
# :caller_reference=>"201004191254412191173215"}
|
168
|
+
#
|
169
|
+
def get_streaming_distribution(aws_id)
|
170
|
+
link = generate_request('GET', "streaming-distribution/#{aws_id}")
|
171
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Get a streaming distribution's configuration.
|
175
|
+
# Returns a distribution's configuration or RightAws::AwsError exception.
|
176
|
+
#
|
177
|
+
# acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
|
178
|
+
# {:trusted_signers=>["self", "648772220000", "120288270000"],
|
179
|
+
# :e_tag=>"E2K6XD13RCJQ6E",
|
180
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
181
|
+
# :enabled=>false,
|
182
|
+
# :s3_origin=> {
|
183
|
+
# :dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
184
|
+
# :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",},
|
185
|
+
# :comment=>"Olah-lah!",
|
186
|
+
# :caller_reference=>"201004191254412191173215"}
|
187
|
+
#
|
188
|
+
def get_streaming_distribution_config(aws_id)
|
189
|
+
link = generate_request('GET', "streaming-distribution/#{aws_id}/config")
|
190
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Set a streaming distribution's configuration
|
194
|
+
# Returns +true+ on success or RightAws::AwsError exception.
|
195
|
+
#
|
196
|
+
# acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
|
197
|
+
# {:e_tag=>"E2588L5QL4BLXH",
|
198
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
199
|
+
# :enabled=>true,
|
200
|
+
# :s3_origin=> {:dns_name=>"bucket-for-konstantin-00.s3.amazonaws.com"},
|
201
|
+
# :comment=>"Woo-Hoo!",
|
202
|
+
# :caller_reference=>"201004191254412191173215"}
|
203
|
+
#
|
204
|
+
# config[:comment] = 'Olah-lah!'
|
205
|
+
# config[:enabled] = false
|
206
|
+
# config[:s3_origin][:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
|
207
|
+
# config[:trusted_signers] = ['self', '648772220000', '120288270000']
|
208
|
+
#
|
209
|
+
# acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true
|
210
|
+
#
|
211
|
+
def set_streaming_distribution_config(aws_id, config)
|
212
|
+
link = generate_request('PUT', "streaming-distribution/#{aws_id}/config", {}, streaming_distribution_config_to_xml(config),
|
213
|
+
'If-Match' => config[:e_tag])
|
214
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
215
|
+
end
|
216
|
+
|
217
|
+
# Delete a streaming distribution. The enabled distribution cannot be deleted.
|
218
|
+
# Returns +true+ on success or RightAws::AwsError exception.
|
219
|
+
#
|
220
|
+
# acf.delete_streaming_distribution('E1M5LERJLU636F', 'E2588L5QL4BLXH') #=> true
|
221
|
+
#
|
222
|
+
def delete_streaming_distribution(aws_id, e_tag)
|
223
|
+
link = generate_request('DELETE', "streaming-distribution/#{aws_id}", {}, nil,
|
224
|
+
'If-Match' => e_tag)
|
225
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|