Link Search Menu Expand Document Edit GitHub

Data Policy


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

Commands

CommandExplanation
createSee Create Data Policy
getSee Get Data Policy
updateSee Update Data Policy
listSee List Data Policies
deleteSee Delete Data Policy

Options

Help Options

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

Create Data Policy


Create a new data 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 data-policy create

Simple Example

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

Options

OptionLong VersionExplanationRequired
 --definitionThe definition of the data 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 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 Data Policy


Retrieve a single existing policy.

mqtt hivemq data-policy get

Simple Example

$ mqtt hivemq data-policy get --id my-policy-id 
{
  "createdAt": "2023-05-25T14:58:09.093Z",
  "id": "my-policy-id",
  "matching": {
    "topicFilter": "topic/1"
  },
  "onFailure": {
    "pipeline": []
  },
  "onSuccess": {
    "pipeline": []
  },
  "validation": {
    "validators": [
      {
        "arguments": {
          "strategy": "ALL_OF",
          "schemas": [
            {
              "schemaId": "my-schema"
            }
          ]
        },
        "type": "schema"
      }
    ]
  }
}

Options

OptionLong VersionExplanationRequired
-i--idThe id of the data 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 Data Policy


Update an existing data 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 data-policy update

Simple Example

mqtt hivemq data-policy update --id my-policy-id --file my-policy.json 

Options

OptionLong VersionExplanationRequired
-i--idThe id of the data policy to be updated.X
 --definitionThe definition of the data 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 data 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 Data Policies


List every data policy that exists on a HiveMQ node. This list may optionally be filtered by policy id, schema id, and MQTT topic.

mqtt hivemq data-policy list

Simple Example

$ mqtt hivemq data-policy list --topic topic/1
{
  "items": [
    {
      "createdAt": "2023-05-25T14:59:03.303Z",
      "id": "policy-1",
      "matching": {
        "topicFilter": "#"
      },
      "onFailure": {
        "pipeline": []
      },
      "onSuccess": {
        "pipeline": []
      },
      "validation": {
        "validators": [
          {
            "arguments": {
              "strategy": "ALL_OF",
              "schemas": [
                {
                  "schemaId": "schema-1"
                }
              ]
            },
            "type": "schema"
          }
        ]
      }
    },
    {
      "createdAt": "2023-05-25T15:18:09.093Z",
      "id": "policy-2",
      "matching": {
        "topicFilter": "topic/1"
      },
      "onFailure": {
        "pipeline": []
      },
      "onSuccess": {
        "pipeline": []
      },
      "validation": {
        "validators": [
          {
            "arguments": {
              "strategy": "ALL_OF",
              "schemas": [
                {
                  "schemaId": "schema-2"
                }
              ]
            },
            "type": "schema"
          }
        ]
      }
    }
  ]
}

Options

OptionLong VersionExplanationRequired
-i--idFilter by policies with a matching policy id. Can be specified multiple times. 
-s--schema-idFilter by policies that reference a schema with a matching schema id. Can be specified multiple times. 
-t--topicFilter by policies that apply to a certain MQTT topic. 
-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 Data Policy


Delete a single existing data policy.

mqtt hivemq data-policy delete

Simple Example

mqtt hivemq data-policy delete --id my-policy-id 

Options

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