-
Notifications
You must be signed in to change notification settings - Fork 5
/
proposal.txt
319 lines (198 loc) · 8.26 KB
/
proposal.txt
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
M. Koster
A. Keränen
K. Hartke
August 1, 2019
Proposal for PubSub Broker Improvements
1. Overview
This document provides a rough sketch for improving the PubSub Broker by
splitting topics into a "configuration resource" and a "data resource".
___ Topic Collection Resources
/ \ * get list of topics
\___/ * create a new topic by submitting
\ an initial topic configuration
\_______________________
\___ \___ \___ Topic Configuration Resources
/ \ / \ / \ * get current topic configuration
\___/ \___/ \___/ * update topic configuration
| | | * get topic metadata (see below)
| | ... | * delete topic
_|_ _|_ _|_
/ \ / \ / \ Topic Data Resources
\___/ \___/ \___/ * publish an item
* observe latest published item
The topic data resource does not exist until the first item has been
published. Before the first item has been published, the topic data resource
yields a 4.04 (Not Found) response. The creator of the topic could publish a
placeholder to create the data resource or simply not give the URI of the
data resource to a subscriber until a publisher has published something.
All topic URIs should be broker-generated. There does not need to be any URI
pattern dependence between the URI where the data exists and the URI of the
topic configuration. Configuration and data resources might even be hosted
on different servers.
2. Topic Configuration
Topic configurations and topic configuration updates are represented by
CoRAL documents.
When retrieving the representation of a topic configuration resource, the
CoRAL document includes both topic metadata and topic configuration data.
When updating a topic configuration resource, the CoRAL document includes
only the topic configuration data.
2.1 Topic Metadata (read-only)
Examples:
* Location of the topic data resource (URI)
* Has any published item (boolean)
* Created timestamp (date/time)
* Last modified timestamp (date/time)
* ...
2.2 Topic Configuration Data (read/write)
Examples:
* User-friendly topic description
* Allowed content format
* Location of the authorization server
* Rate limits
* Topic lifetime
* Tombstone representation
* ...
2.3 Data Resource Attributes (read/write)
Examples:
* Resource type
* Interface type
* Physical sensor location
* Unit of sensor value
* ...
3. Operations
3.1 Get List of Topics
Request:
GET </ps/topics>
Response:
2.05 Content
Content-Format: CoRAL
rdf:type <http://example.org/pubsub/topic-list>
topic </ps/topics/1234>
topic </ps/topics/1235>
topic </ps/topics/1236>
topic </ps/topics/1237>
The list of topics is a standard collection resource. The representation
consists of a list of links to the topic configuration resources. The
resource supports the typical create/read/update/delete operations.
(The example is missing the #using's...)
3.2 Filter List of Topics
Request:
GET </ps/topics?rt=oic.r.temperature>
Accept: CoRAL
Response:
2.05 Content
Content-Format: CoRAL
rdf:type <http://example.org/pubsub/topic-list>
topic </ps/topics/1234>
topic </ps/topics/1237>
It might be useful to use the same API as CoRAL Reef. Query parameters are
limited to a fixed, well-known set of attributes.
The Accept option could be used to express a preference between CoRAL and
(for legacy clients) CoRE Link Format in the response.
3.3 Filter List of Topics by Custom Attributes
Request:
FETCH </ps/topics>
Content-Format: CoRAL
topic _ {
topic-data _ {
<http://example.org/vocab/building> 18
<http://example.org/vocab/floor> 1
<http://example.org/vocab/unit> "Cel"
}
}
Response:
2.05 Content
Content-Format: CoRAL
rdf:type <http://example.org/pubsub/topic-list>
topic </ps/topics/1234>
(CoRAL FETCH is currently not yet defined but would probably work very
similarly to SenML FETCH.)
3.4 Create a New Topic by Submitting an Initial Topic Configuration
Request:
POST </ps/topics>
Content-Format: CoRAL
rdf:type <http://example.org/pubsub/topic>
topic-title "My Office Room Temperature"
Response:
2.01 Created
Content-Format: CoRAL
Location: </ps/topics/1234>
topic </ps/topics/1234>
topic-data </ps/data/1234>
If the creator of a topic just wants all the defaults, they can just submit
an empty CoRAL document.
The Accept option could be used to express a preference between CoRAL and
(for legacy clients) CoRE Link Format in the response.
3.5 Get Current Topic Configuration
Request:
GET </ps/topics/1234>
Response:
2.05 Content
Content-Format: CoRAL
rdf:type <http://example.org/pubsub/topic>
has-published-item true
created dt'2019-07-08T15:35:00+0200'
last-modified dt'2019-07-08T15:35:00+0200'
authorization-server <coaps://my-authorization-server.example/>
max-rate 50
expires dt'2019-07-15T15:35:00+0200'
publish -> </ps/data/1234> [ method 3 ]
topic-data </ps/data/1234> {
title "My Office Room Temperature"
rt "oic.r.temperature"
building 18
floor 1
unit "Cel"
}
Publishers should be given the form with the 'publish' operation type.
Subscribers should be given the link with the 'topic-data' relation type.
3.6 Update the Topic Configuration
Request:
PATCH </ps/topics/1234>
Content-Format: CoRAL
max-rate 60
Response:
2.04 Changed
(CoRAL PATCH is currently not yet defined but would probably work very
similarly to SenML PATCH.)
3.7 Delete the Topic
Request:
DELETE </ps/topics/1234>
Response:
2.02 Deleted
3.8 Publish an Item
A publisher can publish an item by submitting a form with the 'publish'
operation type.
Request:
PUT </ps/data/1234>
Content-Format: SenML
[...SenML data here...]
Response:
2.04 Changed
3.9 Get the Latest Published Item
Request:
GET </ps/data/1234>
Response:
2.05 Content
Content-Format: SenML
[...SenML data here...]
3.10 Observe the Latest Published Item
Request:
GET </ps/data/1234>
Observe: 0
Response:
2.05 Content
Content-Format: SenML
Observe: 9876
[...SenML data here...]
If the 2.05 (Content) response does not include an Observe option, the
subscriber can poll the resource.
4. References
Koster, M., Keränen, A., and J. Jiménez, "Publish-Subscribe Broker for the
Constrained Application Protocol (CoAP)", draft-ietf-core-coap-pubsub-08
(work in progress), March 2019.
Hartke, K., "The Constrained RESTful Application Language (CoRAL)",
draft-hartke-t2trg-coral-09 (work in progress), July 2019.
Acknowledgements
Thanks to Christian Amsüss, Carsten Bormann, and Jim Schaad for helpful
comments and discussions that have shaped the document.