fog 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/README.rdoc +16 -7
- data/fog.gemspec +102 -27
- data/lib/fog.rb +3 -2
- data/lib/fog/aws/cdn.rb +2 -1
- data/lib/fog/aws/compute.rb +3 -2
- data/lib/fog/aws/iam.rb +8 -0
- data/lib/fog/aws/models/compute/flavors.rb +2 -1
- data/lib/fog/aws/models/compute/server.rb +3 -0
- data/lib/fog/aws/models/compute/volume.rb +9 -8
- data/lib/fog/aws/models/storage/file.rb +24 -14
- data/lib/fog/aws/models/storage/files.rb +4 -14
- data/lib/fog/aws/parsers/cdn/distribution.rb +16 -1
- data/lib/fog/aws/parsers/cdn/get_distribution_list.rb +13 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +2 -0
- data/lib/fog/aws/parsers/iam/create_group.rb +2 -2
- data/lib/fog/aws/parsers/iam/create_user.rb +26 -0
- data/lib/fog/aws/parsers/iam/list_group_policies.rb +28 -0
- data/lib/fog/aws/parsers/iam/list_groups.rb +1 -1
- data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/initiate_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/list_multipart_uploads.rb +56 -0
- data/lib/fog/aws/parsers/storage/list_parts.rb +40 -0
- data/lib/fog/aws/requests/cdn/get_distribution.rb +11 -1
- data/lib/fog/aws/requests/cdn/get_distribution_list.rb +9 -1
- data/lib/fog/aws/requests/cdn/post_distribution.rb +16 -5
- data/lib/fog/aws/requests/cdn/put_distribution_config.rb +102 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +1 -0
- data/lib/fog/aws/requests/compute/run_instances.rb +1 -1
- data/lib/fog/aws/requests/iam/add_user_to_group.rb +42 -0
- data/lib/fog/aws/requests/iam/create_group.rb +7 -3
- data/lib/fog/aws/requests/iam/create_user.rb +47 -0
- data/lib/fog/aws/requests/iam/delete_group.rb +5 -1
- data/lib/fog/aws/requests/iam/delete_group_policy.rb +42 -0
- data/lib/fog/aws/requests/iam/delete_user.rb +40 -0
- data/lib/fog/aws/requests/iam/list_group_policies.rb +47 -0
- data/lib/fog/aws/requests/iam/list_groups.rb +9 -4
- data/lib/fog/aws/requests/iam/put_group_policy.rb +44 -0
- data/lib/fog/aws/requests/iam/remove_user_from_group.rb +42 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
- data/lib/fog/aws/requests/storage/abort_multipart_upload.rb +38 -0
- data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +60 -0
- data/lib/fog/aws/requests/storage/get_service.rb +1 -1
- data/lib/fog/aws/requests/storage/initiate_multipart_upload.rb +55 -0
- data/lib/fog/aws/requests/storage/list_multipart_uploads.rb +68 -0
- data/lib/fog/aws/requests/storage/list_parts.rb +67 -0
- data/lib/fog/aws/requests/storage/put_object.rb +12 -5
- data/lib/fog/aws/requests/storage/upload_part.rb +51 -0
- data/lib/fog/aws/storage.rb +12 -6
- data/lib/fog/brightbox.rb +7 -0
- data/lib/fog/brightbox/bin.rb +23 -0
- data/lib/fog/brightbox/compute.rb +134 -0
- data/lib/fog/brightbox/models/compute/account.rb +51 -0
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +43 -0
- data/lib/fog/brightbox/models/compute/cloud_ips.rb +34 -0
- data/lib/fog/brightbox/models/compute/flavor.rb +33 -0
- data/lib/fog/brightbox/models/compute/flavors.rb +28 -0
- data/lib/fog/brightbox/models/compute/image.rb +52 -0
- data/lib/fog/brightbox/models/compute/images.rb +28 -0
- data/lib/fog/brightbox/models/compute/server.rb +94 -0
- data/lib/fog/brightbox/models/compute/servers.rb +29 -0
- data/lib/fog/brightbox/models/compute/user.rb +39 -0
- data/lib/fog/brightbox/models/compute/users.rb +29 -0
- data/lib/fog/brightbox/models/compute/zone.rb +21 -0
- data/lib/fog/brightbox/models/compute/zones.rb +29 -0
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_image.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_interface.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_user.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_zone.rb +28 -0
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_images.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_servers.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_users.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_zones.rb +27 -0
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/resize_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/start_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/stop_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_account.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_image.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_server.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_user.rb +29 -0
- data/lib/fog/core/attributes.rb +3 -3
- data/lib/fog/core/bin.rb +2 -0
- data/lib/fog/core/compute.rb +5 -2
- data/lib/fog/core/credentials.rb +2 -0
- data/lib/fog/core/service.rb +24 -12
- data/lib/fog/google/models/storage/file.rb +23 -14
- data/lib/fog/google/models/storage/files.rb +4 -14
- data/lib/fog/google/requests/storage/get_bucket.rb +0 -1
- data/lib/fog/google/requests/storage/put_object.rb +9 -2
- data/lib/fog/rackspace/models/storage/file.rb +3 -3
- data/lib/fog/rackspace/models/storage/files.rb +5 -13
- data/spec/aws/models/compute/server_spec.rb +0 -3
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +11 -0
- data/spec/core/attributes_spec.rb +52 -0
- data/spec/vcloud/bin_spec.rb +1 -1
- data/spec/vcloud/vcloud_spec.rb +1 -1
- data/tests/aws/models/compute/flavors_tests.rb +5 -0
- data/tests/aws/models/compute/server_tests.rb +6 -0
- data/tests/aws/models/compute/servers_tests.rb +6 -0
- data/tests/aws/requests/storage/bucket_tests.rb +1 -1
- data/tests/aws/requests/storage/multipart_upload_tests.rb +135 -0
- data/tests/bluebox/models/compute/flavors_tests.rb +5 -0
- data/tests/bluebox/models/compute/server_tests.rb +5 -0
- data/tests/bluebox/models/compute/servers_tests.rb +6 -0
- data/tests/brightbox/helper.rb +0 -0
- data/tests/brightbox/models/compute/flavors_tests.rb +5 -0
- data/tests/brightbox/models/compute/server_tests.rb +6 -0
- data/tests/brightbox/models/compute/servers_tests.rb +6 -0
- data/tests/google/requests/storage/bucket_tests.rb +78 -0
- data/tests/google/requests/storage/object_tests.rb +81 -0
- data/tests/helper.rb +19 -4
- data/tests/helpers/collection_tests.rb +51 -0
- data/tests/helpers/compute/flavors_tests.rb +34 -0
- data/tests/helpers/compute/server_tests.rb +19 -0
- data/tests/helpers/compute/servers_tests.rb +11 -0
- data/tests/helpers/model_tests.rb +28 -0
- data/tests/helpers/storage/directories_tests.rb +4 -36
- data/tests/helpers/storage/directory_tests.rb +8 -22
- data/tests/helpers/storage/file_tests.rb +8 -25
- data/tests/helpers/storage/files_tests.rb +5 -39
- data/tests/local/models/storage/directories_tests.rb +1 -1
- data/tests/local/models/storage/directory_tests.rb +1 -1
- data/tests/local/models/storage/file_tests.rb +1 -1
- data/tests/local/models/storage/files_tests.rb +1 -1
- data/tests/rackspace/models/compute/flavors_tests.rb +5 -0
- data/tests/rackspace/models/compute/server_tests.rb +6 -0
- data/tests/rackspace/models/compute/servers_tests.rb +6 -0
- data/tests/rackspace/models/storage/directories_tests.rb +1 -1
- data/tests/rackspace/models/storage/directory_tests.rb +1 -1
- data/tests/rackspace/models/storage/file_tests.rb +1 -1
- data/tests/rackspace/models/storage/files_tests.rb +1 -1
- data/tests/slicehost/models/compute/flavors_tests.rb +5 -0
- data/tests/slicehost/models/compute/server_tests.rb +6 -0
- data/tests/slicehost/models/compute/servers_tests.rb +6 -0
- metadata +108 -31
- data/spec/aws/models/compute/flavors_spec.rb +0 -14
- data/spec/aws/models/compute/servers_spec.rb +0 -21
- data/spec/bluebox/models/compute/flavors_spec.rb +0 -17
- data/spec/bluebox/models/compute/server_spec.rb +0 -29
- data/spec/bluebox/models/compute/servers_spec.rb +0 -31
- data/spec/google/requests/storage/copy_object_spec.rb +0 -61
- data/spec/google/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/google/requests/storage/delete_object_spec.rb +0 -38
- data/spec/google/requests/storage/get_bucket_spec.rb +0 -110
- data/spec/google/requests/storage/get_object_spec.rb +0 -58
- data/spec/google/requests/storage/get_service_spec.rb +0 -32
- data/spec/google/requests/storage/head_object_spec.rb +0 -26
- data/spec/google/requests/storage/put_bucket_spec.rb +0 -21
- data/spec/google/requests/storage/put_object_spec.rb +0 -43
- data/spec/rackspace/models/compute/flavors_spec.rb +0 -18
- data/spec/rackspace/models/compute/server_spec.rb +0 -55
- data/spec/rackspace/models/compute/servers_spec.rb +0 -22
- data/spec/shared_examples/flavors_examples.rb +0 -16
- data/spec/shared_examples/server_examples.rb +0 -43
- data/spec/shared_examples/servers_examples.rb +0 -37
- data/spec/slicehost/models/compute/flavors_spec.rb +0 -18
- data/spec/slicehost/models/compute/server_spec.rb +0 -55
- data/spec/slicehost/models/compute/servers_spec.rb +0 -26
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Brightbox
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def update_server(identifier, options = {})
|
7
|
+
return nil if identifier.nil? || identifier == ""
|
8
|
+
return nil if options.empty? || options.nil?
|
9
|
+
request(
|
10
|
+
:expects => [200],
|
11
|
+
:method => 'PUT',
|
12
|
+
:path => "/1.0/servers/#{identifier}",
|
13
|
+
:headers => {"Content-Type" => "application/json"},
|
14
|
+
:body => options.to_json
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
|
22
|
+
def update_server(identifier, options = {})
|
23
|
+
Fog::Mock.not_implemented
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Brightbox
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def update_user(identifier, options = {})
|
7
|
+
return nil if identifier.nil? || identifier == ""
|
8
|
+
return nil if options.empty? || options.nil?
|
9
|
+
request(
|
10
|
+
:expects => [200],
|
11
|
+
:method => 'PUT',
|
12
|
+
:path => "/1.0/users/#{identifier}",
|
13
|
+
:headers => {"Content-Type" => "application/json"},
|
14
|
+
:body => options.to_json
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
|
22
|
+
def update_user(identifier, options = {})
|
23
|
+
Fog::Mock.not_implemented
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/fog/core/attributes.rb
CHANGED
@@ -51,7 +51,7 @@ module Fog
|
|
51
51
|
when :time
|
52
52
|
class_eval <<-EOS, __FILE__, __LINE__
|
53
53
|
def #{name}=(new_#{name})
|
54
|
-
if new_#{name}.nil? || new_#{name}.is_a?(Time)
|
54
|
+
if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(Time)
|
55
55
|
@#{name} = new_#{name}
|
56
56
|
else
|
57
57
|
@#{name} = Time.parse(new_#{name})
|
@@ -73,8 +73,8 @@ module Fog
|
|
73
73
|
class_eval <<-EOS, __FILE__, __LINE__
|
74
74
|
def #{name}=(new_data)
|
75
75
|
if new_data.is_a?(Hash)
|
76
|
-
if new_data[:#{squash}]
|
77
|
-
@#{name} = new_data[:#{squash}]
|
76
|
+
if new_data[:#{squash}] || new_data["#{squash}"]
|
77
|
+
@#{name} = new_data[:#{squash}] || new_data["#{squash}"]
|
78
78
|
else
|
79
79
|
@#{name} = [ new_data ]
|
80
80
|
end
|
data/lib/fog/core/bin.rb
CHANGED
@@ -7,6 +7,7 @@ module Fog
|
|
7
7
|
[
|
8
8
|
::AWS,
|
9
9
|
::Bluebox,
|
10
|
+
::Brightbox,
|
10
11
|
::GoGrid,
|
11
12
|
::Google,
|
12
13
|
::Linode,
|
@@ -68,6 +69,7 @@ end
|
|
68
69
|
|
69
70
|
require 'fog/aws/bin'
|
70
71
|
require 'fog/bluebox/bin'
|
72
|
+
require 'fog/brightbox/bin'
|
71
73
|
require 'fog/go_grid/bin'
|
72
74
|
require 'fog/google/bin'
|
73
75
|
require 'fog/linode/bin'
|
data/lib/fog/core/compute.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Fog
|
2
|
-
class
|
2
|
+
class Compute
|
3
3
|
|
4
4
|
def self.new(attributes)
|
5
5
|
case provider = attributes.delete(:provider)
|
@@ -9,6 +9,9 @@ module Fog
|
|
9
9
|
when 'Bluebox'
|
10
10
|
require 'fog/bluebox'
|
11
11
|
Fog::Bluebox::Compute.new(attributes)
|
12
|
+
when 'Brightbox'
|
13
|
+
require 'fog/brightbox'
|
14
|
+
Fog::Brightbox::Compute.new(attributes)
|
12
15
|
when 'GoGrid'
|
13
16
|
require 'fog/go_grid'
|
14
17
|
Fog::GoGrid::Compute.new(attributes)
|
@@ -25,7 +28,7 @@ module Fog
|
|
25
28
|
require 'fog/slicehost'
|
26
29
|
Fog::Slicehost::Compute.new(attributes)
|
27
30
|
else
|
28
|
-
raise ArgumentError.new("#{provider} is not a recognized
|
31
|
+
raise ArgumentError.new("#{provider} is not a recognized compute provider")
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
data/lib/fog/core/credentials.rb
CHANGED
@@ -34,6 +34,8 @@ module Fog
|
|
34
34
|
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
|
35
35
|
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
|
36
36
|
:bluebox_customer_id: INTENTIONALLY_LEFT_BLANK
|
37
|
+
:brightbox_client_id: INTENTIONALLY_LEFT_BLANK
|
38
|
+
:brightbox_secret: INTENTIONALLY_LEFT_BLANK
|
37
39
|
:go_grid_api_key: INTENTIONALLY_LEFT_BLANK
|
38
40
|
:go_grid_shared_secret: INTENTIONALLY_LEFT_BLANK
|
39
41
|
:local_root: INTENTIONALLY_LEFT_BLANK
|
data/lib/fog/core/service.rb
CHANGED
@@ -40,18 +40,7 @@ module Fog
|
|
40
40
|
options = default_credentials.merge(options)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
for requirement in requirements
|
45
|
-
missing << requirement unless options[requirement]
|
46
|
-
end
|
47
|
-
unless missing.empty?
|
48
|
-
if missing.length == 1
|
49
|
-
raise(ArgumentError, [missing.first, "is required for this service"].join(' '))
|
50
|
-
else
|
51
|
-
raise(ArgumentError, [missing[0...-1].join(", "), 'and', missing[-1], 'are required for this service'].join(' '))
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
43
|
+
validate_arguments(options)
|
55
44
|
setup_requirements
|
56
45
|
|
57
46
|
if Fog.mocking?
|
@@ -129,10 +118,33 @@ module Fog
|
|
129
118
|
@requirements ||= []
|
130
119
|
end
|
131
120
|
|
121
|
+
def recognizes(*args)
|
122
|
+
recognized.concat(args)
|
123
|
+
end
|
124
|
+
|
125
|
+
def recognized
|
126
|
+
@recognized ||= []
|
127
|
+
end
|
128
|
+
|
132
129
|
def reset_data(keys=Mock.data.keys)
|
133
130
|
Mock.reset_data(keys)
|
134
131
|
end
|
135
132
|
|
133
|
+
def validate_arguments(options)
|
134
|
+
missing = requirements - options.keys
|
135
|
+
unless missing.empty?
|
136
|
+
raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
|
137
|
+
end
|
138
|
+
|
139
|
+
# FIXME: avoid failing for the services that don't have recognizes yet
|
140
|
+
unless recognizes.empty?
|
141
|
+
unrecognized = options.keys - requirements - recognized
|
142
|
+
unless unrecognized.empty?
|
143
|
+
raise ArgumentError, "Unrecognized arguments: #{unrecognized.join(', ')}"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
136
148
|
end
|
137
149
|
|
138
150
|
end
|
@@ -5,17 +5,24 @@ module Fog
|
|
5
5
|
class Storage
|
6
6
|
|
7
7
|
class File < Fog::Model
|
8
|
+
extend Fog::Deprecation
|
9
|
+
deprecate(:size, :content_length)
|
10
|
+
deprecate(:size=, :content_length=)
|
8
11
|
|
9
12
|
identity :key, :aliases => 'Key'
|
10
13
|
|
11
14
|
attr_writer :body
|
12
|
-
attribute :
|
13
|
-
attribute :
|
14
|
-
attribute :
|
15
|
-
attribute :
|
16
|
-
attribute :
|
17
|
-
attribute :
|
18
|
-
attribute :
|
15
|
+
attribute :cache_control, :aliases => 'Cache-Control'
|
16
|
+
attribute :content_disposition, :aliases => 'Content-Disposition'
|
17
|
+
attribute :content_encoding, :aliases => 'Content-Encoding'
|
18
|
+
attribute :content_length, :aliases => ['Content-Length', 'Size'], :type => :integer
|
19
|
+
attribute :content_md5, :aliases => 'Content-MD5'
|
20
|
+
attribute :content_type, :aliases => 'Content-Type'
|
21
|
+
attribute :etag, :aliases => ['Etag', 'ETag']
|
22
|
+
attribute :expires, :aliases => 'Expires'
|
23
|
+
attribute :last_modified, :aliases => ['Last-Modified', 'LastModified'], :type => :time
|
24
|
+
attribute :owner, :aliases => 'Owner'
|
25
|
+
attribute :storage_class, :aliases => ['x-goog-storage-class', 'StorageClass']
|
19
26
|
|
20
27
|
def acl=(new_acl)
|
21
28
|
valid_acls = ['private', 'public-read', 'public-read-write', 'authenticated-read']
|
@@ -83,14 +90,16 @@ module Fog
|
|
83
90
|
if options != {}
|
84
91
|
Formatador.display_line("[yellow][WARN] options param is deprecated, use acl= instead[/] [light_black](#{caller.first})[/]")
|
85
92
|
end
|
86
|
-
if @acl
|
87
|
-
|
88
|
-
|
89
|
-
if
|
90
|
-
|
91
|
-
|
93
|
+
options['x-goog-acl'] ||= @acl if @acl
|
94
|
+
options['Cache-Control'] = cache_control if cache_control
|
95
|
+
options['Content-Disposition'] = content_disposition if content_disposition
|
96
|
+
options['Content-Encoding'] = content_encoding if content_encoding
|
97
|
+
options['Content-MD5'] = content_md5 if content_md5
|
98
|
+
options['Content-Type'] = content_type if content_type
|
99
|
+
options['Expires'] = expires if expires
|
100
|
+
|
92
101
|
data = connection.put_object(directory.key, @key, @body, options)
|
93
|
-
|
102
|
+
merge_attributes(data.headers)
|
94
103
|
true
|
95
104
|
end
|
96
105
|
|
@@ -41,15 +41,10 @@ module Fog
|
|
41
41
|
def get(key, options = {}, &block)
|
42
42
|
requires :directory
|
43
43
|
data = connection.get_object(directory.key, key, options, &block)
|
44
|
-
file_data = {
|
44
|
+
file_data = data.headers.merge({
|
45
45
|
:body => data.body,
|
46
46
|
:key => key
|
47
|
-
}
|
48
|
-
for key, value in data.headers
|
49
|
-
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
50
|
-
file_data[key] = value
|
51
|
-
end
|
52
|
-
end
|
47
|
+
})
|
53
48
|
new(file_data)
|
54
49
|
rescue Excon::Errors::NotFound
|
55
50
|
nil
|
@@ -63,14 +58,9 @@ module Fog
|
|
63
58
|
def head(key, options = {})
|
64
59
|
requires :directory
|
65
60
|
data = connection.head_object(directory.key, key, options)
|
66
|
-
file_data = {
|
61
|
+
file_data = data.headers.merge({
|
67
62
|
:key => key
|
68
|
-
}
|
69
|
-
for key, value in data.headers
|
70
|
-
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
71
|
-
file_data[key] = value
|
72
|
-
end
|
73
|
-
end
|
63
|
+
})
|
74
64
|
new(file_data)
|
75
65
|
rescue Excon::Errors::NotFound
|
76
66
|
nil
|
@@ -49,15 +49,22 @@ module Fog
|
|
49
49
|
response = Excon::Response.new
|
50
50
|
if (bucket = @data[:buckets][bucket_name])
|
51
51
|
response.status = 200
|
52
|
-
|
52
|
+
object = {
|
53
53
|
:body => data[:body],
|
54
|
+
'Content-Type' => data[:headers]['Content-Type'],
|
54
55
|
'ETag' => Fog::Google::Mock.etag,
|
55
56
|
'Key' => object_name,
|
56
57
|
'LastModified' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000"),
|
57
58
|
'Size' => data[:headers]['Content-Length'],
|
58
59
|
'StorageClass' => 'STANDARD'
|
59
60
|
}
|
60
|
-
bucket[:objects][object_name]
|
61
|
+
bucket[:objects][object_name] = object
|
62
|
+
response.headers = {
|
63
|
+
'Content-Length' => object['Size'],
|
64
|
+
'Content-Type' => object['Content-Type'],
|
65
|
+
'ETag' => object['ETag'],
|
66
|
+
'Last-Modified' => object['LastModified']
|
67
|
+
}
|
61
68
|
else
|
62
69
|
response.status = 404
|
63
70
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
@@ -9,10 +9,10 @@ module Fog
|
|
9
9
|
identity :key, :aliases => 'name'
|
10
10
|
|
11
11
|
attr_writer :body
|
12
|
-
attribute :content_length, :aliases => ['bytes', 'Content-Length']
|
12
|
+
attribute :content_length, :aliases => ['bytes', 'Content-Length'], :type => :integer
|
13
13
|
attribute :content_type, :aliases => ['content_type', 'Content-Type']
|
14
14
|
attribute :etag, :aliases => ['hash', 'Etag']
|
15
|
-
attribute :last_modified, :aliases => ['last_modified', 'Last-Modified']
|
15
|
+
attribute :last_modified, :aliases => ['last_modified', 'Last-Modified'], :type => :time
|
16
16
|
|
17
17
|
def body
|
18
18
|
@body ||= if last_modified
|
@@ -51,7 +51,7 @@ module Fog
|
|
51
51
|
def save(options = {})
|
52
52
|
requires :body, :directory, :key
|
53
53
|
data = connection.put_object(directory.key, @key, @body, options)
|
54
|
-
|
54
|
+
merge_attributes(data.headers)
|
55
55
|
true
|
56
56
|
end
|
57
57
|
|
@@ -38,15 +38,10 @@ module Fog
|
|
38
38
|
def get(key, &block)
|
39
39
|
requires :directory
|
40
40
|
data = connection.get_object(directory.key, key, &block)
|
41
|
-
file_data = {
|
41
|
+
file_data = data.headers.merge({
|
42
42
|
:body => data.body,
|
43
43
|
:key => key
|
44
|
-
}
|
45
|
-
for key, value in data.headers
|
46
|
-
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
47
|
-
file_data[key] = value
|
48
|
-
end
|
49
|
-
end
|
44
|
+
})
|
50
45
|
new(file_data)
|
51
46
|
rescue Fog::Rackspace::Storage::NotFound
|
52
47
|
nil
|
@@ -60,12 +55,9 @@ module Fog
|
|
60
55
|
def head(key, options = {})
|
61
56
|
requires :directory
|
62
57
|
data = connection.head_object(directory.name, key, options)
|
63
|
-
file_data = {
|
64
|
-
|
65
|
-
|
66
|
-
file_data[key] = value
|
67
|
-
end
|
68
|
-
end
|
58
|
+
file_data = data.headers.merge({
|
59
|
+
:key => key
|
60
|
+
})
|
69
61
|
new(file_data)
|
70
62
|
rescue Fog::Rackspace::Storage::NotFound
|
71
63
|
nil
|
@@ -1,10 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
3
2
|
|
4
3
|
describe 'Fog::AWS::Compute::Server' do
|
5
4
|
|
6
|
-
it_should_behave_like "Server"
|
7
|
-
|
8
5
|
subject { @server = @servers.new(:image_id => GENTOO_AMI) }
|
9
6
|
|
10
7
|
before(:each) do
|
@@ -36,6 +36,17 @@ describe 'SimpleDB.get_attributes' do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
context "foo item is put with bar attribute as an array" do
|
40
|
+
it "should return the array for foo's bar attribute" do
|
41
|
+
the_array = %w{A B C}
|
42
|
+
AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => the_array })
|
43
|
+
eventually do
|
44
|
+
actual = AWS[:sdb].get_attributes(@domain_name, 'foo')
|
45
|
+
actual.body['Attributes']['bar'].should =~ the_array
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
39
50
|
end
|
40
51
|
describe 'failure' do
|
41
52
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
class FogAttributeTestModel < Fog::Model
|
4
|
+
attribute :key_id, :aliases => "key", :squash => "id"
|
5
|
+
attribute :time, :type => :time
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'Fog::Attributes' do
|
9
|
+
|
10
|
+
describe ".attribute" do
|
11
|
+
describe "squashing a value" do
|
12
|
+
it "should accept squashed key as symbol" do
|
13
|
+
data = {"key" => {:id => "value"}}
|
14
|
+
model = FogAttributeTestModel.new
|
15
|
+
model.merge_attributes(data)
|
16
|
+
model.key_id.should == "value"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept squashed key as string" do
|
20
|
+
data = {"key" => {"id" => "value"}}
|
21
|
+
model = FogAttributeTestModel.new
|
22
|
+
model.merge_attributes(data)
|
23
|
+
model.key_id.should == "value"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "when merging a time field" do
|
28
|
+
it "should accept nil as a suitable setting" do
|
29
|
+
data = {"time" => nil}
|
30
|
+
model = FogAttributeTestModel.new
|
31
|
+
model.merge_attributes(data)
|
32
|
+
model.time.should be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should accept empty string as a suitable setting" do
|
36
|
+
data = {"time" => ""}
|
37
|
+
model = FogAttributeTestModel.new
|
38
|
+
model.merge_attributes(data)
|
39
|
+
model.time.should == ""
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse strings to get a Datetime" do
|
43
|
+
test_time = Time.parse("2010-11-12T13:14:15")
|
44
|
+
data = {"time" => test_time.to_s}
|
45
|
+
model = FogAttributeTestModel.new
|
46
|
+
model.merge_attributes(data)
|
47
|
+
model.time.should == test_time
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|