fog-profitbricks 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -3
  3. data/README.md +437 -3
  4. data/lib/fog/profitbricks/compute.rb +138 -80
  5. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
  6. data/lib/fog/profitbricks/models/compute/contract_resource.rb +35 -0
  7. data/lib/fog/profitbricks/models/compute/contract_resources.rb +19 -0
  8. data/lib/fog/profitbricks/models/compute/group.rb +66 -0
  9. data/lib/fog/profitbricks/models/compute/groups.rb +26 -0
  10. data/lib/fog/profitbricks/models/compute/lan.rb +3 -0
  11. data/lib/fog/profitbricks/models/compute/location.rb +1 -0
  12. data/lib/fog/profitbricks/models/compute/resource.rb +30 -0
  13. data/lib/fog/profitbricks/models/compute/resources.rb +32 -0
  14. data/lib/fog/profitbricks/models/compute/share.rb +59 -0
  15. data/lib/fog/profitbricks/models/compute/shares.rb +33 -0
  16. data/lib/fog/profitbricks/models/compute/user.rb +75 -0
  17. data/lib/fog/profitbricks/models/compute/users.rb +45 -0
  18. data/lib/fog/profitbricks/models/compute/volume.rb +2 -0
  19. data/lib/fog/profitbricks/requests/compute/add_share.rb +64 -0
  20. data/lib/fog/profitbricks/requests/compute/add_user_to_group.rb +89 -0
  21. data/lib/fog/profitbricks/requests/compute/create_group.rb +85 -0
  22. data/lib/fog/profitbricks/requests/compute/create_lan.rb +1 -0
  23. data/lib/fog/profitbricks/requests/compute/create_user.rb +83 -0
  24. data/lib/fog/profitbricks/requests/compute/create_volume.rb +1 -0
  25. data/lib/fog/profitbricks/requests/compute/delete_group.rb +43 -0
  26. data/lib/fog/profitbricks/requests/compute/delete_share.rb +42 -0
  27. data/lib/fog/profitbricks/requests/compute/delete_user.rb +43 -0
  28. data/lib/fog/profitbricks/requests/compute/get_all_contract_resources.rb +55 -0
  29. data/lib/fog/profitbricks/requests/compute/get_all_groups.rb +62 -0
  30. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +1 -0
  31. data/lib/fog/profitbricks/requests/compute/get_all_resources.rb +66 -0
  32. data/lib/fog/profitbricks/requests/compute/get_all_shares.rb +46 -0
  33. data/lib/fog/profitbricks/requests/compute/get_all_users.rb +70 -0
  34. data/lib/fog/profitbricks/requests/compute/get_group.rb +64 -0
  35. data/lib/fog/profitbricks/requests/compute/get_group_users.rb +78 -0
  36. data/lib/fog/profitbricks/requests/compute/get_lan.rb +1 -0
  37. data/lib/fog/profitbricks/requests/compute/get_resource_by_type.rb +73 -0
  38. data/lib/fog/profitbricks/requests/compute/get_resources_by_type.rb +44 -0
  39. data/lib/fog/profitbricks/requests/compute/get_share.rb +52 -0
  40. data/lib/fog/profitbricks/requests/compute/get_user.rb +72 -0
  41. data/lib/fog/profitbricks/requests/compute/remove_user_from_group.rb +49 -0
  42. data/lib/fog/profitbricks/requests/compute/update_group.rb +85 -0
  43. data/lib/fog/profitbricks/requests/compute/update_lan.rb +1 -0
  44. data/lib/fog/profitbricks/requests/compute/update_share.rb +67 -0
  45. data/lib/fog/profitbricks/requests/compute/update_user.rb +94 -0
  46. data/lib/fog/profitbricks/version.rb +1 -1
  47. data/tests/profitbricks/models/compute/compute_tests.rb +6 -0
  48. data/tests/profitbricks/requests/compute/location_tests.rb +4 -4
  49. data/tests/profitbricks/requests/compute/nic_tests.rb +7 -19
  50. data/tests/profitbricks/requests/compute/server_tests.rb +9 -21
  51. metadata +58 -28
  52. data/gemfiles/Gemfile.1.9.2- +0 -5
@@ -0,0 +1,85 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Create a new group and set group privileges.
6
+ #
7
+ # ==== Parameters
8
+ # * options<~Hash>:
9
+ # * name<~String> - Required, The name of the group.
10
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
11
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
12
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
13
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * id<~String> - The resource's unique identifier.
19
+ # * type<~String> - The type of the created resource.
20
+ # * href<~String> - URL to the object's representation (absolute path).
21
+ # * properties<~Hash> - Hash containing the volume properties.
22
+ # * name<~String> - The name of the group.
23
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
24
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
25
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
26
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
27
+ # * entities<~Hash> - A hash containing the group entities.
28
+ # * users<~Hash> - A collection of users that belong to this group.
29
+ # * id<~String> - The resource's unique identifier.
30
+ # * type<~String> - The type of the requested resource.
31
+ # * href<~String> - URL to the object’s representation (absolute path).
32
+ # * items<~Array> - The array containing individual user resources.
33
+ # * resources<~Hash> - A collection of resources that are assigned to this group.
34
+ # * id<~String> - The resource's unique identifier.
35
+ # * type<~String> - The type of the requested resource.
36
+ # * href<~String> - URL to the object’s representation (absolute path).
37
+ # * items<~Array> - An array containing individual resources.
38
+ # * id<~String> - The resource's unique identifier.
39
+ # * type<~String> - The type of the requested resource.
40
+ # * href<~String> - URL to the object’s representation (absolute path).
41
+ #
42
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#create-a-group]
43
+ def create_group(options = {})
44
+ group = {
45
+ :properties => options
46
+ }
47
+
48
+ request(
49
+ :expects => [202],
50
+ :method => 'POST',
51
+ :path => "/um/groups",
52
+ :body => Fog::JSON.encode(group)
53
+ )
54
+ end
55
+ end
56
+
57
+ class Mock
58
+ def create_group(options = {})
59
+ response = Excon::Response.new
60
+ response.status = 202
61
+
62
+ group_id = Fog::UUID.uuid
63
+
64
+ group = {
65
+ 'id' => group_id,
66
+ 'type' => 'group',
67
+ 'href' => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}",
68
+ 'properties' => {
69
+ 'name' => options[:name],
70
+ 'createDataCenter' => options[:create_data_center],
71
+ 'createSnapshot' => options[:create_snapshot],
72
+ 'reserveIp' => options[:reserve_ip],
73
+ 'accessActivityLog' => options[:access_activity_log]
74
+ }
75
+ }
76
+
77
+ data[:groups]['items'] << group
78
+
79
+ response.body = group
80
+ response
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -32,6 +32,7 @@ module Fog
32
32
  # * properties<~Hash> - Hash containing the LAN properties
33
33
  # * name<~String> - The name of the LAN
34
34
  # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
35
+ # * ipFailover<~Array> - Attributes related to IP failover groups
35
36
  # * entities<~Hash> - Hash containing the LAN entities
36
37
  # * nics<~Hash> - Hash containing the NIC properties
37
38
  # * id<~String> - The resource's unique identifier
@@ -0,0 +1,83 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Create a new user under a particular contract.
6
+ #
7
+ # ==== Parameters
8
+ # * options<~Hash>:
9
+ # * firstname<~String> - Required, The name of the group.
10
+ # * lastname<~String> - Required, The group will be allowed to create virtual data centers.
11
+ # * email<~String> - Required, The group will be allowed to create snapshots.
12
+ # * password<~String> - Required, The group will be allowed to reserve IP addresses.
13
+ # * administrator<~Boolean> - The group will be allowed to access the activity log.
14
+ # * forceSecAuth<~Boolean> - The group will be allowed to access the activity log.
15
+ #
16
+ # ==== Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * id<~String> - The resource's unique identifier.
20
+ # * type<~String> - The type of the created resource.
21
+ # * href<~String> - URL to the object's representation (absolute path).
22
+ # * metadata<~Hash> - Hash containing metadata for the user.
23
+ # * etag<~String> - ETag of the user.
24
+ # * creationDate<~String> - A time and date stamp indicating when the user was created.
25
+ # * lastLogin<~String> - A time and date stamp indicating when the user last logged in.
26
+ # * properties<~Hash> - Hash containing the user's properties.
27
+ # * firstname<~String> - The first name of the user.
28
+ # * lastname<~String> - The last name of the user.
29
+ # * email<~String> - The e-mail address of the user.
30
+ # * administrator<~Boolean> - Indicates if the user has administrative rights.
31
+ # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user.
32
+ # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user.
33
+ #
34
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#create-a-user]
35
+ def create_user(options = {})
36
+ user = {
37
+ :properties => options
38
+ }
39
+
40
+ request(
41
+ :expects => [202],
42
+ :method => 'POST',
43
+ :path => "/um/users",
44
+ :body => Fog::JSON.encode(user)
45
+ )
46
+ end
47
+ end
48
+
49
+ class Mock
50
+ def create_user(options = {})
51
+ response = Excon::Response.new
52
+ response.status = 202
53
+
54
+ user_id = Fog::UUID.uuid
55
+
56
+ user = {
57
+ 'id' => user_id,
58
+ 'type' => 'user',
59
+ 'href' => "https=>//api.profitbricks.com/rest/v4/um/users/#{user_id}",
60
+ 'metadata' => {
61
+ 'etag' => '26a6259cc0c1dae299a5687455dff0ce',
62
+ 'creationDate' => '2017-05-22T08:15:55Z',
63
+ 'lastLogin' => '',
64
+ },
65
+ 'properties' => {
66
+ 'firstname' => options[:firstname],
67
+ 'lastname' => options[:lastname],
68
+ 'email' => options[:email],
69
+ 'password' => options[:password],
70
+ 'administrator' => options[:administrator],
71
+ 'forceSecAuth' => options[:force_sec_auth]
72
+ }
73
+ }
74
+
75
+ data[:users]['items'] << user
76
+
77
+ response.body = user
78
+ response
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -11,6 +11,7 @@ module Fog
11
11
  # * size<~Integer> - Required, the size of the volume in GB
12
12
  # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
13
13
  # * image<~String> - Required**, the image or snapshot ID
14
+ # * imageAlias<~String> - Required**, an alias to a ProfitBricks public image. Use instead of "image".
14
15
  # * type<~String> - The volume type, HDD or SSD
15
16
  # * licenceType<~String> - Required**, the licence type of the volume. Options: LINUX, WINDOWS, UNKNOWN, OTHER
16
17
  # * imagePassword<~String> - One-time password is set on the Image for the appropriate account.
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Delete a single group.
6
+ # Resources that are assigned to the group are NOT deleted, but are no longer accessible
7
+ # to the group members unless the member is a Contract Owner, Admin, or Resource Owner.
8
+ #
9
+ # ==== Parameters
10
+ # * group_id<~String> - UUID of the group
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response> - No response parameters
14
+ # (HTTP/1.1 202 Accepted)
15
+ #
16
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-group]
17
+ def delete_group(group_id)
18
+ request(
19
+ :expects => [202],
20
+ :method => 'DELETE',
21
+ :path => "/um/groups/#{group_id}"
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def delete_group(group_id)
28
+ response = Excon::Response.new
29
+ response.status = 202
30
+
31
+ if group = data[:groups]['items'].find do |grp|
32
+ grp['id'] == group_id
33
+ end
34
+ else
35
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
36
+ end
37
+
38
+ response
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Remove a resource share from a specified group.
6
+ #
7
+ # ==== Parameters
8
+ # * group_id<~String> - Required, The ID of the specific group containing the resource to delete.
9
+ # * resource_id<~String> - Required, The ID of the specific resource to delete.
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response> - No response parameters
13
+ # (HTTP/1.1 202 Accepted)
14
+ #
15
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-share]
16
+ def delete_share(group_id, resource_id)
17
+ request(
18
+ :expects => [202],
19
+ :method => 'DELETE',
20
+ :path => "/um/groups/#{group_id}/shares/#{resource_id}"
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def delete_share(group_id, resource_id)
27
+ response = Excon::Response.new
28
+ response.status = 202
29
+
30
+ if share = data[:shares]['items'].find do |shr|
31
+ shr['id'] == resource_id
32
+ end
33
+ else
34
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
35
+ end
36
+
37
+ response
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Blacklists the user, disabling them.
6
+ # The user is not completely purged, therefore if you anticipate needing to create
7
+ # a user with the same name in the future, we suggest renaming the user before you delete it.
8
+ #
9
+ # ==== Parameters
10
+ # * user_id<~String> - UUID of the user
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response> - No response parameters
14
+ # (HTTP/1.1 202 Accepted)
15
+ #
16
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-user]
17
+ def delete_user(user_id)
18
+ request(
19
+ :expects => [202],
20
+ :method => 'DELETE',
21
+ :path => "/um/users/#{user_id}"
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def delete_user(user_id)
28
+ response = Excon::Response.new
29
+ response.status = 202
30
+
31
+ if user = data[:users]['items'].find do |usr|
32
+ usr['id'] == user_id
33
+ end
34
+ else
35
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
36
+ end
37
+
38
+ response
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,55 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Get all contract resources
6
+ #
7
+ # ==== Parameters
8
+ # * None
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * type<~String> - The type of the requested resource
14
+ # * properties<~Hash>
15
+ # * contractNumber<~Integer> - The contract number that the returned information is from
16
+ # * owner<~String> - The username of the Contract Owner
17
+ # * status<~String> - The status of the contract. [ BILLABLE...]
18
+ # * resourceLimits<~Hash> - An object containing the contract's resource limits
19
+ # * coresPerServer<~Integer> - Maximum number of CPU cores per server
20
+ # * coresPerContract<~Integer> - Maximum number of CPU cores per contract
21
+ # * coresProvisioned<~Integer> - The total number of CPU cores that have been provisioned
22
+ # * ramPerServer<~Integer> - The maximum amount of RAM (in MB) that may be provisioned for a particular server under this contract
23
+ # * ramPerContract<~Integer> - The maximum amount of RAM (in MB) that may be provisioned under this contract
24
+ # * ramProvisioned<~Integer> - The amount of RAM (in MB) that has been provisioned under this contract
25
+ # * hddLimitPerVolume<~Integer> - The maximum size (in MB) of an individual hard disk volume
26
+ # * hddLimitPerContract<~Integer> - The maximum amount of hard disk space (in MB) that may be provisioned under this contract
27
+ # * hddVolumeProvisioned<~Integer> - The amount of hard disk space (in MB) that is currently provisioned
28
+ # * ssdLimitPerVolume<~Integer> - The maximum size (in MB) of an individual solid state disk volume
29
+ # * ssdLimitPerContract<~Integer> - The maximum amount of solid state disk space (in MB) that may be provisioned under this contract
30
+ # * ssdVolumeProvisioned<~Integer> - The amount of solid state disk space (in MB) that is currently provisioned
31
+ # * reservableIps<~Integer> - The maximum number of static public IP addresses that may be reserved by this customer across all contracts
32
+ # * reservedIpsOnContract<~Integer> - The maximum number of static public IP addresses that can be reserved under this contract
33
+ # * reservedIpsInUse<~Integer> - The number of static public IP addresses that have been reserved
34
+ #
35
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#contract-resources]
36
+ def get_all_contract_resources
37
+ request(
38
+ :expects => [200],
39
+ :method => 'GET',
40
+ :path => "/contracts"
41
+ )
42
+ end
43
+ end
44
+
45
+ class Mock
46
+ def get_all_contract_resources
47
+ response = Excon::Response.new
48
+ response.status = 200
49
+ response.body = data[:contracts]
50
+ response
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieve a full list of all groups.
6
+ #
7
+ # ==== Parameters
8
+ # * None
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * id<~String> - Id of the requested resource
14
+ # * type<~String> - type of the requested resource
15
+ # * href<~String> - url to the requested resource
16
+ # * items<~Array>
17
+ # * id<~String> - The resource's unique identifier
18
+ # * type<~String> - The type of the requested resource
19
+ # * href<~String> - URL to the object’s representation (absolute path)
20
+ # * properties<~Hash> - Hash containing the volume properties.
21
+ # * name<~String> - The name of the group.
22
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
23
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
24
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
25
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
26
+ # * entities<~Hash> - A hash containing the group entities.
27
+ # * users<~Hash> - A collection of users that belong to this group.
28
+ # * id<~String> - The resource's unique identifier.
29
+ # * type<~String> - The type of the requested resource.
30
+ # * href<~String> - URL to the object’s representation (absolute path).
31
+ # * items<~Array> - The array containing individual user resources.
32
+ # * resources<~Hash> - A collection of resources that are assigned to this group.
33
+ # * id<~String> - The resource's unique identifier.
34
+ # * type<~String> - The type of the requested resource.
35
+ # * href<~String> - URL to the object’s representation (absolute path).
36
+ # * items<~Array> - An array containing individual resources.
37
+ # * id<~String> - The resource's unique identifier.
38
+ # * type<~String> - The type of the requested resource.
39
+ # * href<~String> - URL to the object’s representation (absolute path).
40
+ #
41
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-groups]
42
+ def get_all_groups
43
+ request(
44
+ :expects => [200],
45
+ :method => 'GET',
46
+ :path => "/um/groups?depth=1"
47
+ )
48
+ end
49
+ end
50
+
51
+ class Mock
52
+ def get_all_groups
53
+ response = Excon::Response.new
54
+ response.status = 200
55
+ response.body = data[:groups]
56
+
57
+ response
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -27,6 +27,7 @@ module Fog
27
27
  # * properties<~Hash> - Hash containing the LAN properties
28
28
  # * name<~String> - The name of the LAN
29
29
  # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
30
+ # * ipFailover<~Array> - Attributes related to IP failover groups
30
31
  # * entities<~Hash> - Hash containing the LAN entities
31
32
  # * nics<~Hash> - Hash containing the NIC properties
32
33
  # * id<~String> - The resource's unique identifier