Space Management

Last Updated on : 2022-09-08 13:07:40download

This topic describes how to manage the space under your project by calling the following open API operations.

API operation

Request method API endpoint Description
POST “/v1.0/illumination/construction/room” Create a space
PUT “/v1.0/illumination/construction/room” Edit a space
DELETE “/v1.0/illumination/construction/room/{roomId}” Delete a space
GET “/v2.0/illumination/construction/rooms/project/{projectId}” Get the tree structure of a space under a project

Create a space

API description

Create a space and upload a point map.

API endpoint

POST "/v1.0/illumination/construction/room"

Request parameter

Name Type Location Description Required
projectId String body The project ID. Yes
name String body The name of a building, floor, or room. Yes
parentId String body The ID of the superior room. Specify 0 as the parent room. Yes
roomType Integer body The room type.
  • 1 means a building.
  • 2 means a floor.
  • 4 means a room
Yes
address String body The building address. No

Return parameter

Name Type Description
code Integer Response code. For more information, see the error code section. It is empty when the operation succeeded.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameter of result

{ "roomId": "string // The room ID", "currentBrightness": "int // The current brightness threshold" }

Sample request

{ "projectId": "The project ID", "name":"The name of a building, floor, or room", "parentId":"The ID of the superior room, with 0 for the parent room", "roomType":"The room type. `1` means a building, `2` means a floor, and 4 indicates a room" }

Sample response

{ "roomId": "The room ID", "currentBrightness": "The current brightness threshold" }

Edit a space

API description

Edit the space name and address.

API endpoint

PUT "/v1.0/illumination/construction/room"

Request parameter

Name Type Location Description Required
roomId String body Room ID Yes
name String body The name of a building, floor, or room. Yes
address String body The building address. No

Return parameter

Name Type Description
code Integer Response code. For more information, see the error code section. It is empty when the operation succeeded.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameter of result

{ "roomId": "string // The room ID", }

Sample request

{ "roomId": "The room ID", "name":"The name of a building, floor, or room", "address": "The building address", }

Sample response

{ "roomId": "The room ID", }

Delete a space

API description

Delete a space.

API endpoint

DELETE "/v1.0/illumination/construction/room/{roomId}"

Request parameter

Name Type Location Description Required
roomId String url Room ID Yes

Return parameter

Name Type Description
code Integer Response code. For more information, see the error code section. It is empty when the operation succeeded.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameter of result

{ "success": "boolean // Indicate whether the request is successful" }

Sample request

{ "roomId": "The room ID", }

Sample response

{ "success": "Indicate whether the request is successful" }

Get the tree structure of a space under a project

API description

Get the tree structure of a space under a project.

API endpoint

GET "/v2.0/illumination/construction/rooms/project/{projectId}"

Request parameter

Name Type Location Description Required
projectId String url The project ID. Yes

Return parameter

Name Type Description
code Integer Response code. For more information, see the error code section. It is empty when the operation succeeded.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The error message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameter of result

{ "totalRoomDeviceCount": "int", "list": [ { "roomId": "string // The room ID", "name": "string // The room name", "address": "string // The building address", "roomType":"int // The room type. `1` means a building, `2` means a floor, and `4` means a room" "roomSource": "int // The room source. `1` means a user-defined room, and `2` means an unassigned room",' "rooms": [], "currentBrightness": "int // The current brightness threshold of the room" "deviceCount": "int // The number of devices with threshold DPs", "roomDeviceCount": "int // The number of devices in a room is the total number of devices in the public area and the subset space" } ] }

Sample request

{ "projectId": "The project ID", }

Sample response

{ "totalRoomDeviceCount": "int", "list": [ { "roomId": "The room ID", "name": "The room name", "address": "The building address", "roomType":"The room type. 1 indicates a building, 2 indicates a floor, and 4 indicates a room" "roomSource": "The room source. 1 indicates a user-defined room, and 2 indicates an unassigned room",' "rooms": [], "currentBrightness": "The current brightness threshold of the room" "deviceCount": "The number of devices with threshold DPs", "roomDeviceCount": "The number of devices in a room is the sum of the number of devices in the public area plus those in the subset space" } ] }

Error code

The following table lists the error codes that might be returned when you make the API request. For more exception errors, see global error codes.

Error code Description
500 The error message is returned because a system error has occurred.