openspecimen/rest/ng/rbac/subjects/{userId}/roles/
Use this resource to assign role to user. Use HTTP POST method to call this API by passing the below details in JSON format.
Below are the attributes which need to be sent in the request body:
Parameter | Details |
---|---|
site | Site on which wanted to assign role. Site details in json format. Example : {id: 1, name: "Site1"} |
collectionProtocol | Collection protocol on which wanted to assign role. Collection protocol details in json format. Example: {"title": "Lung cancer protocol", shortTitle: "LCP"} |
role | Role which wanted to assign on given site and cp for user. Role details in json format. Example: {name: "Technician"} |
http[s]:<host>:<port>/openspecimen/rest/ng/rbac/subjects/{userId}/roles/
Use this URL to update user in openSpecimen application.
Result:
The response of this request will contains the details of the updated user.
Below is the example of the update user:
URL | openspecimen/rest/ng/users/1 |
Method | PUT |
Request | application/json |
json | { { "site":{"name":"Porder Drive"}, "collectionProtocol":{"shortTitle":"LCP"}, "role":{"name":"Technician"} } |
Response | { "role": { "id": 4 "name": "Technician" "description": "User who collects and processes specimens." "parentRoleName": null "childRoles": [0] "acl": { "id": 14 "resourceName": "StorageContainer" "operations": [1]0: { "resourceInstanceId": null "operationName": "Read" } } 1: { "id": 44 "resourceName": "ShippingAndTracking" "operations": [ 4]0: { "resourceInstanceId": null "operationName": "Create" } 1: { "resourceInstanceId": null "operationName": "Update" } - 2: { "resourceInstanceId": null "operationName": "Delete" } - 3: { "resourceInstanceId": null "operationName": "Read" } - - } - 2: { "id": 15 "resourceName": "CollectionProtocol" "operations": [ 1]0: { "resourceInstanceId": null "operationName": "Read" } - - } - 3: { "id": 18 "resourceName": "Order" "operations": [ 4]0: { "resourceInstanceId": null "operationName": "Read" } - 1: { "resourceInstanceId": null "operationName": "Create" } - 2: { "resourceInstanceId": null "operationName": "Delete" } - 3: { "resourceInstanceId": null "operationName": "Update" } - - } - 4: { "id": 17 "resourceName": "VisitAndSpecimen" "operations": [ 4]0: { "resourceInstanceId": null "operationName": "Delete" } - 1: { "resourceInstanceId": null "operationName": "Read" } - 2: { "resourceInstanceId": null "operationName": "Create" } - 3: { "resourceInstanceId": null "operationName": "Update" } - - } - 5: { "id": 16 "resourceName": "ParticipantDeid" "operations": [ 1]0: { "resourceInstanceId": null "operationName": "Read" } - - } - - } - "collectionProtocol": { "id": 52 "shortTitle": "LCP" "title": "Lung Cancer Protocol" "code": "LP" "principalInvestigator": { "id": 1 "firstName": "Admin" "lastName": "Admin" "loginName": "admin@admin.com" "domain": "openspecimen" "emailAddress": "openspecimendemo@gmail.com" "admin": true "cpCount": 0 "creationDate": null } - "startDate": 1446661800000 "endDate": null "participantCount": null "specimenCount": null "ppidFmt": "LP-%04d" "manualPpidEnabled": true } - "site": { "id": 35 "name": "3165 Porder Drive" "instituteName": "Stanford" "code": "PD" "type": "Collection Site" "activityStatus": "Active" "cpCount": 0 "coordinators": [ 1]0: { "id": 1 "firstName": "Admin" "lastName": "Admin" "loginName": "admin@admin.com" "domain": "openspecimen" "emailAddress": "openspecimendemo@gmail.com" "admin": true "cpCount": 0 "creationDate": null } - - "address": null "extensionDetail": null } - "systemRole": false } |
Error Cases :
code | Applies to | Status Message |
---|---|---|
200 | All resources | User has been updated successfully |
400 | All requests | Invalid parameters, e.g duplicate login name, duplicate email address, blank first name etc |
401 | All requests | Authorization failed, user doesn’t have authority |
404 | All requests | User not found, user with given details not present in the system |
500 | All requests | Internal server error, encountered server error while performing operations |