CRUD Operations


Create, read, update, and delete (CRUD) are the four main functions for RESTful APIs.


Create

  • POST - Create a new object in a collection. The object is identified by the Universally Unique Identifier (UUID).

POST /api/v1/sites/:site_id/collection

Parameters

Name Type Documentation
name string name of the object
color string Required. red / green / blue
object object a nested object can be used. it will be shallow (at most 3 level, including list)
list list list of lucky numbers

Example

{
    "name": "object name",
    "color": "red",
    "object": {
        "nested": true
    },
    "list": [ "value1", "value2" ]
}

Response

Status: 200 OK

{
    "id": "445c23ed-f8ec-cf05-24ea-64af335cb575",
    "name": "object name",
    "color": "red",
    "object": {
        "nested": true
    },
    "list": [ "value1", "value2" ]
}

Read

  • GET - Read an existing object (or objects) in a collection.

GET /api/v1/sites/:site_id/:collection

Response:

Status: 200 OK

[
    {
        "id": "445c23ed-f8ec-cf05-24ea-64af335cb575",
        "name": "object name",
        "color": "red",
        "object": {
            "nested": true
        },
        "list": [ "value1", "value2" ]
    }
    , ...
]

GET /api/v1/sites/:site_id/:collection/:object_id

Response:

Status: 200 OK

{
    "id": "445c23ed-f8ec-cf05-24ea-64af335cb575",
    "name": "object name",
    "color": "red",
    "object": {
        "nested": true
    },
    "list": [ "value1", "value2" ]
}

Update

  • PUT - Update an existing object.

PUT /api/v1/sites/:site_id/wlans/:object_id POST /api/v1/sites/:site_id/wlans/:object_id

Parameters

Name Type Documentation
name string name of the object
color string red / green / blue
object object a nested object can be used. it will be shallow (at most 3 level, including list)
list list list of lucky numbers

Example

{
    "color": "green"
}

Response:

Status: 200 OK

{
    "id": "445c23ed-f8ec-cf05-24ea-64af335cb575",
    "name": "object name",
    "color": "green",
    "object": {
        "nested": true
    },
    "list": [ "value1", "value2" ]
}

Delete

  • DELETE - Delete an existing object.

DELETE /api/v1/sites/:site_id/:collection/:object_id

Response:

Status: 200 OK