Cumulocity-IoT / cumulocity-analytics-management

Extends the standard cumulocity administration with dialog to add analytics builder extensions
Apache License 2.0
7 stars 3 forks source link

List of Blocks from Sample Repositories shows blocks that are already deployed #5

Closed ck-c8y closed 5 months ago

ck-c8y commented 11 months ago

If a community block is already deployed as an extension. It should be removed or disabled form the list. This is to prevent deploying a block twice.

Screenshot 2023-12-01 at 10 21 41
ck-c8y commented 11 months ago

This requires to match two kind of metadata information:

  1. blocks loaded in the streaming analytics engine
  2. blocks retrieved from github repositories

The metadata for blocks from 1. are in the form:

{
    "consumesInput": true,
    "id": "apama.analyticsbuilder.blocks.PositionInput",
    "inputs": [],
    "parameters": [
        {
            "semanticType": "c8y_deviceOrGroupId",
            "id": "deviceId",
            "name": "Input Source",
            "type": "any",
            "description": "Defines the device or group of devices from which the position is received.",
            "extendedDescription": "This can be a single device, or an object that references or contains a group of devices."
        },
  ]
} 

The metadata for blocks from 2. are in the form:

{
    "name": "CreateEvent.mon",
    "path": "samples/blocks/CreateEvent.mon",
    "sha": "8b5c00f296baffbafb03a70d3444b47e85ddf133",
    "size": 6139,
    "url": "https://api.github.com/repos/SoftwareAG/apama-analytics-builder-block-sdk/contents/samples/blocks/CreateEvent.mon?ref=rel/10.18.0.x",
    "html_url": "https://github.com/SoftwareAG/apama-analytics-builder-block-sdk/blob/rel/10.18.0.x/samples/blocks/CreateEvent.mon",
    "git_url": "https://api.github.com/repos/SoftwareAG/apama-analytics-builder-block-sdk/git/blobs/8b5c00f296baffbafb03a70d3444b47e85ddf133",
    "download_url": "https://raw.githubusercontent.com/SoftwareAG/apama-analytics-builder-block-sdk/rel/10.18.0.x/samples/blocks/CreateEvent.mon",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/SoftwareAG/apama-analytics-builder-block-sdk/contents/samples/blocks/CreateEvent.mon?ref=rel/10.18.0.x",
      "git": "https://api.github.com/repos/SoftwareAG/apama-analytics-builder-block-sdk/git/blobs/8b5c00f296baffbafb03a70d3444b47e85ddf133",
      "html": "https://github.com/SoftwareAG/apama-analytics-builder-block-sdk/blob/rel/10.18.0.x/samples/blocks/CreateEvent.mon"
    }
}

In order to get the complete block name (monitor) one has to parse the content of the EPL from github.

ck-c8y commented 5 months ago

This feature is added to the latest release.