squall 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/README.md +64 -41
  4. data/Rakefile +3 -9
  5. data/lib/squall/data_store_zone.rb +20 -26
  6. data/lib/squall/disk.rb +174 -0
  7. data/lib/squall/firewall_rule.rb +34 -41
  8. data/lib/squall/hypervisor.rb +40 -38
  9. data/lib/squall/hypervisor_zone.rb +51 -63
  10. data/lib/squall/ip_address.rb +32 -37
  11. data/lib/squall/ip_address_join.rb +13 -22
  12. data/lib/squall/network.rb +36 -33
  13. data/lib/squall/network_zone.rb +27 -29
  14. data/lib/squall/payment.rb +22 -32
  15. data/lib/squall/role.rb +30 -37
  16. data/lib/squall/statistic.rb +3 -1
  17. data/lib/squall/support/base.rb +35 -31
  18. data/lib/squall/support/config.rb +25 -1
  19. data/lib/squall/support/version.rb +1 -1
  20. data/lib/squall/template.rb +7 -5
  21. data/lib/squall/transaction.rb +6 -4
  22. data/lib/squall/user.rb +84 -83
  23. data/lib/squall/user_group.rb +17 -30
  24. data/lib/squall/virtual_machine.rb +154 -178
  25. data/lib/squall/whitelist.rb +29 -40
  26. data/lib/squall.rb +27 -25
  27. data/spec/spec_helper.rb +6 -11
  28. data/spec/squall/data_store_zone_spec.rb +2 -20
  29. data/spec/squall/disk_spec.rb +189 -0
  30. data/spec/squall/firewall_rule_spec.rb +2 -32
  31. data/spec/squall/hypervisor_spec.rb +3 -47
  32. data/spec/squall/hypervisor_zone_spec.rb +3 -28
  33. data/spec/squall/ip_address_join_spec.rb +1 -15
  34. data/spec/squall/ip_address_spec.rb +10 -35
  35. data/spec/squall/network_spec.rb +20 -31
  36. data/spec/squall/network_zone_spec.rb +2 -36
  37. data/spec/squall/payment_spec.rb +2 -21
  38. data/spec/squall/role_spec.rb +4 -16
  39. data/spec/squall/support/base_spec.rb +10 -16
  40. data/spec/squall/template_spec.rb +0 -4
  41. data/spec/squall/transaction_spec.rb +1 -3
  42. data/spec/squall/user_group_spec.rb +1 -17
  43. data/spec/squall/user_spec.rb +4 -92
  44. data/spec/squall/virtual_machine_spec.rb +8 -242
  45. data/spec/squall/whitelist_spec.rb +2 -40
  46. data/spec/squall_spec.rb +2 -2
  47. data/spec/vcr_cassettes/disk/add_schedule.yml +40 -0
  48. data/spec/vcr_cassettes/disk/auto_backup_off.yml +40 -0
  49. data/spec/vcr_cassettes/disk/auto_backup_on.yml +40 -0
  50. data/spec/vcr_cassettes/disk/backups.yml +40 -0
  51. data/spec/vcr_cassettes/disk/build.yml +40 -0
  52. data/spec/vcr_cassettes/disk/create.yml +40 -0
  53. data/spec/vcr_cassettes/disk/delete.yml +38 -0
  54. data/spec/vcr_cassettes/disk/edit.yml +40 -0
  55. data/spec/vcr_cassettes/disk/iops_usage.yml +40 -0
  56. data/spec/vcr_cassettes/disk/list.yml +40 -0
  57. data/spec/vcr_cassettes/disk/migrate.yml +38 -0
  58. data/spec/vcr_cassettes/disk/schedules.yml +40 -0
  59. data/spec/vcr_cassettes/disk/unlock.yml +40 -0
  60. data/spec/vcr_cassettes/disk/vm_disk_list.yml +40 -0
  61. data/spec/vcr_cassettes/network/rebuild.yml +41 -0
  62. metadata +217 -66
  63. data/.gitignore +0 -13
  64. data/.rspec +0 -2
  65. data/.rvmrc +0 -41
  66. data/.travis.yml +0 -17
  67. data/lib/squall/support/params.rb +0 -50
  68. data/lib/squall/support/yaml.rb +0 -5
  69. data/spec/squall/support/params_spec.rb +0 -195
  70. data/squall.gemspec +0 -32
data/lib/squall/user.rb CHANGED
@@ -1,183 +1,184 @@
1
1
  module Squall
2
2
  # OnApp User
3
3
  class User < Base
4
- # Return a list of all users
4
+ # Public: Lists all users.
5
+ #
6
+ # Returns an Array.
5
7
  def list
6
8
  response = request(:get, '/users.json')
7
9
  response.collect { |user| user['user'] }
8
10
  end
9
11
 
10
-
11
- # Create a new User
12
- #
13
- # ==== Params
14
- #
15
- # * +options+ - Params for creating the User
16
- #
17
- # ==== Options
18
- #
19
- # * +login*+ - Login name
20
- # * +email*+ - Email address
21
- # * +first_name*+ - First name
22
- # * +last_name*+ - Last name
23
- # * +password*+ - Password
24
- # * +passwor_confirmation*+ - Password
25
- # * +role+ - Role to be assigned to user
26
- # * +time_zone+ - Time zone for user. If not provided it will be set automatically.
27
- # * +locale+ - Locale for user. If not provided it will be set automatically.
28
- # * +status+ - User's status: +active+, +suspended+, +deleted+
29
- # * +billing_plan_id+ - ID of billing plan to be applied to user's account
30
- # * +role_ids+ - Array of IDs of roles to be assigned to the user
31
- # * +suspend_after_hours+ - Number of hours after which the account will be automatically suspended
32
- # * +suspend_at+ - Time after which the account will automatically be suspended, formatted as +YYYYMMDD ThhmmssZ+
33
- #
34
- # ==== Example
35
- #
36
- # create :login => 'bob',
37
- # :email => 'something@example.com',
38
- # :password => 'secret',
39
- # :password_confirmation => 'secret'
40
- # :first_name => 'Bob',
41
- # :last_name => 'Smith'
12
+ # Public: Create a new User
13
+ #
14
+ # options - Params for creating the User:
15
+ # :login - Login name
16
+ # :email - Email address
17
+ # :first_name - First name
18
+ # :last_name - Last name
19
+ # :password - Password
20
+ # :passwor_confirmation - Password
21
+ # :role - Role to be assigned to user
22
+ # :time_zone - Time zone for user. If not provided it
23
+ # will be set automatically.
24
+ # :locale - Locale for user. If not provided it will
25
+ # be set automatically.
26
+ # :status - User's status: `active`, `suspended`,
27
+ # `deleted`
28
+ # :billing_plan_id - ID of billing plan to be applied to
29
+ # user's account
30
+ # :role_ids - Array of IDs of roles to be assigned to
31
+ # the user
32
+ # :suspend_after_hours - Number of hours after which the account
33
+ # will be automatically suspended
34
+ # :suspend_at - Time after which the account will
35
+ # automatically be suspended, formatted
36
+ # as +YYYYMMDD ThhmmssZ+
37
+ #
38
+ # Example
39
+ #
40
+ # create login: 'bob',
41
+ # email: 'something@example.com',
42
+ # password: 'secret',
43
+ # password_confirmation: 'secret'
44
+ # first_name: 'Bob',
45
+ # last_name: 'Smith'
46
+ #
47
+ # Returns a Hash.
42
48
  def create(options = {})
43
- params.required(:login, :email,:first_name, :last_name, :password, :password_confirmation).accepts(:role, :time_zone, :locale, :status, :billing_plan_id, :role_ids, :suspend_after_hours, :suspend_at).validate!(options)
44
49
  request(:post, '/users.json', default_params(options))
45
50
  end
46
51
 
47
- # Edit a user
48
- #
49
- # ==== Params
52
+ # Public: Edit a user
50
53
  #
51
- # * +id*+ - ID of user
52
- # * +options+ - Params for creating the user
54
+ # id - ID of user
55
+ # options - Params for creating the user, see `#create`
53
56
  #
54
- # ==== Options
55
- #
56
- # See #create
57
- def edit(id, options={})
58
- params.accepts(:email, :password, :password_confirmation, :first_name, :last_name, :user_group_id, :billing_plan_id, :role_ids, :suspend_at).validate!(options)
57
+ # Returns a Hash.
58
+ def edit(id, options = {})
59
59
  request(:put, "/users/#{id}.json", default_params(options))
60
60
  end
61
61
 
62
- # Return a Hash of the given user
62
+ # Public: Get info for a user.
63
63
  #
64
- # ==== Params
64
+ # id - ID of user
65
65
  #
66
- # * +id*+ - ID of user
66
+ # Returns a Hash.
67
67
  def show(id)
68
68
  response = request(:get, "/users/#{id}.json")
69
69
  response["user"]
70
70
  end
71
71
 
72
- # Create a new API Key for a user
72
+ # Public: Create a new API Key for a user.
73
73
  #
74
- # ==== Params
74
+ # id - ID of user
75
75
  #
76
- # * +id*+ - ID of user
76
+ # Return a Hash.
77
77
  def generate_api_key(id)
78
78
  response = request(:post, "/users/#{id}/make_new_api_key.json")
79
79
  response["user"]
80
80
  end
81
81
 
82
- # Suspend a user
82
+ # Public: Suspend a user.
83
83
  #
84
- # ==== Params
84
+ # id - ID of user
85
85
  #
86
- # * +id*+ - ID of user
86
+ # Return a Hash.
87
87
  def suspend(id)
88
88
  response = request(:get, "/users/#{id}/suspend.json")
89
89
  response["user"]
90
90
  end
91
91
 
92
- # Activate a user
92
+ # Public: Activate a user.
93
93
  #
94
- # ==== Params
94
+ # id - ID of user
95
95
  #
96
- # * +id*+ - ID of user
96
+ # Return a Hash.
97
97
  def activate(id)
98
98
  response = request(:get, "/users/#{id}/activate_user.json")
99
99
  response["user"]
100
100
  end
101
101
  alias_method :unsuspend, :activate
102
102
 
103
- # Delete a user
103
+ # Public: Delete a user.
104
104
  #
105
- # ==== Params
105
+ # id - ID of user
106
106
  #
107
- # * +id*+ - ID of user
107
+ # Note: this does not delete remove a user from the database. First,
108
+ # their status will be set to "Deleted." If you call this method again,
109
+ # the user will be completely removed.
108
110
  #
109
- # Note: this does not delete remove a user from the database. First, their status will be set to "Deleted." If you call this method again, the user will be completely removed.
111
+ # Return a Hash.
110
112
  def delete(id)
111
113
  request(:delete, "/users/#{id}.json")
112
114
  end
113
115
 
114
- # Get the stats for each of a User's VirtualMachines
116
+ # Public: Get the stats for each of a User's VirtualMachines
115
117
  #
116
- # ==== Params
118
+ # id - ID of user
117
119
  #
118
- # * +id*+ - ID of user
120
+ # Return a Hash.
119
121
  def stats(id)
120
122
  request(:get, "/users/#{id}/vm_stats.json")
121
123
  end
122
124
 
123
- # Get a list of bills for the User
125
+ # Public: List a User's bills.
124
126
  #
125
- # ==== Params
127
+ # id - ID of user
126
128
  #
127
- # * +id*+ - ID of user
129
+ # Return a Hash.
128
130
  def monthly_bills(id)
129
- response = request(:get, "/users/#{id}/monthly_bills.json")
131
+ request(:get, "/users/#{id}/monthly_bills.json")
130
132
  end
131
133
 
132
- # Return a list of VirtualMachines for a User
134
+ # Public: List User's VirtualMachines.
133
135
  #
134
- # ==== Params
136
+ # id - ID of user
135
137
  #
136
- # * +id*+ - ID of user
138
+ # Return a Hash.
137
139
  def virtual_machines(id)
138
140
  response = request(:get, "/users/#{id}/virtual_machines.json")
139
141
  response.collect { |vm| vm['virtual_machine']}
140
142
  end
141
143
 
142
- # Return a list of Hypervisors for a User's VirtualMachines
144
+ # Public: List Hypervisors for a User's VirtualMachines.
143
145
  #
144
- # ==== Params
146
+ # id - ID of user
145
147
  #
146
- # * +id*+ - ID of user
148
+ # Return a Hash.
147
149
  def hypervisors(id)
148
150
  response = request(:get, "/users/#{id}/hypervisors.json")
149
151
  response.collect { |vm| vm['hypervisor']}
150
152
  end
151
153
 
152
- # Return a list of data store zones associated with user
154
+ # Public: List data store zones associated with user.
153
155
  #
154
- # ==== Params
156
+ # id - ID of user
155
157
  #
156
- # * +id*+ - ID of user
158
+ # Return a Hash.
157
159
  def data_store_zones(id)
158
160
  response = request(:get, "/users/#{id}/data_store_zones.json")
159
161
  response.collect { |vm| vm['data-store-group']}
160
162
  end
161
163
 
162
- # Return a list of network zones associated with user
164
+ # Public: List network zones associated with user.
163
165
  #
164
- # ==== Params
166
+ # id - ID of user
165
167
  #
166
- # * +id*+ - ID of user
168
+ # Return a Hash.
167
169
  def network_zones(id)
168
170
  response = request(:get, "/users/#{id}/network_zones.json")
169
171
  response.collect { |vm| vm['network_group']}
170
172
  end
171
173
 
172
- # Return a description of resources available to a user for creating a virtual machine
174
+ # Public: Show resources available to a user for creating a virtual machine.
173
175
  #
174
- # ==== Params
176
+ # id - ID of user
175
177
  #
176
- # * +id*+ - ID of user
178
+ # Returns a Hash.
177
179
  def limits(id)
178
180
  response = request(:get, "/users/#{id}/limits.json")
179
181
  response["limits"]
180
182
  end
181
-
182
183
  end
183
184
  end
@@ -1,56 +1,43 @@
1
1
  module Squall
2
2
  # OnApp UserGroup
3
3
  class UserGroup < Base
4
-
5
- # Return a list of all user groups
4
+ # Public: List all user groups.
5
+ #
6
+ # Returns an Array.
6
7
  def list
7
8
  response = request(:get, "/user_groups.json")
8
9
  response.collect { |user_group| user_group['user_group'] }
9
10
  end
10
11
 
11
- # Create a user group
12
- #
13
- # ==== Params
14
- #
15
- # * +options+ - Params for creating the user groups
16
- #
17
- # ==== Options
12
+ # Public: Create a user group.
18
13
  #
19
- # * +label*+ - Label for the user group
14
+ # options - Params for creating the user groups:
15
+ # :label - Label for the user group
20
16
  #
21
- # ==== Example
17
+ # Example
22
18
  #
23
- # create :label => "My new user group"
24
- def create(options={})
25
- params.required(:label).validate!(options)
19
+ # create label: "My new user group"
20
+ def create(options = {})
26
21
  request(:post, "/user_groups.json", default_params(options))
27
22
  end
28
23
 
29
- # Edit a user group
24
+ # Public: Edit a user group.
30
25
  #
31
- # ==== Params
26
+ # id - ID of the user group
27
+ # options - Params for editing the user group, see `#create`
32
28
  #
33
- # * +id*+ - ID of the user group
34
- # * +options+ - Params for creating the user groups
35
- #
36
- # ==== Options
37
- #
38
- # See #create
39
- #
40
- # * +options+ - Params for editing the user group.
41
- def edit(id, options={})
42
- params.accepts(:label).validate!(options)
29
+ # Returns a Hash.
30
+ def edit(id, options = {})
43
31
  request(:put, "/user_groups/#{id}.json", default_params(options))
44
32
  end
45
33
 
46
- # Delete a user group
34
+ # Public: Delete a user group.
47
35
  #
48
- # ==== Params
36
+ # id - ID of the user group
49
37
  #
50
- # * +id*+ - ID of the user group
38
+ # Returns a Hash.
51
39
  def delete(id)
52
40
  request(:delete, "/user_groups/#{id}.json")
53
41
  end
54
-
55
42
  end
56
43
  end