V2.1 Add Sub-Device

Add new sub-devices to the gateway device (creating a topological relationship).


This API is available in EnOS 2.1.0 and above.

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

Prerequisites


  • The required gateway device has been created.

  • You have learnt the Limitations about devices.

Request Format

POST https://{apigw-address}/connect-service/v2.1/device-topos?action=addSubDevice

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)

Name

Mandatory/Optional

Data Type

Description

gateway

Mandatory

DeviceIdentifier Struct

The information of the gateway device to add the sub-device to. For more details, see DeviceIdentifier Struct.

subDevices

Mandatory

Array of DeviceIdentifier Structs

The list of the sub-devices to add to the specified gateway. For more details, see DeviceIdentifier Struct.

DeviceIdentifier Struct

Note: Use either the (assetId) or (productKey + deviceKey) for the following.

Name

Data Type

Description

assetId

String

The asset ID. How to get assetId>>

productKey

String

The product key. To be used with deviceKey.

deviceKey

String

The device key. To be used with productKey.

Error Codes

Code

Message

Description

11738

Not Gateway

The device specified in gateway is not a gateway.

11739

Exceed max device size

This operation will cause the number of sub-devices of the gateway to exceed the limit.

99400

Invalid arguments

One or multiple parameters are invalid.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/device-topos?action=addSubDevice&orgId=yourOrgId
method: POST
requestBody:
{
  "subDevices":[
    {
      "assetId":"mAEsF3sm"
    }
  ],
  "gateway":{
    "assetId":"J1Rqyaqz"
  }
}

Return Sample

{
  "code":0,
  "msg":"OK",
  "requestId":"5246f91c-f9ce-485c-a9f2-4cd8b7e1f0df",
  "data":null
}

SDK Samples


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