-
Notifications
You must be signed in to change notification settings - Fork 2
/
insight_service.yaml
675 lines (646 loc) · 23.2 KB
/
insight_service.yaml
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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
swagger: '2.0'
################################################################################
# Service Metadata #
################################################################################
info:
version: "1.0"
title: Example Insight
description: |
Example Insight
contact:
name: Exosite
email: support@exosite.com
################################################################################
# API Information #
################################################################################
# A hostname with a valid, signed, and active TSL certificate is required.
host: .io
basePath: /api/v1
tags:
- name: insight
description: Insight Module
schemes:
- https # Only https is supported.
consumes:
- application/json # Only JSON is supported.
produces:
- application/json # Only JSON is supported.
################################################################################
# Solution lifecycle Events #
################################################################################
# Following Operation should generally be restricted with "x-exosite-restricted: true"
x-exosite-init: createSolution # Triggered by Murano when this service is enabled in a solution
x-exosite-gc: delSolution # Triggered by Murano when the service is removed from a solution or if the solution is deleted
################################################################################
# Operations #
################################################################################
paths:
/:
get:
description: Alive check
operationId: alive
x-exosite-restricted: true # Indicate that this operation cannot be called from user scripts
responses:
'200':
description: Solution successfully created
default:
description: Error
schema:
$ref: '#/definitions/ErrorResponse'
# Administration endpoint used by Murano solution lifecycle events
# Those operation uses the "x-exosite-restricted" to prevent the user to access them directly
/{solution_id}:
parameters:
- name: solution_id
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
type: string
in: path
description: The solution identifier. Set automatically.
required: true
post:
description: Used by Murano to create a solution namespace.
operationId: createSolution
x-exosite-restricted: true # Indicate that this operation cannot be called from user scripts
responses:
'200':
description: Solution successfully created
default:
description: Error
schema:
$ref: '#/definitions/ErrorResponse'
delete:
description: Used by Murano to remove a solution and clean its namespace.
operationId: delSolution
x-exosite-restricted: true
responses:
'205':
description: Solution successfully removed.
default:
description: Error
schema:
$ref: '#/definitions/ErrorResponse'
/{solution_id}/info:
parameters:
- name: solution_id
type: string
in: path
description: The solution identifier. Set automatically by Murano at service call.
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
required: true
get:
operationId: info
description: Get some info about this Insight
responses:
"200":
description: Insight Functions successfully listed
schema:
$ref: "#/definitions/InsightInfoResults"
default:
description: Errors
schema:
$ref: '#/definitions/ErrorResponse'
/{solution_id}/insights:
parameters:
- name: solution_id
type: string
in: path
description: The solution identifier. Set automatically by Murano at service call.
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
required: true
post:
operationId: listInsights
description: Get a list of available Insight Functions and info about them
parameters:
- name: body
in: body
description: Get a list of available insight functions
required: true
schema:
$ref: '#/definitions/InsightsFilterParams'
responses:
"200":
description: Insight Functions successfully listed
schema:
$ref: "#/definitions/InsightListResults"
default:
description: Errors
schema:
$ref: '#/definitions/ErrorResponse'
/{solution_id}/insight/{function_id}:
parameters:
- name: solution_id
type: string
in: path
description: The solution identifier. Set automatically by Murano at service call.
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
required: true
get:
operationId: infoInsight
description: Get info about one Insight Function
parameters:
- name: function_id
type: string
in: path
description: Identifier of function
responses:
"200":
description: Insight Functions successfully listed
schema:
$ref: "#/definitions/InsightInfo"
default:
description: Errors
schema:
$ref: '#/definitions/ErrorResponse'
/{solution_id}/lifecycle:
parameters:
- name: solution_id
type: string
in: path
description: The solution identifier. Set automatically by Murano at service call.
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
required: true
post:
operationId: lifecycle
description: |
Notifications of when a linkage that will call the process function is created or deleted.
parameters:
- name: body
in: body
description: Lifecycle event
required: true
schema:
$ref: '#/definitions/LifecycleEvent'
responses:
default:
description: The response to this is ignored.
/{solution_id}/process:
parameters:
- name: solution_id
type: string
in: path
description: The solution identifier. Set automatically by Murano at service call.
x-exosite-from: solution_id # Indicate this value is injected from the user solution_id
x-exosite-restricted: true # Indicate the user cannot provide this parameter
required: true
post:
operationId: process
description: |
Your function to process a bunch of Signal Data.
It is good form to copy all the fields of a source SignalData into the new SignalData,
then update the properties according to your function.
parameters:
- name: body
in: body
description: Data to process and arguments on how to process it
required: true
schema:
$ref: "#/definitions/SignalDataObjectArray"
responses:
"200":
description: Data successfully
schema:
$ref: "#/definitions/SignalDataArrayArray"
default:
description: Error that stops the pipeline.
Non-fatal errors should produce new signals on a separate outlet.
schema:
$ref: '#/definitions/ErrorResponse'
################################################################################
# Definitions #
################################################################################
definitions:
InsightInfoResults:
type: object
description: Info about this Insight Module
properties:
group_id_required:
type: boolean
description: True if the listInsights requires group_id to be something to list functions.
name:
type: string
description: Presented name
description:
type: string
description: Additional text about this insight. Markdown can be used.
wants_lifecycle_events:
type: boolean
description: |
True if this insight wants to be notified when linkages using it are created and deleted.
Defaults to false.
translations:
type: object
description: Translations of the name and description fields
additionalProperties:
type: object
description: Keyed by each translated language code
properties:
name:
type: string
description: Presented name
description:
type: string
description: Additional text about this insight. Markdown can be used.
required: [group_id_required]
InsightsFilterParams:
type: object
description: Filter options for insight functions
properties:
group_id:
type: string
description: |
Which group of insight functions to get. The meaning of the contents is up to the Insight Module.
Including ignoring it and always returning all.
limit:
type: integer
description: Limit how many insights to fetch
offset:
type: integer
description: Offset into the returned insights
required: [group_id]
SignalTypeInputInfo:
type: object
description: |
What data type the incoming Signal must have. One of `primitive_type`, `data_type` or `data_unit`
should be specified.
required: [name]
properties:
primitive_type:
type: string
enum: [NUMERIC, STRING, BOOLEAN, JSON]
description: If present, the primitive type that the connecting signal must have
data_type:
type: array
description: If present, the type that the connecting signal must have
items:
type: string
description: A required data type
data_unit:
type: array
description: If present, the units that the connecting signal must have
items:
type: string
description: A required unit.
tag:
type: string
description: Optional tag to add to the SignalData for inlet matching
name:
type: string
description: Name of this signal
description:
type: string
description: Optional text to help users.
translations:
type: object
description: Translations of the name and description fields
additionalProperties:
type: object
description: Keyed by each translated language code
properties:
name:
type: string
description: Presented name
description:
type: string
description: Optional text to help users.
SignalTypeOutputInfo:
type: object
description: |
What data type the incoming Signal must have. One of `primitive_type`, `data_type` or `data_unit`
should be specified.
properties:
primitive_type:
type: string
enum: [NUMERIC, STRING, BOOLEAN, JSON]
description: If present, the primitive type that the connecting signal must have
data_type:
type: array
description: If present, the type that the connecting signal must have
items:
type: string
description: A required data type.
data_unit:
type: array
description: If present, the unit that the connecting signal must have
items:
type: string
description: A required unit.
name:
type: string
description: Name of this outlet
description:
type: string
description: Optional text to help users.
suggested_name:
type: string
description: |
A suggestion for what to name signals that get created for this outlet.
This may include `{}` to indicate where to place the function name.
translations:
type: object
description: Translations of the name and description fields
additionalProperties:
type: object
description: Keyed by each translated language code
properties:
name:
type: string
description: Presented name
description:
type: string
description: Optional text to help users.
suggested_name:
type: string
description: |
A suggestion for what to name signals that get created for this outlet.
This may include `{}` to indicate where to place the function name.
ConstantInfo:
type: object
description: A constant that needs to be provided by the user
properties:
name:
type: string
description: The name of this constant; This is not shown to users and is the code identifier for this constant.
type:
type: string
enum: [string, number, boolean]
description: What kind of value this constant accepts
description:
type: string
description: Some words for the user about this constant
default:
type: [string, number, boolean]
description: Optional value to use if user doesn't specify one.
enum:
type: array
description: An array of allowed values.
items:
description: An allowed value
oneOf:
- type: string
- type: number
- type: boolean
enum_presented:
type: array
description: If present, the strings to display instead of the values in `enum`. The length of this must match `enum`.
items:
type: string
description: Presentable name for one value
maximum:
type: number
description: For number type, the largest it can be
minimum:
type: number
description: For number type, the smallest it can be
multiple:
type: boolean
description: |
When this is true, this constant will be an array of values instead of a single value.
The UI will present the user a way to enter this constant multiple times.
translations:
type: object
description: Translations of the name and description fields
additionalProperties:
type: object
description: Keyed by each translated language code
properties:
description:
type: string
description: Some words for the user about this constant
enum_presented:
type: array
description: If present, the strings to display instead of the values in `enum`.
items:
type: string
required: [name, type]
InsightInfo:
type: object
description: One insight function
properties:
id:
type: string
description: The unique id for this insight function
name:
type: string
description: A human friendly name for this insight function
description:
type: string
description: A description of this insight function to display to users.
translations:
type: object
description: Translations of the name and description fields
additionalProperties:
type: object
description: Keyed by each translated language code
properties:
name:
type: string
description: A human friendly name for this insight function
description:
type: string
description: A description of this insight function to display to users.
type:
type: string
enum: [transform, rule, action]
description: |
What kind of insight this function is. Determines how it gets used and how the UI
presents it. If omitted, then 'transform' is used.
history:
type: object
description: |
When this object is present, a timeseries query will be called and the results sent along
to the function call. The properties here will be used to augment the query. Only the
Signals connected to the calling of this function will be queried.
properties:
include_from:
type: string
enum: [INLETS, OUTLETS, BOTH]
description: When fetching history, which connected signals to fetch from. Defaults to BOTH.
additionalProperties:
type: object
description: An additional parameter to the query. Use only one property. (value, constant, template)
properties:
value:
type: [string, number]
description: The exact value to use
constant:
type: string
description: Which of this function's constants to use the value of here
template:
type: string
description: |
Which of this function's constants to use the value of here, fitted into a template
string. The constants must be surrounded with '{{}}'. For example '-{{days}}d'
constants:
type: array
description: Additional user specified values to pass to this insight function
items:
$ref: '#/definitions/ConstantInfo'
constants_multiple_maximum:
type: number
description: |
If there are constants with multiple set to true, this states the maximum number of times the
constants can be repeated. (The maximum size of the arrays.)
If unspecified then the UI can apply any limit, including none.
inlets:
type: array
description: The kinds of data that can be connected. (This is an unordered set)
maxItems: 5
items:
$ref: '#/definitions/SignalTypeInputInfo'
outlets:
type: array
description: What kind of data each output will produce. (This is an ordered array)
maxItems: 5
items:
$ref: '#/definitions/SignalTypeOutputInfo'
required:
- id
- name
- description
InsightListResults:
type: object
description: The found insight functions with count info
properties:
total:
type: integer
description: The total number of insight functions in this group
count:
type: integer
description: Number of insight functions returned
insights:
type: array
description: The insight functions
items:
$ref: '#/definitions/InsightInfo'
required:
- insights
- total
- count
LifecycleEvent:
type: object
description: A Lifecycle event
properties:
event:
type: string
description: What action caused this event
pattern: "(create|delete)"
id:
type: string
description: The unique id for the linkage that has the event. This id will match in the calls to process.
args:
type: object
description: The arguments for this linkage that will be also passed to each call of process.
SignalData:
type: object
description: A single instance of a piece of data inside a signal.
properties:
tags:
type: object
description: |
Tag-Value pairs to help ID the data. Used to tie the data back to an
Asset or Device or other things.
additionalProperties:
type: string
description: Value for a tag
minLength: 1
ts:
type: integer
description: Unix timestamp in microseconds of when the data originated
gts:
type: integer
description: Unix timestamp in microseconds of when this SignalData was generated
value:
type: [string, number, object]
description: The value for this instance of data
origin:
type: string
description: The original Publishing ID
minLength: 1
generated:
type: string
description: The Publishing ID that created this SignalData.
minLength: 1
ttl:
type: integer
description: Value used to help prevent data from infinitely cycling
required:
- ts
- value
- origin
- generated
HistoricalData:
type: object
description: The history of signals. Each signal id is the key, with an array of timestamp, value pairs.
additionalProperties:
type: array
description: The history of signals. Each signal id is the key, with an array of timestamp, value pairs.
items:
type: object
description: One point in history
properties:
ts:
type: integer
description: Unix timestamp in microseconds of when the data was stored
value:
type: [string, number, object]
description: The value for this instance of data
tags:
type: object
description: Tag-Value pairs to help ID the data. (Tags here are a subset of those in SignalData)
additionalProperties:
type: string
description: Value for a tag
minLength: 1
required: [ts, value]
SignalDataArray:
type: array
description: Array of Signal Data
items:
$ref: '#/definitions/SignalData'
SignalDataArrayArray:
type: array
description: Array of Array of Signal Data. An array for each outlet, each outlet can have many signals.
items:
$ref: '#/definitions/SignalDataArray'
SignalDataObjectArray:
type: object
description: The data and arguments to be processed.
properties:
id:
type: string
description: A unique ID for this instance of this function in an asset pipeline.
data:
$ref: '#/definitions/SignalDataArray'
history:
$ref: '#/definitions/HistoricalData'
args:
type: object
description: Object of instance arguments.
properties:
function_id:
type: string
description: Which insight function to run
group_id:
type: string
description: Which group_id this is under
constants:
type: object
description: Additional constant parameters for the selected function
ErrorResponse:
type: object
description: Error response that stops the pipeline.
properties:
message:
type: string
description: Error message
status:
type: number
description: A numerical code for the error
name:
description: Error type
type: string