@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
156 lines • 5.14 kB
TypeScript
import { IFetchResponse, IIdentified, IResult, Service } from '../core/index.js';
import { IMeasurement, IMeasurementCreate } from './IMeasurement.js';
import { IMeasurementFilter } from './IMeasurementFilter.js';
import { ISeries } from './ISeries.js';
import { ISeriesFilter } from './ISeriesFilter.js';
/**
* This class allows for managing measurements.
*/
export declare class MeasurementService extends Service<IMeasurement> {
protected baseUrl: string;
protected listUrl: string;
protected propertyName: string;
protected channel: string;
/**
* Gets the details of selected measurement.
*
* @param {string|number|IIdentified} entityOrId Entity or Id of the entity.
*
* @returns Response wrapped in [[IResult]]
*
* @deprecated As of version 10.16.0.0 and the usage of the time series database,
* reading a single measurement via id is not supported any more.
*
* **Example**
* ```typescript
*
* const measurementId: number = 1;
*
* (async () => {
* const {data, res} = await measurementService.detail(measurementId);
* })();
* ```
*/
detail(entityOrId: string | number | IIdentified): Promise<IResult<IMeasurement>>;
/**
* Creates a new measurement.
*
* @param {Partial<IMeasurementCreate>} entity At least sourceId is mandantory.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const mandantoryObject: Partial<IMeasurementCreate> = {
* sourceId: device.id,
* fragment: { series: { unit: '%', value: 51 } },
* };
*
* (async () => {
* const {data, res} = await measurementService.create(mandantoryObject);
* })();
* ```
*/
create(entity: Partial<IMeasurementCreate>): Promise<IResult<IMeasurement>>;
/**
* Gets the list of measurements filtered by parameters.
*
* @returns Response wrapped in [[IResultList]]
*
* @param {object} filter Object containing filters for querying measurements.
*
* **Example**
* ```typescript
*
* const filter: object = {
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await measurementService.list(filter);
* })();
* ```
*/
list(filter?: object): Promise<import("../core/IResultList.js").IResultList<IMeasurement>>;
/**
* Removes a measurement with given id.
*
* @returns Response wrapped in [[IResult]]
*
* @param {string | number | IIdentified} entityOrId
*
* @deprecated As of version 10.16.0.0 and the usage of the time series database,
* deleting a single measurement via id is not supported any more.
*
* **Example**
* ```typescript
*
* const id: number = 1;
*
* (async () => {
* const {data, res} = await measurementService.delete(id);
* })();
* ```
*/
delete(entityOrId: string | number | IIdentified): Promise<IResult<null>>;
/**
* Gets the list of series in a measurement filtered by parameters.
*
* @returns Response wrapped in [[IResult]]
*
* @param {object} filter Object containing filters for querying measurements.
*
* **Example**
* ```typescript
*
* const filter: object = {
* dateFrom: '2018-02-06T10:43:55.077Z',
* dateTo: '2018-02-06T10:50:55.077Z',
* source: device.id
* };
*
* (async () => {
* const {data, res} = await measurementService.listSeries(filter);
* })();
* ```
*/
listSeries(params: ISeriesFilter): Promise<IResult<ISeries>>;
/**
* Retrieves the measurement file based on the provided filter parameters and headers, but only if the response is 200.
* If the response is 202, the file is processed in the background and the file is sent by email.
*
* **Example**
* ```typescript
*
* const filter: IFetchResponse = {
* dateFrom: "2024-08-11T12:13:00+02:00"
* dateTo: "2024-08-12T12:15:00+02:00"
* source: "32666427"
* valueFragmentSeries: "accelerationX"
* valueFragmentType: "c8y_Acceleration"
* };
*
* const headers = {
* accept: 'text/csv'
* }
*
* (async () => {
* const response = await measurementService.getMeasurementsFile(filter, headers);
* if (response.status === 200) {
* const blob = await response.blob();
* }
* })();
* ```
*
* @param filter Object containing filters for querying measurements.
* @param headers The headers for the request.
* @returns A promise that resolves to the fetch response.
*/
getMeasurementsFile(params: IMeasurementFilter, headers: {
accept: string;
}): Promise<IFetchResponse>;
protected onBeforeCreate(entity: Partial<IMeasurementCreate>): Partial<IMeasurementCreate>;
}
//# sourceMappingURL=MeasurementService.d.ts.map