fog-brightbox 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +81 -0
- data/CHANGELOG.md +17 -0
- data/README.md +6 -0
- data/fog-brightbox.gemspec +10 -9
- data/gemfiles/Gemfile.1.8.7 +1 -0
- data/lib/fog/brightbox.rb +2 -2
- data/lib/fog/brightbox/compute.rb +47 -48
- data/lib/fog/brightbox/compute/resource_locking.rb +26 -20
- data/lib/fog/brightbox/compute/shared.rb +2 -7
- data/lib/fog/brightbox/config.rb +12 -15
- data/lib/fog/brightbox/core.rb +5 -5
- data/lib/fog/brightbox/link_helper.rb +33 -0
- data/lib/fog/brightbox/models/compute/account.rb +0 -1
- data/lib/fog/brightbox/models/compute/accounts.rb +2 -6
- data/lib/fog/brightbox/models/compute/api_client.rb +2 -2
- data/lib/fog/brightbox/models/compute/application.rb +2 -2
- data/lib/fog/brightbox/models/compute/applications.rb +2 -6
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +0 -4
- data/lib/fog/brightbox/models/compute/cloud_ips.rb +2 -6
- data/lib/fog/brightbox/models/compute/collaboration.rb +4 -4
- data/lib/fog/brightbox/models/compute/database_server.rb +11 -4
- data/lib/fog/brightbox/models/compute/database_servers.rb +2 -6
- data/lib/fog/brightbox/models/compute/database_snapshot.rb +1 -1
- data/lib/fog/brightbox/models/compute/database_snapshots.rb +2 -2
- data/lib/fog/brightbox/models/compute/database_types.rb +2 -4
- data/lib/fog/brightbox/models/compute/event.rb +0 -2
- data/lib/fog/brightbox/models/compute/events.rb +2 -4
- data/lib/fog/brightbox/models/compute/firewall_policies.rb +2 -6
- data/lib/fog/brightbox/models/compute/firewall_policy.rb +2 -3
- data/lib/fog/brightbox/models/compute/firewall_rule.rb +2 -3
- data/lib/fog/brightbox/models/compute/firewall_rules.rb +2 -6
- data/lib/fog/brightbox/models/compute/flavor.rb +0 -1
- data/lib/fog/brightbox/models/compute/flavors.rb +2 -6
- data/lib/fog/brightbox/models/compute/image.rb +3 -3
- data/lib/fog/brightbox/models/compute/images.rb +2 -6
- data/lib/fog/brightbox/models/compute/load_balancer.rb +5 -5
- data/lib/fog/brightbox/models/compute/load_balancers.rb +2 -6
- data/lib/fog/brightbox/models/compute/server.rb +15 -9
- data/lib/fog/brightbox/models/compute/server_group.rb +1 -1
- data/lib/fog/brightbox/models/compute/server_groups.rb +2 -6
- data/lib/fog/brightbox/models/compute/servers.rb +2 -6
- data/lib/fog/brightbox/models/compute/user.rb +0 -1
- data/lib/fog/brightbox/models/compute/user_collaboration.rb +2 -3
- data/lib/fog/brightbox/models/compute/users.rb +2 -5
- data/lib/fog/brightbox/models/compute/zones.rb +2 -6
- data/lib/fog/brightbox/models/storage/directories.rb +6 -13
- data/lib/fog/brightbox/models/storage/directory.rb +5 -7
- data/lib/fog/brightbox/models/storage/file.rb +37 -45
- data/lib/fog/brightbox/models/storage/files.rb +21 -25
- data/lib/fog/brightbox/oauth2.rb +136 -137
- data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/activate_console_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +0 -2
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_type.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_interface.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_user.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_zone.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_applications.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_collaborations.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_servers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_snapshots.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_types.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_events.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_images.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_server_groups.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_servers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_users.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_zones.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reboot_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +0 -2
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_password_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +19 -3
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +19 -3
- data/lib/fog/brightbox/requests/compute/start_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/stop_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_user.rb +0 -1
- data/lib/fog/brightbox/requests/storage/copy_object.rb +8 -10
- data/lib/fog/brightbox/requests/storage/delete_container.rb +1 -3
- data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -9
- data/lib/fog/brightbox/requests/storage/delete_object.rb +1 -3
- data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +7 -9
- data/lib/fog/brightbox/requests/storage/get_container.rb +3 -5
- data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -6
- data/lib/fog/brightbox/requests/storage/get_object.rb +1 -3
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +5 -10
- data/lib/fog/brightbox/requests/storage/head_container.rb +2 -4
- data/lib/fog/brightbox/requests/storage/head_containers.rb +3 -5
- data/lib/fog/brightbox/requests/storage/head_object.rb +4 -6
- data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +2 -6
- data/lib/fog/brightbox/requests/storage/put_container.rb +3 -5
- data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +2 -4
- data/lib/fog/brightbox/requests/storage/put_object.rb +1 -2
- data/lib/fog/brightbox/requests/storage/put_object_manifest.rb +0 -2
- data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +2 -4
- data/lib/fog/brightbox/storage.rb +26 -29
- data/lib/fog/brightbox/storage/connection.rb +10 -10
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/link_helper_spec.rb +18 -0
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +16 -16
- data/spec/fog/brightbox/storage/connection_spec.rb +12 -12
- data/spec/fog/compute/brightbox/database_server_spec.rb +31 -0
- data/spec/fog/compute/brightbox/server_spec.rb +31 -0
- data/spec/fog/storage/brightbox_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- metadata +28 -10
- data/spec/model_helper.rb +0 -22
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/flavor"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Flavors < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::Flavor
|
11
9
|
|
12
10
|
def all
|
@@ -20,9 +18,7 @@ module Fog
|
|
20
18
|
rescue Excon::Errors::NotFound
|
21
19
|
nil
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
@@ -5,7 +5,7 @@ module Fog
|
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
7
|
class Image < Fog::Brightbox::Model
|
8
|
-
include ResourceLocking
|
8
|
+
include Fog::Brightbox::Compute::ResourceLocking
|
9
9
|
|
10
10
|
identity :id
|
11
11
|
attribute :url
|
@@ -40,7 +40,7 @@ module Fog
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def save
|
43
|
-
raise Fog::Errors::Error.new(
|
43
|
+
raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?
|
44
44
|
requires :source, :arch
|
45
45
|
options = {
|
46
46
|
:source => source,
|
@@ -48,7 +48,7 @@ module Fog
|
|
48
48
|
:name => name,
|
49
49
|
:username => username,
|
50
50
|
:description => description
|
51
|
-
}.delete_if { |
|
51
|
+
}.delete_if { |_k, v| v.nil? || v == "" }
|
52
52
|
data = service.create_image(options)
|
53
53
|
merge_attributes(data)
|
54
54
|
true
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/image"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Images < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::Image
|
11
9
|
|
12
10
|
def all
|
@@ -20,9 +18,7 @@ module Fog
|
|
20
18
|
rescue Excon::Errors::NotFound
|
21
19
|
nil
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
@@ -5,7 +5,7 @@ module Fog
|
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
7
|
class LoadBalancer < Fog::Brightbox::Model
|
8
|
-
include ResourceLocking
|
8
|
+
include Fog::Brightbox::Compute::ResourceLocking
|
9
9
|
|
10
10
|
identity :id
|
11
11
|
attribute :url
|
@@ -42,11 +42,11 @@ module Fog
|
|
42
42
|
attribute :cloud_ip
|
43
43
|
|
44
44
|
def ready?
|
45
|
-
status ==
|
45
|
+
status == "active"
|
46
46
|
end
|
47
47
|
|
48
48
|
def save
|
49
|
-
raise Fog::Errors::Error.new(
|
49
|
+
raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?
|
50
50
|
requires :nodes, :listeners, :healthcheck
|
51
51
|
options = {
|
52
52
|
:nodes => nodes,
|
@@ -58,7 +58,7 @@ module Fog
|
|
58
58
|
:certificate_pem => certificate_pem,
|
59
59
|
:certificate_private_key => certificate_private_key,
|
60
60
|
:sslv3 => ssl3?
|
61
|
-
}.delete_if { |
|
61
|
+
}.delete_if { |_k, v| v.nil? || v == "" }
|
62
62
|
data = service.create_load_balancer(options)
|
63
63
|
merge_attributes(data)
|
64
64
|
true
|
@@ -103,7 +103,7 @@ module Fog
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def ssl3?
|
106
|
-
!!
|
106
|
+
!!attributes[:certificate_enable_ssl3]
|
107
107
|
end
|
108
108
|
|
109
109
|
private
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/load_balancer"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class LoadBalancers < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::LoadBalancer
|
11
9
|
|
12
10
|
def all
|
@@ -20,9 +18,7 @@ module Fog
|
|
20
18
|
rescue Excon::Errors::NotFound
|
21
19
|
nil
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
@@ -6,14 +6,14 @@ module Fog
|
|
6
6
|
class Brightbox
|
7
7
|
class Server < Fog::Compute::Server
|
8
8
|
include Fog::Brightbox::ModelHelper
|
9
|
-
include ResourceLocking
|
9
|
+
include Fog::Brightbox::Compute::ResourceLocking
|
10
10
|
|
11
|
-
identity
|
11
|
+
identity :id
|
12
12
|
attribute :resource_type
|
13
13
|
attribute :url
|
14
14
|
|
15
15
|
attribute :name
|
16
|
-
attribute :state, :aliases =>
|
16
|
+
attribute :state, :aliases => "status"
|
17
17
|
|
18
18
|
attribute :hostname
|
19
19
|
attribute :fqdn
|
@@ -49,7 +49,7 @@ module Fog
|
|
49
49
|
if t_zone_id = attributes[:zone_id]
|
50
50
|
t_zone_id
|
51
51
|
elsif zone
|
52
|
-
zone[:id] || zone[
|
52
|
+
zone[:id] || zone["id"]
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -57,7 +57,7 @@ module Fog
|
|
57
57
|
if t_flavour_id = attributes[:flavor_id]
|
58
58
|
t_flavour_id
|
59
59
|
elsif server_type
|
60
|
-
server_type[:id] || server_type[
|
60
|
+
server_type[:id] || server_type["id"]
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -69,9 +69,15 @@ module Fog
|
|
69
69
|
attributes[:flavor_id] = incoming_flavour_id
|
70
70
|
end
|
71
71
|
|
72
|
-
def snapshot
|
72
|
+
def snapshot(return_snapshot = false)
|
73
73
|
requires :identity
|
74
|
-
service.snapshot_server(identity)
|
74
|
+
response, snapshot_id = service.snapshot_server(identity, :return_link => return_snapshot)
|
75
|
+
|
76
|
+
if return_snapshot
|
77
|
+
service.images.get(snapshot_id)
|
78
|
+
else
|
79
|
+
response
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
# Issues a hard reset to the server (or an OS level reboot command)
|
@@ -170,7 +176,7 @@ module Fog
|
|
170
176
|
end
|
171
177
|
|
172
178
|
def save
|
173
|
-
raise Fog::Errors::Error.new(
|
179
|
+
raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?
|
174
180
|
requires :image_id
|
175
181
|
options = {
|
176
182
|
:image => image_id,
|
@@ -178,7 +184,7 @@ module Fog
|
|
178
184
|
:zone => zone_id,
|
179
185
|
:user_data => user_data,
|
180
186
|
:server_groups => server_groups
|
181
|
-
}.delete_if { |
|
187
|
+
}.delete_if { |_k, v| v.nil? || v == "" }
|
182
188
|
|
183
189
|
options.merge!(:server_type => flavor_id) unless flavor_id.nil? || flavor_id == ""
|
184
190
|
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/server_group"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class ServerGroups < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::ServerGroup
|
11
9
|
|
12
10
|
def all
|
@@ -21,9 +19,7 @@ module Fog
|
|
21
19
|
rescue Excon::Errors::NotFound
|
22
20
|
nil
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
|
-
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/server"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Servers < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::Server
|
11
9
|
|
12
10
|
def all
|
@@ -53,9 +51,7 @@ module Fog
|
|
53
51
|
rescue Excon::Errors::NotFound
|
54
52
|
nil
|
55
53
|
end
|
56
|
-
|
57
54
|
end
|
58
|
-
|
59
55
|
end
|
60
56
|
end
|
61
57
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
module Compute
|
5
5
|
class Brightbox
|
6
6
|
class UserCollaboration < Fog::Brightbox::Model
|
7
|
-
identity
|
7
|
+
identity :id
|
8
8
|
attribute :status
|
9
9
|
attribute :email
|
10
10
|
attribute :role
|
@@ -14,7 +14,7 @@ module Fog
|
|
14
14
|
attribute :inviter
|
15
15
|
|
16
16
|
def account_id
|
17
|
-
account[
|
17
|
+
account["id"] || account[:id]
|
18
18
|
end
|
19
19
|
|
20
20
|
def accept
|
@@ -37,7 +37,6 @@ module Fog
|
|
37
37
|
merge_attributes(data)
|
38
38
|
true
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/user"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Users < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::User
|
11
9
|
|
12
10
|
def all
|
@@ -21,7 +19,6 @@ module Fog
|
|
21
19
|
nil
|
22
20
|
end
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/compute/zone"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Compute
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Zones < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Compute::Brightbox::Zone
|
11
9
|
|
12
10
|
def all
|
@@ -21,9 +19,7 @@ module Fog
|
|
21
19
|
rescue Excon::Errors::NotFound
|
22
20
|
nil
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
|
-
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -1,18 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/brightbox/models/storage/directory"
|
3
3
|
|
4
4
|
module Fog
|
5
5
|
module Storage
|
6
6
|
class Brightbox
|
7
|
-
|
8
7
|
class Directories < Fog::Collection
|
9
|
-
|
10
8
|
model Fog::Storage::Brightbox::Directory
|
11
9
|
|
12
|
-
HEADER_ATTRIBUTES =
|
13
|
-
'X-Container-Bytes-Used', 'X-Container-Object-Count', 'X-Container-Read',
|
14
|
-
'X-Container-Write'
|
15
|
-
]
|
10
|
+
HEADER_ATTRIBUTES = %w(X-Container-Bytes-Used X-Container-Object-Count X-Container-Read X-Container-Write)
|
16
11
|
|
17
12
|
def all
|
18
13
|
data = service.get_containers.body
|
@@ -22,9 +17,9 @@ module Fog
|
|
22
17
|
def get(key, options = {})
|
23
18
|
data = service.get_container(key, options)
|
24
19
|
directory = new(:key => key)
|
25
|
-
|
26
|
-
if HEADER_ATTRIBUTES.include?(
|
27
|
-
directory.merge_attributes(
|
20
|
+
data.headers.each do |header, value|
|
21
|
+
if HEADER_ATTRIBUTES.include?(header)
|
22
|
+
directory.merge_attributes(header => value)
|
28
23
|
end
|
29
24
|
end
|
30
25
|
directory.files.merge_attributes(options)
|
@@ -37,9 +32,7 @@ module Fog
|
|
37
32
|
rescue Fog::Storage::Brightbox::NotFound
|
38
33
|
nil
|
39
34
|
end
|
40
|
-
|
41
35
|
end
|
42
|
-
|
43
36
|
end
|
44
37
|
end
|
45
38
|
end
|
@@ -5,7 +5,7 @@ module Fog
|
|
5
5
|
module Storage
|
6
6
|
class Brightbox
|
7
7
|
class Directory < Fog::Model
|
8
|
-
identity
|
8
|
+
identity :key, :aliases => "name"
|
9
9
|
|
10
10
|
attribute :bytes, :aliases => "X-Container-Bytes-Used"
|
11
11
|
attribute :count, :aliases => "X-Container-Object-Count"
|
@@ -29,20 +29,18 @@ module Fog
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
@public = new_public
|
34
|
-
end
|
32
|
+
attr_writer :public
|
35
33
|
|
36
34
|
def public_url
|
37
|
-
#raise NotImplementedError
|
35
|
+
# raise NotImplementedError
|
38
36
|
""
|
39
37
|
end
|
40
38
|
|
41
39
|
def save
|
42
40
|
requires :key
|
43
41
|
options = {
|
44
|
-
|
45
|
-
|
42
|
+
"read_permissions" => read_permissions,
|
43
|
+
"write_permissions" => write_permissions
|
46
44
|
}
|
47
45
|
service.put_container(key, options)
|
48
46
|
true
|
@@ -1,42 +1,38 @@
|
|
1
|
-
require
|
1
|
+
require "fog/core/model"
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Storage
|
5
5
|
class Brightbox
|
6
|
-
|
7
6
|
class File < Fog::Model
|
7
|
+
identity :key, :aliases => "name"
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
attribute :
|
12
|
-
attribute :
|
13
|
-
attribute :
|
14
|
-
attribute :
|
15
|
-
attribute :
|
16
|
-
attribute :access_control_allow_origin, :aliases => ['Access-Control-Allow-Origin']
|
17
|
-
attribute :origin, :aliases => ['Origin']
|
9
|
+
attribute :content_length, :aliases => %w(bytes Content-Length), :type => :integer
|
10
|
+
attribute :content_type, :aliases => %w(content_type Content-Type)
|
11
|
+
attribute :content_disposition, :aliases => %w(content_disposition Content-Disposition)
|
12
|
+
attribute :etag, :aliases => %w(hash Etag)
|
13
|
+
attribute :last_modified, :aliases => %w(last_modified Last-Modified), :type => :time
|
14
|
+
attribute :access_control_allow_origin, :aliases => ["Access-Control-Allow-Origin"]
|
15
|
+
attribute :origin, :aliases => ["Origin"]
|
18
16
|
|
19
17
|
def body
|
20
18
|
attributes[:body] ||= if last_modified
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
collection.get(identity).body
|
20
|
+
else
|
21
|
+
""
|
22
|
+
end
|
25
23
|
end
|
26
24
|
|
27
25
|
def body=(new_body)
|
28
26
|
attributes[:body] = new_body
|
29
27
|
end
|
30
28
|
|
31
|
-
|
32
|
-
@directory
|
33
|
-
end
|
29
|
+
attr_reader :directory
|
34
30
|
|
35
|
-
def copy(target_directory_key, target_file_key, options={})
|
31
|
+
def copy(target_directory_key, target_file_key, options = {})
|
36
32
|
requires :directory, :key
|
37
|
-
options[
|
38
|
-
options[
|
39
|
-
options[
|
33
|
+
options["Content-Type"] ||= content_type if content_type
|
34
|
+
options["Access-Control-Allow-Origin"] ||= access_control_allow_origin if access_control_allow_origin
|
35
|
+
options["Origin"] ||= origin if origin
|
40
36
|
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
41
37
|
target_directory = service.directories.new(:key => target_directory_key)
|
42
38
|
target_directory.files.get(target_file_key)
|
@@ -55,8 +51,8 @@ module Fog
|
|
55
51
|
def owner=(new_owner)
|
56
52
|
if new_owner
|
57
53
|
attributes[:owner] = {
|
58
|
-
:display_name => new_owner[
|
59
|
-
:id => new_owner[
|
54
|
+
:display_name => new_owner["DisplayName"],
|
55
|
+
:id => new_owner["ID"]
|
60
56
|
}
|
61
57
|
end
|
62
58
|
end
|
@@ -75,21 +71,20 @@ module Fog
|
|
75
71
|
#
|
76
72
|
def url(expires, options = {})
|
77
73
|
requires :directory, :key
|
78
|
-
|
74
|
+
service.create_temp_url(directory.key, key, expires, "GET", options)
|
79
75
|
end
|
80
76
|
|
81
77
|
def public_url
|
82
78
|
requires :key
|
83
|
-
|
79
|
+
collection.get_url(key)
|
84
80
|
end
|
85
81
|
|
86
|
-
|
87
82
|
def save(options = {})
|
88
83
|
requires :body, :directory, :key
|
89
|
-
options[
|
90
|
-
options[
|
91
|
-
options[
|
92
|
-
options[
|
84
|
+
options["Content-Type"] = content_type if content_type
|
85
|
+
options["Content-Disposition"] = content_disposition if content_disposition
|
86
|
+
options["Access-Control-Allow-Origin"] = access_control_allow_origin if access_control_allow_origin
|
87
|
+
options["Origin"] = origin if origin
|
93
88
|
options.merge!(metadata_to_headers)
|
94
89
|
|
95
90
|
data = service.put_object(directory.key, key, body, options)
|
@@ -103,46 +98,44 @@ module Fog
|
|
103
98
|
|
104
99
|
private
|
105
100
|
|
106
|
-
|
107
|
-
@directory = new_directory
|
108
|
-
end
|
101
|
+
attr_writer :directory
|
109
102
|
|
110
103
|
def refresh_metadata
|
111
|
-
metadata.reject! {|
|
104
|
+
metadata.reject! { |_k, v| v.nil? }
|
112
105
|
end
|
113
106
|
|
114
107
|
def headers_to_metadata
|
115
108
|
key_map = key_mapping
|
116
|
-
Hash[metadata_attributes.map {|k, v| [key_map[k], v] }]
|
109
|
+
Hash[metadata_attributes.map { |k, v| [key_map[k], v] }]
|
117
110
|
end
|
118
111
|
|
119
112
|
def key_mapping
|
120
113
|
key_map = metadata_attributes
|
121
|
-
key_map.each_pair {|k,
|
114
|
+
key_map.each_pair { |k, _v| key_map[k] = header_to_key(k) }
|
122
115
|
end
|
123
116
|
|
124
117
|
def header_to_key(opt)
|
125
|
-
opt.gsub(metadata_prefix,
|
118
|
+
opt.gsub(metadata_prefix, "").split("-").map { |k| k[0, 1].downcase + k[1..-1] }.join("_").to_sym
|
126
119
|
end
|
127
120
|
|
128
121
|
def metadata_to_headers
|
129
122
|
header_map = header_mapping
|
130
|
-
Hash[metadata.map {|k, v| [header_map[k], v] }]
|
123
|
+
Hash[metadata.map { |k, v| [header_map[k], v] }]
|
131
124
|
end
|
132
125
|
|
133
126
|
def header_mapping
|
134
127
|
header_map = metadata.dup
|
135
|
-
header_map.each_pair {|k,
|
128
|
+
header_map.each_pair { |k, _v| header_map[k] = key_to_header(k) }
|
136
129
|
end
|
137
130
|
|
138
131
|
def key_to_header(key)
|
139
|
-
metadata_prefix + key.to_s.split(/[-_]/).map(&:capitalize).join(
|
132
|
+
metadata_prefix + key.to_s.split(/[-_]/).map(&:capitalize).join("-")
|
140
133
|
end
|
141
134
|
|
142
135
|
def metadata_attributes
|
143
136
|
if last_modified
|
144
|
-
headers = service.head_object(directory.key,
|
145
|
-
headers.reject! {|k,
|
137
|
+
headers = service.head_object(directory.key, key).headers
|
138
|
+
headers.reject! { |k, _v| !metadata_attribute?(k) }
|
146
139
|
else
|
147
140
|
{}
|
148
141
|
end
|
@@ -157,10 +150,9 @@ module Fog
|
|
157
150
|
end
|
158
151
|
|
159
152
|
def update_attributes_from(data)
|
160
|
-
merge_attributes(data.headers.reject {|key,
|
153
|
+
merge_attributes(data.headers.reject { |key, _value| %w(Content-Length Content-Type).include?(key) })
|
161
154
|
end
|
162
155
|
end
|
163
|
-
|
164
156
|
end
|
165
157
|
end
|
166
158
|
end
|