fog 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +135 -0
- data/benchs/headers_split_vs_match.rb +18 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +60 -0
- data/benchs/stripping.rb +26 -0
- data/lib/fog.rb +21 -0
- data/lib/fog/aws.rb +145 -0
- data/lib/fog/aws/ec2.rb +173 -0
- data/lib/fog/aws/models/ec2/address.rb +31 -0
- data/lib/fog/aws/models/ec2/addresses.rb +36 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +35 -0
- data/lib/fog/aws/models/ec2/key_pairs.rb +36 -0
- data/lib/fog/aws/models/ec2/volume.rb +47 -0
- data/lib/fog/aws/models/ec2/volumes.rb +36 -0
- data/lib/fog/aws/models/s3/bucket.rb +77 -0
- data/lib/fog/aws/models/s3/buckets.rb +83 -0
- data/lib/fog/aws/models/s3/object.rb +76 -0
- data/lib/fog/aws/models/s3/objects.rb +97 -0
- data/lib/fog/aws/models/s3/owner.rb +18 -0
- data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
- data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
- data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
- data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
- data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
- data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
- data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
- data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
- data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
- data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
- data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
- data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
- data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
- data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
- data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
- data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
- data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
- data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +59 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +71 -0
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
- data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +65 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +53 -0
- data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +64 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +114 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +78 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +62 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +55 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
- data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +134 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +80 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +79 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +53 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +100 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +82 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
- data/lib/fog/aws/requests/s3/get_service.rb +58 -0
- data/lib/fog/aws/requests/s3/head_object.rb +61 -0
- data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
- data/lib/fog/aws/requests/s3/put_object.rb +76 -0
- data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
- data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
- data/lib/fog/aws/requests/simpledb/select.rb +29 -0
- data/lib/fog/aws/s3.rb +157 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/collection.rb +77 -0
- data/lib/fog/connection.rb +130 -0
- data/lib/fog/errors.rb +145 -0
- data/lib/fog/model.rb +72 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/spec/aws/models/s3/bucket_spec.rb +130 -0
- data/spec/aws/models/s3/buckets_spec.rb +79 -0
- data/spec/aws/models/s3/object_spec.rb +121 -0
- data/spec/aws/models/s3/objects_spec.rb +112 -0
- data/spec/aws/models/s3/owner_spec.rb +18 -0
- data/spec/aws/requests/ec2/allocate_address_spec.rb +18 -0
- data/spec/aws/requests/ec2/associate_address_spec.rb +42 -0
- data/spec/aws/requests/ec2/attach_volume_spec.rb +53 -0
- data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +26 -0
- data/spec/aws/requests/ec2/create_key_pair_spec.rb +36 -0
- data/spec/aws/requests/ec2/create_security_group_spec.rb +34 -0
- data/spec/aws/requests/ec2/create_snapshot_spec.rb +37 -0
- data/spec/aws/requests/ec2/create_volume_spec.rb +23 -0
- data/spec/aws/requests/ec2/delete_key_pair_spec.rb +21 -0
- data/spec/aws/requests/ec2/delete_security_group_spec.rb +26 -0
- data/spec/aws/requests/ec2/delete_snapshot_spec.rb +35 -0
- data/spec/aws/requests/ec2/delete_volume_spec.rb +26 -0
- data/spec/aws/requests/ec2/describe_addresses_spec.rb +38 -0
- data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +23 -0
- data/spec/aws/requests/ec2/describe_images_spec.rb +39 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +86 -0
- data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +42 -0
- data/spec/aws/requests/ec2/describe_regions_spec.rb +21 -0
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +51 -0
- data/spec/aws/requests/ec2/describe_snapshots_spec.rb +54 -0
- data/spec/aws/requests/ec2/describe_volumes_spec.rb +50 -0
- data/spec/aws/requests/ec2/detach_volume_spec.rb +43 -0
- data/spec/aws/requests/ec2/disassociate_address_spec.rb +35 -0
- data/spec/aws/requests/ec2/get_console_output_spec.rb +23 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +21 -0
- data/spec/aws/requests/ec2/release_address_spec.rb +26 -0
- data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +32 -0
- data/spec/aws/requests/ec2/run_instances_spec.rb +41 -0
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +35 -0
- data/spec/aws/requests/s3/copy_object_spec.rb +62 -0
- data/spec/aws/requests/s3/delete_bucket_spec.rb +36 -0
- data/spec/aws/requests/s3/delete_object_spec.rb +37 -0
- data/spec/aws/requests/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/requests/s3/get_bucket_spec.rb +110 -0
- data/spec/aws/requests/s3/get_object_spec.rb +45 -0
- data/spec/aws/requests/s3/get_request_payment_spec.rb +30 -0
- data/spec/aws/requests/s3/get_service_spec.rb +33 -0
- data/spec/aws/requests/s3/head_object_spec.rb +28 -0
- data/spec/aws/requests/s3/put_bucket_spec.rb +19 -0
- data/spec/aws/requests/s3/put_object_spec.rb +38 -0
- data/spec/aws/requests/s3/put_request_payment_spec.rb +29 -0
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/create_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +43 -0
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +31 -0
- data/spec/aws/requests/simpledb/list_domains_spec.rb +30 -0
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/select_spec.rb +9 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +309 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class EC2
|
4
|
+
|
5
|
+
class Volume < Fog::Model
|
6
|
+
|
7
|
+
attr_accessor :attachment_time,
|
8
|
+
:availability_zone,
|
9
|
+
:device,
|
10
|
+
:instance_id
|
11
|
+
:size,
|
12
|
+
:snapshot_id,
|
13
|
+
:status,
|
14
|
+
:volume_id
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
if attributes['attachmentSet']
|
18
|
+
attributes.merge!(attributes.delete('attachmentSet'))
|
19
|
+
end
|
20
|
+
remap_attributes(attributes, {
|
21
|
+
'attachmentTime' => :attachment_time,
|
22
|
+
'availabilityZone' => :availability_zone,
|
23
|
+
'createTime' => :create_time,
|
24
|
+
'instanceId' => :instance_id,
|
25
|
+
'snapshotId' => :snapshot_id,
|
26
|
+
'status' => :status
|
27
|
+
'volumeId' => :volume_id
|
28
|
+
})
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete
|
33
|
+
connection.delete_volume(@volume_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def save
|
37
|
+
data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
|
38
|
+
new_attributes = data.reject {|key,value| key == 'requestId'}
|
39
|
+
update_attributes(new_attributes)
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class EC2
|
4
|
+
|
5
|
+
def volumes
|
6
|
+
Fog::AWS::EC2::Volumes.new(:connection => self)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Volumes < Fog::Collection
|
10
|
+
|
11
|
+
def all(volume_id = [])
|
12
|
+
data = connection.describe_volumes(volume_id)
|
13
|
+
volumes = []
|
14
|
+
data['volumeSet'].each do |volume|
|
15
|
+
volumes << Fog::AWS::EC2::Volume.new({
|
16
|
+
:connection => connection
|
17
|
+
}.merge!(volume))
|
18
|
+
end
|
19
|
+
volumes
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(attributes = {})
|
23
|
+
volume = new(attributes)
|
24
|
+
volume.save
|
25
|
+
volume
|
26
|
+
end
|
27
|
+
|
28
|
+
def new(attributes = {})
|
29
|
+
Fog::AWS::EC2::Volume.new(attributes.merge!(:connection => connection))
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class S3
|
4
|
+
|
5
|
+
class Bucket < Fog::Model
|
6
|
+
|
7
|
+
attribute :creation_date, 'CreationDate'
|
8
|
+
attribute :location
|
9
|
+
attribute :name, 'Name'
|
10
|
+
attribute :owner
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def buckets
|
17
|
+
@buckets
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
connection.delete_bucket(@name)
|
22
|
+
buckets.delete(name)
|
23
|
+
true
|
24
|
+
rescue Fog::Errors::NotFound
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def location
|
29
|
+
data = s3.get_bucket_location(@name)
|
30
|
+
data.body['LocationConstraint']
|
31
|
+
end
|
32
|
+
|
33
|
+
def objects
|
34
|
+
@objects ||= begin
|
35
|
+
Fog::AWS::S3::Objects.new(
|
36
|
+
:bucket => self,
|
37
|
+
:connection => connection
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def payer
|
43
|
+
data = connection.get_request_payment(@name)
|
44
|
+
data.body['Payer']
|
45
|
+
end
|
46
|
+
|
47
|
+
def payer=(new_payer)
|
48
|
+
connection.put_request_payment(@name, new_payer)
|
49
|
+
@payer = new_payer
|
50
|
+
end
|
51
|
+
|
52
|
+
def reload
|
53
|
+
new_attributes = buckets.get(@name).attributes
|
54
|
+
merge_attributes(new_attributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def save
|
58
|
+
options = {}
|
59
|
+
if @location
|
60
|
+
options['LocationConstraint'] = @location
|
61
|
+
end
|
62
|
+
connection.put_bucket(@name, options)
|
63
|
+
buckets[name] = self
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def buckets=(new_buckets)
|
70
|
+
@buckets = new_buckets
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class S3
|
4
|
+
|
5
|
+
def buckets
|
6
|
+
Fog::AWS::S3::Buckets.new(:connection => self)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Buckets < Fog::Collection
|
10
|
+
|
11
|
+
def all
|
12
|
+
data = connection.get_service.body
|
13
|
+
owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection))
|
14
|
+
self.delete_if {true}
|
15
|
+
data['Buckets'].each do |bucket|
|
16
|
+
self[bucket['Name']] = Fog::AWS::S3::Bucket.new({
|
17
|
+
:buckets => self,
|
18
|
+
:connection => connection,
|
19
|
+
:owner => owner
|
20
|
+
}.merge!(bucket))
|
21
|
+
end
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(attributes = {})
|
26
|
+
bucket = new(attributes)
|
27
|
+
bucket.save
|
28
|
+
bucket
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(name, options = {})
|
32
|
+
remap_attributes(options, {
|
33
|
+
:is_truncated => 'IsTruncated',
|
34
|
+
:marker => 'Marker',
|
35
|
+
:max_keys => 'MaxKeys',
|
36
|
+
:prefix => 'Prefix'
|
37
|
+
})
|
38
|
+
data = connection.get_bucket(name, options).body
|
39
|
+
bucket = Fog::AWS::S3::Bucket.new({
|
40
|
+
:buckets => self,
|
41
|
+
:connection => connection,
|
42
|
+
:name => data['Name']
|
43
|
+
})
|
44
|
+
self[bucket.name] = bucket
|
45
|
+
objects_data = {}
|
46
|
+
for key, value in data
|
47
|
+
if ['IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
|
48
|
+
objects_data[key] = value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
bucket.objects.merge_attributes(objects_data)
|
52
|
+
data['Contents'].each do |object|
|
53
|
+
owner = Fog::AWS::S3::Owner.new(object.delete('Owner').merge!(:connection => connection))
|
54
|
+
bucket.objects[object['key']] = Fog::AWS::S3::Object.new({
|
55
|
+
:bucket => bucket,
|
56
|
+
:connection => connection,
|
57
|
+
:objects => self,
|
58
|
+
:owner => owner
|
59
|
+
}.merge!(object))
|
60
|
+
end
|
61
|
+
bucket
|
62
|
+
rescue Fog::Errors::NotFound
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def new(attributes = {})
|
67
|
+
Fog::AWS::S3::Bucket.new(
|
68
|
+
attributes.merge!(
|
69
|
+
:connection => connection,
|
70
|
+
:buckets => self
|
71
|
+
)
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def reload
|
76
|
+
all
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class S3
|
4
|
+
|
5
|
+
class Object < Fog::Model
|
6
|
+
|
7
|
+
attribute :body
|
8
|
+
attribute :content_length, 'Content-Length'
|
9
|
+
attribute :content_type, 'Content-Type'
|
10
|
+
attribute :etag, ['Etag', 'ETag']
|
11
|
+
attribute :key, 'Key'
|
12
|
+
attribute :last_modified, ['Last-Modified', 'LastModified']
|
13
|
+
attribute :owner
|
14
|
+
attribute :size, 'Size'
|
15
|
+
attribute :storage_class, 'StorageClass'
|
16
|
+
|
17
|
+
def initialize(attributes = {})
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def bucket
|
22
|
+
@bucket
|
23
|
+
end
|
24
|
+
|
25
|
+
def copy(target_bucket_name, target_object_key)
|
26
|
+
data = connection.copy_object(bucket.name, @key, target_bucket_name, target_object_key).body
|
27
|
+
target_bucket = connection.buckets.new(:name => target_bucket_name)
|
28
|
+
target_object = target_bucket.objects.new(attributes.merge!(:key => target_object_key))
|
29
|
+
copy_data = {}
|
30
|
+
for key, value in data
|
31
|
+
if ['ETag', 'LastModified'].include?(key)
|
32
|
+
copy_data[key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
target_object.merge_attributes(copy_data)
|
36
|
+
target_object.objects[target_object_key] = target_object
|
37
|
+
target_object
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
connection.delete_object(bucket.name, @key)
|
42
|
+
objects.delete(@key)
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def objects
|
47
|
+
@objects
|
48
|
+
end
|
49
|
+
|
50
|
+
def reload
|
51
|
+
new_attributes = objects.get(@key).attributes
|
52
|
+
merge_attributes(new_attributes)
|
53
|
+
end
|
54
|
+
|
55
|
+
def save(options = {})
|
56
|
+
data = connection.put_object(bucket.name, @key, @body, options)
|
57
|
+
@etag = data.headers['ETag']
|
58
|
+
objects[@key] = self
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def bucket=(new_bucket)
|
65
|
+
@bucket = new_bucket
|
66
|
+
end
|
67
|
+
|
68
|
+
def objects=(new_objects)
|
69
|
+
@objects = new_objects
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class S3
|
4
|
+
|
5
|
+
class Objects < Fog::Collection
|
6
|
+
|
7
|
+
attribute :is_truncated, 'IsTruncated'
|
8
|
+
attribute :marker, 'Marker'
|
9
|
+
attribute :max_keys, 'MaxKeys'
|
10
|
+
attribute :prefix, 'Prefix'
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def all(options = {})
|
17
|
+
merge_attributes(options)
|
18
|
+
self.delete_if {true}
|
19
|
+
objects = bucket.buckets.get(bucket.name, attributes).objects
|
20
|
+
objects.keys.each do |key|
|
21
|
+
self[key] = objects[key]
|
22
|
+
end
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def bucket
|
27
|
+
@bucket
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(attributes = {})
|
31
|
+
object = new(attributes)
|
32
|
+
object.save
|
33
|
+
object
|
34
|
+
end
|
35
|
+
|
36
|
+
def get(key, options = {})
|
37
|
+
data = connection.get_object(bucket.name, key, options)
|
38
|
+
object_data = {
|
39
|
+
:body => data.body,
|
40
|
+
:key => key
|
41
|
+
}
|
42
|
+
for key, value in data.headers
|
43
|
+
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
44
|
+
object_data[key] = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
self[object_data['key']] = Fog::AWS::S3::Object.new({
|
48
|
+
:bucket => bucket,
|
49
|
+
:connection => connection,
|
50
|
+
:objects => self
|
51
|
+
}.merge!(object_data))
|
52
|
+
rescue Fog::Errors::NotFound
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def head(key, options = {})
|
57
|
+
data = connection.head_object(bucket.name, key, options)
|
58
|
+
object_data = {
|
59
|
+
:key => key
|
60
|
+
}
|
61
|
+
for key, value in data.headers
|
62
|
+
if ['Content-Length', 'ETag', 'Last-Modified'].include?(key)
|
63
|
+
object_data[key] = value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
self[object_data['key']] = Fog::AWS::S3::Object.new({
|
67
|
+
:bucket => bucket,
|
68
|
+
:connection => connection,
|
69
|
+
:objects => self
|
70
|
+
}.merge!(object_data))
|
71
|
+
rescue Fog::Errors::NotFound
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def new(attributes = {})
|
76
|
+
Fog::AWS::S3::Object.new({
|
77
|
+
:bucket => bucket,
|
78
|
+
:connection => connection,
|
79
|
+
:objects => self
|
80
|
+
}.merge!(attributes))
|
81
|
+
end
|
82
|
+
|
83
|
+
def reload
|
84
|
+
all
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def bucket=(new_bucket)
|
90
|
+
@bucket = new_bucket
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module EC2
|
5
|
+
|
6
|
+
class AllocateAddress < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def end_element(name)
|
9
|
+
case name
|
10
|
+
when 'publicIp', 'requestId'
|
11
|
+
@response[name] = @value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|