(Quick Reference)
6 Assign authority to user - Reference Documentation
Version: 2.1
6 Assign authority to user
6.1 List
Service: List of assigned users to authorities (roles)
Description: This web service returns a json list of couples (user,authority).
URL:
https://BASE_URL/api/VERSION/userAuthorities
Method: GET
Parameters:
Pagination parameters:
Name | Description | Type | Required | Possible values |
---|
max | Limits the number of resources requested to return. | Integer | no | |
offset | Tells where to start returning records from the entire set of results. | Integer | no | |
order | Orders ascending or descending. | Integer | no | asc,desc |
sort | Orders the results by the specified field. | String | no | |
The max
parameter is set to 100
by default.
Filters parameters:
Name | Description | Type | Required | Example values |
---|
dateCreated_gt | Filters by the resource's creation date time and operator greater than | Date | no | 2016-08-15T14:52:48Z |
dateCreated_gte | Filters by the resource's creation date time and operator greater than or equal | Date | no | |
dateCreated_lt | Filters by the resource's creation date time and operator less than | Date | no | |
dateCreated_lte | Filters by the resource's creation date time and operator less than or equal | Date | no | |
lastUpdated_gt | Filters by the resource's last-modified date time and operator greater than | Date | no | |
lastUpdated_gte | Filters by the resource's last-modified date time and operator greater than or equal | Date | no | |
lastUpdated_lt | Filters by the resource's last-modified date time and operator less than | Date | no | |
lastUpdated_lte | Filters by the resource's last-modified date time and operator less than or equal | Date | no | |
employeeReference | Wildcard search by the resource's employee reference | String | no | |
Dates should be formatted as the ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ)
Success Output
Success case: response.status=200
{
"paging": {
"total": 5,
"max": 1,
"offset": 0,
"previous": null,
"next": "/api/v2.0/userAuthorities?max=1&offset=1&sort=dateCreated&order=asc"
},
"data": [
{
"id": 1,
"user": {
"id": 1,
"reference": "emp04",
"href": "/api/v2.0/users/1"
},
"authority": {
"id": 24,
"name": "Sales",
"href": "/api/v2.0/authorities/24"
},
"dateCreated": "2015-12-15T09:03:49Z",
"lastUpdated": "2015-12-15T09:03:49Z"
}
]
}
Failure Output
Failure case:response.status = 400
{
"error": "invalid_param",
"error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}
{
"error": "invalid_datetime_format",
"error_description": "Invalid datetime filter (not ISO-8601 formatted): [2016-08-1Z]"
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
6.2 Show
Service: Show an assigned user to an authority (role)
Description: This web service return an existing assigned user to an authority object of the specified id in JSON format
Method: GET
URL:
https://BASE_URL/api/VERSION/userAuthorities/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | id of the desired record | Long | Yes | 100 |
URL with external_id:
https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
userId | reference of the user | String | Yes | U-002 |
authorityId | name of the authority | String | Yes | CEO |
Success Output
Success case: response.status = 200
{
"id": 1,
"user": {
"id": 1,
"reference": "emp04",
"href": "/api/v2.0/users/1"
},
"authority": {
"id": 24,
"name": "Sales",
"href": "/api/v2.0/authorities/24"
},
"dateCreated": "2015-12-15T09:03:49Z",
"lastUpdated": "2015-12-15T09:03:49Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "invalid_param_type",
"error_description": "The type of parameter id you provided is not valid for this request."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The userAuthority with the id 100 doesn't exist."
}
6.3 Create
Service: Assign a route to an employee
Description: This web service is used to assign an employee which is not assigned before to a route
URL:
https://BASE_URL/api/VERSION/userAuthorities
Method: POST
Request content type: application/json
Parameters:
Name | Description | Type | Required | Example values |
---|
userId | the id of user to be assigned | Long/String | Yes | 1 |
authorityId | the id of the authority | Long/String | Yes | 2 |
useExternalId | By default, it is set to false. set it to true if you want to use external ids. | Boolean | no | true , false |
Success Output
Success case: response.status = 201
{
"id": 34,
"user": {
"id": 37,
"reference": "test",
"href": "/api/v2.0/users/37"
},
"authority": {
"id": 19,
"name": "Marketing Director",
"href": "/api/v2.0/authorities/19"
},
"dateCreated": "2017-02-16T10:46:24Z",
"lastUpdated": "2017-02-16T10:46:24Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "invalid_param_type",
"error_description": "The type of parameter authorityId you provided is not valid for this request."
}
{
"error": "missing_param",
"error_description": "userId parameter is missing"
}
{
"error": "already_assigned",
"error_description": "User is already assigned to authority: ADMIN."
}
{
"error": "save_failed",
"error_description": "Failed to save instance"
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The user with the id 11111 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
6.4 Update
Service: Update an assigned user to an authority (role)
Description: This web service is used to update an assigned user to an authority
Method: PUT
Request content type: application/json
URL:
https://BASE_URL/api/VERSION/userAuthorities/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | id of the desired record to update | Long | Yes | 123 |
userId | the id of user to be assigned | Long | Yes | 1 |
authorityId | the id of the authority | Long | Yes | 2 |
URL with external_id:
https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
userId | reference of the user | String | Yes | U-002 |
authorityId | name of the authority | String | Yes | CEO |
Success Output
Success case: response.status = 200
{
"id": 34,
"user": {
"id": 37,
"reference": "test",
"href": "/api/v2.0/users/37"
},
"authority": {
"id": 21,
"name": "Sales Director",
"href": "/api/v2.0/authorities/21"
},
"dateCreated": "2017-02-16T10:46:24Z",
"lastUpdated": "2017-02-16T10:54:51Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "already_assigned",
"error_description": "User is already assigned to authority: CEO."
}
{
"error": "invalid_param_type",
"error_description": "The type of parameter authorityId you provided is not valid for this request."
}
{
"error": "save_failed",
"error_description": "Failed to save instance"
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The authority with the id 17000 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
6.5 Delete
Service: Dissociate a user from an authority (role)
Description: This web service is used to dissociate an assigned user to a role and delete it.
Method: DELETE
URL:
https://BASE_URL/api/VERSION/userAuthorities/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | id of the desired record to delete | Long | Yes | 7 |
URL with external_id:
https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
userId | reference of the user | String | Yes | U-002 |
authorityId | name of the authority | String | Yes | CEO |
Success Output
Success case: response.status = 200
{
"success": "true",
"success_description": "Instance deleted successfully"
}
Failure Output
Failure case:response.status = 400
{
"error":"invalid_param_type",
"error_description": "The type of parameter id you provided is not valid for this request."
}
{
"error": "delete_failed",
"error_description": "Failed to delete instance."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The user authority with the id 35 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}