ⓘ 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
| Parameter | Type | Description |
|---|---|---|
| type | String | Configuration type to create. |
| props | Dictionary | Properties 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
| Parameter | Type | Description |
|---|---|---|
| type | String | Configuration type to read. Valid options are General and Users. |
Returns
A list of dictionaries representing the requested configuration records.
General Configuration Properties
| Property | Type |
|---|---|
| Id | Long |
| Enabled | Boolean |
| EnableTCP | Boolean |
| Port | Integer |
| EnableWebsocket | Boolean |
| WebsocketPort | Integer |
| EnableTLS | Boolean |
| SecurePort | Integer |
| EnableSecureWebsocket | Boolean |
| SecureWebsocketPort | Integer |
| AllowAnonymousConnections | Boolean |
User Configuration Properties
| Property | Type |
|---|---|
| Id | Long |
| Username | String |
| Password | String |
| ACLs | String |
👁️🗨️ 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
| Parameter | Type | Description |
|---|---|---|
| type | String | Configuration type to update. Valid options are General and Users. |
| id | Long | ID of the record to update. |
| collisionPolicy | String | Update behavior. Valid options are MergeOverwrite and Overwrite. |
| props | Dictionary | Properties to update on the configuration record. |
Collision Policies
| Policy | Description |
|---|---|
| MergeOverwrite | Replaces only the properties included in the request while preserving all other values. |
| Overwrite | Replaces all properties in the record with the values supplied in the request. |
Supported Properties
General Configuration
| Property | Type |
|---|---|
| Id | Long |
| Enabled | Boolean |
| EnableTCP | Boolean |
| Port | Integer |
| EnableWebsocket | Boolean |
| WebsocketPort | Integer |
| EnableTLS | Boolean |
| SecurePort | Integer |
| EnableSecureWebsocket | Boolean |
| SecureWebsocketPort | Integer |
| AllowAnonymousConnections | Boolean |
User Configuration
| Property | Type |
|---|---|
| Id | Long |
| Username | String |
| Password | String |
| ACLs | String |
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
| Parameter | Type | Description |
|---|---|---|
| type | String | Configuration type to delete. Valid option is Users. |
| id | Long | ID of the record to delete. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns 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