fog-brightbox 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -10
- data/CHANGELOG.md +17 -0
- data/Rakefile +1 -1
- data/fog-brightbox.gemspec +5 -3
- data/lib/fog/brightbox/compute/shared.rb +11 -10
- data/lib/fog/brightbox/compute.rb +20 -21
- data/lib/fog/brightbox/config.rb +6 -9
- data/lib/fog/brightbox/models/compute/api_client.rb +4 -4
- data/lib/fog/brightbox/models/compute/application.rb +2 -2
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +11 -11
- data/lib/fog/brightbox/models/compute/collaboration.rb +3 -3
- data/lib/fog/brightbox/models/compute/collaborations.rb +1 -1
- data/lib/fog/brightbox/models/compute/config_map.rb +2 -3
- data/lib/fog/brightbox/models/compute/database_server.rb +17 -5
- data/lib/fog/brightbox/models/compute/database_snapshot.rb +2 -2
- data/lib/fog/brightbox/models/compute/firewall_policy.rb +6 -6
- data/lib/fog/brightbox/models/compute/firewall_rule.rb +9 -9
- data/lib/fog/brightbox/models/compute/image.rb +9 -9
- data/lib/fog/brightbox/models/compute/load_balancer.rb +12 -12
- data/lib/fog/brightbox/models/compute/server.rb +21 -23
- data/lib/fog/brightbox/models/compute/server_group.rb +6 -6
- data/lib/fog/brightbox/models/compute/user.rb +3 -3
- data/lib/fog/brightbox/models/compute/volume.rb +16 -16
- data/lib/fog/brightbox/models/storage/directories.rb +2 -2
- data/lib/fog/brightbox/models/storage/directory.rb +7 -7
- data/lib/fog/brightbox/models/storage/file.rb +13 -13
- data/lib/fog/brightbox/models/storage/files.rb +9 -13
- data/lib/fog/brightbox/oauth2.rb +11 -11
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +1 -1
- data/lib/fog/brightbox/requests/compute/reset_database_server.rb +21 -0
- data/lib/fog/brightbox/requests/compute/resize_database_server.rb +25 -0
- data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +1 -1
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +1 -1
- data/lib/fog/brightbox/requests/storage/copy_object.rb +5 -5
- data/lib/fog/brightbox/requests/storage/delete_container.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -7
- data/lib/fog/brightbox/requests/storage/delete_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +6 -6
- data/lib/fog/brightbox/requests/storage/get_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_object.rb +4 -6
- data/lib/fog/brightbox/requests/storage/get_object_http_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/head_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +3 -3
- data/lib/fog/brightbox/requests/storage/put_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_object.rb +7 -7
- data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +6 -6
- data/lib/fog/brightbox/storage/authentication_request.rb +4 -4
- data/lib/fog/brightbox/storage/connection.rb +2 -2
- data/lib/fog/brightbox/storage.rb +13 -14
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/compute/config_spec.rb +4 -4
- data/spec/fog/brightbox/compute/get_access_token_spec.rb +28 -28
- data/spec/fog/brightbox/compute/wrapped_request_spec.rb +23 -23
- data/spec/fog/brightbox/config_spec.rb +23 -23
- data/spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/credential_set_spec.rb +5 -5
- data/spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb +3 -3
- data/spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb +4 -4
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +34 -34
- data/spec/fog/brightbox/storage/config_spec.rb +4 -4
- data/spec/fog/brightbox/storage/connection_errors_spec.rb +6 -6
- data/spec/fog/brightbox/storage/connection_spec.rb +37 -37
- data/spec/fog/brightbox/storage/directory_spec.rb +6 -6
- data/spec/fog/brightbox/storage/files_spec.rb +5 -5
- data/spec/fog/brightbox/storage_spec.rb +5 -5
- data/spec/fog/compute/brightbox/database_server_spec.rb +19 -19
- data/spec/fog/compute/brightbox/image_selector_spec.rb +18 -18
- data/spec/fog/compute/brightbox/load_balancer_spec.rb +5 -5
- data/spec/fog/compute/brightbox/server_spec.rb +44 -44
- data/spec/fog/compute/brightbox/volume_spec.rb +68 -69
- data/spec/fog/compute/brightbox_spec.rb +10 -10
- data/spec/fog/storage/brightbox_spec.rb +83 -83
- data/spec/model_setup.rb +9 -9
- data/spec/stock_storage_responses.rb +9 -9
- data/spec/supports_resource_locking.rb +6 -6
- data/tests/brightbox/compute/schema.rb +74 -74
- data/tests/brightbox/compute_tests.rb +14 -14
- data/tests/brightbox/models/compute/server_tests.rb +0 -1
- data/tests/brightbox/requests/compute/account_tests.rb +9 -9
- data/tests/brightbox/requests/compute/api_client_tests.rb +9 -9
- data/tests/brightbox/requests/compute/application_test.rb +8 -8
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +11 -13
- data/tests/brightbox/requests/compute/collaboration_tests.rb +1 -1
- data/tests/brightbox/requests/compute/database_server_tests.rb +7 -7
- data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +5 -5
- data/tests/brightbox/requests/compute/database_type_tests.rb +1 -1
- data/tests/brightbox/requests/compute/firewall_policy_tests.rb +7 -7
- data/tests/brightbox/requests/compute/firewall_rule_tests.rb +8 -10
- data/tests/brightbox/requests/compute/helper.rb +1 -1
- data/tests/brightbox/requests/compute/image_tests.rb +2 -2
- data/tests/brightbox/requests/compute/interface_tests.rb +1 -1
- data/tests/brightbox/requests/compute/load_balancer_tests.rb +23 -23
- data/tests/brightbox/requests/compute/server_group_tests.rb +16 -18
- data/tests/brightbox/requests/compute/server_tests.rb +12 -12
- data/tests/brightbox/requests/compute/server_type_tests.rb +2 -2
- data/tests/brightbox/requests/compute/user_tests.rb +4 -4
- data/tests/brightbox/requests/compute/volume_tests.rb +5 -5
- data/tests/brightbox/requests/compute/zone_tests.rb +2 -2
- data/tests/helper.rb +1 -1
- data/tests/helpers/collection_helper.rb +16 -23
- data/tests/helpers/compute/server_helper.rb +4 -6
- data/tests/helpers/formats_helper.rb +5 -5
- data/tests/helpers/formats_helper_tests.rb +16 -16
- data/tests/helpers/mock_helper.rb +84 -86
- data/tests/helpers/model_helper.rb +1 -3
- data/tests/helpers/schema_validator_tests.rb +14 -14
- metadata +17 -2
- data/.rubocop_todo.yml +0 -81
@@ -54,16 +54,16 @@ module Fog
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def zone_id
|
57
|
-
if
|
58
|
-
|
57
|
+
if attributes[:zone_id]
|
58
|
+
attributes[:zone_id]
|
59
59
|
elsif zone
|
60
60
|
zone[:id] || zone["id"]
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
def flavor_id
|
65
|
-
if
|
66
|
-
|
65
|
+
if attributes[:flavor_id]
|
66
|
+
attributes[:flavor_id]
|
67
67
|
elsif server_type
|
68
68
|
server_type[:id] || server_type["id"]
|
69
69
|
end
|
@@ -79,7 +79,7 @@ module Fog
|
|
79
79
|
|
80
80
|
def snapshot(return_snapshot = false)
|
81
81
|
requires :identity
|
82
|
-
response, snapshot_id = service.snapshot_server(identity, :
|
82
|
+
response, snapshot_id = service.snapshot_server(identity, return_link: return_snapshot)
|
83
83
|
|
84
84
|
if return_snapshot
|
85
85
|
service.images.get(snapshot_id)
|
@@ -184,32 +184,30 @@ module Fog
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def save
|
187
|
-
raise Fog::Errors::Error
|
187
|
+
raise Fog::Errors::Error, "Resaving an existing object may create a duplicate" if persisted?
|
188
188
|
requires :image_id
|
189
189
|
options = {
|
190
|
-
:
|
191
|
-
:
|
192
|
-
:
|
193
|
-
:
|
190
|
+
name: name,
|
191
|
+
zone: zone_id,
|
192
|
+
user_data: user_data,
|
193
|
+
server_groups: server_groups
|
194
194
|
}.delete_if { |_k, v| v.nil? || v == "" }
|
195
195
|
|
196
|
-
options
|
197
|
-
options
|
198
|
-
options
|
196
|
+
options[:server_type] = flavor_id unless flavor_id.nil? || flavor_id == ""
|
197
|
+
options[:cloud_ip] = cloud_ip unless cloud_ip.nil? || cloud_ip == ""
|
198
|
+
options[:disk_encrypted] = disk_encrypted if disk_encrypted
|
199
199
|
|
200
200
|
if volume_id
|
201
|
-
options
|
201
|
+
options[:volumes] = [{ volume: volume_id }]
|
202
202
|
elsif volume_size
|
203
|
-
options
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
]
|
210
|
-
)
|
203
|
+
options[:volumes] = [
|
204
|
+
{
|
205
|
+
image: image_id,
|
206
|
+
size: volume_size
|
207
|
+
}
|
208
|
+
]
|
211
209
|
else
|
212
|
-
options
|
210
|
+
options[:image] = image_id
|
213
211
|
end
|
214
212
|
|
215
213
|
data = service.create_server(options)
|
@@ -26,8 +26,8 @@ module Fog
|
|
26
26
|
|
27
27
|
def save
|
28
28
|
options = {
|
29
|
-
:
|
30
|
-
:
|
29
|
+
name: name,
|
30
|
+
description: description
|
31
31
|
}.delete_if { |_k, v| v.nil? || v == "" }
|
32
32
|
data = service.create_server_group(options)
|
33
33
|
merge_attributes(data)
|
@@ -48,7 +48,7 @@ module Fog
|
|
48
48
|
def add_servers(identifiers)
|
49
49
|
requires :identity
|
50
50
|
options = {
|
51
|
-
:
|
51
|
+
servers: server_references(identifiers)
|
52
52
|
}
|
53
53
|
data = service.add_servers_server_group identity, options
|
54
54
|
merge_attributes data
|
@@ -61,7 +61,7 @@ module Fog
|
|
61
61
|
def remove_servers(identifiers)
|
62
62
|
requires :identity
|
63
63
|
options = {
|
64
|
-
:
|
64
|
+
servers: server_references(identifiers)
|
65
65
|
}
|
66
66
|
data = service.remove_servers_server_group identity, options
|
67
67
|
merge_attributes data
|
@@ -75,8 +75,8 @@ module Fog
|
|
75
75
|
def move_servers(identifiers, destination_group_id)
|
76
76
|
requires :identity
|
77
77
|
options = {
|
78
|
-
:
|
79
|
-
:
|
78
|
+
servers: server_references(identifiers),
|
79
|
+
destination: destination_group_id
|
80
80
|
}
|
81
81
|
data = service.move_servers_server_group identity, options
|
82
82
|
merge_attributes data
|
@@ -27,9 +27,9 @@ module Fog
|
|
27
27
|
requires :identity
|
28
28
|
|
29
29
|
options = {
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
30
|
+
email_address: email_address,
|
31
|
+
ssh_key: ssh_key,
|
32
|
+
name: name
|
33
33
|
}
|
34
34
|
|
35
35
|
data = service.update_user(identity, options)
|
@@ -102,7 +102,7 @@ module Fog
|
|
102
102
|
|
103
103
|
# The API requires the old "from" size to avoid acting on stale data
|
104
104
|
# We can merge this and if the API rejects the request, the model was out of sync
|
105
|
-
options
|
105
|
+
options[:from] = size
|
106
106
|
|
107
107
|
data = service.resize_volume(identity, options)
|
108
108
|
merge_attributes(data)
|
@@ -112,29 +112,29 @@ module Fog
|
|
112
112
|
def save
|
113
113
|
if persisted?
|
114
114
|
options = {
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
115
|
+
delete_with_server: delete_with_server,
|
116
|
+
description: description,
|
117
|
+
name: name,
|
118
|
+
serial: serial
|
119
119
|
}.delete_if { |_k, v| v.nil? || v == "" }
|
120
120
|
|
121
121
|
data = service.update_volume(identity, options)
|
122
122
|
else
|
123
|
-
raise Fog::Errors::Error
|
124
|
-
raise Fog::Errors::Error
|
123
|
+
raise Fog::Errors::Error, "'image_id' and 'filesystem_type' are mutually exclusive" if image_id && filesystem_type
|
124
|
+
raise Fog::Errors::Error, "'image_id' or 'filesystem_type' is required" unless image_id || filesystem_type
|
125
125
|
|
126
126
|
options = {
|
127
|
-
:
|
128
|
-
:
|
129
|
-
:
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
127
|
+
delete_with_server: delete_with_server,
|
128
|
+
description: description,
|
129
|
+
encrypted: encrypted,
|
130
|
+
filesystem_label: filesystem_label,
|
131
|
+
filesystem_type: filesystem_type,
|
132
|
+
name: name,
|
133
|
+
serial: serial,
|
134
|
+
size: size
|
135
135
|
}.delete_if { |_k, v| v.nil? || v == "" }
|
136
136
|
|
137
|
-
options
|
137
|
+
options[:image] = image_id unless image_id.nil? || image_id == ""
|
138
138
|
|
139
139
|
data = service.create_volume(options)
|
140
140
|
end
|
@@ -6,7 +6,7 @@ module Fog
|
|
6
6
|
class Directories < Fog::Collection
|
7
7
|
model Fog::Brightbox::Storage::Directory
|
8
8
|
|
9
|
-
HEADER_ATTRIBUTES = %w
|
9
|
+
HEADER_ATTRIBUTES = %w[X-Container-Bytes-Used X-Container-Object-Count X-Container-Read X-Container-Write].freeze
|
10
10
|
|
11
11
|
def all
|
12
12
|
data = service.get_containers.body
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
|
16
16
|
def get(key, options = {})
|
17
17
|
data = service.get_container(key, options)
|
18
|
-
directory = new(:
|
18
|
+
directory = new(key: key)
|
19
19
|
data.headers.each do |header, value|
|
20
20
|
if HEADER_ATTRIBUTES.include?(header)
|
21
21
|
directory.merge_attributes(header => value)
|
@@ -4,12 +4,12 @@ module Fog
|
|
4
4
|
module Brightbox
|
5
5
|
class Storage
|
6
6
|
class Directory < Fog::Model
|
7
|
-
identity :key, :
|
7
|
+
identity :key, aliases: "name"
|
8
8
|
|
9
|
-
attribute :bytes, :
|
10
|
-
attribute :count, :
|
11
|
-
attribute :read_permissions, :
|
12
|
-
attribute :write_permissions, :
|
9
|
+
attribute :bytes, aliases: "X-Container-Bytes-Used"
|
10
|
+
attribute :count, aliases: "X-Container-Object-Count"
|
11
|
+
attribute :read_permissions, aliases: "X-Container-Read"
|
12
|
+
attribute :write_permissions, aliases: "X-Container-Write"
|
13
13
|
|
14
14
|
def destroy
|
15
15
|
requires :key
|
@@ -22,8 +22,8 @@ module Fog
|
|
22
22
|
def files
|
23
23
|
@files ||= begin
|
24
24
|
Fog::Brightbox::Storage::Files.new(
|
25
|
-
:
|
26
|
-
:
|
25
|
+
directory: self,
|
26
|
+
service: service
|
27
27
|
)
|
28
28
|
end
|
29
29
|
end
|
@@ -2,15 +2,15 @@ module Fog
|
|
2
2
|
module Brightbox
|
3
3
|
class Storage
|
4
4
|
class File < Fog::Model
|
5
|
-
identity :key,
|
5
|
+
identity :key, aliases: "name"
|
6
6
|
|
7
|
-
attribute :content_length, :
|
8
|
-
attribute :content_type, :
|
9
|
-
attribute :content_disposition, :
|
10
|
-
attribute :etag, :
|
11
|
-
attribute :last_modified, :
|
12
|
-
attribute :access_control_allow_origin, :
|
13
|
-
attribute :origin,
|
7
|
+
attribute :content_length, aliases: %w[bytes Content-Length], type: :integer
|
8
|
+
attribute :content_type, aliases: %w[content_type Content-Type]
|
9
|
+
attribute :content_disposition, aliases: %w[content_disposition Content-Disposition]
|
10
|
+
attribute :etag, aliases: %w[hash Etag]
|
11
|
+
attribute :last_modified, aliases: %w[last_modified Last-Modified], type: :time
|
12
|
+
attribute :access_control_allow_origin, aliases: ["Access-Control-Allow-Origin"]
|
13
|
+
attribute :origin, aliases: ["Origin"]
|
14
14
|
|
15
15
|
def body
|
16
16
|
attributes[:body] ||= if last_modified
|
@@ -32,7 +32,7 @@ module Fog
|
|
32
32
|
options["Access-Control-Allow-Origin"] ||= access_control_allow_origin if access_control_allow_origin
|
33
33
|
options["Origin"] ||= origin if origin
|
34
34
|
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
35
|
-
target_directory = service.directories.new(:
|
35
|
+
target_directory = service.directories.new(key: target_directory_key)
|
36
36
|
target_directory.files.get(target_file_key)
|
37
37
|
end
|
38
38
|
|
@@ -49,8 +49,8 @@ module Fog
|
|
49
49
|
def owner=(new_owner)
|
50
50
|
if new_owner
|
51
51
|
attributes[:owner] = {
|
52
|
-
:
|
53
|
-
:
|
52
|
+
display_name: new_owner["DisplayName"],
|
53
|
+
id: new_owner["ID"]
|
54
54
|
}
|
55
55
|
end
|
56
56
|
end
|
@@ -133,7 +133,7 @@ module Fog
|
|
133
133
|
def metadata_attributes
|
134
134
|
if last_modified
|
135
135
|
headers = service.head_object(directory.key, key).headers
|
136
|
-
headers.
|
136
|
+
headers.select! { |k, _v| metadata_attribute?(k) }
|
137
137
|
else
|
138
138
|
{}
|
139
139
|
end
|
@@ -148,7 +148,7 @@ module Fog
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def update_attributes_from(data)
|
151
|
-
merge_attributes(data.headers.reject { |key, _value| %w
|
151
|
+
merge_attributes(data.headers.reject { |key, _value| %w[Content-Length Content-Type].include?(key) })
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
@@ -25,14 +25,10 @@ module Fog
|
|
25
25
|
directory.key,
|
26
26
|
options
|
27
27
|
)
|
28
|
-
if parent
|
29
|
-
load(parent.files.map { |file| file.attributes })
|
30
|
-
else
|
31
|
-
nil
|
32
|
-
end
|
28
|
+
load(parent.files.map(&:attributes)) if parent
|
33
29
|
end
|
34
30
|
|
35
|
-
|
31
|
+
alias each_file_this_page each
|
36
32
|
def each
|
37
33
|
if !block_given?
|
38
34
|
self
|
@@ -41,7 +37,7 @@ module Fog
|
|
41
37
|
|
42
38
|
subset.each_file_this_page { |f| yield f }
|
43
39
|
while subset.length == (subset.limit || 10_000)
|
44
|
-
subset = subset.all(:
|
40
|
+
subset = subset.all(marker: subset.last.key)
|
45
41
|
subset.each_file_this_page { |f| yield f }
|
46
42
|
end
|
47
43
|
|
@@ -53,9 +49,9 @@ module Fog
|
|
53
49
|
requires :directory
|
54
50
|
data = service.get_object(directory.key, key, &block)
|
55
51
|
file_data = data.headers.merge(
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
body: data.body,
|
53
|
+
key: key
|
54
|
+
)
|
59
55
|
new(file_data)
|
60
56
|
rescue Fog::Brightbox::Storage::NotFound
|
61
57
|
nil
|
@@ -82,8 +78,8 @@ module Fog
|
|
82
78
|
requires :directory
|
83
79
|
data = service.head_object(directory.key, key)
|
84
80
|
file_data = data.headers.merge(
|
85
|
-
|
86
|
-
|
81
|
+
key: key
|
82
|
+
)
|
87
83
|
new(file_data)
|
88
84
|
rescue Fog::Brightbox::Storage::NotFound
|
89
85
|
nil
|
@@ -91,7 +87,7 @@ module Fog
|
|
91
87
|
|
92
88
|
def new(attributes = {})
|
93
89
|
requires :directory
|
94
|
-
super({ :
|
90
|
+
super({ directory: directory }.merge!(attributes))
|
95
91
|
end
|
96
92
|
end
|
97
93
|
end
|
data/lib/fog/brightbox/oauth2.rb
CHANGED
@@ -25,11 +25,11 @@ module Fog
|
|
25
25
|
if two_factor?
|
26
26
|
# When 2FA opt-in is set, we can expect 401 responses as well
|
27
27
|
response = connection.request(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
28
|
+
path: "/token",
|
29
|
+
expects: [200, 401],
|
30
|
+
headers: token_strategy.headers,
|
31
|
+
method: "POST",
|
32
|
+
body: Fog::JSON.encode(token_strategy.authorization_body_data)
|
33
33
|
)
|
34
34
|
|
35
35
|
if response.status == 401 && response.headers[Fog::Brightbox::OAuth2::TWO_FACTOR_HEADER] == "required"
|
@@ -42,11 +42,11 @@ module Fog
|
|
42
42
|
else
|
43
43
|
# Use classic behaviour and return Excon::
|
44
44
|
connection.request(
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
45
|
+
path: "/token",
|
46
|
+
expects: 200,
|
47
|
+
headers: token_strategy.headers,
|
48
|
+
method: "POST",
|
49
|
+
body: Fog::JSON.encode(token_strategy.authorization_body_data)
|
50
50
|
)
|
51
51
|
end
|
52
52
|
end
|
@@ -154,7 +154,7 @@ module Fog
|
|
154
154
|
class ClientCredentialsStrategy < GrantTypeStrategy
|
155
155
|
def authorization_body_data
|
156
156
|
{
|
157
|
-
"grant_type" => "client_credentials"
|
157
|
+
"grant_type" => "client_credentials"
|
158
158
|
}
|
159
159
|
end
|
160
160
|
end
|
@@ -10,7 +10,7 @@ module Fog
|
|
10
10
|
# @see https://api.gb1.brightbox.com/1.0/#account_list_accounts
|
11
11
|
#
|
12
12
|
def list_accounts(options = {})
|
13
|
-
options
|
13
|
+
options[:nested] = "false" unless options.key?(:nested)
|
14
14
|
wrapped_request("get", "/1.0/accounts", [200], options)
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Brightbox
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
# Reset a database server restarting the DBMS.
|
6
|
+
#
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
8
|
+
# @param [Hash] options
|
9
|
+
# @option options [Boolean] :nested passed through with the API request. When true nested resources are expanded.
|
10
|
+
#
|
11
|
+
# @return [Hash] if successful Hash version of JSON object
|
12
|
+
# @return [NilClass] if no options were passed
|
13
|
+
#
|
14
|
+
def reset_database_server(identifier, options = {})
|
15
|
+
return nil if identifier.nil? || identifier == ""
|
16
|
+
wrapped_request("post", "/1.0/database_servers/#{identifier}/reset", [202], options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Brightbox
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
# Resize a database server, increasing resources available to the DBMS.
|
6
|
+
#
|
7
|
+
# A `reset` may be required for the DBMS to pick up changes.
|
8
|
+
#
|
9
|
+
# @param [String] identifier Unique reference to identify the resource
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Boolean] :nested passed through with the API request. When true nested resources are expanded.
|
12
|
+
# @option options [String] :new_type New Database type to use
|
13
|
+
#
|
14
|
+
# @return [Hash] if successful Hash version of JSON object
|
15
|
+
# @return [NilClass] if no options were passed
|
16
|
+
#
|
17
|
+
def resize_database_server(identifier, options)
|
18
|
+
return nil if identifier.nil? || identifier == ""
|
19
|
+
return nil if options.empty? || options.nil?
|
20
|
+
wrapped_request("post", "/1.0/database_servers/#{identifier}/resize", [202], options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -22,7 +22,7 @@ module Fog
|
|
22
22
|
|
23
23
|
if options[:return_link]
|
24
24
|
request_parameters = {
|
25
|
-
:
|
25
|
+
method: method, path: path, expects: expected
|
26
26
|
}
|
27
27
|
response = request(request_parameters)
|
28
28
|
data = Fog::JSON.decode(response.body)
|
@@ -22,7 +22,7 @@ module Fog
|
|
22
22
|
|
23
23
|
if options[:return_link]
|
24
24
|
request_parameters = {
|
25
|
-
:
|
25
|
+
method: method, path: path, expects: expected
|
26
26
|
}
|
27
27
|
response = request(request_parameters)
|
28
28
|
data = Fog::JSON.decode(response.body)
|
@@ -13,11 +13,11 @@ module Fog
|
|
13
13
|
def copy_object(source_container_name, source_object_name, target_container_name, target_object_name, options = {})
|
14
14
|
headers = { "X-Copy-From" => "/#{source_container_name}/#{source_object_name}" }.merge(options)
|
15
15
|
request(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
expects: 201,
|
17
|
+
headers: headers,
|
18
|
+
method: "PUT",
|
19
|
+
path: "#{Fog::Brightbox::Storage.escape(target_container_name)}/#{Fog::Brightbox::Storage.escape(target_object_name)}"
|
20
|
+
)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -44,17 +44,17 @@ module Fog
|
|
44
44
|
# * "Response Body" [String] - Response body for "Response Status".
|
45
45
|
def delete_multiple_objects(container, object_names, options = {})
|
46
46
|
body = object_names.map do |name|
|
47
|
-
object_name = container ? "#{
|
47
|
+
object_name = container ? "#{container}/#{name}" : name
|
48
48
|
URI.encode(object_name)
|
49
49
|
end.join("\n")
|
50
50
|
|
51
51
|
response = request({
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
|
56
|
-
:
|
57
|
-
:
|
52
|
+
expects: 200,
|
53
|
+
method: "DELETE",
|
54
|
+
headers: options.merge("Content-Type" => "text/plain",
|
55
|
+
"Accept" => "application/json"),
|
56
|
+
body: body,
|
57
|
+
query: { "bulk-delete" => true }
|
58
58
|
}, false)
|
59
59
|
response.body = Fog::JSON.decode(response.body)
|
60
60
|
response
|
@@ -10,9 +10,9 @@ module Fog
|
|
10
10
|
#
|
11
11
|
def delete_object(container, object)
|
12
12
|
request(
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
expects: 204,
|
14
|
+
method: "DELETE",
|
15
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}"
|
16
16
|
)
|
17
17
|
end
|
18
18
|
end
|
@@ -25,12 +25,12 @@ module Fog
|
|
25
25
|
# @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/static-large-objects.html
|
26
26
|
def delete_static_large_object(container, object, options = {})
|
27
27
|
response = request({
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
|
32
|
-
:
|
33
|
-
:
|
28
|
+
expects: 200,
|
29
|
+
method: "DELETE",
|
30
|
+
headers: options.merge("Content-Type" => "text/plain",
|
31
|
+
"Accept" => "application/json"),
|
32
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}",
|
33
|
+
query: { "multipart-manifest" => "delete" }
|
34
34
|
}, false)
|
35
35
|
response.body = Fog::JSON.decode(response.body)
|
36
36
|
response
|
@@ -30,10 +30,10 @@ module Fog
|
|
30
30
|
def get_container(container, options = {})
|
31
31
|
options = options.reject { |_key, value| value.nil? }
|
32
32
|
request(
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
33
|
+
expects: 200,
|
34
|
+
method: "GET",
|
35
|
+
path: Fog::Brightbox::Storage.escape(container),
|
36
|
+
query: { "format" => "json" }.merge!(options)
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
@@ -19,10 +19,10 @@ module Fog
|
|
19
19
|
def get_containers(options = {})
|
20
20
|
options = options.reject { |_key, value| value.nil? }
|
21
21
|
request(
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
22
|
+
expects: [200, 204],
|
23
|
+
method: "GET",
|
24
|
+
path: "",
|
25
|
+
query: { "format" => "json" }.merge!(options)
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
@@ -10,14 +10,12 @@ module Fog
|
|
10
10
|
#
|
11
11
|
def get_object(container, object, &block)
|
12
12
|
params = {
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
expects: 200,
|
14
|
+
method: "GET",
|
15
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}"
|
16
16
|
}
|
17
17
|
|
18
|
-
if block_given?
|
19
|
-
params[:response_block] = block
|
20
|
-
end
|
18
|
+
params[:response_block] = block if block_given?
|
21
19
|
|
22
20
|
request(params, false)
|
23
21
|
end
|
@@ -13,7 +13,7 @@ module Fog
|
|
13
13
|
# * response<~Excon::Response>:
|
14
14
|
# * body<~String> - url for object
|
15
15
|
def get_object_http_url(container, object, expires, options = {})
|
16
|
-
create_temp_url(container, object, expires, "GET", options.merge(:
|
16
|
+
create_temp_url(container, object, expires, "GET", options.merge(scheme: "http"))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -13,7 +13,7 @@ module Fog
|
|
13
13
|
# * response<~Excon::Response>:
|
14
14
|
# * body<~String> - url for object
|
15
15
|
def get_object_https_url(container, object, expires, options = {})
|
16
|
-
create_temp_url(container, object, expires, "GET", options.merge(:
|
16
|
+
create_temp_url(container, object, expires, "GET", options.merge(scheme: "https"))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|