Skip to main content

ⓘ API Reference with Python Scripting

MQTT Distributor provides a set of scripting functions that allow you to create, read, update, and delete Distributor configuration settings programmatically. These functions can be executed from any Ignition Scripting Scope.

The available functions are:

  • createConfig() – Create a new configuration record.
  • readConfig() – Retrieve existing configuration settings.
  • updateConfig() – Modify an existing configuration record.
  • deleteConfig() – Remove a configuration record.

These functions can be used to manage MQTT Distributor settings and user accounts without manually configuring them through the Gateway web interface.


createConfig()​

Creates a new MQTT Distributor configuration record.

Syntax​

system.cirruslink.distributor.createConfig(type, props)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to create.
propsDictionaryProperties for the new configuration record.

👁️‍🗨️ Example​

props = {
"Username": "mqttuser",
"Password": "password123",
"ACLs": "#"
}

system.cirruslink.distributor.createConfig(
"Users",
props
)

readConfig()​

Retrieves MQTT Distributor configuration records.

Syntax​

system.cirruslink.distributor.readConfig(type)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to read. Valid options are General and Users.

Returns​

A list of dictionaries representing the requested configuration records.

General Configuration Properties​

PropertyType
IdLong
EnabledBoolean
EnableTCPBoolean
PortInteger
EnableWebsocketBoolean
WebsocketPortInteger
EnableTLSBoolean
SecurePortInteger
EnableSecureWebsocketBoolean
SecureWebsocketPortInteger
AllowAnonymousConnectionsBoolean

User Configuration Properties​

PropertyType
IdLong
UsernameString
PasswordString
ACLsString

👁️‍🗨️ Example​

users = system.cirruslink.distributor.readConfig("Users")

for user in users:
print user["Username"]

updateConfig()​

Updates an existing MQTT Distributor configuration record.

Syntax​

system.cirruslink.distributor.updateConfig(
type,
id,
collisionPolicy,
props
)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to update. Valid options are General and Users.
idLongID of the record to update.
collisionPolicyStringUpdate behavior. Valid options are MergeOverwrite and Overwrite.
propsDictionaryProperties to update on the configuration record.

Collision Policies​

PolicyDescription
MergeOverwriteReplaces only the properties included in the request while preserving all other values.
OverwriteReplaces all properties in the record with the values supplied in the request.

Supported Properties​

General Configuration​

PropertyType
IdLong
EnabledBoolean
EnableTCPBoolean
PortInteger
EnableWebsocketBoolean
WebsocketPortInteger
EnableTLSBoolean
SecurePortInteger
EnableSecureWebsocketBoolean
SecureWebsocketPortInteger
AllowAnonymousConnectionsBoolean

User Configuration​

PropertyType
IdLong
UsernameString
PasswordString
ACLsString

Returns​

A dictionary representing the updated configuration record after it has been written to the database.

⚠️ Added in MQTT Distributor 4.0.16.

👁️‍🗨️ Example​

props = {
"ACLs": "RW #"
}

system.cirruslink.distributor.updateConfig(
"Users",
1,
"MergeOverwrite",
props
)

deleteConfig()​

Deletes an MQTT Distributor configuration record.

Syntax​

system.cirruslink.distributor.deleteConfig(type, id)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to delete. Valid option is Users.
idLongID of the record to delete.

Returns​

TypeDescription
BooleanReturns True if the record was successfully deleted; otherwise returns False.

⚠️ Added in MQTT Distributor 4.0.16.

👁️‍🗨️ Example​

success = system.cirruslink.distributor.deleteConfig(
"Users",
1
)

print success