Cumulocity Web SDK - v1021.62.8
    Preparing search index...

    Class InventoryService

    This class allows for managing managed objects and different child types, see [[ChildType]].

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    queriesUtil: QueriesUtil

    Methods

    • Adds bulk of existing managed objects as child addition to another managed object (parent).

      Parameters

      • childReference: IdReference[]

        List of existing managed objects IDs that should be added to another managed object (parent).

      • parentReference: IdReference

        Example


        const childAdditionsRefIds: string[] = ['2', '3'];
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAdditionsBulkAdd(childAdditionsRefIds, parentReferenceId);
        })();

      Returns Promise<IResultList<IIdentified>>

      Response wrapped in array of [[IResult]]

    • Creates a new managed object as child addition to another managed object (parent)

      Parameters

      • managedObject: Partial<IManagedObject>
      • parentReference: IdReference

        Example


        const mOAsChildAddition: Partial<IManagedObject> = {
        name: 'Child addition MO',
        type: 'new type',
        ...
        };

        // This is the identifier of the managed object which should be the parent of
        // mOAsChildAddition, see above.
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAdditionsCreate(mOAsChildAddition, parentReferenceId);
        })();

      Returns Promise<IResult<IIdentified>>

      Response wrapped in [[IResult]]

    • Gets a list of child additions from a given managed object (parent)

      Parameters

      • parentReference: IdReference
      • filter: object = {}

        Example

           const parentReferenceId: IdReference = 1;

        const filter: object = {
        pageSize: 100,
        withTotalPages: true
        };

        (async () => {
        const {data, res, paging} = await inventoryService.childAdditionsList(parentReferenceId, filter);
        })();

      Returns Promise<IResultList<IManagedObject>>

      Response wrapped in [[IResultList]]

    • Removes an existing managed object as child addition from another managed object (parent)

      Parameters

      • childReference: IdReference
      • parentReference: IdReference

        Example


        const childRef: number = 2;
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAdditionsRemove(childRef, parentReferenceId);
        })();

      Returns Promise<IResult<null>>

      Response wrapped in [[IResult]]

    • Adds bulk of existing managed objects as child assets to another managed object (parent).

      Parameters

      • childReference: IdReference[]

        List of existing managed objects IDs that should be added to another managed object (parent).

      • parentReference: IdReference

        Example


        const childAssetsRefIds: string[] = ['2', '3'];
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAssetsBulkAdd(childAssetsRefIds, parentReferenceId);
        })();

      Returns Promise<IResultList<IIdentified>>

      Response wrapped in array of [[IResult]]

    • Creates a new managed object as child asset to another managed object (parent)

      Parameters

      • managedObject: Partial<IManagedObject>
      • parentReference: IdReference

        Example


        const mOAsChildAsset: Partial<IManagedObject> = {
        name: 'Child asset MO',
        type: 'new type',
        ...
        };

        // This is the identifier of the managed object which should be the parent of
        // mOAsChildAsset, see above.
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAdditionsCreate(mOAsChildAddition, parentReferenceId);
        })();

      Returns Promise<IResult<IIdentified>>

      Response wrapped in [[IResult]]

    • Removes an existing managed object as child asset from another managed object (parent)

      Parameters

      • childReference: IdReference
      • parentReference: IdReference

        Example


        const childRef: number = 2;
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childAssetsRemove(childRef, parentReferenceId);
        })();

      Returns Promise<IResult<null>>

      Response wrapped in [[IResult]]

    • Adds bulk of existing managed objects as child devices to another managed object (parent).

      Parameters

      • childReference: IdReference[]

        List of existing managed objects IDs that should be added to another managed object (parent).

      • parentReference: IdReference

        Example


        const childDevicesRefIds: string[] = ['2', '3'];
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childDevicesBulkAdd(childDevicesRefIds, parentReferenceId);
        })();

      Returns Promise<IResultList<IIdentified>>

      Response wrapped in array of [[IResult]]

    • Creates a new managed object as child device to another managed object (parent)

      Parameters

      • managedObject: Partial<IManagedObject>
      • parentReference: IdReference

        Example


        const mOAsChildDevice: Partial<IManagedObject> = {
        name: 'Child device MO',
        type: 'new type',
        ...
        };

        // This is the identifier of the managed object which should be the parent of
        // mOAsChildDevice, see above.
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childDevicesCreate(mOAsChildDevice, parentReferenceId);
        })();

      Returns Promise<IResult<IIdentified>>

      Response wrapped in [[IResult]]

    • Removes an existing managed object as child device from another managed object (parent)

      Parameters

      • childReference: IdReference
      • parentReference: IdReference

        Example


        const childRef: number = 2;
        const parentReferenceId: number = 1;

        (async () => {
        const {data, res} = await inventoryService.childDevicesRemove(childRef, parentReferenceId);
        })();

      Returns Promise<IResult<null>>

      Response wrapped in [[IResult]]

    • Gets total count of managed objects filtered by parameters.

      Parameters

      • filter: object = {}

        Object containing filters for querying managed objects.

        Example


        const filter: object = {
        type: 'c8y_MQTTDevice'
        };

        (async () => {
        const {data, res} = await inventoryService.count(filter);
        })();

      Returns Promise<IResult<number>>

      Response wrapped in [[IResultList]]

    • Removes managed object with given id.

      Parameters

      • managedObjectOrId: IdReference

        ManagedObject or Id of the ManagedObject.

      • params: any = {}

        Additional query params.

        Example


        const managedObjectId: number = 1;
        const params: any = {
        cascade: true
        }

        (async () => {
        const {data, res} = await inventoryService.delete(managedObjectId, params);
        })();

      Returns Promise<IResult<null>>

      Response wrapped in [[IResult]]

    • Gets the details of managed object

      Parameters

      • managedObjectOrId: IdReference

        ManagedObject or Id of the ManagedObject.

      • filter: object = {}

        Filter object.

      Returns Promise<IResult<IManagedObject>>

      Response wrapped in [[IResult]]

      Example


      const managedObjId: number = 1;
      const filter = { withChildren: false };

      (async () => {
      const {data, res} = await inventoryService.detail(managedObjId, filter);
      })();
    • Gets an array of measurement series and fragments supported by the specified managedObject.

      Parameters

      Returns Promise<{ fragment: string; series: string }[]>

      array of supported measurement series and fragments

    • Gets the list of all managed objects filtered and sorted by given query.

      Parameters

      • query: any
      • filter: object = {}

        Object containing filters for querying managed objects.

        Example


        const filter: object = {
        pageSize: 100,
        withTotalPages: true
        };

        const query = {
        name: 'MY-NAM*'
        }

        (async () => {
        const {data, res, paging} = await inventoryService.listQuery(query, filter);
        })();

      Returns Promise<IResultList<IManagedObject>>

      Response wrapped in [[IResultList]]

    • Gets the list of all devices filtered and sorted by given query.

      Parameters

      • query: any
      • filter: object = {}

        Object containing filters for querying devices.

        Example


        const filter: object = {
        pageSize: 100,
        withTotalPages: true
        };

        const query = {
        name: 'MY-NAM*'
        }

        (async () => {
        const {data, res, paging} = await inventoryService.listQueryDevices(query, filter);
        })();

      Returns Promise<IResultList<IManagedObject>>

      Response wrapped in [[IResultList]]