summaryrefslogtreecommitdiffstats
path: root/docs/sections/components/data-formats.rst
blob: ecb019c22dfd74c315df16d5cac49ab839950932 (plain)
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
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

.. _data-formats:

Data Formats
============

| Because the DCAE designer composes your component with others at
  service design time, in most cases you do not know what specific
  component(s) your component will send data to during runtime. Thus, it
  is vital that DCAE has a language of describing the data passed
  between components, so that it is known which components are
  composable with others. Data formats are descriptions of data—they are
  the data contract between your component and other components. You
  need to describe the available outputs and assumed inputs of your
  components as data formats. These data descriptions are onboarded into
  ASDC, and each receives a UUID. If component X outputs data format
  DF-Y, and another component Z specifies DF-Y as their input data
  format, then X is said to be *composable* with that component. The
  data formats are referenced in the component specifications by the
  data format’s id and version.
| The vision is to have a repository of shared data formats that
  developers and teams can re-use and also provide them the means to
  extend and create new custom data formats.

.. _dataformat_metadata:

Meta Schema Definition
----------------------

The “Meta Schema” implementation defines how data format JSON schemas
can be written to define user input. It is itself a JSON schema (thus it
is a “meta schema”). It requires the name of the data format entry, the
data format entry version and allows a description under “self” object.
The meta schema version must be specified as the value of the
“dataformatversion” key. Then the input schema itself is described.
There are four types of schema descriptions objects - jsonschema for
inline standard JSON Schema definitions of JSON inputs, delimitedschema
for delimited data input using a defined JSON description, unstructured
for unstructured text, and reference that allows a pointer to another
artifact for a schema. The reference allows for XML schema, but can be
used as a pointer to JSON, Delimited Format, and Unstructured schemas as
well.

The current Meta Schema implementation is defined below:

::

    {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "Data format specification schema Version 1.0",
        "type": "object",
        "oneOf": [{
            "properties": {
                "self": {
                    "$ref": "#/definitions/self"
                },
                "dataformatversion": {
                    "$ref": "#/definitions/dataformatversion"
                },
                "reference": {
    
                    "type": "object",
                    "description": "A reference to an external schema - name/version is used to access the artifact",
                    "properties": {
                        "name": {
                            "$ref": "#/definitions/name"
                        },
                        "version": {
                            "$ref": "#/definitions/version"
                        },
                        "format": {
                            "$ref": "#/definitions/format"
                        }
                    },
                    "required": [
                        "name",
                        "version",
                        "format"
                    ],
                    "additionalProperties": false
                }
            },
            "required": ["self", "dataformatversion", "reference"],
            "additionalProperties": false
        }, {
            "properties": {
                "self": {
                    "$ref": "#/definitions/self"
                },
                "dataformatversion": {
                    "$ref": "#/definitions/dataformatversion"
                },
                "jsonschema": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "description": "The actual JSON schema for this data format"
                }
    
            },
            "required": ["self", "dataformatversion", "jsonschema"],
            "additionalProperties": false
        }, {
            "properties": {
                "self": {
                    "$ref": "#/definitions/self"
                },
                "dataformatversion": {
                    "$ref": "#/definitions/dataformatversion"
                },
                "delimitedschema": {
                    "type": "object",
                    "description": "A JSON schema for delimited files",
                    "properties": {
                        "delimiter": {
                            "enum": [",", "|", "\t", ";"]
                        },
                        "fields": {
                            "type": "array",
                            "description": "Array of field descriptions",
                            "items": {
                                "$ref": "#/definitions/field"
                            }
                        }
                    },
                    "additionalProperties": false
                }
            },
            "required": ["self", "dataformatversion", "delimitedschema"],
            "additionalProperties": false
        }, {
            "properties": {
                "self": {
                    "$ref": "#/definitions/self"
                },
                "dataformatversion": {
                    "$ref": "#/definitions/dataformatversion"
                },
                "unstructured": {
                    "type": "object",
                    "description": "A JSON schema for unstructured text",
                    "properties": {
                        "encoding": {
                            "type": "string",
                            "enum": ["ASCII", "UTF-8", "UTF-16", "UTF-32"]
                        }
                    },
                    "additionalProperties": false
    
                }
            },
            "required": ["self", "dataformatversion", "unstructured"],
            "additionalProperties": false
        }],
        "definitions": {
            "name": {
                "type": "string"
            },
            "version": {
                "type": "string",
                "pattern": "^(\\d+\\.)(\\d+\\.)(\\*|\\d+)$"
            },
            "self": {
                "description": "Identifying Information for the Data Format - name/version can be used to access the artifact",
                "type": "object",
                "properties": {
                    "name": {
                        "$ref": "#/definitions/name"
                    },
                    "version": {
                        "$ref": "#/definitions/version"
                    },
                    "description": {
                        "type": "string"
                    }
                },
                "required": [
                    "name",
                    "version"
                ],
                "additionalProperties": false
            },
            "format": {
                "description": "Reference schema type",
                "type": "string",
                "enum": [
                    "JSON",
                    "Delimited Format",
                    "XML",
                    "Unstructured"
                ]
            },
            "field": {
                "description": "A field definition for the delimited schema",
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "fieldtype": {
                        "description": "the field type - from the XML schema types",
                        "type": "string",
                        "enum": ["string", "boolean",
                            "decimal", "float", "double",
                            "duration", "dateTime", "time",
                            "date", "gYearMonth", "gYear",
                            "gMonthDay", "gDay", "gMonth",
                            "hexBinary", "base64Binary",
                            "anyURI", "QName", "NOTATION",
                            "normalizedString", "token",
                            "language", "IDREFS", "ENTITIES",
                            "NMTOKEN", "NMTOKENS", "Name",
                            "NCName", "ID", "IDREF", "ENTITY",
                            "integer", "nonPositiveInteger",
                            "negativeInteger", "long", "int",
                            "short", "byte",
                            "nonNegativeInteger", "unsignedLong",
                            "unsignedInt", "unsignedShort",
                            "unsignedByte", "positiveInteger"
    
                        ]
                    },
                    "fieldPattern": {
                        "description": "Regular expression that defines the field format",
                        "type": "integer"
                    },
                    "fieldMaxLength": {
                        "description": "The maximum length of the field",
                        "type": "integer"
                    },
                    "fieldMinLength": {
                        "description": "The minimum length of the field",
                        "type": "integer"
                    },
                    "fieldMinimum": {
                        "description": "The minimum numeric value of the field",
                        "type": "integer"
                    },
                    "fieldMaximum": {
                        "description": "The maximum numeric value of the field",
                        "type": "integer"
                    }
                },
                "additionalProperties": false
            },
            "dataformatversion": {
                "type": "string",
                "enum": ["1.0.0"]
            }
        }
    }

Examples
-----------

By reference example - Common Event Format 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

First the full JSON schema description of the Common Event Format would
be loaded with a name of “Common Event Format” and the current version
of “25.0.0”.

Then the data format description is loaded by this schema:

::

    {
        "self": {
            "name": "Common Event Format Definition",
            "version": "25.0.0",
            "description": "Common Event Format Definition"
     
        },
        "dataformatversion": "1.0.0",
        "reference": {
            "name": "Common Event Format",
            "format": "JSON",
            "version": "25.0.0"
       }
    }



Simple JSON Example
~~~~~~~~~~~~~~~~~~~~~~~~


::

    {
        "self": {
            "name": "Simple JSON Example",
            "version": "1.0.0",
            "description": "An example of unnested JSON schema for Input and output"
    
        },
        "dataformatversion": "1.0.0",
        "jsonschema": {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "properties": {
                "raw-text": {
                    "type": "string"
                }
            },
            "required": ["raw-text"],
            "additionalProperties": false
        }
    }

Nested JSON Example
~~~~~~~~~~~~~~~~~~~~~~~~

::

    {
        "self": {
            "name": "Nested JSON Example",
            "version": "1.0.0",
            "description": "An example of nested JSON schema for Input and output"
    
        },
        "dataformatversion": "1.0.0",
        "jsonschema": {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "properties": {
                "numFound": {
                    "type": "integer"
                },
                "start": {
                    "type": "integer"
                },
                "engagements": {
                    "type": "array",
                    "items": {
                        "properties": {
                            "engagementID": {
                                "type": "string",
                                "transcript": {
                                    "type": "array",
                                    "items": {
                                        "type": {
                                            "type": "string"
                                        },
                                        "content": {
                                            "type": "string"
                                        },
                                        "senderName": {
                                            "type": "string"
                                        },
                                        "iso": {
                                            "type": "string"
                                        },
                                        "timestamp": {
                                            "type": "integer"
                                        },
                                        "senderId": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "additionalProperties": false
        }
    }

Unstructured Example
~~~~~~~~~~~~~~~~~~~~~~~~~

::

    {
        "self": {
            "name": "Unstructured Text Example",
            "version": "25.0.0",
            "description": "An example of a unstructured text used for both input and output for "
    
        },
        "dataformatversion": "1.0.0",
        "unstructured": {
            "encoding": "UTF-8"
        }
    }


An example of a delimited schema
--------------------------------

::

    {
        "self": {
            "name": "Delimited Format Example",
            "version": "1.0.0",
            "description": "Delimited format example just for testing"

        },
        "dataformatversion": "1.0.0",
        "delimitedschema": {
            "delimiter": "|",
            "fields": [{
                "name": "field1",
                "description": "test field1",
                "fieldtype": "string"
            }, {
                "name": "field2",
                "description": "test field2",
                "fieldtype": "boolean"
            }]
        }
    }