-
-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathstreetlights.ts
More file actions
612 lines (586 loc) · 17.1 KB
/
Copy pathstreetlights.ts
File metadata and controls
612 lines (586 loc) · 17.1 KB
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
export const streetlights = `asyncapi: '2.6.0'
id: 'urn:com:smartylighting:streetlights:server'
info:
x-x: AsyncAPISpec
x-linkedin: https://www.linkedin.com/company/asyncapi
x-random-2: random-2
x-random-1: random-1
title: Streetlights API
version: '1.0.0'
description: |
The Smartylighting Streetlights API allows you to remotely manage the city lights.
### Check out its awesome features:
* Turn a specific streetlight on/off 🌃
* Dim a specific streetlight 😎
* Receive real-time information about environmental lighting conditions 📈
termsOfService: http://asyncapi.org/terms/
contact:
name: API Support
url: http://www.asyncapi.org/support
email: support@asyncapi.org
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
tags:
- name: root-tag1
externalDocs:
description: External docs description 1
url: https://www.asyncapi.com/
- name: root-tag2
description: Description 2
externalDocs:
url: "https://www.asyncapi.com/"
- name: root-tag3
- name: root-tag4
description: Description 4
- name: root-tag5
externalDocs:
url: "https://www.asyncapi.com/"
externalDocs:
description: Find more info here
url: https://example.com
defaultContentType: application/json
servers:
production:
url: api.streetlights.smartylighting.com:{port}
protocol: mqtt
description: |
Private server that requires authorization.
Once the socket is open you can subscribe to private-data channels by sending an authenticated subscribe request message.
The API client must request an authentication "token" via the following REST API endpoint "GetWebSocketsToken" to connect to WebSockets Private endpoints. For more details read https://support.kraken.com/hc/en-us/articles/360034437672-How-to-retrieve-a-WebSocket-authentication-token-Example-code-in-Python-3
The resulting token must be provided in the "token" field of any new private WebSocket feed subscription:
\`\`\`json
{
"event": "subscribe",
"subscription":
{
"name": "ownTrades",
"token": "WW91ciBhdXRoZW50aWNhdGlvbiB0b2tlbiBnb2VzIGhlcmUu"
}
}
\`\`\`
\`\`\`elixir
defmodule Hello do
def world do
IO.puts("hello")
end
end
\`\`\`
variables:
port:
description: Secure connection (TLS) is available through port 8883.
default: '1883'
enum:
- '1883'
- '8883'
tags:
- name: 'env:production'
security:
- apiKey: []
- supportedOauthFlows:
- streetlights:on
- streetlights:off
- streetlights:dim
- openIdConnectWellKnown: []
dummy-mqtt:
url: mqtt://localhost
protocol: mqtt
description: |
Private server
\`\`\`csharp
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
\`\`\`
bindings:
mqtt:
clientId: guest
cleanSession: false
keepAlive: 60
bindingVersion: 0.1.0
lastWill:
topic: smartylighting/streetlights/1/0/lastwill
qos: 1
message: so long and thanks for all the fish
retain: false
dummy-amqp:
url: amqp://localhost:{port}
protocol: amqp
description: dummy AMQP broker
protocolVersion: "0.9.1"
variables:
port:
enum:
- '15672'
- '5672'
dommy-kafka:
url: http://localhost:{port}
protocol: kafka
description: dummy Kafka broker
variables:
port:
default: '9092'
channels:
smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
x-security:
$ref: '#/components/securitySchemes/supportedOauthFlows/flows/clientCredentials'
description: The topic on which measured values may be produced and consumed.
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
servers:
- production
- dommy-kafka
subscribe:
summary: Receive information about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
externalDocs:
description: Find more info here
url: https://example.com
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/lightMeasured'
bindings:
mqtt:
qos: 1
bindingVersion: 0.1.0
http:
type: request
method: GET
query:
type: object
required:
- companyId
properties:
companyId:
type: number
minimum: 1
description: The Id of the company.
additionalProperties: false
smartylighting/streetlights/1/0/action/{streetlightId}/turn/on:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
servers:
- production
- dummy-amqp
publish:
operationId: turnOn
security:
- supportedOauthFlows:
- streetlights:on
externalDocs:
description: Find more info here
url: https://example.com
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/turnOnOff'
smartylighting/streetlights/1/0/action/{streetlightId}/turn/off:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/turnOnOff'
smartylighting/streetlights/1/0/action/{streetlightId}/dim:
parameters:
streetlightId:
$ref: '#/components/parameters/streetlightId'
servers:
- production
- dummy-amqp
publish:
operationId: dimLight
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/dimLight'
components:
messages:
lightMeasured:
messageId: lightMeasured Message ID
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions for a particular streetlight.
contentType: application/json
correlationId:
$ref: "#/components/correlationIds/sentAtCorrelator"
externalDocs:
url: "https://www.asyncapi.com/"
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/lightMeasuredPayload"
bindings:
mqtt:
bindingVersion: 0.1.0
examples:
- headers:
my-app-header: 12
payload:
lumens: 1
sentAt: "2020-01-31T13:24:53Z"
- headers:
my-app-header: 13
- payload:
lumens: 3
sentAt: "2020-10-31T13:24:53Z"
x-schema-extensions-as-object:
type: object
properties:
prop1:
type: string
prop2:
type: integer
minimum: 0
x-schema-extensions-as-primitive: dummy
x-schema-extensions-as-array:
- "item1"
- "item2"
LwM2mOjbects:
payload:
type: object
properties:
objectLinks:
type: string
example:
objectLinks: "lwm2m=1.1, </0/0>, </1/1>;ssid=1, </2>, </3/0>"
turnOnOff:
name: turnOnOff
title: Turn on/off
summary: Command a particular streetlight to turn the lights on or off.
payload:
$ref: "#/components/schemas/turnOnOffPayload"
headers:
type: object
properties:
$ref: '#/components/schemas/streamHeaders'
dimLight:
name: dimLight
title: Dim light
summary: Command a particular streetlight to dim the lights.
correlationId:
$ref: "#/components/correlationIds/sentAtCorrelator"
externalDocs:
url: "https://www.asyncapi.com/"
tags:
- name: operation-tag1
externalDocs:
description: External docs description 1
url: https://www.asyncapi.com/
- name: operation-tag2
description: Description 2
externalDocs:
url: "https://www.asyncapi.com/"
- name: operation-tag3
- name: operation-tag4
description: Description 4
- name: operation-tag5
externalDocs:
url: "https://www.asyncapi.com/"
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/dimLightPayload"
schemas:
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
description: Light intensity measured in lumens.
writeOnly: true
oneOf:
- minimum: 0
maximum: 5
- minimum: 10
maximum: 20
externalDocs:
url: "https://www.asyncapi.com/"
sentAt:
$ref: "#/components/schemas/sentAt"
ifElseThen:
type: integer
minimum: 1
maximum: 1000
if:
minimum: 100
then:
multipleOf: 100
else:
if:
minimum: 10
then:
multipleOf: 10
dependencies:
$ref: "#/components/schemas/dependenciesObject"
anySchema: true
cannotBeDefined: false
restrictedAny:
minimum: 1
maximum: 1000
required:
- lumens
x-schema-extensions-as-object:
type: object
properties:
prop1:
type: string
prop2:
type: integer
minimum: 0
x-schema-extensions-as-primitive: dummy
x-schema-extensions-as-array:
- "item1"
- "item2"
turnOnOffPayload:
type: object
properties:
command:
type: string
enum:
- on
- off
description: Whether to turn on or off the light.
sentAt:
$ref: "#/components/schemas/sentAt"
arrayRank:
$ref: '#/components/schemas/arrayRank'
additionalProperties:
type: string
dimLightPayload:
type: object
properties:
percentage:
type: integer
description: Percentage to which the light should be dimmed to.
minimum: 0
maximum: 100
readOnly: true
sentAt:
$ref: "#/components/schemas/sentAt"
key:
type: integer
not:
minimum: 3
patternProperties:
^S_:
type: string
^I_:
type: integer
additionalProperties: false
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
union:
type: [string, number]
objectWithKey:
title: objectWithKey
type: object
propertyNames:
format: email
properties:
key:
type: string
objectWithKey2:
type: object
properties:
key2:
type: string
format: time
oneOfSchema:
oneOf:
- $ref: "#/components/schemas/objectWithKey"
- $ref: "#/components/schemas/objectWithKey2"
anyOfSchema:
anyOf:
- $ref: "#/components/schemas/objectWithKey"
- $ref: "#/components/schemas/objectWithKey2"
allOfSchema:
allOf:
- $ref: "#/components/schemas/objectWithKey"
- $ref: "#/components/schemas/objectWithKey2"
arrayContains:
type: array
contains:
type: integer
dependenciesObject:
type: object
properties:
name:
type: string
credit_card:
type: integer
billing_address:
type: string
schema_dependency:
type: string
required:
- name
dependencies:
credit_card:
properties:
billing_address:
type: string
billing_address2:
type: string
required:
- billing_address
dependencies:
billing_address2:
properties:
billing_address3:
type: string
required:
- billing_address3
subscriptionStatus:
type: object
oneOf:
- properties:
channelID:
type: integer
description: ChannelID on successful subscription, applicable to public messages only.
channelName:
type: string
description: Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix.
- properties:
errorMessage:
type: string
properties:
event:
type: string
const: subscriptionStatus
subscription:
type: object
properties:
depth:
type: string
interval:
type: string
required:
- name
required:
- event
arrayRank:
type: object
properties:
valueRank:
$ref: '#/components/schemas/arrayValueRank'
arrayDimensions:
$ref: '#/components/schemas/arrayArrayDimensions'
arrayValueRank:
description: >
This Attribute indicates whether the val Attribute of the datapoint is an
array and how many dimensions the array has.
type: integer
default: -1
examples:
- 2
oneOf:
- const: -1
description: 'Scalar: The value is not an array.'
- const: 0
description: 'OneOrMoreDimensions: The value is an array with one or more dimensions.'
- const: 1
description: 'OneDimension: The value is an array with one dimension.'
- const: 2
description: 'The value is an array with two dimensions.'
arrayArrayDimensions:
type: array
items:
type: integer
minimum: 0
examples:
- [3, 5]
streamHeaders:
Etag:
type: string
description: |
The RFC7232 ETag header field in a response provides the current entity-
tag for the selected resource. An entity-tag is an opaque identifier for
different versions of a resource over time, regardless whether multiple
versions are valid at the same time. An entity-tag consists of an opaque
quoted string, possibly prefixed by a weakness indicator.
example: 411a
Cache-Control:
description: The Cache-Control HTTP header holds directives (instructions) for caching in request.
type: string
example: no-cache, no-store, must-revalidate
securitySchemes:
apiKey:
type: apiKey
in: user
description: Provide your API key as the user and leave the password empty.
supportedOauthFlows:
type: oauth2
description: Flows to support OAuth 2.0
flows:
implicit:
authorizationUrl: 'https://authserver.example/auth'
scopes:
'streetlights:on': Ability to switch lights on
'streetlights:off': Ability to switch lights off
'streetlights:dim': Ability to dim the lights
password:
tokenUrl: 'https://authserver.example/token'
scopes:
'streetlights:on': Ability to switch lights on
'streetlights:off': Ability to switch lights off
'streetlights:dim': Ability to dim the lights
clientCredentials:
tokenUrl: 'https://authserver.example/token'
scopes:
'streetlights:on': Ability to switch lights on
'streetlights:off': Ability to switch lights off
'streetlights:dim': Ability to dim the lights
authorizationCode:
authorizationUrl: 'https://authserver.example/auth'
tokenUrl: 'https://authserver.example/token'
refreshUrl: 'https://authserver.example/refresh'
scopes:
'streetlights:on': Ability to switch lights on
'streetlights:off': Ability to switch lights off
'streetlights:dim': Ability to dim the lights
openIdConnectWellKnown:
type: openIdConnect
openIdConnectUrl: 'https://authserver.example/.well-known'
parameters:
streetlightId:
description: The ID of the streetlight.
schema:
type: string
location: "$message.payload#/user/id"
correlationIds:
sentAtCorrelator:
description: Data from message payload used as correlation ID
location: $message.payload#/sentAt
messageTraits:
commonHeaders:
headers:
type: object
properties:
my-app-header:
type: integer
minimum: 0
maximum: 100
required:
- my-app-header
operationTraits:
kafka:
bindings:
kafka:
clientId: my-app-id
`;