V2.4 Modify Device Status


Modify the status of a device.

You can use this API to modify the Inactive and Offline statuses of devices. The status of the device should be subject to the actual connection to EnOS. For example, if you use this API to modify the status of an Offline device to Online, the device status will show Online in page but actually offline, which can be modified by this API.

Operation Permissions


Before invoking this API, ensure that the service account has been authorized the policy that includes the following service(s) and action permission(s). For how to authorize the service account, see Managing Service Accounts.


Required Service Required Operation Permission
Device Management Service Full Access

Prerequisite


  • The device to modify the status exists.
  • You have learnt the Limitations about devices.

Request Format


POST https://{apigw-address}/connect-service/v2.4/devices?action=modifyDeviceStatus

Request Parameters (URI)


Name Location (Path/Query) Mandatory/Optional Data Type Description
orgId Query Mandatory String The organization ID which the asset belongs to. How to get orgId >>

Request Parameters (Body)


Note

Use one of the following methods to specify the device:

  • Include assetId in the request
  • Include productKey + deviceKey in the request


Name Mandatory/Optional Data Type Description
status Mandatory Enum The status of the device. Supports inactive, online, and offline.
assetId Optional String The asset ID. How to get assetId >>
productKey Optional String The product key. To be used with deviceKey.
deviceKey Optional String The device key. To be used with productKey.

Error Codes


Code Message Description
11404 Device cannot be found The device has not existed.
99400 Invalid arguments: Device information is invalid. Specify (assetId) or (productKey + deviceKey) in your request.
99400 Invalid arguments: Status {status} is not allowed to be modified. The status that you set in the request parameter is not allowed to be modified.
99400 Invalid arguments: Unable to modify status as the device is currently connected to EnOS. Unable to modify status as the device is currently connected to EnOS. You can close the connection first if required.
99400 Invalid arguments: Unable to modify status for mirrored devices. Unable to modify status for mirrored devices.
99400 Invalid arguments: Unable to modify status for disabled devices. Unable to modify status for disabled devices.

Samples

Request Sample


url:https://{apigw-address}/connect-service/v2.4/devices?action=modifyDeviceStatus&orgId=yourordId
method: POST
requestBody:
{
    "assetId":"yourassetId",
    "status":"offline"
}

Return Sample


{
    "code":0,
    "msg":"OK",
    "requestId":"fd79d0f5-69c5-4fa8-add4-69f5ca1b635f",
    "data":null
}

SDK Samples


You can access the SDK samples for Connection Service on GitHub: