Class: Squall::User
Overview
OnApp User
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#activate(id) ⇒ Object
(also: #unsuspend)
Public: Activate a user.
-
#create(options = {}) ⇒ Object
Public: Create a new User.
-
#data_store_zones(id) ⇒ Object
Public: List data store zones associated with user.
-
#delete(id) ⇒ Object
Public: Delete a user.
-
#edit(id, options = {}) ⇒ Object
Public: Edit a user.
-
#generate_api_key(id) ⇒ Object
Public: Create a new API Key for a user.
-
#hypervisors(id) ⇒ Object
Public: List Hypervisors for a User’s VirtualMachines.
-
#limits(id) ⇒ Object
Public: Show resources available to a user for creating a virtual machine.
-
#list ⇒ Object
Public: Lists all users.
-
#monthly_bills(id) ⇒ Object
Public: List a User’s bills.
-
#network_zones(id) ⇒ Object
Public: List network zones associated with user.
-
#show(id) ⇒ Object
Public: Get info for a user.
-
#stats(id) ⇒ Object
Public: Get the stats for each of a User’s VirtualMachines.
-
#suspend(id) ⇒ Object
Public: Suspend a user.
-
#virtual_machines(id) ⇒ Object
Public: List User’s VirtualMachines.
Methods inherited from Base
#check_config, #default_params, #key_for_class, #request
Instance Method Details
#activate(id) ⇒ Object Also known as: unsuspend
Public: Activate a user.
id - ID of user
Return a Hash.
97 98 99 100 |
# File 'lib/squall/user.rb', line 97 def activate(id) response = request(:get, "/users/#{id}/activate_user.json") response["user"] end |
#create(options = {}) ⇒ Object
Public: Create a new User
options - Params for creating the User:
:login - Login name
:email - Email address
:first_name - First name
:last_name - Last name
:password - Password
:passwor_confirmation - Password
:role - Role to be assigned to user
:time_zone - Time zone for user. If not provided it
will be set automatically.
:locale - Locale for user. If not provided it will
be set automatically.
:status - User's status: `active`, `suspended`,
`deleted`
:billing_plan_id - ID of billing plan to be applied to
user's account
:role_ids - Array of IDs of roles to be assigned to
the user
:suspend_after_hours - Number of hours after which the account
will be automatically suspended
:suspend_at - Time after which the account will
automatically be suspended, formatted
as +YYYYMMDD ThhmmssZ+
Example
create login: 'bob',
email: '[email protected]',
password: 'secret',
password_confirmation: 'secret'
first_name: 'Bob',
last_name: 'Smith'
Returns a Hash.
48 49 50 |
# File 'lib/squall/user.rb', line 48 def create( = {}) request(:post, '/users.json', default_params()) end |
#data_store_zones(id) ⇒ Object
Public: List data store zones associated with user.
id - ID of user
Return a Hash.
159 160 161 162 |
# File 'lib/squall/user.rb', line 159 def data_store_zones(id) response = request(:get, "/users/#{id}/data_store_zones.json") response.collect { |vm| vm['data-store-group']} end |
#delete(id) ⇒ Object
Public: Delete a user.
id - ID of user
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.
Return a Hash.
112 113 114 |
# File 'lib/squall/user.rb', line 112 def delete(id) request(:delete, "/users/#{id}.json") end |
#edit(id, options = {}) ⇒ Object
Public: Edit a user
id - ID of user options - Params for creating the user, see ‘#create`
Returns a Hash.
58 59 60 |
# File 'lib/squall/user.rb', line 58 def edit(id, = {}) request(:put, "/users/#{id}.json", default_params()) end |
#generate_api_key(id) ⇒ Object
Public: Create a new API Key for a user.
id - ID of user
Return a Hash.
77 78 79 80 |
# File 'lib/squall/user.rb', line 77 def generate_api_key(id) response = request(:post, "/users/#{id}/make_new_api_key.json") response["user"] end |
#hypervisors(id) ⇒ Object
Public: List Hypervisors for a User’s VirtualMachines.
id - ID of user
Return a Hash.
149 150 151 152 |
# File 'lib/squall/user.rb', line 149 def hypervisors(id) response = request(:get, "/users/#{id}/hypervisors.json") response.collect { |vm| vm['hypervisor']} end |
#limits(id) ⇒ Object
Public: Show resources available to a user for creating a virtual machine.
id - ID of user
Returns a Hash.
179 180 181 182 |
# File 'lib/squall/user.rb', line 179 def limits(id) response = request(:get, "/users/#{id}/limits.json") response["limits"] end |
#list ⇒ Object
Public: Lists all users.
Returns an Array.
7 8 9 10 |
# File 'lib/squall/user.rb', line 7 def list response = request(:get, '/users.json') response.collect { |user| user['user'] } end |
#monthly_bills(id) ⇒ Object
Public: List a User’s bills.
id - ID of user
Return a Hash.
130 131 132 |
# File 'lib/squall/user.rb', line 130 def monthly_bills(id) request(:get, "/users/#{id}/monthly_bills.json") end |
#network_zones(id) ⇒ Object
Public: List network zones associated with user.
id - ID of user
Return a Hash.
169 170 171 172 |
# File 'lib/squall/user.rb', line 169 def network_zones(id) response = request(:get, "/users/#{id}/network_zones.json") response.collect { |vm| vm['network_group']} end |
#show(id) ⇒ Object
Public: Get info for a user.
id - ID of user
Returns a Hash.
67 68 69 70 |
# File 'lib/squall/user.rb', line 67 def show(id) response = request(:get, "/users/#{id}.json") response["user"] end |
#stats(id) ⇒ Object
Public: Get the stats for each of a User’s VirtualMachines
id - ID of user
Return a Hash.
121 122 123 |
# File 'lib/squall/user.rb', line 121 def stats(id) request(:get, "/users/#{id}/vm_stats.json") end |
#suspend(id) ⇒ Object
Public: Suspend a user.
id - ID of user
Return a Hash.
87 88 89 90 |
# File 'lib/squall/user.rb', line 87 def suspend(id) response = request(:get, "/users/#{id}/suspend.json") response["user"] end |
#virtual_machines(id) ⇒ Object
Public: List User’s VirtualMachines.
id - ID of user
Return a Hash.
139 140 141 142 |
# File 'lib/squall/user.rb', line 139 def virtual_machines(id) response = request(:get, "/users/#{id}/virtual_machines.json") response.collect { |vm| vm['virtual_machine']} end |