Manage Organizations

Last Updated on : 2023-01-12 07:14:19download

This topic describes the API operations related to organizational management.

Request method API Description
GET /v1.0/iot-02/building/structures/actions/children-info Get sub-organizations
GET /v1.0/iot-02/building/structures/actions/match-name Perform a fuzzy search for an organization
GET /v1.0/iot-02/building/structures/actions/parents-info Get all the parent organizations
POST /v1.0/iot-02/building/structures Add organizations
PUT /v1.0/iot-02/building/structures Edit organizations
PUT /v1.0/iot-02/building/structures/actions/move Move an organization
DELETE /v1.0/iot-02/building/structures/{structure_id} Delete an organization

Get sub-organizations

Functional description

Get the information about the specified sub-organizations.

API endpoint

GET /v1.0/iot-02/building/structures/actions/children-info

Request parameters

Parameter Type Parameter type Description Required
projectId String query The project ID. true
structureId String query The organization ID. true

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

[
    {
        "structureId": "String // The organization ID",
        "parentStructureId": "String // The ID of the parent organization",
        "structureName": "String // The organization name",
        "level": "int // The organization level",
        "projectId": "String // The project ID",
        "sort": "int // The sorting value of a level",
        "mobile": "String // The mobile phone number",
        "externalNo": "String // The external number",
    }
]

Sample request

{
    "projectId":"1424615984265764***",
    "structureId":"1439128101413011***"
}

Sample response

{
    "result": [
        {
            "alias_code": "fuY**",
            "alias_code_path": "Sn0QFfu***",
            "external_no": "Level-1 Organization",
            "level": 1,
            "parent_structure_id": "1439128101413011***",
            "project_id": "1424615984265764***",
            "remark": "",
            "sort": 100000,
            "structure_id": "1439128403298041***",
            "structure_name": "Level-1 Organization 00",
        },
        {
            "alias_code": "n0N**",
            "alias_code_path": "Sn0QFn0***",
            "external_no": "Level-1 Organization 04",
            "level": 1,
            "parent_structure_id": "1439128101413011***",
            "project_id": "1424615984265764***",
            "remark": "",
            "sort": 200000,
            "structure_id": "1440882131684409***",
            "structure_name": "Test Modification"
        }
    ],
    "success": true,
    "t": 1662709452591,
    "tid": "323259e2301311edaf4dfa23c521f7ba"
}

Perform a fuzzy search for an organization

Functional description

Perform a fuzzy search for an organization.

API endpoint

GET /v1.0/iot-02/building/structures/actions/match-name

Request parameters

Parameter Type Parameter type Description Required
projectId String query The project ID. true
structureName String query The organization name. true

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

[
    {
        "structureId": "String // The organization ID",
        "parentStructureId": "String // The ID of the parent organization",
        "structureName": "String // The organization name",
        "level": "int // The organization level",
        "projectId": "String // The project ID",
        "sort": "int // The sorting value of a level",
        "mobile": "String // The mobile phone number",
        "externalNo": "String // The external number",
    }
]

Sample request

{
    "projectId":"1424615984265764***",
    "structureName": "Test",
}

Sample response

Same as above.

Get all the parent organizations

Functional description

Get all the parent organizations.

API endpoint

GET /v1.0/iot-02/building/structures/actions/parents-info

Request parameters

Parameter Type Parameter type Description Required
projectId String query The project ID. true
structureId String query The organization ID. true

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

[
    {
        "structureId": "String // The organization ID",
        "parentStructureId": "String // The ID of the parent organization",
        "structureName": "String // The organization name",
        "level": "int // The organization level",
        "projectId": "String // The project ID",
        "sort": "int // The sorting value of a level",
        "mobile": "String // The mobile phone number",
        "externalNo": "String // The external number",
    }
]

Sample request

{
    "projectId":"1424615984265764***",
    "structureId":"1439128101413011***"
}

Sample response

Same as above.

Add organizations

Functional description

Add organizations.

API endpoint

POST /v1.0/iot-02/building/structures

Request parameters

Parameter Type Parameter type Description Required
projectId String body The project ID. true
parentStructureId String body The ID of the parent organization. true
structureName String body The organization name. true
externalNo String body The external number. false

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

String{}

Sample request

{
    "projectId":"1424615984265764***",
    "parentStructureId":"1439128101413011***",
    "structureName": "OpnAPI Test Organization",
}

Sample response

{
    "result": "1568143944687058944",
    "success": true,
    "t": 1662709625841,
    "tid": "99821b47301311edaf4dfa23c521f7ba"
}

Edit organizations

Functional description

Edit the information about organizations.

API endpoint

PUT /v1.0/iot-02/building/structures

Request parameters

Parameter Type Parameter type Description Required
projectId String body The project ID. true
structureId String body The organization ID. true
structureName String body The organization name. true
externalNo String body The external number. false

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

boolean{}

Sample request

{
    "projectId":"1424615984265764***",
    "structureId":"1440882131684409***",
    "structureName":"Test Modification"
}

Sample response

{
    "result": true,
    "success": true,
    "t": 1628669342514
}

Move an organization

Functional description

Move an organization.

API endpoint

PUT /v1.0/iot-02/building/structures/actions/move

Request parameters

Parameter Type Parameter type Description Required
projectId String body The project ID. true
positionRequest Object body The organization to be moved. true
sortRequestList List body The list of organizations that shall be sorted again. false

positionRequest

Parameter Type Parameter type Description Required
structureId String body The ID of the organization to be moved. true
parentStructureId String body The ID of the target parent organization. true
sort int body The sorting value of a level under the target parent organization. false

sortRequestList

Parameter Type Parameter type Description Required
structureId String body The organization ID. true
sort int body The sorting value of a level under the organization. false

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

boolean{}

Sample request

{
  "projectId": "String // The project ID",
  "positionRequest": {
    "structureId": "String // The ID of the organization to be moved",
    "parentStructureId": "String // The ID of the target parent organization",
    "sort": "int // The sorting value of a level under the target parent organization",
  },
  "sortRequestList": [
    {
      "structureId": "String // The organization ID",
      "sort": "int // The sorting value of a level"
    }
  ]
}

Sample response

{
    "result": true,
    "success": true,
    "t": 1628669342514
}

Delete an organization

Functional description

Delete the specified organization.

API endpoint

DELETE /v1.0/iot-02/building/structures/{structure_id}

Request parameters

Parameter Type Parameter type Description Required
structure_id String uri The organization ID. true
projectId String body The project ID. true

Return parameters

Parameter Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

boolean{}

Sample request

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

Sample response

{
    "result": true,
    "success": true,
    "t": 1628669342514
}

Error code

The following table lists common error codes for the API calls. For more error codes, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.