Users
This chapter focuses on services for the users.
Get all users
A GET
to /users
returns all the users.
HTTP request
GET /api/rest/latest/users?page=2&size=1 HTTP/1.1
Accept: application/json
Host: localhost:8080
Request parameters
Parameter | Description |
---|---|
|
number of the page to retrieve (optional) |
|
size of the page to retrieve (optional) |
|
which attributes of the returned entities should be sorted on (optional) |
|
which fields of the elements should be returned (optional) |
|
which type of the test case should be returned (optional) |
HTTP response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 894
{
"_embedded" : {
"users" : [ {
"_type" : "user",
"id" : 486,
"login" : "User-1",
"active" : true,
"group" : "User",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users/486"
}
}
} ]
},
"_links" : {
"first" : {
"href" : "http://localhost:8080/api/rest/latest/users?page=0&size=1"
},
"prev" : {
"href" : "http://localhost:8080/api/rest/latest/users?page=1&size=1"
},
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users?page=2&size=1"
},
"next" : {
"href" : "http://localhost:8080/api/rest/latest/users?page=3&size=1"
},
"last" : {
"href" : "http://localhost:8080/api/rest/latest/users?page=4&size=1"
}
},
"page" : {
"size" : 1,
"totalElements" : 5,
"totalPages" : 5,
"number" : 2
}
}
Response fields
Path | Type | Description |
---|---|---|
|
|
the list of elements for that page |
|
|
the page size for that query |
|
|
total number of elements the client is allowed to read |
|
|
how many pages can be browsed |
|
|
the page number |
|
|
related links |
Links
Relation | Description |
---|---|
|
link to the first page (optional) |
|
link to the previous page (optional) |
|
link to this page |
|
link to the next page (optional) |
|
link to the last page (optional) |
Create user
A POST
to /users
creates a new user.
HTTP request
POST /api/rest/latest/users HTTP/1.1
Accept: application/json
Content-Length: 180
Content-Type: application/json
Host: localhost:8080
{
"_type" : "user",
"first_name" : "Charles",
"last_name" : "Dupond",
"login" : "User-1",
"password" : "123456",
"email" : "charlesdupond@aaaa@aa",
"group" : "User"
}
Request fields
Path | Type | Description |
---|---|---|
|
|
the type of the entity |
|
|
the first name of the user |
|
|
the last name of the user |
|
|
the login of the user |
|
|
the password of the user |
|
|
the email address of the user |
|
|
the group of the user belong (admin or user) |
Request parameters
Parameter | Description |
---|---|
|
which fields of the elements should be returned (optional) |
HTTP response
HTTP/1.1 201 Created
Content-Length: 529
Content-Type: application/json;charset=UTF-8
{
"_type" : "user",
"id" : 987,
"first_name" : "Charles",
"last_name" : "Dupond",
"login" : "User-1",
"email" : "charlesdupond@aaaa.aa",
"active" : true,
"group" : "User",
"teams" : [ ],
"last_connected_on" : "2018-03-05T11:00:00.000+0000",
"created_by" : "admin",
"created_on" : "2017-07-04T10:00:00.000+0000",
"last_modified_by" : "admin",
"last_modified_on" : "2017-07-05T10:00:00.000+0000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users/987"
}
}
}
Response fields
Path | Type | Description |
---|---|---|
|
|
the id of the user |
|
|
whether the user is activate or not |
|
|
the team of the user participate |
|
|
the date of this user was last connected |
|
|
the user who created this user account |
|
|
the date of this user account was created |
|
|
the user who last modified this user account |
|
|
the date of this user account was last modified |
|
|
related links |
Links
Relation | Description |
---|---|
|
link to this user |
Get user
A GET
to /users/{id}
returns the user with the given id.
Path parameters
Parameter | Description |
---|---|
|
the id of the user |
HTTP request
GET /api/rest/latest/users/486 HTTP/1.1
Accept: application/json
Host: localhost:8080
Request parameters
Parameter | Description |
---|---|
|
which fields of the elements should be returned (optional) |
HTTP response
HTTP/1.1 200 OK
Content-Length: 529
Content-Type: application/json;charset=UTF-8
{
"_type" : "user",
"id" : 486,
"first_name" : "Charles",
"last_name" : "Dupond",
"login" : "User-1",
"email" : "charlesdupond@aaaa.aa",
"active" : true,
"group" : "User",
"teams" : [ ],
"last_connected_on" : "2018-02-11T11:00:00.000+0000",
"created_by" : "admin",
"created_on" : "2017-07-04T10:00:00.000+0000",
"last_modified_by" : "admin",
"last_modified_on" : "2017-07-05T10:00:00.000+0000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users/486"
}
}
}
Response fields
Path | Type | Description |
---|---|---|
|
|
the type of the entity |
|
|
the id of the user |
|
|
the first name of the user |
|
|
the last name of the user |
|
|
the login of the user |
|
|
the email address of the user |
|
|
whether the user is activate or not |
|
|
the group of the user belong (admin or user) |
|
|
the team of the user participate |
|
|
the date of this user was last connected |
|
|
the user who created this user account |
|
|
the date of this user account was created |
|
|
the user who last modified this user account |
|
|
the date of this user account was last modified |
|
|
related links |
Links
Relation | Description |
---|---|
|
link to this user |
Modify user
A PATCH
to /users/{id}
modifies the user with the given id.
Path parameters
Parameter | Description |
---|---|
|
the id of the user |
HTTP request
PATCH /api/rest/latest/users/987 HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: localhost:8080
Content-Length: 201
{
"_type" : "user",
"first_name" : "Charles",
"last_name" : "Dupond",
"login" : "User-42",
"password" : "123456",
"email" : "charlesdupond@bbbb@bb",
"active" : false,
"group" : "User"
}
Request fields
Path | Type | Description |
---|---|---|
|
|
the type of the entity |
|
|
the first name of the user |
|
|
the last name of the user |
|
|
the login of the user |
|
|
the password of the user |
|
|
the email address of the user |
|
|
whether the user is activate or not |
|
|
the group of the user belong (admin or user) |
Request parameters
Parameter | Description |
---|---|
|
which fields of the elements should be returned (optional) |
HTTP response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 531
{
"_type" : "user",
"id" : 987,
"first_name" : "Charles",
"last_name" : "Dupond",
"login" : "User-42",
"email" : "charlesdupond@bbbb.bb",
"active" : false,
"group" : "User",
"teams" : [ ],
"last_connected_on" : "2018-03-05T11:00:00.000+0000",
"created_by" : "admin",
"created_on" : "2017-07-04T10:00:00.000+0000",
"last_modified_by" : "admin",
"last_modified_on" : "2017-07-05T10:00:00.000+0000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users/987"
}
}
}
Response fields
Path | Type | Description |
---|---|---|
|
|
the id of the user |
|
|
the team of which the user is a member |
|
|
the date of this user was last connected |
|
|
the user who created this user account |
|
|
the date of this user account was created |
|
|
the user who last modified this user account |
|
|
the date of this user account was last modified |
|
|
related links |
Links
Relation | Description |
---|---|
|
link to this user |
Delete user
A DELETE
to /users/{ids}
deletes one or several user(s) with the given id(s).
Path parameters
Parameter | Description |
---|---|
|
the list of ids of the users |
HTTP request
DELETE /api/rest/latest/users/169 HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: localhost:8080
Get user subscribed teams
A GET
to /users/{id}/teams
returns all the subscribed teams of the user with the given id.
Path parameters
Parameter | Description |
---|---|
|
the id of the user |
HTTP request
GET /api/rest/latest/users/486/teams HTTP/1.1
Accept: application/json
Host: localhost:8080
Request parameters
Parameter | Description |
---|---|
|
number of the page to retrieve (optional) |
|
size of the page to retrieve (optional) |
|
which fields of the elements should be returned (optional) |
HTTP response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1116
{
"_embedded" : {
"teams" : [ {
"_type" : "team",
"id" : 567,
"name" : "Team A",
"description" : "<p>black panther</p>",
"created_by" : "admin",
"created_on" : "2017-07-04T10:00:00.000+0000",
"last_modified_by" : "admin",
"last_modified_on" : "2017-07-05T10:00:00.000+0000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/teams/567"
}
}
}, {
"_type" : "team",
"id" : 568,
"name" : "Team B",
"description" : "<p>black widow</p>",
"created_by" : "admin",
"created_on" : "2017-07-04T10:00:00.000+0000",
"last_modified_by" : "admin",
"last_modified_on" : "2017-07-05T10:00:00.000+0000",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/teams/568"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/rest/latest/users/486/teams?page=0&size=20"
}
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
Response fields
Path | Type | Description |
---|---|---|
|
|
the teams of this user |
|
|
the page size for that query |
|
|
total number of elements the client is allowed to read |
|
|
how many pages can be browsed |
|
|
the page number |
|
|
related links |
Links
Relation | Description |
---|---|
|
link to the first page (optional) |
|
link to the previous page (optional) |
|
link to this page |
|
link to the next page (optional) |
|
link to the last page (optional) |
Subscribe to teams
A POST
to /users/{userId}/teams
with teamIds in request parameters subscribes the user with the given id to these teams.
Path parameters
Parameter | Description |
---|---|
|
the id of the user |
HTTP request
POST /api/rest/latest/users/987/teams HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: localhost:8080
teamIds=486%2C+487
Request parameters
Parameter | Description |
---|---|
|
the list of ids of the teams |
Unsubscribe from teams
A DELETE
to /users/{userId}/teams
with teamIds in request parameters unsubscribes the user with the given id from these teams.
Path parameters
Parameter | Description |
---|---|
|
the id of the user |
HTTP request
DELETE /api/rest/latest/users/987/teams?teamIds=486,487 HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: localhost:8080
Request parameters
Parameter | Description |
---|---|
|
the list of ids of the teams |