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.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +20 -0
  4. data/.rubocop_todo.yml +81 -0
  5. data/CHANGELOG.md +17 -0
  6. data/README.md +6 -0
  7. data/fog-brightbox.gemspec +10 -9
  8. data/gemfiles/Gemfile.1.8.7 +1 -0
  9. data/lib/fog/brightbox.rb +2 -2
  10. data/lib/fog/brightbox/compute.rb +47 -48
  11. data/lib/fog/brightbox/compute/resource_locking.rb +26 -20
  12. data/lib/fog/brightbox/compute/shared.rb +2 -7
  13. data/lib/fog/brightbox/config.rb +12 -15
  14. data/lib/fog/brightbox/core.rb +5 -5
  15. data/lib/fog/brightbox/link_helper.rb +33 -0
  16. data/lib/fog/brightbox/models/compute/account.rb +0 -1
  17. data/lib/fog/brightbox/models/compute/accounts.rb +2 -6
  18. data/lib/fog/brightbox/models/compute/api_client.rb +2 -2
  19. data/lib/fog/brightbox/models/compute/application.rb +2 -2
  20. data/lib/fog/brightbox/models/compute/applications.rb +2 -6
  21. data/lib/fog/brightbox/models/compute/cloud_ip.rb +0 -4
  22. data/lib/fog/brightbox/models/compute/cloud_ips.rb +2 -6
  23. data/lib/fog/brightbox/models/compute/collaboration.rb +4 -4
  24. data/lib/fog/brightbox/models/compute/database_server.rb +11 -4
  25. data/lib/fog/brightbox/models/compute/database_servers.rb +2 -6
  26. data/lib/fog/brightbox/models/compute/database_snapshot.rb +1 -1
  27. data/lib/fog/brightbox/models/compute/database_snapshots.rb +2 -2
  28. data/lib/fog/brightbox/models/compute/database_types.rb +2 -4
  29. data/lib/fog/brightbox/models/compute/event.rb +0 -2
  30. data/lib/fog/brightbox/models/compute/events.rb +2 -4
  31. data/lib/fog/brightbox/models/compute/firewall_policies.rb +2 -6
  32. data/lib/fog/brightbox/models/compute/firewall_policy.rb +2 -3
  33. data/lib/fog/brightbox/models/compute/firewall_rule.rb +2 -3
  34. data/lib/fog/brightbox/models/compute/firewall_rules.rb +2 -6
  35. data/lib/fog/brightbox/models/compute/flavor.rb +0 -1
  36. data/lib/fog/brightbox/models/compute/flavors.rb +2 -6
  37. data/lib/fog/brightbox/models/compute/image.rb +3 -3
  38. data/lib/fog/brightbox/models/compute/images.rb +2 -6
  39. data/lib/fog/brightbox/models/compute/load_balancer.rb +5 -5
  40. data/lib/fog/brightbox/models/compute/load_balancers.rb +2 -6
  41. data/lib/fog/brightbox/models/compute/server.rb +15 -9
  42. data/lib/fog/brightbox/models/compute/server_group.rb +1 -1
  43. data/lib/fog/brightbox/models/compute/server_groups.rb +2 -6
  44. data/lib/fog/brightbox/models/compute/servers.rb +2 -6
  45. data/lib/fog/brightbox/models/compute/user.rb +0 -1
  46. data/lib/fog/brightbox/models/compute/user_collaboration.rb +2 -3
  47. data/lib/fog/brightbox/models/compute/users.rb +2 -5
  48. data/lib/fog/brightbox/models/compute/zones.rb +2 -6
  49. data/lib/fog/brightbox/models/storage/directories.rb +6 -13
  50. data/lib/fog/brightbox/models/storage/directory.rb +5 -7
  51. data/lib/fog/brightbox/models/storage/file.rb +37 -45
  52. data/lib/fog/brightbox/models/storage/files.rb +21 -25
  53. data/lib/fog/brightbox/oauth2.rb +136 -137
  54. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +0 -1
  55. data/lib/fog/brightbox/requests/compute/activate_console_server.rb +0 -1
  56. data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +0 -1
  57. data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +0 -1
  58. data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +0 -1
  59. data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +0 -1
  60. data/lib/fog/brightbox/requests/compute/create_api_client.rb +0 -1
  61. data/lib/fog/brightbox/requests/compute/create_application.rb +0 -1
  62. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +0 -1
  63. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +0 -1
  64. data/lib/fog/brightbox/requests/compute/create_database_server.rb +0 -1
  65. data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +0 -1
  66. data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +0 -1
  67. data/lib/fog/brightbox/requests/compute/create_image.rb +0 -1
  68. data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +0 -1
  69. data/lib/fog/brightbox/requests/compute/create_server.rb +0 -1
  70. data/lib/fog/brightbox/requests/compute/create_server_group.rb +0 -1
  71. data/lib/fog/brightbox/requests/compute/get_account.rb +0 -1
  72. data/lib/fog/brightbox/requests/compute/get_api_client.rb +0 -1
  73. data/lib/fog/brightbox/requests/compute/get_application.rb +0 -1
  74. data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +0 -2
  75. data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +0 -1
  76. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +0 -1
  77. data/lib/fog/brightbox/requests/compute/get_database_server.rb +0 -1
  78. data/lib/fog/brightbox/requests/compute/get_database_snapshot.rb +0 -1
  79. data/lib/fog/brightbox/requests/compute/get_database_type.rb +0 -1
  80. data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +0 -1
  81. data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +0 -1
  82. data/lib/fog/brightbox/requests/compute/get_image.rb +0 -1
  83. data/lib/fog/brightbox/requests/compute/get_interface.rb +0 -1
  84. data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +0 -1
  85. data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +0 -1
  86. data/lib/fog/brightbox/requests/compute/get_server.rb +0 -1
  87. data/lib/fog/brightbox/requests/compute/get_server_group.rb +0 -1
  88. data/lib/fog/brightbox/requests/compute/get_server_type.rb +0 -1
  89. data/lib/fog/brightbox/requests/compute/get_user.rb +0 -1
  90. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +0 -1
  91. data/lib/fog/brightbox/requests/compute/get_zone.rb +0 -1
  92. data/lib/fog/brightbox/requests/compute/list_accounts.rb +0 -1
  93. data/lib/fog/brightbox/requests/compute/list_api_clients.rb +0 -1
  94. data/lib/fog/brightbox/requests/compute/list_applications.rb +0 -1
  95. data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +0 -1
  96. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +0 -1
  97. data/lib/fog/brightbox/requests/compute/list_database_servers.rb +0 -1
  98. data/lib/fog/brightbox/requests/compute/list_database_snapshots.rb +0 -1
  99. data/lib/fog/brightbox/requests/compute/list_database_types.rb +0 -1
  100. data/lib/fog/brightbox/requests/compute/list_events.rb +0 -1
  101. data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +0 -1
  102. data/lib/fog/brightbox/requests/compute/list_images.rb +0 -1
  103. data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +0 -1
  104. data/lib/fog/brightbox/requests/compute/list_server_groups.rb +0 -1
  105. data/lib/fog/brightbox/requests/compute/list_server_types.rb +0 -1
  106. data/lib/fog/brightbox/requests/compute/list_servers.rb +0 -1
  107. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +0 -1
  108. data/lib/fog/brightbox/requests/compute/list_users.rb +0 -1
  109. data/lib/fog/brightbox/requests/compute/list_zones.rb +0 -1
  110. data/lib/fog/brightbox/requests/compute/lock_resource_database_server.rb +0 -1
  111. data/lib/fog/brightbox/requests/compute/lock_resource_database_snapshot.rb +0 -1
  112. data/lib/fog/brightbox/requests/compute/lock_resource_image.rb +0 -1
  113. data/lib/fog/brightbox/requests/compute/lock_resource_load_balancer.rb +0 -1
  114. data/lib/fog/brightbox/requests/compute/lock_resource_server.rb +0 -1
  115. data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +0 -1
  116. data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +0 -1
  117. data/lib/fog/brightbox/requests/compute/reboot_server.rb +0 -1
  118. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +0 -1
  119. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +0 -1
  120. data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +0 -1
  121. data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +0 -1
  122. data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +0 -1
  123. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +0 -1
  124. data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +0 -2
  125. data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +0 -1
  126. data/lib/fog/brightbox/requests/compute/reset_password_database_server.rb +0 -1
  127. data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +0 -1
  128. data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +0 -1
  129. data/lib/fog/brightbox/requests/compute/reset_server.rb +0 -1
  130. data/lib/fog/brightbox/requests/compute/shutdown_server.rb +0 -1
  131. data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +19 -3
  132. data/lib/fog/brightbox/requests/compute/snapshot_server.rb +19 -3
  133. data/lib/fog/brightbox/requests/compute/start_server.rb +0 -1
  134. data/lib/fog/brightbox/requests/compute/stop_server.rb +0 -1
  135. data/lib/fog/brightbox/requests/compute/unlock_resource_database_server.rb +0 -1
  136. data/lib/fog/brightbox/requests/compute/unlock_resource_database_snapshot.rb +0 -1
  137. data/lib/fog/brightbox/requests/compute/unlock_resource_image.rb +0 -1
  138. data/lib/fog/brightbox/requests/compute/unlock_resource_load_balancer.rb +0 -1
  139. data/lib/fog/brightbox/requests/compute/unlock_resource_server.rb +0 -1
  140. data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +0 -1
  141. data/lib/fog/brightbox/requests/compute/update_account.rb +0 -1
  142. data/lib/fog/brightbox/requests/compute/update_api_client.rb +0 -1
  143. data/lib/fog/brightbox/requests/compute/update_application.rb +0 -1
  144. data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +0 -1
  145. data/lib/fog/brightbox/requests/compute/update_database_server.rb +0 -1
  146. data/lib/fog/brightbox/requests/compute/update_database_snapshot.rb +0 -1
  147. data/lib/fog/brightbox/requests/compute/update_firewall_policy.rb +0 -1
  148. data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +0 -1
  149. data/lib/fog/brightbox/requests/compute/update_image.rb +0 -1
  150. data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +0 -1
  151. data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +0 -1
  152. data/lib/fog/brightbox/requests/compute/update_server.rb +0 -1
  153. data/lib/fog/brightbox/requests/compute/update_server_group.rb +0 -1
  154. data/lib/fog/brightbox/requests/compute/update_user.rb +0 -1
  155. data/lib/fog/brightbox/requests/storage/copy_object.rb +8 -10
  156. data/lib/fog/brightbox/requests/storage/delete_container.rb +1 -3
  157. data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -9
  158. data/lib/fog/brightbox/requests/storage/delete_object.rb +1 -3
  159. data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +7 -9
  160. data/lib/fog/brightbox/requests/storage/get_container.rb +3 -5
  161. data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -6
  162. data/lib/fog/brightbox/requests/storage/get_object.rb +1 -3
  163. data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +5 -10
  164. data/lib/fog/brightbox/requests/storage/head_container.rb +2 -4
  165. data/lib/fog/brightbox/requests/storage/head_containers.rb +3 -5
  166. data/lib/fog/brightbox/requests/storage/head_object.rb +4 -6
  167. data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +2 -6
  168. data/lib/fog/brightbox/requests/storage/put_container.rb +3 -5
  169. data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +2 -4
  170. data/lib/fog/brightbox/requests/storage/put_object.rb +1 -2
  171. data/lib/fog/brightbox/requests/storage/put_object_manifest.rb +0 -2
  172. data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +2 -4
  173. data/lib/fog/brightbox/storage.rb +26 -29
  174. data/lib/fog/brightbox/storage/connection.rb +10 -10
  175. data/lib/fog/brightbox/version.rb +1 -1
  176. data/spec/fog/brightbox/link_helper_spec.rb +18 -0
  177. data/spec/fog/brightbox/storage/authentication_request_spec.rb +16 -16
  178. data/spec/fog/brightbox/storage/connection_spec.rb +12 -12
  179. data/spec/fog/compute/brightbox/database_server_spec.rb +31 -0
  180. data/spec/fog/compute/brightbox/server_spec.rb +31 -0
  181. data/spec/fog/storage/brightbox_spec.rb +3 -3
  182. data/spec/spec_helper.rb +1 -1
  183. metadata +28 -10
  184. data/spec/model_helper.rb +0 -22
@@ -1,12 +1,10 @@
1
- require 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/flavor'
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('Resaving an existing object may create a duplicate') if persisted?
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 { |k, v| v.nil? || v == "" }
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 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/image'
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 == 'active'
45
+ status == "active"
46
46
  end
47
47
 
48
48
  def save
49
- raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
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 { |k, v| v.nil? || v == "" }
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
- !! attributes[:certificate_enable_ssl3]
106
+ !!attributes[:certificate_enable_ssl3]
107
107
  end
108
108
 
109
109
  private
@@ -1,12 +1,10 @@
1
- require 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/load_balancer'
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 :id
11
+ identity :id
12
12
  attribute :resource_type
13
13
  attribute :url
14
14
 
15
15
  attribute :name
16
- attribute :state, :aliases => 'status'
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['id']
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['id']
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('Resaving an existing object may create a duplicate') if persisted?
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 { |k, v| v.nil? || v == "" }
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
 
@@ -22,7 +22,7 @@ module Fog
22
22
  options = {
23
23
  :name => name,
24
24
  :description => description
25
- }.delete_if { |k, v| v.nil? || v == "" }
25
+ }.delete_if { |_k, v| v.nil? || v == "" }
26
26
  data = service.create_server_group(options)
27
27
  merge_attributes(data)
28
28
  true
@@ -1,12 +1,10 @@
1
- require 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/server_group'
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 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/server'
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,6 @@ module Fog
4
4
  module Compute
5
5
  class Brightbox
6
6
  class User < Fog::Brightbox::Model
7
-
8
7
  identity :id
9
8
  attribute :resource_type
10
9
  attribute :url
@@ -4,7 +4,7 @@ module Fog
4
4
  module Compute
5
5
  class Brightbox
6
6
  class UserCollaboration < Fog::Brightbox::Model
7
- identity :id
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['id'] || account[:id]
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 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/user'
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 'fog/core/collection'
2
- require 'fog/brightbox/models/compute/zone'
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 'fog/core/collection'
2
- require 'fog/brightbox/models/storage/directory'
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
- for key, value in data.headers
26
- if HEADER_ATTRIBUTES.include?(key)
27
- directory.merge_attributes(key => value)
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 :key, :aliases => "name"
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
- def public=(new_public)
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
- 'read_permissions' => read_permissions,
45
- 'write_permissions' => write_permissions
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 'fog/core/model'
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
- identity :key, :aliases => 'name'
10
-
11
- attribute :content_length, :aliases => ['bytes', 'Content-Length'], :type => :integer
12
- attribute :content_type, :aliases => ['content_type', 'Content-Type']
13
- attribute :content_disposition, :aliases => ['content_disposition', 'Content-Disposition']
14
- attribute :etag, :aliases => ['hash', 'Etag']
15
- attribute :last_modified, :aliases => ['last_modified', 'Last-Modified'], :type => :time
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
- collection.get(identity).body
22
- else
23
- ''
24
- end
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
- def directory
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['Content-Type'] ||= content_type if content_type
38
- options['Access-Control-Allow-Origin'] ||= access_control_allow_origin if access_control_allow_origin
39
- options['Origin'] ||= origin if origin
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['DisplayName'],
59
- :id => new_owner['ID']
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
- self.service.create_temp_url(directory.key, key, expires, "GET", options)
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
- self.collection.get_url(self.key)
79
+ collection.get_url(key)
84
80
  end
85
81
 
86
-
87
82
  def save(options = {})
88
83
  requires :body, :directory, :key
89
- options['Content-Type'] = content_type if content_type
90
- options['Content-Disposition'] = content_disposition if content_disposition
91
- options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
92
- options['Origin'] = origin if origin
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
- def directory=(new_directory)
107
- @directory = new_directory
108
- end
101
+ attr_writer :directory
109
102
 
110
103
  def refresh_metadata
111
- metadata.reject! {|k, v| v.nil? }
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, v| key_map[k] = header_to_key(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, '').split('-').map {|k| k[0, 1].downcase + k[1..-1]}.join('_').to_sym
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, v| header_map[k] = key_to_header(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, self.key).headers
145
- headers.reject! {|k, v| !metadata_attribute?(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, value| ['Content-Length', 'Content-Type'].include?(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