fog 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/fog.gemspec +26 -20
- data/lib/fog.rb +1 -11
- data/lib/fog/aws.rb +5 -0
- data/lib/fog/aws/bin.rb +5 -1
- data/lib/fog/aws/cdn.rb +98 -0
- data/lib/fog/aws/iam.rb +86 -0
- data/lib/fog/aws/models/compute/volume.rb +10 -0
- data/lib/fog/aws/models/storage/directory.rb +11 -0
- data/lib/fog/aws/models/storage/file.rb +9 -11
- data/lib/fog/aws/parsers/cdn/distribution.rb +44 -0
- data/lib/fog/aws/parsers/cdn/get_distribution_list.rb +48 -0
- data/lib/fog/aws/parsers/cdn/post_invalidation.rb +28 -0
- data/lib/fog/aws/parsers/iam/basic.rb +19 -0
- data/lib/fog/aws/parsers/iam/create_group.rb +26 -0
- data/lib/fog/aws/parsers/iam/list_groups.rb +32 -0
- data/lib/fog/aws/requests/cdn/delete_distribution.rb +36 -0
- data/lib/fog/aws/requests/cdn/get_distribution.rb +55 -0
- data/lib/fog/aws/requests/cdn/get_distribution_list.rb +59 -0
- data/lib/fog/aws/requests/cdn/post_distribution.rb +88 -0
- data/lib/fog/aws/requests/cdn/post_invalidation.rb +59 -0
- data/lib/fog/aws/requests/compute/create_volume.rb +1 -0
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +3 -0
- data/lib/fog/aws/requests/iam/create_group.rb +43 -0
- data/lib/fog/aws/requests/iam/delete_group.rb +36 -0
- data/lib/fog/aws/requests/iam/list_groups.rb +45 -0
- data/lib/fog/aws/requests/storage/copy_object.rb +4 -1
- data/lib/fog/aws/requests/storage/delete_bucket.rb +5 -1
- data/lib/fog/aws/requests/storage/delete_object.rb +5 -1
- data/lib/fog/aws/requests/storage/get_bucket.rb +4 -1
- data/lib/fog/aws/requests/storage/get_bucket_acl.rb +4 -1
- data/lib/fog/aws/requests/storage/get_bucket_location.rb +5 -1
- data/lib/fog/aws/requests/storage/get_bucket_logging.rb +4 -1
- data/lib/fog/aws/requests/storage/get_bucket_object_versions.rb +4 -1
- data/lib/fog/aws/requests/storage/get_bucket_versioning.rb +4 -1
- data/lib/fog/aws/requests/storage/get_object.rb +4 -1
- data/lib/fog/aws/requests/storage/get_object_acl.rb +4 -1
- data/lib/fog/aws/requests/storage/get_object_torrent.rb +4 -1
- data/lib/fog/aws/requests/storage/get_object_url.rb +4 -1
- data/lib/fog/aws/requests/storage/get_request_payment.rb +5 -1
- data/lib/fog/aws/requests/storage/get_service.rb +5 -1
- data/lib/fog/aws/requests/storage/head_object.rb +5 -1
- data/lib/fog/aws/requests/storage/post_object_hidden_fields.rb +4 -3
- data/lib/fog/aws/requests/storage/put_bucket.rb +11 -6
- data/lib/fog/aws/requests/storage/put_bucket_acl.rb +5 -1
- data/lib/fog/aws/requests/storage/put_bucket_logging.rb +5 -1
- data/lib/fog/aws/requests/storage/put_bucket_versioning.rb +5 -1
- data/lib/fog/aws/requests/storage/put_object.rb +5 -1
- data/lib/fog/aws/requests/storage/put_object_url.rb +4 -1
- data/lib/fog/aws/requests/storage/put_request_payment.rb +5 -1
- data/lib/fog/aws/storage.rb +2 -0
- data/lib/fog/bluebox/compute.rb +1 -0
- data/lib/fog/core.rb +4 -2
- data/lib/fog/core/attributes.rb +9 -5
- data/lib/fog/core/compute.rb +33 -0
- data/lib/fog/core/credentials.rb +0 -1
- data/lib/fog/core/model.rb +2 -11
- data/lib/fog/core/ssh.rb +1 -0
- data/lib/fog/core/storage.rb +24 -0
- data/lib/fog/go_grid/compute.rb +2 -0
- data/lib/fog/google.rb +3 -0
- data/lib/fog/google/models/storage/directory.rb +11 -0
- data/lib/fog/google/models/storage/file.rb +19 -10
- data/lib/fog/google/requests/storage/put_bucket.rb +5 -4
- data/lib/fog/google/storage.rb +2 -0
- data/lib/fog/linode/compute.rb +1 -0
- data/lib/fog/new_servers.rb +3 -0
- data/lib/fog/rackspace.rb +1 -0
- data/lib/fog/rackspace/bin.rb +3 -1
- data/lib/fog/rackspace/cdn.rb +81 -0
- data/lib/fog/rackspace/compute.rb +1 -0
- data/lib/fog/rackspace/models/storage/file.rb +2 -2
- data/lib/fog/rackspace/requests/{storage → cdn}/get_cdn_containers.rb +1 -1
- data/lib/fog/rackspace/requests/{storage → cdn}/head_cdn_container.rb +1 -1
- data/lib/fog/rackspace/requests/{storage → cdn}/put_cdn_container.rb +1 -1
- data/lib/fog/rackspace/requests/storage/delete_container.rb +1 -1
- data/lib/fog/rackspace/requests/storage/delete_object.rb +1 -1
- data/lib/fog/rackspace/requests/storage/get_container.rb +1 -1
- data/lib/fog/rackspace/requests/storage/get_containers.rb +1 -1
- data/lib/fog/rackspace/requests/storage/get_object.rb +1 -1
- data/lib/fog/rackspace/requests/storage/head_container.rb +1 -1
- data/lib/fog/rackspace/requests/storage/head_containers.rb +1 -1
- data/lib/fog/rackspace/requests/storage/head_object.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_container.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_object.rb +1 -1
- data/lib/fog/rackspace/storage.rb +13 -47
- data/lib/fog/slicehost.rb +4 -1
- data/lib/fog/terremark.rb +3 -0
- data/lib/fog/vcloud.rb +3 -0
- data/spec/aws/models/storage/directory_spec.rb +1 -0
- data/spec/bluebox/models/compute/flavors_spec.rb +5 -2
- data/spec/bluebox/models/compute/server_spec.rb +5 -1
- data/spec/bluebox/models/compute/servers_spec.rb +5 -1
- data/spec/google/models/storage/files_spec.rb +1 -2
- data/spec/rackspace/models/compute/flavors_spec.rb +5 -1
- data/spec/rackspace/models/compute/server_spec.rb +5 -1
- data/spec/slicehost/models/compute/flavors_spec.rb +5 -1
- data/spec/slicehost/models/compute/server_spec.rb +5 -1
- data/spec/slicehost/models/compute/servers_spec.rb +5 -1
- data/tests/aws/requests/compute/volume_tests.rb +8 -7
- data/tests/aws/requests/storage/bucket_tests.rb +55 -0
- data/tests/aws/requests/storage/object_tests.rb +18 -0
- data/tests/rackspace/requests/storage/container_tests.rb +64 -0
- data/tests/rackspace/requests/storage/object_tests.rb +69 -0
- metadata +27 -21
- data/spec/aws/requests/storage/copy_object_spec.rb +0 -61
- data/spec/aws/requests/storage/get_bucket_location_spec.rb +0 -30
- data/spec/aws/requests/storage/get_bucket_spec.rb +0 -114
- data/spec/aws/requests/storage/get_request_payment_spec.rb +0 -30
- data/spec/aws/requests/storage/put_request_payment_spec.rb +0 -29
- data/spec/rackspace/requests/storage/delete_container_spec.rb +0 -24
- data/spec/rackspace/requests/storage/delete_object_spec.rb +0 -37
- data/spec/rackspace/requests/storage/get_container_spec.rb +0 -35
- data/spec/rackspace/requests/storage/get_containers_spec.rb +0 -22
- data/spec/rackspace/requests/storage/get_object_spec.rb +0 -21
- data/spec/rackspace/requests/storage/head_container_spec.rb +0 -30
- data/spec/rackspace/requests/storage/head_containers_spec.rb +0 -19
- data/spec/rackspace/requests/storage/head_object_spec.rb +0 -21
- data/spec/rackspace/requests/storage/put_container_spec.rb +0 -15
- data/spec/rackspace/requests/storage/put_object_spec.rb +0 -20
@@ -39,17 +39,9 @@ module Fog
|
|
39
39
|
|
40
40
|
def copy(target_directory_key, target_file_key)
|
41
41
|
requires :directory, :key
|
42
|
-
|
42
|
+
connection.copy_object(directory.key, @key, target_directory_key, target_file_key)
|
43
43
|
target_directory = connection.directories.new(:key => target_directory_key)
|
44
|
-
|
45
|
-
copy_data = {}
|
46
|
-
for key, value in data
|
47
|
-
if ['ETag', 'LastModified'].include?(key)
|
48
|
-
copy_data[key] = value
|
49
|
-
end
|
50
|
-
end
|
51
|
-
target_file.merge_attributes(copy_data)
|
52
|
-
target_file
|
44
|
+
target_directory.files.get(target_file_key)
|
53
45
|
end
|
54
46
|
|
55
47
|
def destroy
|
@@ -70,8 +62,14 @@ module Fog
|
|
70
62
|
|
71
63
|
def save(options = {})
|
72
64
|
requires :body, :directory, :key
|
65
|
+
if options != {}
|
66
|
+
Formatador.display_line("[yellow][WARN] options param is deprecated, use acl= instead[/] [light_black](#{caller.first})[/]")
|
67
|
+
end
|
73
68
|
if @acl
|
74
|
-
options['x-amz-acl']
|
69
|
+
options['x-amz-acl'] ||= @acl
|
70
|
+
end
|
71
|
+
if content_type
|
72
|
+
options['Content-Type'] = content_type
|
75
73
|
end
|
76
74
|
data = connection.put_object(directory.key, @key, @body, options)
|
77
75
|
@etag = data.headers['ETag']
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module CDN
|
5
|
+
|
6
|
+
class Distribution < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = { 'DistributionConfig' => { 'CNAME' => [], 'Logging' => {}, 'TrustedSigners' => [] } }
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_element(name)
|
13
|
+
case name
|
14
|
+
when 'AwsAccountNumber'
|
15
|
+
@response['DistributionConfig']['TrustedSigners'] << @value
|
16
|
+
when 'Bucket', 'Prefix'
|
17
|
+
@response['DistributionConfig']['Logging'][name] = @value
|
18
|
+
when 'CNAME'
|
19
|
+
@response['DistributionConfig']['CNAME'] << @value
|
20
|
+
when 'DomainName', 'Id', 'Status'
|
21
|
+
@response[name] = @value
|
22
|
+
when 'CallerReference', 'Comment', 'DefaultRootObject', 'Origin', 'OriginAccessIdentity'
|
23
|
+
@response['DistributionConfig'][name] << @value
|
24
|
+
when 'Enabled'
|
25
|
+
if @value == 'true'
|
26
|
+
@response['DistributionConfig'][name] = true
|
27
|
+
else
|
28
|
+
@response['DistributionConfig'][name] = false
|
29
|
+
end
|
30
|
+
when 'LastModifiedTime'
|
31
|
+
@response[name] = Time.parse(@value)
|
32
|
+
when 'Protocol'
|
33
|
+
@response['DistributionConfig']['RequireProtocols'] = @value
|
34
|
+
when 'Self'
|
35
|
+
@response['DistributionConfig']['TrustedSigners'] << 'Self'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module CDN
|
5
|
+
|
6
|
+
class GetDistributionList < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@distribution_summary = { 'CNAME' => [], 'TrustedSigners' => [] }
|
10
|
+
@response = { 'DistributionSummary' => [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_element(name)
|
14
|
+
case name
|
15
|
+
when 'DistributionSummary'
|
16
|
+
@response['DistributionSummary'] << @distribution_summary
|
17
|
+
@distribution_summary = { 'CNAME' => [], 'TrustedSigners' => [] }
|
18
|
+
when 'Comment', 'DomainName', 'Id', 'Origin', 'Status'
|
19
|
+
@distribution_summary[name] = @value
|
20
|
+
when 'CNAME'
|
21
|
+
@distribution_summary[name] << @value
|
22
|
+
when 'Enabled'
|
23
|
+
if @value == 'true'
|
24
|
+
@distribution_summary[name] = true
|
25
|
+
else
|
26
|
+
@distribution_summary[name] = false
|
27
|
+
end
|
28
|
+
when 'LastModifiedTime'
|
29
|
+
@distribution_summary[name] = Time.parse(@value)
|
30
|
+
when 'IsTruncated'
|
31
|
+
if @value == 'true'
|
32
|
+
@response[name] = true
|
33
|
+
else
|
34
|
+
@response[name] = false
|
35
|
+
end
|
36
|
+
when 'Marker', 'NextMarker'
|
37
|
+
@response[name] = @value
|
38
|
+
when 'MaxItems'
|
39
|
+
@response[name] = @value.to_i
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module CDN
|
5
|
+
|
6
|
+
class PostInvalidation < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = { 'InvalidationBatch' => { 'Path' => [] } }
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_element(name)
|
13
|
+
case name
|
14
|
+
when 'CallerReference'
|
15
|
+
@response['InvalidationBatch'][name] = @value
|
16
|
+
when 'CreateTime', 'Id', 'Status'
|
17
|
+
@response[name] = @value
|
18
|
+
when 'Path'
|
19
|
+
@response['InvalidationBatch'][name] << @value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module IAM
|
5
|
+
|
6
|
+
class CreateGroups < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = { 'Group' => {} }
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_element(name)
|
13
|
+
case name
|
14
|
+
when 'Arn', 'GroupId', 'GroupName', 'Path'
|
15
|
+
@response['Group'][name] = @value
|
16
|
+
when 'RequestId'
|
17
|
+
response[name] = @value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module IAM
|
5
|
+
|
6
|
+
class ListGroups < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@group = {}
|
10
|
+
@response = { 'Groups' => [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_element(name)
|
14
|
+
case name
|
15
|
+
when 'Arn', 'GroupId', 'GroupName', 'Path'
|
16
|
+
@group[name] = @value
|
17
|
+
when 'member'
|
18
|
+
@response['Groups'] << @group
|
19
|
+
@group = {}
|
20
|
+
when 'IsTruncated'
|
21
|
+
response[name] = (@value == 'true')
|
22
|
+
when 'RequestId'
|
23
|
+
response[name] = @value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class CDN
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Delete a distribution from CloudFront
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * distribution_id<~String> - Id of distribution to delete
|
10
|
+
# * etag<~String> - etag of that distribution from earlier get or put
|
11
|
+
#
|
12
|
+
# ==== See Also
|
13
|
+
# http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html
|
14
|
+
|
15
|
+
def delete_distribution(distribution_id, etag)
|
16
|
+
request({
|
17
|
+
:expects => 204,
|
18
|
+
:headers => { 'If-Match' => etag },
|
19
|
+
:idempotent => true,
|
20
|
+
:method => 'DELETE',
|
21
|
+
:path => "/distribution/#{distribution_id}"
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class Mock # :nodoc:all
|
28
|
+
|
29
|
+
def delete_distribution(distribution_id, etag)
|
30
|
+
Fog::Mock.not_implemented
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class CDN
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/aws/parsers/cdn/distribution'
|
7
|
+
|
8
|
+
# Get information about a distribution from CloudFront
|
9
|
+
#
|
10
|
+
# ==== Parameters
|
11
|
+
# * distribution_id<~String> - id of distribution
|
12
|
+
#
|
13
|
+
# ==== Returns
|
14
|
+
# * response<~Excon::Response>:
|
15
|
+
# * body<~Hash>:
|
16
|
+
# * 'DomainName'<~String>: Domain name of distribution
|
17
|
+
# * 'Id'<~String> - Id of distribution
|
18
|
+
# * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution
|
19
|
+
# * 'Status'<~String> - Status of distribution
|
20
|
+
# * 'DistributionConfig'<~Array>:
|
21
|
+
# * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s
|
22
|
+
# * 'CNAME'<~Array> - array of associated cnames
|
23
|
+
# * 'Comment'<~String> - comment associated with distribution
|
24
|
+
# * 'Enabled'<~Boolean> - whether or not distribution is enabled
|
25
|
+
# * 'Logging'<~Hash>:
|
26
|
+
# * 'Bucket'<~String> - bucket logs are stored in
|
27
|
+
# * 'Prefix'<~String> - prefix logs are stored with
|
28
|
+
# * 'Origin'<~String> - s3 origin bucket
|
29
|
+
# * 'TrustedSigners'<~Array> - trusted signers
|
30
|
+
#
|
31
|
+
# ==== See Also
|
32
|
+
# http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetDistribution.html
|
33
|
+
|
34
|
+
def get_distribution(distribution_id)
|
35
|
+
request({
|
36
|
+
:expects => 200,
|
37
|
+
:idempotent => true,
|
38
|
+
:method => 'GET',
|
39
|
+
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
|
40
|
+
:path => "/distribution/#{distribution_id}"
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class Mock # :nodoc:all
|
47
|
+
|
48
|
+
def get_distribution(distribution_id)
|
49
|
+
Fog::Mock.not_implemented
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class CDN
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/aws/parsers/cdn/get_distribution_list'
|
7
|
+
|
8
|
+
# List information about distributions in CloudFront
|
9
|
+
#
|
10
|
+
# ==== Parameters
|
11
|
+
# * options<~Hash> - config arguments for list. Defaults to {}.
|
12
|
+
# * 'Marker'<~String> - limits object keys to only those that appear
|
13
|
+
# lexicographically after its value.
|
14
|
+
# * 'MaxItems'<~Integer> - limits number of object keys returned
|
15
|
+
#
|
16
|
+
# ==== Returns
|
17
|
+
# * response<~Excon::Response>:
|
18
|
+
# * body<~Hash>:
|
19
|
+
# * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated
|
20
|
+
# * 'Marker'<~String> - Marker specified for query
|
21
|
+
# * 'MaxItems'<~Integer> - Maximum number of keys specified for query
|
22
|
+
# * 'NextMarker'<~String> - Marker to specify for next page (id of last result of current page)
|
23
|
+
# * 'DistributionSummary'<~Array>:
|
24
|
+
# * 'Comment'<~String> - comment associated with distribution
|
25
|
+
# * 'CNAME'<~Array> - array of associated cnames
|
26
|
+
# * 'DomainName'<~String> - Domain name of distribution
|
27
|
+
# * 'Enabled'<~Boolean> - whether or not distribution is enabled
|
28
|
+
# * 'Id'<~String> - Id of distribution
|
29
|
+
# * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution
|
30
|
+
# * 'Origin'<~String> - s3 origin bucket
|
31
|
+
# * 'Status'<~String> - Status of distribution
|
32
|
+
# * 'TrustedSigners'<~Array> - trusted signers
|
33
|
+
#
|
34
|
+
# ==== See Also
|
35
|
+
# http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListDistributions.html
|
36
|
+
|
37
|
+
def get_distribution_list(options = {})
|
38
|
+
request({
|
39
|
+
:expects => 200,
|
40
|
+
:idempotent => true,
|
41
|
+
:method => 'GET',
|
42
|
+
:parser => Fog::Parsers::AWS::CDN::GetDistributionList.new,
|
43
|
+
:path => "/distribution",
|
44
|
+
:query => options
|
45
|
+
})
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class Mock # :nodoc:all
|
51
|
+
|
52
|
+
def get_distribution_list(options = {})
|
53
|
+
Fog::Mock.not_implemented
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class CDN
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/aws/parsers/cdn/distribution'
|
7
|
+
|
8
|
+
# create a new distribution in CloudFront
|
9
|
+
#
|
10
|
+
# ==== Parameters
|
11
|
+
# * origin<~String> - s3 bucket, ie 'mybucket.s3.amazonaws.com'
|
12
|
+
# * config<~Hash> - config for distribution. Defaults to {}.
|
13
|
+
# * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s
|
14
|
+
# * 'Comment'<~String> - Optional comment about distribution
|
15
|
+
# * 'CNAME'<~Array> - Optional array of strings to set as CNAMEs
|
16
|
+
# * 'DefaultRootObject'<~String> - Optional default object to return for '/'
|
17
|
+
# * 'Enabled'<~Boolean> - Whether or not distribution should accept requests, defaults to true
|
18
|
+
# * 'Logging'<~Hash>: Optional logging config
|
19
|
+
# * 'Bucket'<~String> - Bucket to store logs in, ie 'mylogs.s3.amazonaws.com'
|
20
|
+
# * 'Prefix'<~String> - Optional prefix for log filenames, ie 'myprefix/'
|
21
|
+
# * 'OriginAccessIdentity'<~String> - Used for serving private content, in format 'origin-access-identity/cloudfront/ID'
|
22
|
+
# * 'RequiredProtocols'<~String> - Optional, set to 'https' to force https connections
|
23
|
+
# * 'TrustedSigners'<~Array> - Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either 'Self' for your own account or an AWS Account Number
|
24
|
+
#
|
25
|
+
# ==== Returns
|
26
|
+
# * response<~Excon::Response>:
|
27
|
+
# * body<~Hash>:
|
28
|
+
# * 'DomainName'<~String>: Domain name of distribution
|
29
|
+
# * 'Id'<~String> - Id of distribution
|
30
|
+
# * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution
|
31
|
+
# * 'Status'<~String> - Status of distribution
|
32
|
+
# * 'DistributionConfig'<~Array>:
|
33
|
+
# * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s
|
34
|
+
# * 'CNAME'<~Array> - array of associated cnames
|
35
|
+
# * 'Comment'<~String> - comment associated with distribution
|
36
|
+
# * 'Enabled'<~Boolean> - whether or not distribution is enabled
|
37
|
+
# * 'Logging'<~Hash>:
|
38
|
+
# * 'Bucket'<~String> - bucket logs are stored in
|
39
|
+
# * 'Prefix'<~String> - prefix logs are stored with
|
40
|
+
# * 'Origin'<~String> - s3 origin bucket
|
41
|
+
# * 'TrustedSigners'<~Array> - trusted signers
|
42
|
+
#
|
43
|
+
# ==== See Also
|
44
|
+
# http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html
|
45
|
+
|
46
|
+
def post_distribution(origin, options = {})
|
47
|
+
data = '<?xml version="1.0" encoding="UTF-8"?>'
|
48
|
+
data << "<DistributionConfig xmlns=\"http://cloudfront.amazonaws.com/doc/#{@version}/\">"
|
49
|
+
for key, value in options
|
50
|
+
case value
|
51
|
+
when Array
|
52
|
+
for item in array
|
53
|
+
data << "<#{key}>#{item}</#{key}>"
|
54
|
+
end
|
55
|
+
when Hash
|
56
|
+
data << "<#{key}>"
|
57
|
+
for inner_key, inner_value in value
|
58
|
+
data << "<#{inner_key}>#{inner_value}</#{inner_key}>"
|
59
|
+
end
|
60
|
+
data << "</#{key}>"
|
61
|
+
else
|
62
|
+
data << "<#{key}>#{value}</#{key}>"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
data << "</DistributionConfig>"
|
66
|
+
request({
|
67
|
+
:body => data,
|
68
|
+
:expects => 201,
|
69
|
+
:headers => { 'Content-Type' => 'text/xml' },
|
70
|
+
:idempotent => true,
|
71
|
+
:method => 'POST',
|
72
|
+
:parser => Fog::Parsers::AWS::CDN::Distribution.new,
|
73
|
+
:path => "/distribution"
|
74
|
+
})
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
class Mock # :nodoc:all
|
80
|
+
|
81
|
+
def post_distribution(origin, options = {})
|
82
|
+
Fog::Mock.not_implemented
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|