Link Search Menu Expand Document Edit GitHub

Script


The script command of the HiveMQ command line offers a set of commands to work with scripts using a HiveMQ Data Hub API endpoint.

NOTE: The HiveMQ Data Hub is a new product in the HiveMQ platform and commands using it may be subject to breaking changes in the future.

mqtt hivemq script

Commands

CommandExplanation
createSee Create Script
getSee Get Script
listSee List Scripts
deleteSee Delete Script

Options

Help Options

OptionLong VersionExplanation
-h--helpDisplay help message for command.
-V--versionDisplay version information of the cli.

Create Script


Create a new script and upload it to a HiveMQ node. The script definition may be provided either directly from the command line or from a file.

mqtt hivemq script create

Simple Example

mqtt hivemq script create --id hello_world --description "Yet another hello world script." --file hello.js --type transformation

Options

OptionLong VersionExplanationDefaultRequired
-i--idThe id of the script to be created. X
 --typeThe function type of the script. (Currently supported types [TRANSFORMATION]) X
 --definitionThe source code of the script. Either --definition or --file, but not both
 --descriptionShort human-readable description of what the script does.  
 --fileA path to a file containing the source code of the script. Either --definition or --file, but not both
 --print-versionPrint the assigned script version after creation.false 

API Connection Options

OptionLong VersionExplanationDefault
-u--urlThe URL of the HiveMQ REST API endpoint.http://localhost:8888
-r--rateThe rate limit of the rest calls to the HiveMQ API endpoint in requests per second.1500

Logging Options

OptionLong VersionExplanationDefault
-l Log to ~./mqtt-cli/logs (Configurable through ~/.mqtt-cli/config.properties).false

Help Options

OptionLong VersionExplanation
-h--helpDisplay help message for command.
-V--versionDisplay version information of the cli.

Get Script


Retrieve a single existing script.

mqtt hivemq script get

Simple Example

$ mqtt hivemq script get --id hello_world 
{
  "id": "hello_world",
  "version": 1,
  "createdAt": "2023-11-03T13:07:15.650Z",
  "description": "This function greets a person.",
  "functionType": "TRANSFORMATION",
  "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ=="
}

Options

OptionLong VersionExplanationRequired
-i--idThe id of the script to fetch.X
-f--fieldSelect which JSON fields appear in the response. Can be specified multiple times. 

API Connection Options

OptionLong VersionExplanationDefault
-u--urlThe URL of the HiveMQ REST API endpoint.http://localhost:8888
-r--rateThe rate limit of the rest calls to the HiveMQ API endpoint in requests per second.1500

Logging Options

OptionLong VersionExplanationDefault
-l Log to ~./mqtt-cli/logs (Configurable through ~/.mqtt-cli/config.properties).false

Help Options

OptionLong VersionExplanation
-h--helpDisplay help message for command.
-V--versionDisplay version information of the cli.

List Scripts


List every script that exists on a HiveMQ node. This list may optionally be filtered by script id and script type.

mqtt hivemq script list

Simple Example

$ mqtt hivemq script list --id hello_world
{
  "items": [
    {
      "id": "hello_world",
      "version": 1,
      "createdAt": "2023-11-03T13:59:47.262Z",
      "description": "This function greets a person.",
      "functionType": "TRANSFORMATION",
      "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ=="
    },
    {
      "id": "hello_world",
      "version": 2,
      "createdAt": "2023-11-03T13:59:48.348Z",
      "description": "This function greets a person.",
      "functionType": "TRANSFORMATION",
      "source": "ZnVuY3Rpb24gdHJhbnNmb3JtKHBlcnNvbikgeyByZXR1cm4gJ2hlbGxvICcgKyBwZXJzb24gfQ=="
    }
  ]
}

Options

OptionLong VersionExplanationRequired
-i--idFilter by scripts with a matching script id. Can be specified multiple times. 
-t--typeFilter by scripts of a matching script type. Can be specified multiple times 
-f--fieldSelect which JSON fields appear in the response. Can be specified multiple times. 
 --limitLimit the maximum number of scripts returned. 

API Connection Options

OptionLong VersionExplanationDefault
-u--urlThe URL of the HiveMQ REST API endpoint.http://localhost:8888
-r--rateThe rate limit of the rest calls to the HiveMQ API endpoint in requests per second.1500

Logging Options

OptionLong VersionExplanationDefault
-l Log to ~./mqtt-cli/logs (Configurable through ~/.mqtt-cli/config.properties).false

Help Options

OptionLong VersionExplanation
-h--helpDisplay help message for command.
-V--versionDisplay version information of the cli.

Delete Script


Delete a single existing script.

mqtt hivemq script delete

Simple Example

mqtt hivemq script delete --id hello_world 

Options

OptionLong VersionExplanationRequired
-i--idThe id of the script to be deleted.X

API Connection Options

OptionLong VersionExplanationDefault
-u--urlThe URL of the HiveMQ REST API endpoint.http://localhost:8888
-r--rateThe rate limit of the rest calls to the HiveMQ API endpoint in requests per second.1500

Logging Options

OptionLong VersionExplanationDefault
-l Log to ~./mqtt-cli/logs (Configurable through ~/.mqtt-cli/config.properties).false

Help Options

OptionLong VersionExplanation
-h--helpDisplay help message for command.
-V--versionDisplay version information of the cli.