Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create an engine? #327

Closed
xdien opened this issue Jan 18, 2024 · 4 comments
Closed

How to create an engine? #327

xdien opened this issue Jan 18, 2024 · 4 comments

Comments

@xdien
Copy link

xdien commented Jan 18, 2024

Hello kuzzle

  • I'm trying to create an asset using the API. I have read the documentation here,
  • In the input parameter, there is a parameter called :engineId but in the documentation there is no mention of creating an engine? Is it a paid plugin?
  • Is there any example to create engine?

Thank you

@rolljee
Copy link
Contributor

rolljee commented Jan 18, 2024

Hello, we are currently working on a new documentation that will be much more precise on how to initialise the device manager plugin.

But you should be able to create an engine using this piece of code.

this.app.sdk
      .query({
        action: 'create',
        controller: `device-manager/engine`,
        group,
        index,
      })
      .catch((error) => {
        this.app.log.error(`[${index}] Cannot ${action} ${plugin} engine: ${error}`);

        throw error;
      });

The device manager is an open source plugin, there is no need to have a paid plugin to setup engine

@xdien
Copy link
Author

xdien commented Jan 18, 2024

Thank you @rolljee .
I hope the documentation is completed soon and has more examples.

@xdien
Copy link
Author

xdien commented Jan 19, 2024

I tried successfully creating the engine, then I created the asset, maybe I created the correct json content
body

POST http://localhost:7512/_/device-manager/models/assets
Authorization: Bearer xxxx

{
    "engineGroup":"esp",
    "model":"Distiller",
    "measures": [
        {
            "name": "temperature",
            "type": "float"
        },
        {
            "name": "humidity",
            "type": "float"
        }
    ]
}

But the server responded back error, I know index, but I don't know collection and targets on the url?

{
  "action": "writeAsset",
  "controller": "device-manager/models",
  "error": {
    "code": 33619971,
    "id": "api.assert.missing_argument",
    "message": "Missing argument \"index, collection or targets\".",
    "props": [
      "index, collection or targets"
    ],
    "stack": "BadRequestError: Missing argument \"index, collection or targets\".\n      [...Kuzzle internal calls deleted...]\n      at DocumentController.search (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/api/controllers/documentController.js:92:20)\n      at doAction (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/api/funnel.js:1079:47)\n      at Funnel.executePluginRequest (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/api/funnel.js:756:20)\n      at FunnelProtocol.query (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/core/shared/sdk/funnelProtocol.js:95:51)\n      at Proxy._timeoutRequest (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle-sdk/src/Kuzzle.js:763:34)\n      at Proxy.query (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle-sdk/src/Kuzzle.js:591:21)\n      at Proxy.query (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/core/shared/sdk/embeddedSdk.js:132:22)\n      at AssetService.refreshModel (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle-device-manager/lib/modules/asset/AssetService.ts:333:35)\n      at async Kuzzle.ask (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/kuzzle/event/kuzzleEventEmitter.js:229:22)\n      at async ModelService.writeAsset (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle-device-manager/lib/modules/model/ModelService.ts:106:5)\n      at async ModelsController.writeAsset (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle-device-manager/lib/modules/model/ModelsController.ts:115:24)\n      at async Funnel.processRequest (/home/xdien/workspace/next-iot/backend/node_modules/kuzzle/lib/api/funnel.js:668:28)",
    "status": 400
  },
  "headers": {},
  "node": "knode-bored-maugrim-14974",
  "requestId": "7afe4c19-d9d2-417e-907c-90908ff3e827",
  "result": null,
  "status": 400,
  "volatile": null
}

@xdien
Copy link
Author

xdien commented Jan 19, 2024

I was able to create the asset but the error was because I filled in the wrong engineGroup

"engineGroup":"esp",

@xdien xdien closed this as completed Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants