User (OpenNebula Cloud API)
Description: declaration: package: org.opennebula.client.user, class: User

Package org.opennebula.client.user

# Class User

java.lang.Object
org.opennebula.client.PoolElement
org.opennebula.client.user.User

public class User extends PoolElement
This class represents an OpenNebula User. It also offers static XML-RPC call wrappers.

- ## Field Summary

  ### Fields inherited from class org.opennebula.client.PoolElement

  `client, id, xml, xpath`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `User(int id, Client client)`
  Creates a new User representation.
  `protected`
  `User(Node xmlElement, Client client)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `OneResponse`
  `addgroup(int gid)`
  Adds the User to a secondary group
  `static OneResponse`
  `addgroup(Client client, int id, int gid)`
  Adds the User to a secondary group
  `static OneResponse`
  `allocate(Client client, String username, String password)`
  Allocates a new user in OpenNebula.
  `static OneResponse`
  `allocate(Client client, String username, String password, String auth, Integer[] gids)`
  Allocates a new user in OpenNebula.
  `OneResponse`
  `chauth(String auth)`
  Changes the auth driver of the given user
  `OneResponse`
  `chauth(String auth, String password)`
  Changes the auth driver and the password of the given user
  `static OneResponse`
  `chauth(Client client, int id, String auth, String password)`
  Changes the auth driver and the password of the given user
  `OneResponse`
  `chgrp(int gid)`
  Changes the main group of the given user
  `static OneResponse`
  `chgrp(Client client, int id, int gid)`
  Changes the main group of the given user
  `OneResponse`
  `delete()`
  Deletes the user from OpenNebula.
  `static OneResponse`
  `delete(Client client, int id)`
  Deletes a user from OpenNebula.
  `OneResponse`
  `delgroup(int gid)`
  Removes the User from a secondary group.
  `static OneResponse`
  `delgroup(Client client, int id, int gid)`
  Removes the User from a secondary group.
  `OneResponse`
  `enable(boolean enable)`
  Enables or disables a User
  `static OneResponse`
  `enable(Client client, int id, boolean enable)`
  Enables or disables a User
  `OneResponse`
  `info()`
  Loads the xml representation of the user.
  `static OneResponse`
  `info(Client client, int id)`
  Retrieves the information of the given user.
  `static OneResponse`
  `info(Client client, int id, boolean decrypt)`
  Retrieves the information of the given User.
  `boolean`
  `isEnabled()`
  Returns true if the user is enabled.
  `OneResponse`
  `login(String token, int expire)`
  Sets the LOGIN_TOKEN for the user.
  `OneResponse`
  `login(String token, int expire, int egid)`
  Sets the LOGIN_TOKEN for the user.
  `static OneResponse`
  `login(Client client, String username, String token, int expire)`
  Sets the LOGIN_TOKEN for the user
  `static OneResponse`
  `login(Client client, String username, String token, int expire, int egid)`
  Sets the LOGIN_TOKEN for the user
  `OneResponse`
  `passwd(String password)`
  Changes the password for the user.
  `static OneResponse`
  `passwd(Client client, int id, String password)`
  Changes the password for the given user.
  `OneResponse`
  `setQuota(String quota_template)`
  Replaces the user quota template contents.
  `static OneResponse`
  `setQuota(Client client, int id, String quota_template)`
  Replaces the user quota template contents.
  `OneResponse`
  `update(String new_template)`
  Replaces the user template contents.
  `OneResponse`
  `update(String new_template, boolean append)`
  Replaces the user template contents.
  `static OneResponse`
  `update(Client client, int id, String new_template, boolean append)`
  Replaces the user template contents.

  ### Methods inherited from class org.opennebula.client.PoolElement

  `chmod, chmod, chmod, getId, getName, gid, id, processInfo, state, uid, xpath`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### User

    public User(int id, Client client)
    Creates a new User representation.
    Parameters:
      `id` - The user id (uid).
      `client` - XML-RPC Client.

  - ### User

    protected User(Node xmlElement, Client client)
    See Also:
      - `PoolElement`

- ## Method Details

  - ### allocate

    public static OneResponse allocate(Client client, String username, String password)
    Allocates a new user in OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `username` - Username for the new user.
      `password` - Password for the new user
    Returns:
      If successful the message contains the associated id (int uid) generated for this user.

  - ### allocate

    public static OneResponse allocate(Client client, String username, String password, String auth, Integer[] gids)
    Allocates a new user in OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `username` - Username for the new user.
      `password` - Password for the new user
      `auth` - Auth driver for the new user.
      `gids` - Group IDs. The first ID will be used as the main group. This array can be empty, in which case the default group will be used.
    Returns:
      If successful the message contains the associated id (int uid) generated for this user.

  - ### info

    public static OneResponse info(Client client, int id)
    Retrieves the information of the given user.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) for the user to retrieve the information from.
    Returns:
      if successful the message contains the string with the information about the user returned by OpenNebula.

  - ### info

    public static OneResponse info(Client client, int id, boolean decrypt)
    Retrieves the information of the given User.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The User id for the User to retrieve the information from
      `decrypt` - If true decrypt sensitive attributes
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### delete

    public static OneResponse delete(Client client, int id)
    Deletes a user from OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to delete.
    Returns:
      If an error occurs the error message contains the reason.

  - ### passwd

    public static OneResponse passwd(Client client, int id, String password)
    Changes the password for the given user.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to modify.
      `password` - The new password.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chgrp

    public static OneResponse chgrp(Client client, int id, int gid)
    Changes the main group of the given user
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to modify.
      `gid` - The new group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### addgroup

    public static OneResponse addgroup(Client client, int id, int gid)
    Adds the User to a secondary group
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to modify.
      `gid` - The new group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### delgroup

    public static OneResponse delgroup(Client client, int id, int gid)
    Removes the User from a secondary group. Fails if the group is the main one
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to modify.
      `gid` - The group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chauth

    public static OneResponse chauth(Client client, int id, String auth, String password)
    Changes the auth driver and the password of the given user
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id (uid) of the target user we want to modify.
      `auth` - The new auth driver.
      `password` - The new password. If it is an empty string, the user password is not changed
    Returns:
      If an error occurs the error message contains the reason.

  - ### update

    public static OneResponse update(Client client, int id, String new_template, boolean append)
    Replaces the user template contents.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id of the target user we want to modify.
      `new_template` - New template contents.
      `append` - True to append new attributes instead of replace the whole template
    Returns:
      If successful the message contains the user id.

  - ### setQuota

    public static OneResponse setQuota(Client client, int id, String quota_template)
    Replaces the user quota template contents.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id of the target user we want to modify.
      `quota_template` - New quota template contents.
    Returns:
      If successful the message contains the user id.

  - ### login

    public static OneResponse login(Client client, String username, String token, int expire)
    Sets the LOGIN_TOKEN for the user
    Parameters:
      `client` - XML-RPC Client.
      `username` - of the user
      `token` - the login token, if empty OpenNebula will generate one
      `expire` - valid period of the token in secs. If <= 0 the token will be reset
    Returns:
      token in case of success, Error otherwise

  - ### login

    public static OneResponse login(Client client, String username, String token, int expire, int egid)
    Sets the LOGIN_TOKEN for the user
    Parameters:
      `client` - XML-RPC Client.
      `username` - of the user
      `token` - the login token, if empty OpenNebula will generate one
      `expire` - valid period of the token in secs. If <= 0 the token will be reset
      `egid` - effective GID to use with this token. To use the current GID and user groups set it to -1
    Returns:
      token in case of success, Error otherwise

  - ### enable

    public static OneResponse enable(Client client, int id, boolean enable)
    Enables or disables a User
    Parameters:
      `client` - XML-RPC Client.
      `id` - The user id of the target user we want to modify.
      `enable` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the User id.

  - ### info

    public OneResponse info()
    Loads the xml representation of the user. The info is also stored internally.
    See Also:
      - `info(Client, int)`

  - ### delete

    public OneResponse delete()
    Deletes the user from OpenNebula.
    See Also:
      - `delete(Client, int)`

  - ### passwd

    public OneResponse passwd(String password)
    Changes the password for the user.
    Parameters:
      `password` - The new password.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chgrp

    public OneResponse chgrp(int gid)
    Changes the main group of the given user
    Parameters:
      `gid` - The new group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### addgroup

    public OneResponse addgroup(int gid)
    Adds the User to a secondary group
    Parameters:
      `gid` - The new group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### delgroup

    public OneResponse delgroup(int gid)
    Removes the User from a secondary group. Fails if the group is the main one
    Parameters:
      `gid` - The group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chauth

    public OneResponse chauth(String auth, String password)
    Changes the auth driver and the password of the given user
    Parameters:
      `auth` - The new auth driver.
      `password` - The new password. If it is an empty string, the user password is not changed
    Returns:
      If an error occurs the error message contains the reason.

  - ### chauth

    public OneResponse chauth(String auth)
    Changes the auth driver of the given user
    Parameters:
      `auth` - The new auth driver.
    Returns:
      If an error occurs the error message contains the reason.

  - ### update

    public OneResponse update(String new_template)
    Replaces the user template contents.
    Parameters:
      `new_template` - New template contents.
    Returns:
      If successful the message contains the user id.

  - ### update

    public OneResponse update(String new_template, boolean append)
    Replaces the user template contents.
    Parameters:
      `new_template` - New template contents.
      `append` - True to append new attributes instead of replace the whole template
    Returns:
      If successful the message contains the user id.

  - ### setQuota

    public OneResponse setQuota(String quota_template)
    Replaces the user quota template contents.
    Parameters:
      `quota_template` - New quota template contents.
    Returns:
      If successful the message contains the user id.

  - ### login

    public OneResponse login(String token, int expire)
    Sets the LOGIN_TOKEN for the user. The method info() must be called before.
    Parameters:
      `token` - the login token, if empty OpenNebula will generate one
      `expire` - valid period of the token in secs. If <= 0 the token will be reset
    Returns:
      token in case of success, Error otherwise

  - ### login

    public OneResponse login(String token, int expire, int egid)
    Sets the LOGIN_TOKEN for the user. The method info() must be called before.
    Parameters:
      `token` - the login token, if empty OpenNebula will generate one
      `expire` - valid period of the token in secs. If <= 0 the token will be reset
      `egid` - effective GID to use with this token. To use the current GID and user groups set it to -1
    Returns:
      token in case of success, Error otherwise

  - ### enable

    public OneResponse enable(boolean enable)
    Enables or disables a User
    Parameters:
      `enable` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the User id.

  - ### isEnabled

    public boolean isEnabled()
    Returns true if the user is enabled.
    Returns:
      True if the user is enabled.