Version 2021

Activate resources

Activates one or more physical resources, such as doors, in the system on behalf of a user. For example, this call can unlock a door with Badge.

Request format


HTTP method

GET

Resource URL

/resource/activate_resources?user=userid&resources=resources1,resources2...

Parameters

Parameter Required? Description
userid Required The user ID.
resources Required The resource IDs of one or more physical resources that will be activated. For example, the resource ID of the door to unlock with Badge. To activate multiple resources, send a comma-separated string with the resource ID of each resource to activate.

Response format


Response header

Content-Type:application/json

Response body

When the parameters are valid and activation of all the resources is successful, a SUCCESS status is returned.

Success response

Copy
{
  "json_version": "2.0",
  "status":"SUCCESS",
}

When one or more parameters are invalid or missing, then an ERROR status is returned, along with an error message.

Error response (invalid parameters)

Copy
{
  "json_version": "2.0",
  "status": "ERROR",
  "message": "<error_message>"
}

When an activation failed, then we return an ERROR_RESOURCES status along with a response_status field. The response_status field is an array of JSONs for each resource that was requested to be activated. We also add the 0-based index of the resource in their corresponding status JSONs so that the Identity Server can reference the statuses correctly even if JSON parser were to reorder the response array.

Error response (an activation failed)

Copy
{
  "json_version" : "2.0",
  "status": "ERROR_RESOURCES",
  "resource_status":
    [
      {
        "status": "SUCCESS",
        "index": <index of the resource in the request>,
      },
      {
        "status": "ERROR",
        "index": <index of the resource in the request>,
        "message": "<error_message>"
      }
    ]
}

Example

Two resources are requested to be activated on behalf of user 6388.

Request

http://localhost:8080/Usher.svc/resource/activate_resources?user=6388&resources=2959fa5d-feeb-47d7-9df1-0c76080b912e,71f8efbf-09af-418d-91f1-52707cdfa274

The activation of the first resource succeeded while the activation of the second one failed.

Response

Copy
{
  "json_version" : "2.0",
  "status": "ERROR_RESOURCES",
  "resource_status":
    [
      {
        "status": "SUCCESS",
        "index": 0,
      },
      {
        "status": "ERROR",
        "index": 1,
        "message": "resource (2) does NOT exist"
      }
    ]
}

Request

http://localhost:8080/Usher.svc/resource/activate_resources?user=6388&resources=2959fa5d-feeb-47d7-9df1-0c76080b912e&extra_param

Invalid number of parameters

Response

Copy
{
  "json_version" : "2.0",
  "status": "ERROR",
  "message": "Invalid number of parameters in the URL request."
}