Link Search Menu Expand Document Edit GitHub

Behavior Policy


The behavior-policy command of the HiveMQ command line offers a set of commands to work with behavior validation policies 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 behavior-policy

Commands


Options

Help Options

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

Create Behavior Policy


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

mqtt hivemq behavior-policy create

Simple Example

mqtt hivemq behavior-policy create --file my-policy.json 

Options

OptionLong VersionExplanationRequired
 --definitionThe definition of the behavior policy. This should be a JSON string containing a complete policy definition.Either --definition or --file, but not both
 --fileA path to a file containing the definition of the behavior policy.Either --definition or --file, but not both

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 Behavior Policy


Retrieve a single existing behavior policy.

mqtt hivemq behavior-policy get

Simple Example

$ mqtt hivemq behavior-policy get --id matchingThree 
{
  "id": "matchingThree",
  "createdAt": "2023-09-21T11:24:25.464Z",
  "lastUpdatedAt": "2023-09-21T11:24:25.464Z",
  "matching": {
    "clientIdRegex": "three.*"
  },
  "deserialization": {
    "publish": {
      "schema": {
        "schemaId": "one",
        "version": "latest"
      }
    },
    "will": {
      "schema": {
        "schemaId": "one",
        "version": "latest"
      }
    }
  },
  "behavior": {
    "id": "Mqtt.events",
    "arguments": {}
  },
  "onTransitions": []
}

Options

OptionLong VersionExplanationRequired
-i--idThe id of the policy 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.

Update Behavior Policy


Update an existing behavior policy. The policy definition may be provided either directly from the command line or from a file. The provided policy id argument must match the id in the policy definition.

mqtt hivemq behavior-policy update

Simple Example

mqtt hivemq behavior-policy update --id my-policy-id --file behavior-one.json 

Options

OptionLong VersionExplanationRequired
-i--idThe id of the behavior policy to be updated.X
 --definitionThe definition of the behavior policy. This should be a JSON string containing a complete policy definition.Either --definition or --file, but not both
 --fileA path to a file containing the definition of the behavior policy.Either --definition or --file, but not both

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 Behavior Policies


List every behavior policy that exists on a HiveMQ node. This list may optionally be filtered by policy id and matching client id.

mqtt hivemq behavior-policy list

Simple Example

$ mqtt hivemq behavior-policy list -i behaviorOne -i behaviorTwo
{
  "items": [
    {
      "id": "behaviorOne",
      "createdAt": "2023-09-19T23:52:28.381Z",
      "lastUpdatedAt": "2023-09-19T23:52:28.381Z",
      "matching": {
        "clientIdRegex": "one.*"
      },
      "behavior": {
        "id": "Mqtt.events",
        "arguments": {}
      },
      "onTransitions": []
    },
    {
      "id": "behaviorTwo",
      "createdAt": "2023-09-21T11:24:25.464Z",
      "lastUpdatedAt": "2023-09-21T11:24:25.464Z",
      "matching": {
        "clientIdRegex": "two.*"
      },
      "deserialization": {
        "publish": {
          "schema": {
            "schemaId": "schema1",
            "version": "latest"
          }
        }
      },
      "behavior": {
        "id": "Mqtt.events",
        "arguments": {}
      },
      "onTransitions": [
        {
          "Connection.OnDisconnect": {
            "pipeline": [
              {
                "arguments": {
                  "metricName": "testMetric",
                  "incrementBy": 1
                },
                "functionId": "Metrics.Counter.increment",
                "id": "increment1"
              }
            ]
          },
          "fromState": "any.*",
          "toState": "any.*"
        }
      ]
    }
  ]
}

Options

OptionLong VersionExplanation
-i--idFilter by behavior policies with a matching policy id. Can be specified multiple times.
-c--client-idFilter by behavior policies that apply to clients with a matching client id. Can be specified multiple times.
-f--fieldSelect which JSON fields appear in the response. Can be specified multiple times.
 --limitLimit the maximum number of policies 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 Behavior Policy


Delete a single existing behavior policy.

mqtt hivemq behavior-policy delete

Simple Example

mqtt hivemq behavior-policy delete --id my-policy-id 

Options

OptionLong VersionExplanationRequired
-i--idThe id of the behavior policy 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.