| Class | RightAws::AcfInterface |
| In: |
lib/acf/right_acf_origin_access_identities.rb
lib/acf/right_acf_interface.rb lib/acf/right_acf_streaming_interface.rb |
| Parent: | Object |
The AcfInterface class provides a complete interface to Amazon‘s CloudFront service.
For explanations of the semantics of each call, please refer to Amazon‘s documentation at developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=211
Example:
acf = RightAws::AcfInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX')
list = acf.list_distributions #=>
[{:status => "Deployed",
:domain_name => "d74zzrxmpmygb.6hops.net",
:aws_id => "E4U91HCJHGXVC",
:origin => "my-bucket.s3.amazonaws.com",
:cnames => ["x1.my-awesome-site.net", "x1.my-awesome-site.net"]
:comment => "My comments",
:last_modified_time => "2008-09-10T17:00:04.000Z" }, ..., {...} ]
distibution = list.first
info = acf.get_distribution(distibution[:aws_id]) #=>
{:enabled => true,
:caller_reference => "200809102100536497863003",
:e_tag => "E39OHHU1ON65SI",
:status => "Deployed",
:domain_name => "d3dxv71tbbt6cd.6hops.net",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:aws_id => "E2REJM3VUN5RSI",
:comment => "Woo-Hoo!",
:origin => "my-bucket.s3.amazonaws.com",
:last_modified_time => "2008-09-10T17:00:54.000Z" }
config = acf.get_distribution_config(distibution[:aws_id]) #=>
{:enabled => true,
:caller_reference => "200809102100536497863003",
:e_tag => "E39OHHU1ON65SI",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:comment => "Woo-Hoo!",
:origin => "my-bucket.s3.amazonaws.com"}
config[:comment] = 'Olah-lah!'
config[:enabled] = false
config[:cnames] << "web3.my-awesome-site.net"
acf.set_distribution_config(distibution[:aws_id], config) #=> true
| API_VERSION | = | "2010-03-01" |
| DEFAULT_HOST | = | 'cloudfront.amazonaws.com' |
| DEFAULT_PORT | = | 443 |
| DEFAULT_PROTOCOL | = | 'https' |
| DEFAULT_PATH | = | '/' |
Create a new handle to a CloudFront account. All handles share the same per process or per thread HTTP connection to CloudFront. Each handle is for a specific account. The params have the following options:
acf = RightAws::AcfInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX',
{:logger => Logger.new('/tmp/x.log')}) #=> #<RightAws::AcfInterface::0xb7b3c30c>
Create a new distribution. Returns the just created distribution or RightAws::AwsError exception.
acf.create_distribution('my-bucket.s3.amazonaws.com', 'Woo-Hoo!', true, ['web1.my-awesome-site.net'], nil,
{ :prefix=>"log/", :bucket=>"my-logs.s3.amazonaws.com" } ) #=>
{:comment => "Woo-Hoo!",
:enabled => true,
:location => "https://cloudfront.amazonaws.com/2008-06-30/distribution/E2REJM3VUN5RSI",
:status => "InProgress",
:aws_id => "E2REJM3VUN5RSI",
:domain_name => "d3dxv71tbbt6cd.6hops.net",
:origin => "my-bucket.s3.amazonaws.com",
:cnames => ["web1.my-awesome-site.net"],
:logging => { :prefix => "log/",
:bucket => "my-logs.s3.amazonaws.com"},
:last_modified_time => "2008-10-22T19:31:23.000Z",
:caller_reference => "200809102100536497863003"}
Create a new CloudFront Origin Access Identity.
acf.create_origin_access_identity('MyTestAccessIdentity') #=>
{:e_tag=>"E2QOKZEXCUWHJX",
:comment=>"MyTestAccessIdentity",
:location=>
"https://cloudfront.amazonaws.com/origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
:caller_reference=>"201004161657467493031273",
:s3_canonical_user_id=>
"de4361b33dbaf499d3d77159bfa1571d3451eaec25a2b16553de5e534da8089bb8c31a4898d73d1a658155d0e48872a7",
:aws_id=>"E3JPJZ80ZBX24G"}
Create a new streaming distribution. Returns the just created distribution or RightAws::AwsError exception.
acf.create_streaming_distribution('bucket-for-konstantin-00.s3.amazonaws.com', 'Woo-Hoo!', true,
['stream-1.web.my-awesome-site.net']) #=>
{:status=>"InProgress",
:caller_reference=>"201004191254412191173215",
:cnames=>["stream-1.web.my-awesome-site.net"],
:aws_id=>"E1M5LERJLU636F",
:e_tag=>"E2588L5QL4BLXH",
:enabled=>true,
:domain_name=>"s1di8imd85wgld.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:last_modified_time=>Mon Apr 19 08:54:42 UTC 2010,
:location=>
"https://cloudfront.amazonaws.com/streaming-distribution/E1M5LERJLU636F",
:comment=>"Woo-Hoo!"}
Delete a distribution. The enabled distribution cannot be deleted. Returns true on success or RightAws::AwsError exception.
acf.delete_distribution('E2REJM3VUN5RSI', 'E39OHHU1ON65SI') #=> true
Get Origin Access Identity
acf.get_origin_access_identity('E3HJ7V8C3324VF') #=>
{:comment=>"kd: TEST-2",
:caller_reference=>"201004161655035372351604",
:aws_id=>"E3HJ7V8C3324VF",
:s3_canonical_user_id=>
"9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
:e_tag=>"E309Q4IM450498"}
acf.delete_origin_access_identity("E3HJ7V8C3324VF","E309Q4IM450498") #=> true
Delete a streaming distribution. The enabled distribution cannot be deleted. Returns true on success or RightAws::AwsError exception.
acf.delete_streaming_distribution('E1M5LERJLU636F', 'E2588L5QL4BLXH') #=> true
Get a distribution‘s information. Returns a distribution‘s information or RightAws::AwsError exception.
acf.get_distribution('E2REJM3VUN5RSI') #=>
{:enabled => true,
:caller_reference => "200809102100536497863003",
:e_tag => "E39OHHU1ON65SI",
:status => "Deployed",
:domain_name => "d3dxv71tbbt6cd.6hops.net",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:aws_id => "E2REJM3VUN5RSI",
:comment => "Woo-Hoo!",
:origin => "my-bucket.s3.amazonaws.com",
:last_modified_time => "2008-09-10T17:00:54.000Z" }
acf.get_distribution('E2FNSBHNVVF11E') #=>
{:e_tag=>"E1Q2DJEPTQOLJD",
:status=>"InProgress",
:last_modified_time=>"2010-04-17T17:24:25.000Z",
:cnames=>["web1.my-awesome-site.net", "web2.my-awesome-site.net"],
:aws_id=>"E2FNSBHNVVF11E",
:logging=>{:prefix=>"xlog/", :bucket=>"my-bucket.s3.amazonaws.com"},
:enabled=>true,
:active_trusted_signers=>
[{:aws_account_number=>"120288270000",
:key_pair_ids=>["APKAJTD5OHNDX0000000", "APKAIK74BJWCL0000000"]},
{:aws_account_number=>"self"},
{:aws_account_number=>"648772220000"}],
:caller_reference=>"201004171154450740700072",
:domain_name=>"d1f6lpevremt5m.cloudfront.net",
:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
:trusted_signers=>["self", "648772220000", "120288270000"],
:origin=>"my-bucket.s3.amazonaws.com"}
Get a distribution‘s configuration. Returns a distribution‘s configuration or RightAws::AwsError exception.
acf.get_distribution_config('E2REJM3VUN5RSI') #=>
{:enabled => true,
:caller_reference => "200809102100536497863003",
:e_tag => "E39OHHU1ON65SI",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:comment => "Woo-Hoo!",
:origin => "my-bucket.s3.amazonaws.com"}
acf.get_distribution_config('E2FNSBHNVVF11E') #=>
{:e_tag=>"E1Q2DJEPTQOLJD",
:logging=>{:prefix=>"xlog/", :bucket=>"my-bucket.s3.amazonaws.com"},
:enabled=>true,
:caller_reference=>"201004171154450740700072",
:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
:trusted_signers=>["self", "648772220000", "120288270000"],
:origin=>"my-bucket.s3.amazonaws.com"}
Get Origin Access Identity
acf.get_origin_access_identity('E3HJ7V8C3324VF') #=>
{:comment=>"kd: TEST-2",
:caller_reference=>"201004161655035372351604",
:aws_id=>"E3HJ7V8C3324VF",
:s3_canonical_user_id=>
"9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
:e_tag=>"E309Q4IM450498"}
Get Origin Access Identity config
acf.get_origin_access_identity_config("E3JPJZ80ZBX24G") #=>
{:comment=>"MyTestAccessIdentity",
:caller_reference=>"201004161657467493031273",
:e_tag=>"E2QOKZEXCUWHJX"}
Get a streaming distribution‘s information. Returns a distribution‘s information or RightAws::AwsError exception.
acf.get_streaming_distribution('E3CWE2Z9USOS6B') #=>
{:status=>"Deployed",
:e_tag=>"EXTZ2SXAQT39K",
:cnames=>["stream.web.my-awesome-site.net"],
:aws_id=>"E3CWE2Z9USOS6B",
:enabled=>true,
:domain_name=>"s2jz1ourvss1fj.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:last_modified_time=>"2010-04-19T08:53:32.574Z",
:comment=>"Woo-Hoo!",
:caller_reference=>"201004191253311625537161"}
acf.get_streaming_distribution('E1M5LERJLU636F') #=>
{:trusted_signers=>["self", "648772220000", "120288270000"],
:status=>"InProgress",
:e_tag=>"E2K6XD13RCJQ6E",
:cnames=>["stream-1.web.my-awesome-site.net"],
:active_trusted_signers=>
[{:key_pair_ids=>["APKAIK74BJWCLXZUMEJA"],
:aws_account_number=>"120288270000"},
{:aws_account_number=>"self"},
{:aws_account_number=>"648772220000"}],
:aws_id=>"E1M5LERJLU636F",
:enabled=>false,
:domain_name=>"s1di8imd85wgld.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:last_modified_time=>"2010-04-19T09:14:07.160Z",
:comment=>"Olah-lah!",
:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
:caller_reference=>"201004191254412191173215"}
Get a streaming distribution‘s configuration. Returns a distribution‘s configuration or RightAws::AwsError exception.
acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
{:trusted_signers=>["self", "648772220000", "120288270000"],
:e_tag=>"E2K6XD13RCJQ6E",
:cnames=>["stream-1.web.my-awesome-site.net"],
:enabled=>false,
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:comment=>"Olah-lah!",
:origin_access_identity=>"origin-access-identity/cloudfront/E3JPJZ80ZBX24G",
:caller_reference=>"201004191254412191173215"}
Incrementally list distributions.
Optional params: +:marker+ and +:max_items+.
# get first distribution
incrementally_list_distributions(:max_items => 1) #=>
{:distributions=>
[{:status=>"Deployed",
:aws_id=>"E2Q0AOOMFNPSYL",
:origin=>"my-bucket.s3.amazonaws.com",
:domain_name=>"d1s5gmdtmafnre.6hops.net",
:comment=>"ONE LINE OF COMMENT",
:last_modified_time=>"2008-10-22T19:31:23.000Z",
:enabled=>true,
:cnames=>[]}],
:is_truncated=>true,
:max_items=>1,
:marker=>"",
:next_marker=>"E2Q0AOOMFNPSYL"}
# get max 100 distributions (the list will be restricted by a default MaxItems value ==100 )
incrementally_list_distributions
# list distributions by 10
incrementally_list_distributions(:max_items => 10) do |response|
puts response.inspect # a list of 10 distributions
true # return false if the listing should be broken otherwise use true
end
Incrementally list Origin Access Identities. Optional params: +:marker+ and +:max_items+.
acf.incrementally_list_origin_access_identities(:max_items => 2) #=>
{:origin_access_identities=>
[{:comment=>"kd: TEST",
:s3_canonical_user_id=>
"c7ca36f6c5d384e60aeca02032ac748bae3c458c5322a2e279382935f1f71b16d9ac251f7f71f1ea91c37d3c214645b8",
:aws_id=>"E3TL4XWF5KTGH"},
{:comment=>"kd: TEST-2",
:s3_canonical_user_id=>
"9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
:aws_id=>"E3HJ7V8C3324VF"}],
:is_truncated=>true,
:max_items=>2,
:marker=>"",
:next_marker=>"E3HJ7V8C3324VF"}
# get max 100 origin access identities (the list will be restricted by a default MaxItems value ==100 )
incrementally_list_origin_access_identities
# list origin access identities by 10
acf.incrementally_list_origin_access_identities(:max_items => 10) do |response|
puts response.inspect # a list of 10 distributions
true # return false if the listing should be broken otherwise use true
end
Incrementally list streaming distributions.
Optional params: +:marker+ and +:max_items+.
# get first streaming distribution
incrementally_list_distributions(:max_items => 1) #=>
{:marker=>"",
:next_marker=>"E3CWE2Z9USOS6B",
:distributions=>
[{:status=>"Deployed",
:cnames=>["stream.web.my-awesome-site.net"],
:aws_id=>"E3CWE2Z9USOS6B",
:enabled=>true,
:last_modified_time=>"2010-04-19T08:53:32.574Z",
:domain_name=>"s2jz1ourvss1fj.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:comment=>"Woo-Hoo!"}],
:max_items=>1,
:is_truncated=>true}
# get max 100 streaming distributions (the list will be restricted by a default MaxItems value ==100 )
incrementally_list_streaming_distributions
# list streaming distributions by 10
incrementally_list_streaming_distributions(:max_items => 10) do |response|
puts response.inspect # a list of 10 distributions
true # return false if the listing should be broken otherwise use true
end
List all distributions. Returns an array of distributions or RightAws::AwsError exception.
acf.list_distributions #=>
[{:status => "Deployed",
:domain_name => "d74zzrxmpmygb.6hops.net",
:aws_id => "E4U91HCJHGXVC",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:origin => "my-bucket.s3.amazonaws.com",
:comment => "My comments",
:last_modified_time => Wed Sep 10 17:00:04 UTC 2008 }, ..., {...} ]
List Origin Access Identities.
acf.list_origin_access_identities #=>
[{:comment=>"kd: TEST",
:s3_canonical_user_id=>
"c7ca36f6c5d384e60aeca02032ac748bae3c458c5322a2e279382935f1f71b16d9ac251f7f71f1ea91c37d3c214645b8",
:aws_id=>"E3TL4XWF5KTGH"},
{:comment=>"kd: TEST-2",
:s3_canonical_user_id=>
"9af7058b1d197c2c03fdcc3ddad07012a7822f5fc4a8156025409ffac646bdae4dc714820482c92e6988e5703c8d9954",
:aws_id=>"E3HJ7V8C3324VF"},
{:comment=>"MyTestAccessIdentity",
:s3_canonical_user_id=>
"de4361b33dbaf499d3d77159bfa1571d3451eaec25a2b16553de5e534da8089bb8c31a4898d73d1a658155d0e48872a7",
:aws_id=>"E3JPJZ80ZBX24G"}]
List all streaming distributions. Returns an array of distributions or RightAws::AwsError exception.
acf.list_streaming_distributions #=>
[{:status=>"Deployed",
:aws_id=>"E3CWE2Z9USOS6B",
:enabled=>true,
:domain_name=>"s2jz1ourvss1fj.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:last_modified_time=>"2010-04-19T08:53:32.574Z",
:comment=>"Woo-Hoo!",
:cnames=>["stream.web.my-awesome-site.net"]},
...
{:status=>"Deployed",
:aws_id=>"E3NPQZY4LKAYQ8",
:enabled=>true,
:domain_name=>"sw9nrsq9pudk3.cloudfront.net",
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:last_modified_time=>"2010-04-19T08:59:09.600Z",
:comment=>"Woo-Hoo!",
:cnames=>["stream-6.web.my-awesome-site.net"]}]
Set a distribution‘s configuration (the :origin and the :caller_reference cannot be changed). Returns true on success or RightAws::AwsError exception.
config = acf.get_distribution_config('E2REJM3VUN5RSI') #=>
{:enabled => true,
:caller_reference => "200809102100536497863003",
:e_tag => "E39OHHU1ON65SI",
:cnames => ["web1.my-awesome-site.net", "web2.my-awesome-site.net"]
:comment => "Woo-Hoo!",
:origin => "my-bucket.s3.amazonaws.com"}
config[:comment] = 'Olah-lah!'
config[:enabled] = false
config[:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
# or just
# config[:origin_access_identity] = "E3JPJZ80ZBX24G"
config[:trusted_signers] = ['self', '648772220000', '120288270000']
config[:logging] = { :bucket => 'my-bucket.s3.amazonaws.com', :prefix => 'xlog/' }
acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true
Set Origin Access Identity config
acf.set_origin_access_identity_config("E2QOKZEXCUWHJX",
:comment => "MyBestOriginAccessConfig",
:caller_reference => '01234567890',
:e_tag=>"E2QOKZEXCUWHJX") #=> true
P.S. This guy is not tested yet: developer.amazonwebservices.com/connect/thread.jspa?threadID=45256
Set a streaming distribution‘s configuration (the :origin and the :caller_reference cannot be changed). Returns true on success or RightAws::AwsError exception.
acf.get_streaming_distribution_config('E1M5LERJLU636F') #=>
{:e_tag=>"E2588L5QL4BLXH",
:cnames=>["stream-1.web.my-awesome-site.net"],
:enabled=>true,
:origin=>"bucket-for-konstantin-00.s3.amazonaws.com",
:comment=>"Woo-Hoo!",
:caller_reference=>"201004191254412191173215"}
config[:comment] = 'Olah-lah!'
config[:enabled] = false
config[:origin_access_identity] = "origin-access-identity/cloudfront/E3JPJZ80ZBX24G"
config[:trusted_signers] = ['self', '648772220000', '120288270000']
acf.set_distribution_config('E2REJM3VUN5RSI', config) #=> true