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,52 @@
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, The ID of the specific group to retrieve.
9
+ # * resource_id<~String> - Required, The ID of the specific resource to retrieve.
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 share 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/#retrieve-a-share]
26
+ def get_share(group_id, resource_id)
27
+ request(
28
+ :expects => [200],
29
+ :method => "GET",
30
+ :path => "/um/groups/#{group_id}/shares/#{resource_id}"
31
+ )
32
+ end
33
+ end
34
+
35
+ class Mock
36
+ def get_share(group_id, resource_id)
37
+ if share = data[:shares]['items'].find do |shr|
38
+ shr["id"] == resource_id
39
+ end
40
+ else
41
+ raise Excon::Error::HTTPStatus, "The requested resource could not be found"
42
+ end
43
+
44
+ response = Excon::Response.new
45
+ response.status = 200
46
+ response.body = share
47
+ response
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,72 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieve details about a specific user including what groups and resources the user is associated with.
6
+ #
7
+ # ==== Parameters
8
+ # * user_id<~String> - Required, UUID of the user
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 resource.
15
+ # * href<~String> - URL to the object's representation (absolute path).
16
+ # * metadata<~Hash> - Hash containing metadata for the user.
17
+ # * etag<~String> - ETag of the user.
18
+ # * creationDate<~String> - A time and date stamp indicating when the user was created.
19
+ # * lastLogin<~String> - A time and date stamp indicating when the user last logged in.
20
+ # * properties<~Hash> - Hash containing the user's properties.
21
+ # * firstname<~String> - The first name of the user.
22
+ # * lastname<~String> - The last name of the user.
23
+ # * email<~String> - The e-mail address of the user.
24
+ # * administrator<~Boolean> - Indicates if the user has administrative rights.
25
+ # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user.
26
+ # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user.
27
+ # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of.
28
+ # * owns<~Hash> - Hash containing resources the user owns.
29
+ # * id<~String> - The resource's unique identifier.
30
+ # * type<~String> - The type of the created resource.
31
+ # * href<~String> - URL to the object's representation (absolute path).
32
+ # * items<~Array>
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
+ # * groups<~Hash> - Hash containing groups the user is a member of.
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
+ # * items<~Array>
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
+ #
45
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#retrieve-a-user]
46
+ def get_user(user_id)
47
+ request(
48
+ :expects => [200],
49
+ :method => "GET",
50
+ :path => "/um/users/#{user_id}?depth=1"
51
+ )
52
+ end
53
+ end
54
+
55
+ class Mock
56
+ def get_user(user_id)
57
+ if user = data[:users]['items'].find do |usr|
58
+ usr["id"] == user_id
59
+ end
60
+ else
61
+ raise Excon::Error::HTTPStatus, "The requested resource could not be found"
62
+ end
63
+
64
+ response = Excon::Response.new
65
+ response.status = 200
66
+ response.body = user
67
+ response
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Remove a user from a group.
6
+ #
7
+ # ==== Parameters
8
+ # * group_id<~String> - Required, The ID of the specific group you want to remove a user from.
9
+ # * user_id<~String> - Required, The ID of the specific user to remove from the group.
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/#remove-user-from-a-group]
16
+ def remove_user_from_group(group_id, user_id)
17
+ request(
18
+ :expects => [202],
19
+ :method => 'DELETE',
20
+ :path => "/um/groups/#{group_id}/users/#{user_id}"
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def remove_user_from_group(group_id, user_id)
27
+ response = Excon::Response.new
28
+ response.status = 202
29
+
30
+ if group = data[:groups]['items'].find do |grp|
31
+ grp["id"] == group_id
32
+ end
33
+ else
34
+ raise Excon::Error::HTTPStatus, "The requested resource could not be found"
35
+ end
36
+
37
+ if user = data[:users]['items'].find do |usr|
38
+ usr["id"] == user_id
39
+ end
40
+ else
41
+ raise Excon::Error::HTTPStatus, "The requested resource could not be found"
42
+ end
43
+
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,85 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a group.
6
+ # Normally a PUT request would require that you pass all the attributes and values.
7
+ # In this implementation, you must supply the name, even if it isn't being changed.
8
+ # As a convenience, the other four attributes will default to false.
9
+ # You should explicitly set them to true if you want to have them enabled.
10
+ #
11
+ # ==== Parameters
12
+ # * group_id<~String> - Required, The ID of the specific group to update.
13
+ # * options<~Hash>:
14
+ # * name<~String> - Required, The name of the group.
15
+ # * createDataCenter<~Integer> - The group will be allowed to create virtual data centers.
16
+ # * createSnapshot<~Integer> - The group will be allowed to create snapshots.
17
+ # * reserveIp<~Integer> - The group will be allowed to reserve IP addresses.
18
+ # * accessActivityLog<~Integer> - The group will be allowed to access the activity log.
19
+ #
20
+ # ==== Returns
21
+ # * response<~Excon::Response>:
22
+ # * body<~Hash>:
23
+ # * id<~String> - The resource's unique identifier
24
+ # * type<~String> - The type of the requested resource
25
+ # * href<~String> - URL to the object’s representation (absolute path)
26
+ # * properties<~Hash> - Hash containing the volume properties.
27
+ # * name<~String> - The name of the group.
28
+ # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers.
29
+ # * createSnapshot<~Boolean> - The group will be allowed to create snapshots.
30
+ # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses.
31
+ # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log.
32
+ # * entities<~Hash> - A hash containing the group entities.
33
+ # * users<~Hash> - A collection of users that belong 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> - The array containing individual user resources.
38
+ # * resources<~Hash> - A collection of resources that are assigned 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> - An array containing individual resources.
43
+ # * id<~String> - The resource's unique identifier.
44
+ # * type<~String> - The type of the requested resource.
45
+ # * href<~String> - URL to the object’s representation (absolute path).
46
+ #
47
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-group]
48
+ def update_group(group_id, options = {})
49
+ group = {
50
+ :properties => options
51
+ }
52
+
53
+ request(
54
+ :expects => [202],
55
+ :method => 'PUT',
56
+ :path => "/um/groups/#{group_id}",
57
+ :body => Fog::JSON.encode(group)
58
+ )
59
+ end
60
+ end
61
+
62
+ class Mock
63
+ def update_group(group_id, options = {})
64
+ if group = data[:groups]['items'].find do |grp|
65
+ grp["id"] == group_id
66
+ end
67
+ group['name'] = options[:name]
68
+ group['createDataCenter'] = options[:create_data_center] if options[:create_data_center]
69
+ group['createSnapshot'] = options[:create_snapshot] if options[:create_snapshot]
70
+ group['reserveIp'] = options[:reserve_ip] if options[:reserve_ip]
71
+ group['accessActivityLog'] = options[:access_activity_log] if options[:access_activity_log]
72
+ else
73
+ raise Excon::Error::HTTPStatus, 'The requested resource could not be found'
74
+ end
75
+
76
+ response = Excon::Response.new
77
+ response.status = 202
78
+ response.body = group
79
+
80
+ response
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -31,6 +31,7 @@ module Fog
31
31
  # * properties<~Hash> - Hash containing the LAN properties
32
32
  # * name<~String> - The name of the LAN
33
33
  # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
34
+ # * ipFailover<~Array> - Attributes related to IP failover groups
34
35
  # * entities<~Hash> - Hash containing the LAN entities
35
36
  # * nics<~Hash> - Hash containing the NIC properties
36
37
  # * id<~String> - The resource's unique identifier
@@ -0,0 +1,67 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a group.
6
+ # Normally a PUT request would require that you pass all the attributes and values.
7
+ # In this implementation, you must supply the name, even if it isn't being changed.
8
+ # As a convenience, the other four attributes will default to false.
9
+ # You should explicitly set them to true if you want to have them enabled.
10
+ #
11
+ # ==== Parameters
12
+ # * group_id<~String> - Required, The ID of the specific group to update.
13
+ # * resource_id<~String> - Required, The ID of the specific resource to update.
14
+ # * properties<~Hash>: - A collection of properties.
15
+ # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource.
16
+ # * sharePrivilege<~Boolean> - The group has permission to share this resource.
17
+ #
18
+ # ==== Returns
19
+ # * response<~Excon::Response>:
20
+ # * body<~Hash>:
21
+ # * id<~String> - Id of the requested resource
22
+ # * type<~String> - type of the requested resource
23
+ # * href<~String> - url to the requested resource
24
+ # * items<~Array>
25
+ # * id<~String> - The resource's unique identifier
26
+ # * type<~String> - The type of the requested resource
27
+ # * href<~String> - URL to the object’s representation (absolute path)
28
+ # * properties<~Hash> - Hash containing the share properties.
29
+ # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource.
30
+ # * sharePrivilege<~Boolean> - The group has permission to share this resource.
31
+ #
32
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-share]
33
+ def update_share(group_id, resource_id, options = {})
34
+ share = {
35
+ :properties => options
36
+ }
37
+
38
+ request(
39
+ :expects => [202],
40
+ :method => 'PUT',
41
+ :path => "/um/groups/#{group_id}/shares/#{resource_id}",
42
+ :body => Fog::JSON.encode(share)
43
+ )
44
+ end
45
+ end
46
+
47
+ class Mock
48
+ def update_share(group_id, resource_id, options = {})
49
+ if share = data[:shares]['items'].find do |shr|
50
+ shr["id"] == resource_id
51
+ end
52
+ share['editPrivilege'] = options[:edit_privilege] if options[:edit_privilege]
53
+ share['sharePrivilege'] = options[:share_privilege] if options[:share_privilege]
54
+ else
55
+ raise Excon::Error::HTTPStatus, 'The requested resource could not be found'
56
+ end
57
+
58
+ response = Excon::Response.new
59
+ response.status = 202
60
+ response.body = share
61
+
62
+ response
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,94 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update details about a specific user including their privileges.
6
+ # With this PUT operation, you need to supply values for all the attributes,
7
+ # even if you are only updating some of them.
8
+ #
9
+ # The password attribute is immutable. It is not allowed in update requests.
10
+ # It is recommended that a new user log into the DCD and change their password.
11
+ #
12
+ # ==== Parameters
13
+ # * user_id<~String> - Required, The ID of the specific user to update.
14
+ # * options<~Hash>:
15
+ # * firstname<~String> - Required, The name of the group.
16
+ # * lastname<~String> - Required, The group will be allowed to create virtual data centers.
17
+ # * email<~String> - Required, The group will be allowed to create snapshots.
18
+ # * administrator<~Boolean> - Required, The group will be allowed to access the activity log.
19
+ # * forceSecAuth<~Boolean> - Required, The group will be allowed to access the activity log.
20
+ #
21
+ # ==== Returns
22
+ # * response<~Excon::Response>:
23
+ # * body<~Hash>:
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
+ # * metadata<~Hash> - Hash containing metadata for the user.
28
+ # * etag<~String> - ETag of the user.
29
+ # * creationDate<~String> - A time and date stamp indicating when the user was created.
30
+ # * lastLogin<~String> - A time and date stamp indicating when the user last logged in.
31
+ # * properties<~Hash> - Hash containing the user's properties.
32
+ # * firstname<~String> - The first name of the user.
33
+ # * lastname<~String> - The last name of the user.
34
+ # * email<~String> - The e-mail address of the user.
35
+ # * administrator<~Boolean> - Indicates if the user has administrative rights.
36
+ # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user.
37
+ # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user.
38
+ # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of.
39
+ # * owns<~Hash> - Hash containing resources the user owns.
40
+ # * id<~String> - The resource's unique identifier.
41
+ # * type<~String> - The type of the created resource.
42
+ # * href<~String> - URL to the object's representation (absolute path).
43
+ # * items<~Array>
44
+ # * id<~String> - The resource's unique identifier.
45
+ # * type<~String> - The type of the created resource.
46
+ # * href<~String> - URL to the object's representation (absolute path).
47
+ # * groups<~Hash> - Hash containing groups the user is a member of.
48
+ # * id<~String> - The resource's unique identifier.
49
+ # * type<~String> - The type of the created resource.
50
+ # * href<~String> - URL to the object's representation (absolute path).
51
+ # * items<~Array>
52
+ # * id<~String> - The resource's unique identifier.
53
+ # * type<~String> - The type of the created resource.
54
+ # * href<~String> - URL to the object's representation (absolute path).
55
+ #
56
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-user]
57
+ def update_user(user_id, options = {})
58
+ user = {
59
+ :properties => options
60
+ }
61
+
62
+ request(
63
+ :expects => [202],
64
+ :method => 'PUT',
65
+ :path => "/um/users/#{user_id}",
66
+ :body => Fog::JSON.encode(user)
67
+ )
68
+ end
69
+ end
70
+
71
+ class Mock
72
+ def update_user(user_id, options = {})
73
+ if user = data[:users]['items'].find do |usr|
74
+ usr["id"] == user_id
75
+ end
76
+ user['firstname'] = options[:firstname]
77
+ user['lastname'] = options[:lastname]
78
+ user['email'] = options[:email]
79
+ user['administrator'] = options[:administrator]
80
+ user['forceSecAuth'] = options[:force_sec_auth]
81
+ else
82
+ raise Excon::Error::HTTPStatus, 'The requested resource could not be found'
83
+ end
84
+
85
+ response = Excon::Response.new
86
+ response.status = 202
87
+ response.body = user
88
+
89
+ response
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module ProfitBricks
3
- VERSION = "3.0.0".freeze
3
+ VERSION = "4.0.0".freeze
4
4
  end
5
5
  end
@@ -4,6 +4,12 @@ Shindo.tests('Fog::Compute[:profitbricks] | compute models', %w(profitbricks com
4
4
  tests('success') do
5
5
  Excon.defaults[:connection_timeout] = 500
6
6
 
7
+ tests('should retrieve contract resources').succeeds do
8
+ contract_resources = compute.contract_resources.all
9
+
10
+ !contract_resources.empty?
11
+ end
12
+
7
13
  tests('should create a datacenter').succeeds do
8
14
  datacenter = compute.datacenters.create(:name => 'fog-demo',
9
15
  :location => 'de/fra',