-
Notifications
You must be signed in to change notification settings - Fork 214
/
connectionTemplates.json
256 lines (256 loc) · 9.98 KB
/
connectionTemplates.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
"AMQP 0.9.1": {
"name": "AMQP 0.9.1",
"connectionType": "amqp-091",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "amqp://user:password@localhost:5672/vhost",
"sources": [
{
"addresses": [
"queueName"
],
"authorizationContext": [
"ditto:inbound-auth-subject"
]
}
],
"targets": [
{
"address": "exchangeName/routingKey",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
]
}
]
},
"AMQP 1.0": {
"name": "AMQP 1.0",
"connectionType": "amqp-10",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "amqps://user:password@hono.eclipseprojects.io:5671",
"sources": [
{
"addresses": [
"telemetry/FOO"
],
"authorizationContext": [
"ditto:inbound-auth-subject"
]
}
],
"targets": [
{
"address": "events/twin",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
]
}
]
},
"MQTT 3.1.1": {
"name": "MQTT 3.1.1",
"connectionType": "mqtt",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "tcp://test.mosquitto.org:1883",
"sources": [
{
"addresses": [
"eclipse-ditto-sandbox/#"
],
"authorizationContext": [
"ditto:inbound-auth-subject"
],
"qos": 0
}
],
"targets": [
{
"address": "eclipse-ditto-sandbox/{{ thing:id }}",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
],
"qos": 0
}
]
},
"MQTT 5": {
"name": "MQTT 5",
"connectionType": "mqtt-5",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "tcp://test.mosquitto.org:1883",
"sources": [
{
"addresses": [
"eclipse-ditto-sandbox/#"
],
"authorizationContext": [
"ditto:inbound-auth-subject"
],
"qos": 0
}
],
"targets": [
{
"address": "eclipse-ditto-sandbox/{{ thing:id }}",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
],
"qos": 0
}
]
},
"MQTT 5 with JS mapping": {
"name": "MQTT 5 with JS mapping",
"connectionType": "mqtt-5",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "tcp://test.mosquitto.org:1883",
"sources": [
{
"addresses": [
"eclipse-ditto-sandbox/#"
],
"authorizationContext": [
"ditto:inbound-auth-subject"
],
"qos": 0,
"enforcement": {
"input": "{{ source:address }}",
"filters": [
"eclipse-ditto-sandbox/{{ thing:name }}/update"
]
},
"replyTarget": {
"enabled": false
},
"payloadMapping": ["javascript"]
}
],
"targets": [
{
"address": "eclipse-ditto-sandbox/{{ thing:id }}",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
],
"qos": 0,
"payloadMapping": ["javascript"]
}
],
"mappingDefinitions": {
"javascript": {
"mappingEngine": "JavaScript",
"options": {
"incomingScript": "/**\n * Maps the passed parameters to a Ditto Protocol message.\n * @param {Object.<string, string>} headers - The headers Object containing all received header values\n * @param {string} [textPayload] - The String to be mapped\n * @param {ArrayBuffer} [bytePayload] - The bytes to be mapped as ArrayBuffer\n * @param {string} [contentType] - The received Content-Type, e.g. \"application/json\"\n * @returns {(DittoProtocolMessage|Array<DittoProtocolMessage>)} dittoProtocolMessage(s) -\n * The mapped Ditto Protocol message,\n * an array of Ditto Protocol messages or\n * <code>null</code> if the message could/should not be mapped\n */\nfunction mapToDittoProtocolMsg(\n headers,\n textPayload,\n bytePayload,\n contentType\n) {\n\n // ### Insert/adapt your mapping logic here.\n // Use helper function Ditto.buildDittoProtocolMsg to build Ditto protocol message\n // based on incoming payload.\n // See https://www.eclipse.org/ditto/connectivity-mapping.html#helper-functions for details.\n\n // ### example code assuming the Ditto protocol content type for incoming messages.\n if (contentType === 'application/vnd.eclipse.ditto+json') {\n // Message is sent as Ditto protocol text payload and can be used directly\n return JSON.parse(textPayload);\n } else if (contentType === 'application/octet-stream') {\n // Message is sent as binary payload; assume Ditto protocol message (JSON).\n try {\n return JSON.parse(Ditto.arrayBufferToString(bytePayload));\n } catch (e) {\n // parsing failed (no JSON document); return null to drop the message\n return null;\n }\n }\n\n // no mapping logic matched; return null to drop the message\n return null;\n}",
"outgoingScript": "/**\n * Maps the passed parameters which originated from a Ditto Protocol message to an external message.\n * @param {string} namespace - The namespace of the entity in java package notation, e.g.: \"org.eclipse.ditto\". Or \"_\"\n * (underscore) for connection announcements.\n * @param {string} name - The name of the entity, e.g.: \"device\".\n * @param {string} group - The affected group/entity: \"things\"|\"policies\"|\"connections\".\n * @param {string} channel - The channel for the signal: \"twin\"|\"live\"|\"none\"\n * @param {string} criterion - The criterion to apply: \"commands\"|\"events\"|\"search\"|\"messages\"|\"announcements\"|\"errors\".\n * @param {string} action - The action to perform: \"create\"|\"retrieve\"|\"modify\"|\"delete\". Or the announcement name:\n * \"opened\"|\"closed\"|\"subjectDeletion\". Or the subject of the message.\n * @param {string} path - The path which is affected by the message (e.g.: \"/attributes\"), or the destination\n * of a message (e.g.: \"inbox\"|\"outbox\").\n * @param {Object.<string, string>} dittoHeaders - The headers Object containing all Ditto Protocol header values.\n * @param {*} [value] - The value to apply / which was applied (e.g. in a \"modify\" action).\n * @param {number} [status] - The status code that indicates the result of the command. When this field is set,\n * it indicates that the Ditto Protocol Message contains a response.\n * @param {Object} [extra] - The enriched extra fields when selected via \"extraFields\" option.\n * @returns {(ExternalMessage|Array<ExternalMessage>)} externalMessage - The mapped external message, an array of\n * external messages or <code>null</code> if the message could/should not be mapped.\n */\nfunction mapFromDittoProtocolMsg(\n namespace,\n name,\n group,\n channel,\n criterion,\n action,\n path,\n dittoHeaders,\n value,\n status,\n extra\n) {\n\n // ###\n // Insert your mapping logic here\n\n // ### example code using the Ditto protocol content type.\n let headers = dittoHeaders;\n let textPayload = JSON.stringify(Ditto.buildDittoProtocolMsg(namespace, name, group, channel, criterion, action,\n path, dittoHeaders, value, status, extra));\n let bytePayload = null;\n let contentType = 'application/vnd.eclipse.ditto+json';\n\n return Ditto.buildExternalMsg(\n headers, // The external headers Object containing header values\n textPayload, // The external mapped String\n bytePayload, // The external mapped byte[]\n contentType // The returned Content-Type\n );\n}",
"loadBytebufferJS": "false",
"loadLongJS": "false"
}
}
}
},
"HTTP 1.1": {
"name": "HTTP 1.1",
"connectionType": "http-push",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "https://webhook.site:443/<YOUR-WEBHOOK-ID>",
"specificConfig": {
"parallelism": "1"
},
"sources": [],
"targets": [
{
"address": "POST:/ditto-event/{{ thing:id }}",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
],
"headerMapping": {
"content-type": "{{ header:content-type }}",
"api-key": "this-is-a-secret-api-key-to-send-along"
}
}
]
},
"Kafka 2.x": {
"name": "Kafka 2.x",
"connectionType": "kafka",
"connectionStatus": "closed",
"failoverEnabled": true,
"uri": "tcp://user:password@localhost:9092",
"specificConfig": {
"bootstrapServers": "localhost:9092,other.host:9092",
"saslMechanism": "plain"
},
"sources": [
{
"addresses": [
"theTopic"
],
"consumerCount": 1,
"qos": 1,
"authorizationContext": [
"ditto:inbound-auth-subject"
],
"enforcement": {
"input": "{{ header:device_id }}",
"filters": [
"{{ entity:id }}"
]
},
"headerMapping": {},
"payloadMapping": [
"Ditto"
],
"replyTarget": {
"enabled": true,
"address": "theReplyTopic",
"headerMapping": {},
"expectedResponseTypes": [
"response",
"error",
"nack"
]
},
"acknowledgementRequests": {
"includes": []
},
"declaredAcks": []
}
],
"targets": [
{
"address": "topic/key",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
],
"authorizationContext": [
"ditto:outbound-auth-subject"
]
}
]
}
}