@nuralogix.ai/dfx-api-client
Version:
DeepAffex API JavaScript Client Library
193 lines (117 loc) • 4.61 kB
Markdown
[@nuralogix.ai/dfx-api-client](../../index.md) / [HTTP](../../http/index.md) / Devices
# Devices
Devices end points
Devices can be used to record the platform by which a measurement
captured was conducted on. The DeviceTypeID references a pre-defined
set of devices with the following chart. New Device Types cannot be
created by organizations and are managed by the API specifically.
Devices types can be retrieved from a dedicated endpoint returning
all their values and meanings.
### Sample code
```js
const apiClient = client();
const response = await apiClient.http.devices.retrieve('your-device-id');
const { status, body } = response;
if (status !== '200') {
/**
* TypeScript knows that once we are inside this block, the only response
* shape that matches a non "200" response is the ErrorResponse
*/
throw body;
}
/** Otherwise the shape of the response is DeviceRetrieve200Response */
console.log(body.StatusID);
```
### Methods
- [create](index.md#create)
- [deleteDeviceMeasurement](index.md#deletedevicemeasurement)
- [list](index.md#list)
- [remove](index.md#remove)
- [retrieve](index.md#retrieve)
- [retrieveLicenseId](index.md#retrievelicenseid)
- [types](index.md#types)
- [update](index.md#update)
### create
▸ **create**(`data`)
Creates a new device reference to associate with measurements.
Each device is mapped to a device type ID.
Endpoint Action ID = 903
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`DeviceCreateRequest`](./interfaces/DeviceCreateRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceCreated200Response`](./interfaces/DeviceCreated200Response.md)\>
___
### deleteDeviceMeasurement
▸ **deleteDeviceMeasurement**(`id`)
Only DFX_ORG_ADMIN has permission to delete all measurements of a
specific device for their own organization.
Endpoint Action ID = 907
#### Parameters
| Name | Type |
| :------ | :------ |
| `id` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceDeleteMeasurements200Response`](./interfaces/DeviceDeleteMeasurements200Response.md)\>
___
### list
▸ **list**(`data`)
Retrieves a list of existing devices in an organization.
Endpoint Action ID = 906
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`DeviceListRequest`](./interfaces/DeviceListRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceList200Response`](./interfaces/DeviceList200Response.md)\>
___
### remove
▸ **remove**(`id`)
Deletes a device from the dataset.
Endpoint Action ID = 905
#### Parameters
| Name | Type |
| :------ | :------ |
| `id` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceDeleted200Response`](./interfaces/DeviceDeleted200Response.md)\>
___
### retrieve
▸ **retrieve**(`id`)
Retrieves a single reference to a device. The body response includes details
about the device and the number of measurements that have been associated with it.
Endpoint Action ID = 902
#### Parameters
| Name | Type |
| :------ | :------ |
| `id` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceRetrieve200Response`](./interfaces/DeviceRetrieve200Response.md)\>
___
### retrieveLicenseId
▸ **retrieveLicenseId**()
We want to extend the EP to use deviceID (instead of {ID}) in the device token
to extract license information and return to client.
Endpoint Action ID = 908
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceRetrieveLicenseId200Response`](./interfaces/DeviceRetrieveLicenseId200Response.md)\>
___
### types
▸ **types**()
Retrieves a list of allowed device types.
Endpoint Action ID = 900
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceTypes200Response`](./interfaces/DeviceTypes200Response.md)\>
___
### update
▸ **update**(`id`, `data`)
Updates a device reference via the UUID supplied.
Endpoint Action ID = 904
#### Parameters
| Name | Type |
| :------ | :------ |
| `id` | `string` |
| `data` | [`DeviceUpdateRequest`](./interfaces/DeviceUpdateRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`DeviceUpdated200Response`](./interfaces/DeviceUpdated200Response.md)\>