UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

121 lines 4.46 kB
import { IFetchClient, IResult } from '../core/index.js'; import { Service } from '../core/Service.js'; import { IManagedObject, IdReference } from '../inventory/index.js'; export declare class SmartGroupsService extends Service<IManagedObject> { protected baseUrl: string; protected listUrl: string; private readonly SMART_GROUP_TYPE; private readonly SMART_GROUP_FRAGMENT_TYPE; private readonly COLUMNS_CONFIG_FRAGMENT; private readonly FILTER_CONFIG_FRAGMENT; private readonly QUERY_STRING_FRAGMENT; constructor(client: IFetchClient); /** * Gets the details of managed object * * @param {IdReference} entityOrId Entity or Id of the ManagedObject. * @param {object} filter Filter object. * * @returns Response wrapped in [[IResult]] * * ```typescript * * const id: string = '1'; * const filter: any = { withChildren: false }; * * (async () => { * const {data, res} = await smartGroupsService.detail(id, filter); * })(); * ``` */ detail(entityOrId: IdReference, filter?: object): Promise<IResult<IManagedObject>>; /** * Creates a smart group managed object with columns configuration. * * @param {object} smartGroup Dynamic group managed object. * @param {object} deviceQueryString Columns configuration query string to filter the new group. * @param {object} configurableColumns Configurable columns definitions. * @param {object} filterConfig Columns filter configuration for the new group. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const smartGroup = { name: 'newName', type: 'c8y_DynamicGroup', c8y_IsDynamicGroup: {} }; * const deviceQueryString = 'c8y_DeviceQueryString: "$filter=(name eq 'test*') $orderby=c8y_Hardware.model asc'; * const configurableColumns = [ * {headerName: 'Status', active: false, key: 'status'}, * {headerName: 'Name', active: true, key: 'name', filter: { externalFilterQuery: { name: { names: ['test*'] } } }}, * {headerName: 'Model', active: true, key: 'model'} * ]; * * (async () => { * await smartGroupsService.create({ smartGroup, deviceQueryString, configurableColumns }); * })(); * * Note: filterConfig has been removed as a default property to the input object. * Now it is part of the configurable columns properties as it is shown above. * You can still pass it as an optional parameter. * ( const filterConfig = [{ name: { names: ['test*'] } }] ) * ``` */ create(obj: Partial<IManagedObject>): Promise<IResult<IManagedObject>>; /** * Updates smart group managed object with given id. * * @param {Partial<IManagedObject>} mo Partial managed object of the smart group. * * @returns Response wrapped in [[IResult]] * * ```typescript * * const smartGroup = { id: '1', name: 'newName' }; * * (async () => { * await smartGroupsService.update(smartGroup); * })(); * ``` */ update(mo: Partial<IManagedObject>): Promise<IResult<IManagedObject>>; /** * Removes managed object with given id. * * @param {IManagedObject} group Managed object of the group. * @param {object} params Additional query params. * * @returns Response wrapped in [[IResult]] * * ```typescript * * const group = { id: '1' } as IManagedObject; * const params: any = { * withChildren: false * } * * (async () => { * await smartGroupsService.delete(group, params); * })(); * ``` */ delete(entityOrId: IdReference, params?: any): Promise<IResult<null>>; /** * Checks whether a given managed object is a smart group * * @param {IManagedObject} mo Managed object to check. * * @returns boolean * * ```typescript * * const mo: IManagedObject = {id: 1, type: "c8y_DeviceGroup", c8y_IsDeviceGroup: {}} as IManagedObject; * * (() => { * const isSmartGroup = smartGroupsService.isSmartGroup(mo); * })(); * ``` */ isSmartGroup(mo: Partial<IManagedObject>): boolean; protected getUrl(url?: string): string; } //# sourceMappingURL=SmartGroupsService.d.ts.map