To create a new source, provide a JSON object with the properties for the new source. Read-only properties are ignored. MQTT sources are validated against ActiveMQ 5.14.0 and Mosquitto 1.3.4.
Definition
POST https://CLUSTER.DOMAIN/listener/appservices/sources HTTP/1.1
Example REST Source Request
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-X POST \
-d '{
"name": "My source",
"description": "A superb source",
"source_type": "REST"
}' \
-i \
https://CLUSTER.DOMAIN/listener/appservices/sources
Example MQTT Source Request
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-X POST \
-d '{
"name": "My source",
"description": "A superb source",
"source_type": "MQTT",
"subscription_info": {
"broker": "http://localhost:1234",
"topic": "My MQTT topic",
"certificate": "-----BEGIN CERTIFICATE-----\nMIID...",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIE..."
}
}' \
-i \
https://CLUSTER.DOMAIN/listener/appservices/sources
Example REST Source Response
HTTP/1.1 201 OK Content-Type: application/json
{ "source_id": "758fbda4-accc-4f90-8f09-cc0a164c8c28", "owner": ["jd123456"], "created_at": "2015-07-04T10:20:00Z", "created_by": "av012345", "updated_at": "2015-12-20T10:20:00Z", "updated_by": "jd123456", "secret": "f8a9f620-e0e6-470b-a6b8-1f16b003c034", "name": "My source", "description": "A superb source", "state": 1, "production": false, "source_type": "REST" }
Example MQTT Source Response
HTTP/1.1 201 OK Content-Type: application/json
{ "source_id": "016b3bd0-70d5-489c-bb77-30169a5cc5c4", "owner": [ "listener" ], "collaborators": null, "created_at": "2017-08-17T06:15:14Z", "created_by": "listener", "updated_at": "2017-08-17T06:15:15Z", "updated_by": "listener", "name": "My source", "description": "A superb source", "secret": "", "size": 2, "state": "1", "production": false, "source_type": "MQTT", "subscription_info": { "broker": "http://localhost:1234", "topic": "My MQTT topic" } }
Response Codes
Code | Description |
---|---|
201 | Source successfully created. |
400 | Required property missing from request. |
401 | Authorization header not found. |
If you add a source when the Elasticsearch limit of 10,000 has been reached, Listener does not return an error and Elasticsearch retains the source.