Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Assign Role

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
siteSite on which wanted to assign role. Site details in json format. Example : {id: 1, name: "Site1"}
collectionProtocolCollection protocol on which wanted to assign role. Collection protocol details in json format. Example: {"title": "Lung cancer protocol", shortTitle: "LCP"}
roleRole 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:

URLopenspecimen/rest/ng/users/1
MethodPUT
Requestapplication/json
json

{

{
  "site":{"name":"Porder Drive"},
  "collectionProtocol":{"shortTitle":"LCP"},
  "role":{"name":"Technician"}
}
 
{
  "id":null,
  "role": {
      "id":4,
      "name":"Technician",
      "description":"User who collects and processes specimens.",
      "parentRoleName":null,
      "childRoles":[],
      "acl":[
         {"id":14,"resourceName":"StorageContainer","operations":[{"resourceInstanceId":null,"operationName":"Read"}]},
         {"id":44,"resourceName":"ShippingAndTracking",
           "operations":[
             {"resourceInstanceId":null,"operationName":"Create"},
             {"resourceInstanceId":null,"operationName":"Update"},
             {"resourceInstanceId":null,"operationName":"Delete"},
             {"resourceInstanceId":null,"operationName":"Read"}]},
         {"id":15,"resourceName":"CollectionProtocol","operations":[{"resourceInstanceId":null,"operationName":"Read"}]},
         {"id":18,"resourceName":"Order",
            "operations":[
              {"resourceInstanceId":null,"operationName":"Read"},{"resourceInstanceId":null,"operationName":"Create"},
              {"resourceInstanceId":null,"operationName":"Delete"},{"resourceInstanceId":null,"operationName":"Update"}]},
        {"id":17,"resourceName":"VisitAndSpecimen",
          "operations":[
             {"resourceInstanceId":null,"operationName":"Delete"},
             {"resourceInstanceId":null,"operationName":"Read"},
             {"resourceInstanceId":null,"operationName":"Create"},
             {"resourceInstanceId":null,"operationName":"Update"}]},
       {"id":16,"resourceName":"ParticipantDeid","operations":[{"resourceInstanceId":null,"operationName":"Read"}]}
     ]
   },
   "collectionProtocol":{"id":52,"shortTitle":"LCP","title":"Lung Cancer Protocol","code":"LP"},
   "site":{"id":35,"name":"3165 Porder Drive","instituteName":"Stanford","code":"PD","type":"Collection Site"},
   "systemRole":false
}

 Error Cases :

code
Applies to
Status Message
200All resourcesRole has been assigned successfully to user
400All requestsInvalid parameters, e.g  site, cp, role etc
401All requestsAuthorization failed, user doesn’t have authority to assign role
404All requestsUser not found, user with given details not present in the system
500All requestsInternal server error, encountered server error while performing operations

 

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com