fog-oneandone 1.0 → 1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +3 -1
- data/Rakefile +24 -0
- data/examples/example_app.rb +39 -12
- data/fog-oneandone.gemspec +2 -1
- data/lib/oneandone/compute.rb +103 -16
- data/lib/oneandone/models/compute/baremetal_model.rb +15 -0
- data/lib/oneandone/models/compute/baremetal_models.rb +24 -0
- data/lib/oneandone/models/compute/block_storage.rb +100 -0
- data/lib/oneandone/models/compute/block_storages.rb +24 -0
- data/lib/oneandone/models/compute/firewall.rb +0 -15
- data/lib/oneandone/models/compute/image.rb +6 -1
- data/lib/oneandone/models/compute/public_ip.rb +2 -1
- data/lib/oneandone/models/compute/recovery_appliance.rb +18 -0
- data/lib/oneandone/models/compute/recovery_appliances.rb +24 -0
- data/lib/oneandone/models/compute/server.rb +44 -105
- data/lib/oneandone/models/compute/server_appliance.rb +25 -0
- data/lib/oneandone/models/compute/server_appliances.rb +24 -0
- data/lib/oneandone/models/compute/ssh_key.rb +67 -0
- data/lib/oneandone/models/compute/ssh_keys.rb +24 -0
- data/lib/oneandone/requests/compute/add_block_storage_server.rb +61 -0
- data/lib/oneandone/requests/compute/add_ports.rb +1 -1
- data/lib/oneandone/requests/compute/create_block_storage.rb +80 -0
- data/lib/oneandone/requests/compute/create_image.rb +9 -3
- data/lib/oneandone/requests/compute/create_server.rb +11 -5
- data/lib/oneandone/requests/compute/create_ssh_key.rb +74 -0
- data/lib/oneandone/requests/compute/delete_block_storage.rb +51 -0
- data/lib/oneandone/requests/compute/delete_ssh_key.rb +51 -0
- data/lib/oneandone/requests/compute/get_baremetal_model.rb +42 -0
- data/lib/oneandone/requests/compute/get_block_storage.rb +50 -0
- data/lib/oneandone/requests/compute/get_block_storage_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_recovery_appliance.rb +41 -0
- data/lib/oneandone/requests/compute/get_ssh_key.rb +50 -0
- data/lib/oneandone/requests/compute/list_baremetal_models.rb +49 -0
- data/lib/oneandone/requests/compute/list_block_storages.rb +56 -0
- data/lib/oneandone/requests/compute/list_recovery_appliances.rb +47 -0
- data/lib/oneandone/requests/compute/list_ssh_keys.rb +56 -0
- data/lib/oneandone/requests/compute/remove_block_storage_server.rb +50 -0
- data/lib/oneandone/requests/compute/update_block_storage.rb +80 -0
- data/lib/oneandone/requests/compute/update_ssh_key.rb +78 -0
- data/tests/oneandone/test_block_storages.rb +82 -0
- data/tests/oneandone/test_firewalls.rb +5 -16
- data/tests/oneandone/test_recovery_appliances.rb +34 -0
- data/tests/oneandone/test_server_appliances.rb +34 -0
- data/tests/oneandone/test_ssh_keys.rb +82 -0
- metadata +58 -13
- data/lib/oneandone/requests/compute/remove_firewall_ip.rb +0 -60
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns information about a ssh key
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/v1/en/api/documentation.html#ssh_keys__ssh_key_id__delete]
|
10
|
+
##
|
11
|
+
def delete_ssh_key(ssh_key_id)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/ssh_keys/#{ssh_key_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def delete_ssh_key(ssh_key_id)
|
28
|
+
|
29
|
+
# Search for ssh key to delete
|
30
|
+
if ssh_key = self.data[:ssh_keys].find {
|
31
|
+
|hash| hash['id'] == ssh_key_id
|
32
|
+
}
|
33
|
+
self.data[:ssh_keys].delete(ssh_key)
|
34
|
+
else
|
35
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
36
|
+
not be found.')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Return Response Object to User
|
40
|
+
response = Excon::Response.new
|
41
|
+
response.status = 202
|
42
|
+
response.body = []
|
43
|
+
response
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end # Mock
|
48
|
+
|
49
|
+
end # OneAndOne
|
50
|
+
end # Compute
|
51
|
+
end # Fog
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class Real
|
5
|
+
##
|
6
|
+
# Returns information about a baremetal model
|
7
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#]
|
8
|
+
##
|
9
|
+
def get_baremetal_model(id)
|
10
|
+
|
11
|
+
params = {
|
12
|
+
'method' => :get,
|
13
|
+
'endpoint' => "/servers/baremetal_models/#{id}"
|
14
|
+
}
|
15
|
+
|
16
|
+
request(params)
|
17
|
+
|
18
|
+
end
|
19
|
+
end # Real
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def get_baremetal_model(id)
|
23
|
+
|
24
|
+
# Search for baremetal model to return
|
25
|
+
if baremetal_model = self.data[:baremetal_models].find {
|
26
|
+
|hash| hash['id'] == id
|
27
|
+
}
|
28
|
+
else
|
29
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
30
|
+
not be found.')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return Response Object to User
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response.body = baremetal_model
|
37
|
+
response
|
38
|
+
end
|
39
|
+
end # Mock
|
40
|
+
end # OneAndOne
|
41
|
+
end # Compute
|
42
|
+
end # Fog
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns information about a block storage
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/v1/en/api/documentation.html#block_storages__block_storage_id__get]
|
10
|
+
##
|
11
|
+
def get_block_storage(block_storage_id)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :get,
|
15
|
+
'endpoint' => "/block_storages/#{block_storage_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def get_block_storage(block_storage_id)
|
28
|
+
|
29
|
+
# Search for block storage to return
|
30
|
+
if block_storage = self.data[:block_storages].find {
|
31
|
+
|hash| hash['id'] == block_storage_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return Response Object to User
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 202
|
41
|
+
response.body = block_storage
|
42
|
+
response
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Mock
|
47
|
+
|
48
|
+
end # OneAndOne
|
49
|
+
end # Compute
|
50
|
+
end # Fog
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns information about a server attached to a block storage
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/v1/en/api/documentation.html#block_storages__block_storage_id__server_get]
|
10
|
+
##
|
11
|
+
def get_block_storage_server(block_storage_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :get,
|
15
|
+
'endpoint' => "/block_storages/#{block_storage_id}/server"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def get_block_storage_server(block_storage_id: nil)
|
28
|
+
|
29
|
+
# Search for block storage
|
30
|
+
if block_storage = self.data[:block_storages].find {
|
31
|
+
|hash| hash['id'] == block_storage_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return Response Object to User
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 202
|
41
|
+
response.body = block_storage['server']
|
42
|
+
response
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Mock
|
47
|
+
|
48
|
+
end # OneAndOne
|
49
|
+
end # Compute
|
50
|
+
end # Fog
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class Real
|
5
|
+
##
|
6
|
+
# Returns information about a recovery appliance
|
7
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#]
|
8
|
+
##
|
9
|
+
def get_recovery_appliance(appliance_id)
|
10
|
+
|
11
|
+
params = {
|
12
|
+
'method' => :get,
|
13
|
+
'endpoint' => "/recovery_appliances/#{appliance_id}"
|
14
|
+
}
|
15
|
+
|
16
|
+
request(params)
|
17
|
+
end
|
18
|
+
end # Real
|
19
|
+
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def get_recovery_appliance(appliance_id)
|
23
|
+
# Search for server appliance to return
|
24
|
+
if server_appliance = self.data[:recovery_appliances].find {
|
25
|
+
|hash| hash['id'] == appliance_id
|
26
|
+
}
|
27
|
+
else
|
28
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
29
|
+
not be found.')
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return Response Object to User
|
33
|
+
response = Excon::Response.new
|
34
|
+
response.status = 200
|
35
|
+
response.body = server_appliance
|
36
|
+
response
|
37
|
+
end
|
38
|
+
end # Mock
|
39
|
+
end # OneAndOne
|
40
|
+
end # Compute
|
41
|
+
end # Fog
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns information about a ssh key
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/v1/en/api/documentation.html#ssh_keys__ssh_key_id__get]
|
10
|
+
##
|
11
|
+
def get_ssh_key(ssh_key_id)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :get,
|
15
|
+
'endpoint' => "/ssh_keys/#{ssh_key_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def get_ssh_key(ssh_key_id)
|
28
|
+
|
29
|
+
# Search for ssh key to return
|
30
|
+
if ssh_key = self.data[:ssh_keys].find {
|
31
|
+
|hash| hash['id'] == ssh_key_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return Response Object to User
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 202
|
41
|
+
response.body = ssh_key
|
42
|
+
response
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Mock
|
47
|
+
|
48
|
+
end # OneAndOne
|
49
|
+
end # Compute
|
50
|
+
end # Fog
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class Real
|
5
|
+
##
|
6
|
+
# Returns a list of all baremetal models
|
7
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#]
|
8
|
+
##
|
9
|
+
def list_baremetal_models(page: nil, per_page: nil, sort: nil, q: nil,
|
10
|
+
fields: nil)
|
11
|
+
|
12
|
+
# Build hash for query parameters
|
13
|
+
keyword_args = {
|
14
|
+
:page => page,
|
15
|
+
:per_page => per_page,
|
16
|
+
:sort => sort,
|
17
|
+
:q => q,
|
18
|
+
:fields => fields
|
19
|
+
}
|
20
|
+
|
21
|
+
# Clean out null query parameters
|
22
|
+
query = clean_hash(keyword_args)
|
23
|
+
|
24
|
+
# Request
|
25
|
+
params = {
|
26
|
+
'method' => :get,
|
27
|
+
'endpoint' => '/servers/baremetal_models',
|
28
|
+
'params' => query
|
29
|
+
}
|
30
|
+
|
31
|
+
request(params)
|
32
|
+
end
|
33
|
+
end # Real
|
34
|
+
|
35
|
+
|
36
|
+
class Mock
|
37
|
+
def list_baremetal_models(page: nil, per_page: nil, sort: nil, q: nil,
|
38
|
+
fields: nil)
|
39
|
+
|
40
|
+
response = Excon::Response.new
|
41
|
+
response.status = 200
|
42
|
+
response.body = self.data[:baremetal_models]
|
43
|
+
response
|
44
|
+
end
|
45
|
+
end # Mock
|
46
|
+
|
47
|
+
end # OneAndOne
|
48
|
+
end # Compute
|
49
|
+
end # Fog
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns a list of all block storages on your account
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/v1/en/api/documentation.html#block_storages_get]
|
10
|
+
##
|
11
|
+
def list_block_storages(page: nil, per_page: nil, sort: nil, q: nil,
|
12
|
+
fields: nil)
|
13
|
+
|
14
|
+
# Build hash for query parameters
|
15
|
+
keyword_args = {
|
16
|
+
:page => page,
|
17
|
+
:per_page => per_page,
|
18
|
+
:sort => sort,
|
19
|
+
:q => q,
|
20
|
+
:fields => fields
|
21
|
+
}
|
22
|
+
|
23
|
+
# Clean out null query parameters
|
24
|
+
query = clean_hash(keyword_args)
|
25
|
+
|
26
|
+
# Request
|
27
|
+
params = {
|
28
|
+
'method' => :get,
|
29
|
+
'endpoint' => '/block_storages',
|
30
|
+
'params' => query
|
31
|
+
}
|
32
|
+
|
33
|
+
request(params)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Real
|
38
|
+
|
39
|
+
|
40
|
+
class Mock
|
41
|
+
|
42
|
+
def list_block_storages(page: nil, per_page: nil, sort: nil, q: nil,
|
43
|
+
fields: nil)
|
44
|
+
|
45
|
+
response = Excon::Response.new
|
46
|
+
response.status = 200
|
47
|
+
response.body = self.data[:block_storages]
|
48
|
+
response
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end # Mock
|
53
|
+
|
54
|
+
end # OneAndOne
|
55
|
+
end # Compute
|
56
|
+
end # Fog
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
class Real
|
5
|
+
##
|
6
|
+
# Returns a list of images available for recovering purposes
|
7
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#]
|
8
|
+
##
|
9
|
+
def list_recovery_appliances(page: nil, per_page: nil, sort: nil, q: nil,
|
10
|
+
fields: nil)
|
11
|
+
|
12
|
+
# Build hash for query parameters
|
13
|
+
keyword_args = {
|
14
|
+
:page => page,
|
15
|
+
:per_page => per_page,
|
16
|
+
:sort => sort,
|
17
|
+
:q => q,
|
18
|
+
:fields => fields
|
19
|
+
}
|
20
|
+
|
21
|
+
# Clean out null query parameters
|
22
|
+
query = clean_hash(keyword_args)
|
23
|
+
|
24
|
+
# Request
|
25
|
+
params = {
|
26
|
+
'method' => :get,
|
27
|
+
'endpoint' => '/recovery_appliances',
|
28
|
+
'params' => query
|
29
|
+
}
|
30
|
+
|
31
|
+
request(params)
|
32
|
+
end
|
33
|
+
end # Real
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def list_recovery_appliances(page: nil, per_page: nil, sort: nil, q: nil,
|
37
|
+
fields: nil)
|
38
|
+
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 200
|
41
|
+
response.body = self.data[:recovery_appliances]
|
42
|
+
response
|
43
|
+
end
|
44
|
+
end # Mock
|
45
|
+
end # OneAndOne
|
46
|
+
end # Compute
|
47
|
+
end # Fog
|