View Source

h1. Get all users in the system

h2. Syntax
Users in the system can be accessed using http GET method through below url:
{code}http://localhost:8810/rest/users{code}
The response is of mime type _application/xml_ and the content is XML representation of all users in the system.

h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get all users:
{code}curl -u admin:admin http://localhost:8810/rest/users{code}

h1. Access user by id

h2. Syntax
User can be accessed by id using http GET method through below url:
{code}http://localhost:8810/rest/users/<user id>{code}
The response is of mime type _application/xml_ and the content is XML representation of the user.

h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get user of id _1_:
{code}curl -u admin:admin http://localhost:8810/rest/users/1{code}

h1. Get user display name by id

h2. Syntax
User display name can be accessed by id using http GET method through below url:
{code}http://localhost:8810/rest/users/<user id>/display_name{code}
The response is of mime type _text/plain_ and the content is string representation of the user.

h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get display name of user with id _1_:
{code}curl -u admin:admin http://localhost:8810/rest/users/1/display_name{code}

h1. Update user

h2. Syntax
User can be updated by posting XML representation of the user to below url:
{code}http://localhost:8810/rest/users{code}
Normally you do not need to create the xml from scratch: you may retrieve XML representation of the user using http GET method, modify certain parts of the XML and post back to above url.
The response is of mime type _text/plain_ and the content is string representation of the user id being updated.
{note:title=NOTE}
If you want to change user password, please remove the "secret=hash" attribute from the password element and replace the element text with a plain text password; otherwise, QuickBuild will think that the supplied password has already been hashed.
{note}

h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

h2. Demo
We will use [curl|http://curl.haxx.se/] to demonstrate how to modify password of user _robin_ to be _12345_:
# Retrieve id of user _robin_ using [id service|retrieve object identifier]:
{code}curl http://localhost:8810/rest/ids?user_name=robin{code}
Assume returned id is _2_.
# Retrieve XML representation of user _robin_ into a temp file using below command:
{code}curl -u admin:admin http://localhost:8810/rest/users/2 > tempfile.xml{code}
# Edit _tempfile.xml_ to set content of _password_ element as _12345_, and remove attribute _secret="hash"_. The password element should look like below after modification:
{code}<password>12345</password>{code}
# Post back modified content using below command:
{code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/users{code}

h1. Create user

h2. Syntax
User can be created by posting XML representation of the user to below url:
{code}http://localhost:8810/rest/users{code}
Please note that the posted XML should NOT contain the _id_ element; otherwise, QuickBuild will treat the post as an update to the user with that id.
Normally you do not need to create the XML from scratch: you may retrieve XML representation of a templating user using http GET method, remove the _id_ element, modify certain parts and post back to above url.
The response is of mime type _text/plain_ and the content is string representation of the newly created user id.
{note:title=NOTE}
The password element will contain the attribute "secret" when retrieve the XML representation of an existing user. This attribute should be removed when a new user is created. This tells QuickBuild that the password is in plain text form and should be hashed. However, if you are creating user by copying existing one and want to remain the password, the "secret" attribute should then be preserved.
{note}

h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative rights.

h2. Demo
We will use [curl|http://curl.haxx.se/] to demonstrate how to create a new user _robin_ by copying the existing user _admin_, and change the password to _12345_.
# Get id of user _admin_ with [id service|retrieve object identifier]
{code}curl http://localhost/rest/ids?user_name=admin{code}
Assume returned id is _1_.
# Retrieve XML representation of user _admin_ into a temp file using below command:
{code}curl -u admin:admin http://localhost:8810/rest/users/1 > tempfile.xml{code}
# Edit _tempfile.xml_ to do the following:
## Remove the _id_ element.
## Change content of the _name_ element to be _robin_.
## Change content of _password_ element to be _12345_.
## Remove attribute _secret="hash"_ from the password element.
# Post back modified content using below command:
{code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/users{code}

h1. Delete user

h2. Syntax
User can be deleted using http DELETE method through below url:
{code}http://localhost:8810/rest/users/<user id>{code}
Here _<user id}_ stands for id of the user to be deleted.

h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to delete the user with id _2_:
{code}curl -X DELETE -u admin:admin http://localhost:8810/rest/users/2{code}