Class: Datacentred::Model::User

Inherits:
Base
  • Object
show all
Defined in:
lib/datacentred/model/user.rb

Overview

A user on your DataCentred account.

Users are team members with the ability to log into your DataCentred account.

All users created in your DataCented account are backed by a corresponding user in OpenStack’s identity service (Keystone).

Class Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Datacentred::Model::Base

Class Method Details

.all[User]

List all available users.

 @raise [Errors::Unauthorized] Raised if credentials aren’t valid.

Returns:

  • ([User])

    A collection of all users on this account.



24
25
26
# File 'lib/datacentred/model/user.rb', line 24

def all
  Request::Users.list.map {|user| new user }
end

.create(params) ⇒ Object

Create a new user.

 @return [User] New user.

Parameters:

  • params (Hash)

    User attributes.

Raises:



16
17
18
# File 'lib/datacentred/model/user.rb', line 16

def create(params)
  new Request::Users.create params
end

.destroy(id) ⇒ Boolean

Permanently remove the specified user.

Parameters:

  • id (String)

    The unique identifier for this user.

Returns:

  • (Boolean)

    Confirms the user was destroyed.

Raises:



57
58
59
60
# File 'lib/datacentred/model/user.rb', line 57

def destroy(id)
  Request::Users.destroy id
  true
end

.find(id) ⇒ User

Find a user by unique ID.

Parameters:

  • id (String)

    The unique identifier for this user.

Returns:

  • (User)

    The user, if it exists.

Raises:



34
35
36
# File 'lib/datacentred/model/user.rb', line 34

def find(id)
  new Request::Users.show id
end

.update(id, params) ⇒ User

Update a user by unique ID.

Parameters:

  • id (String)

    The unique identifier for this user.

  • params (Hash)

    User attributes.

Returns:

  • (User)

    The updated user.

Raises:



46
47
48
# File 'lib/datacentred/model/user.rb', line 46

def update(id, params)
  new Request::Users.update id, params
end