Skip to content

Generic

Generic Access to Database Data.

The Generic controller provides "generic" access to database items without requiring specific database models for different database items. By providing the database item "_type" and the required item properties, you can query and modify database items.

Create

Create a generic data item.

Endpoint

HTTP
POST /generic/create

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
_typestringyesDatabase item type.
deviceIdstringDevice ID owning the item. This must be a deviceId claimed by the app account of the authenticated user.
*anyItem attributes to create.

Query String Options

FieldTypeDefaultNotes

Response

The created item.

FieldTypeNotes
_typestringDatabase item type.
*anyItem attributes.

Find

Find data items from a database table.

Endpoint

HTTP
POST /generic/find

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
_typestringyesDatabase item type.
deviceIdstringDevice ID owning the item.
*anyOptional item attributes to filter selected items.

Query String Options

FieldTypeDefaultRoleNotes
indexstringownerDatabase index name: primary or gs1.
limitnumberNumber of items to retrieve.
nextobjectPagination token for the next page.
prevobjectPagination token for the previous page.

Response

Paged response.

FieldTypeNotes
dataarrayAn array of devices owned by the user.
nextstringPaged cursor to use for the next page of items.
prevstringPages cursor to use for the previous page of items.

Item

FieldTypeNotes
*anyItem attributes.
curl
curl -X POST ${CLOUD_ENDPOINT}/tok/generic/find \
    -H 'Authorization: ${CLOUDAPI_TOKEN}' \
    -H 'Content-Type: application/json' \
    -d '{"_type": "Device"}'
url
url ${CLOUD_ENDPOINT}/tok/generic/find \
    'Authorization: ${CLOUDAPI_TOKEN}' \
    '{_type: "Device"}'

Get

Get a data item from a database table.

Endpoint

HTTP
POST /generic/get

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
_typestringyesDatabase item type.
deviceIdstringDevice ID owning the item.
*anyOptional item attributes to filter the selected item.

Response

The retrieved item.

FieldTypeNotes
*anyItem attributes.
curl
curl -X POST ${CLOUD_ENDPOINT}/tok/generic/get \
    -H 'Authorization: ${CLOUDAPI_TOKEN}' \
    -H 'Content-Type: application/json' \
    -d '{"_type": "Device", "deviceId": "DEV0123456"}'
url
url ${CLOUD_ENDPOINT}/tok/generic/get \
    'Authorization: ${CLOUDAPI_TOKEN}' \
    '{_type: "Device", deviceId: "DEV0123456"}'

Remove

Remove a data item.

Endpoint

HTTP
POST /generic/remove

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
_typestringyesDatabase item type.
deviceIdstringDevice ID owning the item.
*anyOther item attributes sufficient to identify the item.

Update

Update a data item.

Endpoint

HTTP
POST /generic/update

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
_typestringyesDatabase item type.
deviceIdstringDevice ID owning the item.
*anyOther item attributes sufficient to identify the item.

Response

The updated data item.

FieldTypeNotes
*anyItem attributes.