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,66 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieves a list of all resources and optionally their group associations.
6
+ # Please note that this API call can take a significant amount of time to return when
7
+ # there are a large number of provisioned resources.
8
+ #
9
+ # ==== Parameters
10
+ # * None
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * id<~String> - Id of the requested resource
16
+ # * type<~String> - type of the requested resource
17
+ # * href<~String> - url to the requested resource
18
+ # * items<~Array>
19
+ # * id<~String> - The resource's unique identifier
20
+ # * type<~String> - The type of the requested resource
21
+ # * href<~String> - URL to the object’s representation (absolute path)
22
+ # * metadata<~Hash> - Hash containing the metadata for the specific resource.
23
+ # * createdDate<~String> - A time and date stamp indicating when the resource was created.
24
+ # * createdBy<~String> - The user who created the resource.
25
+ # * etag<~String> - Resource's ETag.
26
+ # * lastModifiedDate<~String> - A time and date stamp indicating when the resource was last modified.
27
+ # * lastModifiedBy<~String> - The user who last modified the resource.
28
+ # * state<~String> - The current state of the resource. [ AVAILABLE, BUSY, INACTIVE ]
29
+ # * entities<~Hash> - A hash containing groups the resource is associated with.
30
+ # * groups<~Hash> - A collection of groups associated with the resource.
31
+ # * id<~String> - The resource's unique identifier
32
+ # * type<~String> - The type of the requested resource
33
+ # * href<~String> - URL to the object’s representation (absolute path)
34
+ # * items<~Array>
35
+ # * id<~String> - The resource's unique identifier
36
+ # * type<~String> - The type of the requested resource
37
+ # * href<~String> - URL to the object’s representation (absolute path)
38
+ # * properties<~Hash> - Hash containing the volume properties.
39
+ # * name<~String> - The name of the group.
40
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
41
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
42
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
43
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
44
+ #
45
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-resources]
46
+ def get_all_resources
47
+ request(
48
+ :expects => [200],
49
+ :method => 'GET',
50
+ :path => "/um/resources?depth=2"
51
+ )
52
+ end
53
+ end
54
+
55
+ class Mock
56
+ def get_all_resources
57
+ response = Excon::Response.new
58
+ response.status = 200
59
+ response.body = data[:resources]
60
+
61
+ response
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieve a full list of all the resources that are shared through this group
6
+ # and lists the permissions granted to the group members for each shared resource.
7
+ #
8
+ # ==== Parameters
9
+ # * group_id<~String> - Required, The ID of a specific group.
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * id<~String> - Id of the requested resource
15
+ # * type<~String> - type of the requested resource
16
+ # * href<~String> - url to the requested resource
17
+ # * items<~Array>
18
+ # * id<~String> - The resource's unique identifier
19
+ # * type<~String> - The type of the requested resource
20
+ # * href<~String> - URL to the object’s representation (absolute path)
21
+ # * properties<~Hash> - Hash containing the volume properties.
22
+ # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource.
23
+ # * sharePrivilege<~Boolean> - The group has permission to share this resource.
24
+ #
25
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-shares]
26
+ def get_all_shares(group_id)
27
+ request(
28
+ :expects => [200],
29
+ :method => 'GET',
30
+ :path => "/um/groups/#{group_id}/shares?depth=1"
31
+ )
32
+ end
33
+ end
34
+
35
+ class Mock
36
+ def get_all_shares(group_id)
37
+ response = Excon::Response.new
38
+ response.status = 200
39
+ response.body = data[:shares]
40
+
41
+ response
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieve a list of all the users that have been created under a contract.
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 created resource.
19
+ # * href<~String> - URL to the object's representation (absolute path).
20
+ # * metadata<~Hash> - Hash containing metadata for the user.
21
+ # * etag<~String> - ETag of the user.
22
+ # * creationDate<~String> - A time and date stamp indicating when the user was created.
23
+ # * lastLogin<~String> - A time and date stamp indicating when the user last logged in.
24
+ # * properties<~Hash> - Hash containing the user's properties.
25
+ # * firstname<~String> - The first name of the user.
26
+ # * lastname<~String> - The last name of the user.
27
+ # * email<~String> - The e-mail address of the user.
28
+ # * administrator<~Boolean> - Indicates if the user has administrative rights.
29
+ # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user.
30
+ # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user.
31
+ # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of.
32
+ # * owns<~Hash> - Hash containing resources the user owns.
33
+ # * id<~String> - The resource's unique identifier.
34
+ # * type<~String> - The type of the created resource.
35
+ # * href<~String> - URL to the object's representation (absolute path).
36
+ # * items<~Array>
37
+ # * id<~String> - The resource's unique identifier.
38
+ # * type<~String> - The type of the created resource.
39
+ # * href<~String> - URL to the object's representation (absolute path).
40
+ # * groups<~Hash> - Hash containing groups the user is a member of.
41
+ # * id<~String> - The resource's unique identifier.
42
+ # * type<~String> - The type of the created resource.
43
+ # * href<~String> - URL to the object's representation (absolute path).
44
+ # * items<~Array>
45
+ # * id<~String> - The resource's unique identifier.
46
+ # * type<~String> - The type of the created resource.
47
+ # * href<~String> - URL to the object's representation (absolute path).
48
+ #
49
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-users]
50
+ def get_all_users
51
+ request(
52
+ :expects => [200],
53
+ :method => 'GET',
54
+ :path => "/um/users?depth=1"
55
+ )
56
+ end
57
+ end
58
+
59
+ class Mock
60
+ def get_all_users
61
+ response = Excon::Response.new
62
+ response.status = 200
63
+ response.body = data[:users]
64
+
65
+ response
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,64 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieves the attributes of a given volume
6
+ #
7
+ # ==== Parameters
8
+ # * group_id<~String> - Required, UUID of the group
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * id<~String> - The resource's unique identifier
14
+ # * type<~String> - The type of the requested resource
15
+ # * href<~String> - URL to the object’s representation (absolute path)
16
+ # * properties<~Hash> - Hash containing the volume properties.
17
+ # * name<~String> - The name of the group.
18
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
19
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
20
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
21
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
22
+ # * entities<~Hash> - A hash containing the group entities.
23
+ # * users<~Hash> - A collection of users that belong to this group.
24
+ # * id<~String> - The resource's unique identifier.
25
+ # * type<~String> - The type of the requested resource.
26
+ # * href<~String> - URL to the object’s representation (absolute path).
27
+ # * items<~Array> - The array containing individual user resources.
28
+ # * resources<~Hash> - A collection of resources that are assigned 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> - An array containing individual resources.
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
+ #
37
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#retrieve-a-group]
38
+ def get_group(group_id)
39
+ request(
40
+ :expects => [200],
41
+ :method => "GET",
42
+ :path => "/um/groups/#{group_id}"
43
+ )
44
+ end
45
+ end
46
+
47
+ class Mock
48
+ def get_group(group_id)
49
+ if group = data[:groups]['items'].find do |grp|
50
+ grp["id"] == group_id
51
+ end
52
+ else
53
+ raise Excon::Error::HTTPStatus, "The requested resource could not be found"
54
+ end
55
+
56
+ response = Excon::Response.new
57
+ response.status = 200
58
+ response.body = group
59
+ response
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,78 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieves a full list of all the users that are members of a particular group.
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 created resource.
19
+ # * href<~String> - URL to the object's representation (absolute path).
20
+ # * metadata<~Hash> - Hash containing metadata for the user.
21
+ # * etag<~String> - ETag of the user.
22
+ # * creationDate<~String> - A time and date stamp indicating when the user was created.
23
+ # * lastLogin<~String> - A time and date stamp indicating when the user last logged in.
24
+ # * properties<~Hash> - Hash containing the user's properties.
25
+ # * firstname<~String> - The first name of the user.
26
+ # * lastname<~String> - The last name of the user.
27
+ # * email<~String> - The e-mail address of the user.
28
+ # * administrator<~Boolean> - Indicates if the user has administrative rights.
29
+ # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user.
30
+ # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user.
31
+ # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of.
32
+ # * owns<~Hash> - Hash containing resources the user owns.
33
+ # * id<~String> - The resource's unique identifier.
34
+ # * type<~String> - The type of the created resource.
35
+ # * href<~String> - URL to the object's representation (absolute path).
36
+ # * items<~Array>
37
+ # * id<~String> - The resource's unique identifier.
38
+ # * type<~String> - The type of the created resource.
39
+ # * href<~String> - URL to the object's representation (absolute path).
40
+ # * groups<~Hash> - Hash containing groups the user is a member of.
41
+ # * id<~String> - The resource's unique identifier.
42
+ # * type<~String> - The type of the created resource.
43
+ # * href<~String> - URL to the object's representation (absolute path).
44
+ # * items<~Array>
45
+ # * id<~String> - The resource's unique identifier.
46
+ # * type<~String> - The type of the created resource.
47
+ # * href<~String> - URL to the object's representation (absolute path).
48
+ #
49
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-users-in-a-group]
50
+ def get_group_users(group_id)
51
+ request(
52
+ :expects => [200],
53
+ :method => 'GET',
54
+ :path => "/um/groups/#{group_id}/users?depth=2"
55
+ )
56
+ end
57
+ end
58
+
59
+ class Mock
60
+ def get_group_users(group_id)
61
+ if users = data[:groups]['items']['users'].find do |usr|
62
+ usr["groups"]["items"].find do |grp|
63
+ grp["id"] == group_id
64
+ end
65
+ end
66
+ else
67
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
68
+ end
69
+
70
+ response = Excon::Response.new
71
+ response.status = 200
72
+ response.body = users
73
+ response
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -28,6 +28,7 @@ module Fog
28
28
  # * properties<~Hash> - Hash containing the LAN properties
29
29
  # * name<~String> - The name of the LAN
30
30
  # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
31
+ # * ipFailover<~Array> - Attributes related to IP failover groups
31
32
  # * entities<~Hash> - Hash containing the LAN entities
32
33
  # * nics<~Hash> - Hash containing the NIC properties
33
34
  # * id<~String> - The resource's unique identifier
@@ -0,0 +1,73 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # ==== Parameters
6
+ # * resource_type<~String> - Required, Type of resource. [datacenter, image, snapshot, ipblock]
7
+ # * resource_id<~String> - Required, The ID of the specific resource to retrieve information about.
8
+ #
9
+ # ==== Returns
10
+ # * response<~Excon::Response>:
11
+ # * body<~Hash>:
12
+ # * id<~String> - The resource's unique identifier.
13
+ # * type<~String> - The type of the requested resource.
14
+ # * href<~String> - A URI for accessing the resource object.
15
+ # * metadata<~Hash> - Hash containing metadata for the specific resource.
16
+ # * createdDate<~String> - A time and date stamp indicating when the resource was created.
17
+ # * createdBy<~String> - The user who created the resource.
18
+ # * etag<~String> - Resource's ETag.
19
+ # * lastModifiedDate<~String> - A time and date stamp indicating when the resource was last modified.
20
+ # * lastModifiedBy<~String> - The user who last modified the resource.
21
+ # * state<~String> - The current state of the resource. [ AVAILABLE, BUSY, INACTIVE ]
22
+ # * entities<~Hash> - Hash containing groups the resource is associated with.
23
+ # * groups<~Hash> - Hash containing groups associated with the resource.
24
+ # * id<~String> - The resource's unique identifier.
25
+ # * type<~String> - The type of the created resource.
26
+ # * href<~String> - URL to the object's representation (absolute path).
27
+ # * items<~Array>
28
+ # * id<~String> - The resource's unique identifier.
29
+ # * type<~String> - The type of the created resource.
30
+ # * href<~String> - URL to the object's representation (absolute path).
31
+ # * properties<~Hash> - Hash containing the volume properties.
32
+ # * name<~String> - The name of the group.
33
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
34
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
35
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
36
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
37
+ # * entities<~Hash> - A hash containing the group entities.
38
+ # * users<~Hash> - A collection of users that belong to this group.
39
+ # * id<~String> - The resource's unique identifier.
40
+ # * type<~String> - The type of the requested resource.
41
+ # * href<~String> - URL to the object’s representation (absolute path).
42
+ # * items<~Array> - The array containing individual user resources.
43
+ # * resources<~Hash> - A collection of resources that are assigned to this group.
44
+ # * id<~String> - The resource's unique identifier.
45
+ # * type<~String> - The type of the requested resource.
46
+ # * href<~String> - URL to the object’s representation (absolute path).
47
+ # * items<~Array> - An array containing individual resources.
48
+ # * id<~String> - The resource's unique identifier.
49
+ # * type<~String> - The type of the requested resource.
50
+ # * href<~String> - URL to the object’s representation (absolute path).
51
+ #
52
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-a-specific-resource-type]
53
+ def get_resource_by_type(resource_type, resource_id)
54
+ request(
55
+ :expects => [200],
56
+ :method => 'GET',
57
+ :path => "/um/resources/#{resource_type}/#{resource_id}?depth=2"
58
+ )
59
+ end
60
+ end
61
+
62
+ class Mock
63
+ def get_resource_by_type(resource_type, resource_id)
64
+ response = Excon::Response.new
65
+ response.status = 200
66
+ response.body = data[:resources]
67
+
68
+ response
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # List all shareable resources of a specific type.
6
+ # Optionally include their association with groups, permissions that a group has
7
+ # for the resource, and users that are members of the group.
8
+ #
9
+ # ==== Parameters
10
+ # * resource_type<~String> - Required, Type of resource. [datacenter, image, snapshot, ipblock]
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * id<~String> - "resources"
16
+ # * type<~String> - The type of response, in this case it will be "collection".
17
+ # * href<~String> - A URI for accessing the object. "baseurl/um/resources"
18
+ # * items<~Array> - A collection containing the available resources.
19
+ # * id<~String> - The resource's unique identifier
20
+ # * type<~String> - The type of object.
21
+ # * href<~String> - A URI for accessing the object.
22
+ #
23
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-all-resources-of-a-type]
24
+ def get_resources_by_type(resource_type)
25
+ request(
26
+ :expects => [200],
27
+ :method => 'GET',
28
+ :path => "/um/resources/#{resource_type}?depth=2"
29
+ )
30
+ end
31
+ end
32
+
33
+ class Mock
34
+ def get_resources_by_type(resource_type)
35
+ response = Excon::Response.new
36
+ response.status = 200
37
+ response.body = data[:resources]
38
+
39
+ response
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end