Class: SolusVM::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/solusvm/client.rb

Overview

SolusVM::Client is the class for working with clients.

Constant Summary

Constants inherited from Base

Base::VALID_SERVER_TYPES

Instance Attribute Summary

Attributes inherited from Base

#returned_parameters

Instance Method Summary collapse

Methods inherited from Base

#api_endpoint, #api_id, #api_key, #api_login, #api_options, #conn, #initialize, #log_messages, #parse_error, #parse_response, #parse_returned_params_as_list, #perform_request, #ssl_option, #statusmsg, #successful?, #validate_server_type

Constructor Details

This class inherits a constructor from SolusVM::Base

Instance Method Details

#authenticate(username, password) ⇒ Object

Public: Verify a client's login.

username - The client's username password - The client's password

Returns true if the given credentials are correct.


46
47
48
# File 'lib/solusvm/client.rb', line 46

def authenticate(username, password)
  perform_request(action: 'client-authenticate', username: username, password: password)
end

#change_password(username, new_password) ⇒ Object

Public: Change client password for the Solus admin.

username - The client's username new_password - The new password

Returns true if the client's password was successfully changed.


26
27
28
# File 'lib/solusvm/client.rb', line 26

def change_password(username, new_password)
  perform_request(action: "client-updatepassword", username: username, password: new_password)
end

#create(options = {}) ⇒ Object

Public: Creates a client.

options - A Hash of options:

:username
:password
:email
:firstname
:lastname
:company

Returns a Hash with the new client info, or false if the client was not created successfully.


16
17
18
# File 'lib/solusvm/client.rb', line 16

def create(options = {})
  perform_request(options.merge(action: 'client-create')) && returned_parameters
end

#delete(username) ⇒ Object

Public: Deletes an existing client.

username - The client's username

Returns true if the client was successfully deleted.


55
56
57
# File 'lib/solusvm/client.rb', line 55

def delete(username)
  perform_request(action: "client-delete", username: username)
end

#exists?(username) ⇒ Boolean

Public: Checks if a specific client exists.

username - The client's username

Returns true if the client exists.


35
36
37
38
# File 'lib/solusvm/client.rb', line 35

def exists?(username)
  perform_request(action: 'client-checkexists', username: username)
  !!statusmsg.match(/Client exists/i)
end

#listObject

Public: Lists existing clients.

Returns an Array if clients were found, otherwise nil.


62
63
64
65
# File 'lib/solusvm/client.rb', line 62

def list
  perform_request(action: "client-list")
  returned_parameters["clients"]
end