revans_right_aws 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/History.txt +284 -0
- data/Manifest.txt +50 -0
- data/README.txt +167 -0
- data/Rakefile +110 -0
- data/lib/acf/right_acf_interface.rb +485 -0
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +236 -0
- data/lib/acw/right_acw_interface.rb +249 -0
- data/lib/as/right_as_interface.rb +699 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +978 -0
- data/lib/awsbase/support.rb +115 -0
- data/lib/ec2/right_ec2.rb +395 -0
- data/lib/ec2/right_ec2_ebs.rb +452 -0
- data/lib/ec2/right_ec2_images.rb +373 -0
- data/lib/ec2/right_ec2_instances.rb +755 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +170 -0
- data/lib/ec2/right_ec2_security_groups.rb +277 -0
- data/lib/ec2/right_ec2_spot_instances.rb +399 -0
- data/lib/ec2/right_ec2_vpc.rb +571 -0
- data/lib/elb/right_elb_interface.rb +496 -0
- data/lib/rds/right_rds_interface.rb +998 -0
- data/lib/right_aws.rb +83 -0
- data/lib/s3/right_s3.rb +1126 -0
- data/lib/s3/right_s3_interface.rb +1199 -0
- data/lib/sdb/active_sdb.rb +1122 -0
- data/lib/sdb/right_sdb_interface.rb +721 -0
- data/lib/sqs/right_sqs.rb +388 -0
- data/lib/sqs/right_sqs_gen2.rb +343 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +524 -0
- data/lib/sqs/right_sqs_interface.rb +594 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +138 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +108 -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/s3/test_helper.rb +2 -0
- data/test/s3/test_right_s3.rb +421 -0
- data/test/s3/test_right_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +357 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +253 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +291 -0
- data/test/sqs/test_right_sqs_gen2.rb +264 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +14 -0
- metadata +169 -0
@@ -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].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>#{AcfInterface::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] = AcfInterface::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,236 @@
|
|
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
|
+
# :origin=>"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
|
+
# :origin=>"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
|
+
# :origin=>"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].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
|
+
# :origin=>"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(origin, comment='', enabled=true, cnames=[], caller_reference=nil)
|
128
|
+
config = { :origin => origin,
|
129
|
+
:comment => comment,
|
130
|
+
:enabled => enabled,
|
131
|
+
:cnames => Array(cnames),
|
132
|
+
:caller_reference => caller_reference }
|
133
|
+
create_streaming_distribution_by_config(config)
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_streaming_distribution_by_config(config)
|
137
|
+
config[:caller_reference] ||= generate_call_reference
|
138
|
+
link = generate_request('POST', 'streaming-distribution', {}, streaming_distribution_config_to_xml(config))
|
139
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Get a streaming distribution's information.
|
143
|
+
# Returns a distribution's information or RightAws::AwsError exception.
|
144
|
+
#
|
145
|
+
# acf.get_streaming_distribution('E3CWE2Z9USOS6B') #=>
|
146
|
+
# {:status=>"Deployed",
|
147
|
+
# :e_tag=>"EXTZ2SXAQT39K",
|
148
|
+
# :cnames=>["stream.web.my-awesome-site.net"],
|
149
|
+
# :aws_id=>"E3CWE2Z9USOS6B",
|
150
|
+
# :enabled=>true,
|
151
|
+
# :domain_name=>"s2jz1ourvss1fj.cloudfront.net",
|
152
|
+
# :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
153
|
+
# :last_modified_time=>"2010-04-19T08:53:32.574Z",
|
154
|
+
# :comment=>"Woo-Hoo!",
|
155
|
+
# :caller_reference=>"201004191253311625537161"}
|
156
|
+
#
|
157
|
+
# acf.get_streaming_distribution('E1M5LERJLU636F') #=>
|
158
|
+
# {:trusted_signers=>["self", "648772220000", "120288270000"],
|
159
|
+
# :status=>"InProgress",
|
160
|
+
# :e_tag=>"E2K6XD13RCJQ6E",
|
161
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
162
|
+
# :active_trusted_signers=>
|
163
|
+
# [{:key_pair_ids=>["APKAIK74BJWCLXZUMEJA"],
|
164
|
+
# :aws_account_number=>"120288270000"},
|
165
|
+
# {:aws_account_number=>"self"},
|
166
|
+
# {:aws_account_number=>"648772220000"}],
|
167
|
+
# :aws_id=>"E1M5LERJLU636F",
|
168
|
+
# :enabled=>false,
|
169
|
+
# :domain_name=>"s1di8imd85wgld.cloudfront.net",
|
170
|
+
# :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
171
|
+
# :last_modified_time=>"2010-04-19T09:14:07.160Z",
|
172
|
+
# :comment=>"Olah-lah!",
|
173
|
+
# :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
|
174
|
+
# :caller_reference=>"201004191254412191173215"}
|
175
|
+
#
|
176
|
+
def get_streaming_distribution(aws_id)
|
177
|
+
link = generate_request('GET', "streaming-distribution/#{aws_id}")
|
178
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Get a streaming distribution's configuration.
|
182
|
+
# Returns a distribution's configuration or RightAws::AwsError exception.
|
183
|
+
#
|
184
|
+
# acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
|
185
|
+
# {:trusted_signers=>["self", "648772220000", "120288270000"],
|
186
|
+
# :e_tag=>"E2K6XD13RCJQ6E",
|
187
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
188
|
+
# :enabled=>false,
|
189
|
+
# :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
190
|
+
# :comment=>"Olah-lah!",
|
191
|
+
# :origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
|
192
|
+
# :caller_reference=>"201004191254412191173215"}
|
193
|
+
#
|
194
|
+
def get_streaming_distribution_config(aws_id)
|
195
|
+
link = generate_request('GET', "streaming-distribution/#{aws_id}/config")
|
196
|
+
merge_headers(request_info(link, AcfDistributionListParser.new(:logger => @logger))[:distributions].first)
|
197
|
+
end
|
198
|
+
|
199
|
+
# Set a streaming distribution's configuration
|
200
|
+
# (the :origin and the :caller_reference cannot be changed).
|
201
|
+
# Returns +true+ on success or RightAws::AwsError exception.
|
202
|
+
#
|
203
|
+
# acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
|
204
|
+
# {:e_tag=>"E2588L5QL4BLXH",
|
205
|
+
# :cnames=>["stream-1.web.my-awesome-site.net"],
|
206
|
+
# :enabled=>true,
|
207
|
+
# :origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
|
208
|
+
# :comment=>"Woo-Hoo!",
|
209
|
+
# :caller_reference=>"201004191254412191173215"}
|
210
|
+
#
|
211
|
+
# config[:comment] = 'Olah-lah!'
|
212
|
+
# config[:enabled] = false
|
213
|
+
# config[:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
|
214
|
+
# config[:trusted_signers] = ['self', '648772220000', '120288270000']
|
215
|
+
#
|
216
|
+
# acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true
|
217
|
+
#
|
218
|
+
def set_streaming_distribution_config(aws_id, config)
|
219
|
+
link = generate_request('PUT', "streaming-distribution/#{aws_id}/config", {}, streaming_distribution_config_to_xml(config),
|
220
|
+
'If-Match' => config[:e_tag])
|
221
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
222
|
+
end
|
223
|
+
|
224
|
+
# Delete a streaming distribution. The enabled distribution cannot be deleted.
|
225
|
+
# Returns +true+ on success or RightAws::AwsError exception.
|
226
|
+
#
|
227
|
+
# acf.delete_streaming_distribution('E1M5LERJLU636F', 'E2588L5QL4BLXH') #=> true
|
228
|
+
#
|
229
|
+
def delete_streaming_distribution(aws_id, e_tag)
|
230
|
+
link = generate_request('DELETE', "streaming-distribution/#{aws_id}", {}, nil,
|
231
|
+
'If-Match' => e_tag)
|
232
|
+
request_info(link, RightHttp2xxParser.new(:logger => @logger))
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
end
|