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

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

- (Object) authenticate(username, password)

Verify a client's login.

Parameters:

  • 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

- (Object) change_password(username, new_password)

Change client password for the Solus admin.

Parameters:

  • 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

- (Object) create(options = {})

Creates a client.

Parameters:

  • options (defaults to: {})

    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

- (Object) delete(username)

Deletes an existing client.

Parameters:

  • 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

- (Boolean) exists?(username)

Checks if a specific client exists.

Parameters:

  • username

    The client's username

Returns:

  • (Boolean)

    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

- (Object) list

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