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.
For Kafka sources, Listener validates the Kafka topic exists. If a topic is on a different broker than the default broker configured during installation, you can specify the correct Kafka broker and ZooKeeper details in the request. In this case, Listener validates broker and ZooKeeper details as well.
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 Kafka Source Request
curl -X "POST" "https://myenv.uda.io/listener/appservices/v1/sources" \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVfdG9rZW5fdGltZSI6MTU2NDY4MDk0Nzc1OTg0MzgwMCwiZXhwIjoxNTY0NzY3MzQ3LCJpZCI6Imxpc3RlbmVyIiwic2l0ZV9hZG1pbiI6dHJ1ZX0.zs6MF70Lb7jUtXf41nFpJMDfWPRwoO38VLxIpVmv9tA' \ -d $'{ "subscription_info": { "topic": "listener", "zookeeper": "zookeeper_host:zookeeper_port:/{path}", "broker": "broker_host:broker_port" }, "owner": [ "listener" ], "source_type": "KAFKA", "name": "customerkafka", "description": "Kafka source" }'
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" } }
Example Kafka Source Response
{ "source_id": "22b05fee-80a1-486d-9d1e-95e650a16cc7", "owner": [ "listener" ], "collaborators": null, "created_at": "2019-08-02T16:55:21Z", "created_by": "listener", "updated_at": "2019-08-02T16:55:21Z", "updated_by": "listener", "name": "customerkafka", "description": "test", "secret": "", "size": 2, "state": "1", "production": false, "source_type": "KAFKA", "subscription_info": { "broker": "broker_host:broker_port", "topic": "listener", "zookeeper": "zookeeper_host:zookeeper_port:/{path}" } }
Response Codes
Code | Description |
---|---|
201 | Source successfully created. |
400 | Required property missing from request. |
400 | Data validation error. Topic does not exist. |
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.