Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Specification Audit

Active Version

v2.0

CDAP >= v3.0Initial Version
Dev Versionv2.1CDAP > 3.4Adding label to metadata section to display better plugin names. CDAP-5340

Purpose

To help any hydrator plugin developer write a configuration JSON for representing properties of a hydrator plugin, group them and configure the output(s) (the schema of data going out of a plugin) if any required.

Why do we need this?

What this JSON achieves is to help in configuring the configurations of a plugin to be specific components in UI so that overhead of giving the right format of value for a configuration is removed. By default if no configuration is provided for a plugin all the properties appear as text-boxes in UI. It will be difficult to fill in the values for them if it requires it in specific format (for instance JSON or select one from multiple choices etc.,).

What does it have - Structure?

Before we dive into the structure it is imperative we clear up certain terms.

  • Configuring (Configurations) – A plugin in hydrator has configurations that needs to be set with appropriate value, for the plugin to function. This configuration could be a string or a number or a JSON blob or a Javascript/Python snippet etc., Configuring here refers to setting plugin configurations with appropriate value and for hydrator developers to do that we need to map configurations to widget to set a value.
  •  Output –  Every plugin will have data emitted out of it (passing it to subsequent plugins or dump to a database). An output of a plugin specifies the schema of data that is emitted out of the plugin.
  •  Input –  Similar to output every plugin will have an input data coming into the plugin (except for source plugins)

Configuration JSON for a plugin is structured as,

  • metadata

  • list of groups of configurations

  • list of output configurations

...

Specification Audit

Active Version

v2.0

CDAP >= v3.0Initial Version
Dev Versionv2.1CDAP > 3.4Adding label to metadata section to display better plugin names. CDAP-5340

Purpose

To help any hydrator plugin developer write a configuration JSON for representing properties of a hydrator plugin, group them and configure the output(s) (the schema of data going out of a plugin) if any required.

Why do we need this?

What this JSON achieves is to help in configuring the configurations of a plugin to be specific components in UI so that overhead of giving the right format of value for a configuration is removed. By default if no configuration is provided for a plugin all the properties appear as text-boxes in UI. It will be difficult to fill in the values for them if it requires it in specific format (for instance JSON or select one from multiple choices etc.,).

What does it have - Structure?

Before we dive into the structure it is imperative we clear up certain terms.

  • Configuring (Configurations) – A plugin in hydrator has configurations that needs to be set with appropriate value, for the plugin to function. This configuration could be a string or a number or a JSON blob or a Javascript/Python snippet etc., Configuring here refers to setting plugin configurations with appropriate value and for hydrator developers to do that we need to map configurations to widget to set a value.
  •  Output –  Every plugin will have data emitted out of it (passing it to subsequent plugins or dump to a database). An output of a plugin specifies the schema of data that is emitted out of the plugin.
  •  Input –  Similar to output every plugin will have an input data coming into the plugin (except for source plugins)

Configuration JSON for a plugin is structured as,

  • metadata

  • list of groups of configurations

  • list of output configurations

Groups’ refers to collection of configurations of a plugin. An example structure of a configuration JSON would look like this - Sample JSON

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
{
 "metadata": {...},
 "inputs": null,
 "configuration-groups": [
   {group1},
   {group2},
   ...
 ],
 "output": [
   {configuration-output-1},
   {configuration-output-2},
   ...
 ]
}

Metadata

Metadata refers to the top level information of a plugin. Metadata map includes,

  • label - Label for the plugin in hydrator
  • type - Type of the plugin
  • name - Name of the plugin (not sure if name and label should be separate)
  • artifact-version - Version of the plugin (artifact).
  • spec-version - Version of SPEC based on which the json is generated.

Following is an example of the metadata section:

Code Block
languagejs
linenumberstrue
{
 "metadata": {
   "spec-version" : "2.1",
   "label" : "Azure Blob Store"
 },
 ...
}

Groups

A group is a meaningful collection of configurations where related configs are grouped together to view and edit in hydrator. For instance in a Stream plugin we group together the stream, Processing time window & delay together [more explanation is needed as to why they are grouped together]. A group can essentially have a label , representing the label of the group and a list of fields inside the group. These are represented as ‘label’ and ‘fields’ inside the group map. Based on these information a sample JSON for a custom plugin would look something like this,

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
[
 {
    "metadatalabel": {...},
 "inputs": nullMy Group Title",
    "configuration-groupsproperties":  [
    {group1property1},
    {group2property2},
    ...
     ],
 "output": [
   {configuration-output-1},
   {configuration-output-2},
   ...
 ]
}

Metadata

Metadata refers to the top level information of a plugin. Metadata map includes,

  • label - Label for the plugin in hydrator
  • type - Type of the plugin
  • name - Name of the plugin (not sure if name and label should be separate)
  • artifact-version - Version of the plugin (artifact).
  • spec-version - Version of SPEC based on which the json is generated.

Following is an example of the metadata section:

Code Block
languagejs
linenumberstrue
{
 "metadata": {
   "spec-version" : "2.1",
   "label" : "Azure Blob Store"
 },
 ...
}

Groups

A group is a meaningful collection of configurations where related configs are grouped together to view and edit in hydrator. For instance in a Stream plugin we group together the stream, Processing time window & delay together [more explanation is needed as to why they are grouped together]. A group can essentially have a label , representing the label of the group and a list of fields inside the group. These are represented as ‘label’ and ‘fields’ inside the group map. Based on these information a sample JSON for a custom plugin would look something like this,

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
[
 {
   "label": "My Group Title",
   "properties": [
 {property1},
 {property2},
 ...
    ]
 }
]

Here ‘My Group Title’ is the label of the group that will be grouping fields 1 & 2 under it(as they are related). A field inside a group is nothing but the configuration of the plugin.

Fields

In the above mentioned sample JSON, fields 1 & 2 are configurations of CustomPlugin defined in the backend. We could now configure them in the JSON so that it gets easier to use view/edit them in hydrator.

Configurations for a field

Configurations of a field are the set of properties that we define in the JSON, that governs what/how that particular plugin field gets rendered in hydrator. 

  •  ‘How’ refers how should it be displayed - like a textbox, passwordbox, dropdown, JSON editor etc., and 
  •  ‘What’ refers to what should it default to. For instance if the property is rendered as a select widget and if we know that the possible list of values for it would be [‘Male’, ‘Female’], then we could configure that particular plugin property to have those values for the dropdown.

Required

  • name - Name of the field as specified in the backend.  

  • widget-type - Type of widget to represent the field.

Optional

  • label - Label for the field. For instance a field coming from the backend like time.ticks.sec could be labelled as ‘Time in Seconds’.

  • widget-attributes - Attribute/values required by the widget. For instance, list of values for select widget or a default value for a number-textbox. More details should be available in widgets list section.

  • plugin-function - Function available for the plugin. For instance, Database batchsource plugin have a getSchema endpoint method. output-property signify the plugin property that will get updated from this plugin-function action. 

From the above explanation we could enhance the above mentioned sample JSON to something like this,

 

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
{
 "configuration-groups": [
   {
     "label": "My Group Title",
     "properties": [
       {
         "name": "Field1",
         "widget-type": "numberbox",
         "widget-attributes": {
           "default": "1"
         },
		 "plugin-function": {
		   "method": "POST",
		   "endpoint": "getSchema",
		   "output-property": "schema"
		 }
       },
       {
         "name": "Field2",
         "widget-type": "json-editor"
       }
     ]
   }
 ],
 "output": [
   {output-property1} 
   {output-property2}
   ...
 ]
}

Widgets

A widget in UI represents a component that we could use to set the value of a property of a plugin. It could be anything representable in HTML. For instance if our CustomPlugin has a property that requires a JSON value, we could use a json-editor to set value to it. A widget, in general, is a component that we can use to represent a property of a plugin to attach a value to it. The following are the list of widgets that we right now have in CDAP that could be readily be used.

 

...

Widget-type

...

Description

...

Attributes

...

Output data type

...

Sample JSON

...

textbox

...

Default html textbox to enter any string

...

}
]

Here ‘My Group Title’ is the label of the group that will be grouping fields 1 & 2 under it(as they are related). A field inside a group is nothing but the configuration of the plugin.

Fields

In the above mentioned sample JSON, fields 1 & 2 are configurations of CustomPlugin defined in the backend. We could now configure them in the JSON so that it gets easier to use view/edit them in hydrator.

Configurations for a field

Configurations of a field are the set of properties that we define in the JSON, that governs what/how that particular plugin field gets rendered in hydrator. 

  •  ‘How’ refers how should it be displayed - like a textbox, passwordbox, dropdown, JSON editor etc., and 
  •  ‘What’ refers to what should it default to. For instance if the property is rendered as a select widget and if we know that the possible list of values for it would be [‘Male’, ‘Female’], then we could configure that particular plugin property to have those values for the dropdown.

Required

  • name - Name of the field as specified in the backend.  

  • widget-type - Type of widget to represent the field.

Optional

  • label - Label for the field. For instance a field coming from the backend like time.ticks.sec could be labelled as ‘Time in Seconds’.

  • widget-attributes - Attribute/values required by the widget. For instance, list of values for select widget or a default value for a number-textbox. More details should be available in widgets list section.

  • plugin-function - Function available for the plugin. For instance, Database batchsource plugin have a getSchema endpoint method. output-property signify the plugin property that will get updated from this plugin-function action. 

From the above explanation we could enhance the above mentioned sample JSON to something like this,

 

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
{
 "configuration-groups": [
   {
     "label": "My Group Title",
     "properties": [
       {
         "name": "Field1",
         "widget-type": "numberbox",
         "widget-attributes": {
           "default": "1"
         },
		 "plugin-function": {
		   "method": "POST",
		   "endpoint": "getSchema",
		   "output-property": "schema"
		 }
       },
       {
         "name": "Field2",
         "widget-type": "json-editor"
       }
     ]
   }
 ],
 "output": [
   {output-property1} 
   {output-property2}
   ...
 ]
}

Widgets

A widget in UI represents a component that we could use to set the value of a property of a plugin. It could be anything representable in HTML. For instance if our CustomPlugin has a property that requires a JSON value, we could use a json-editor to set value to it. A widget, in general, is a component that we can use to represent a property of a plugin to attach a value to it. The following are the list of widgets that we right now have in CDAP that could be readily be used.

 

    A1  password}

 

default, format (format could be ISO, long, short or full format dates.Reference       json-editor    default": "function shouldFilter(input, context) {\n  return false;\n}"  

 

      "keyvalue",  widget-attributes": {    "values": ["Apples", "Oranges", "Bananas"],    "default": "Bananas"  }

Widget-type

Description

Attributes

Output data type

Sample JSON

textbox

Default html textbox to enter any string

default: default value for the widget

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "textbox",
  "widget-attributes": {
    "default": "Some Text"
  }
}

 

number

Default html number textbox. Can enter only valid numbers.

default: default value for the widget
min: minimum value for the number box
max: maximum value for the number box

int

 

Code Block
languagejs
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "number",
  "widget-attributes": {
    "default": 1,
    "min": 1,
    "max": 100
  }
}

 

passwordbox

Default html password box.

No attributes

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "password",
}

 

datetime

Date time picker. Used to set date (in string) for any property

default, format (format could be ISO, long, short or full format dates.Reference

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 PropertyMy Date Property",
  "widget-type": "textboxdatetime",
  "widget-attributes": {
    "default": "Some Textcurrent",
    "format": "MM-DD-YYYY"
  }
}

 

number

Default html number textbox. Can enter only valid numbers.

default, min, max. (default should be between min and max)

int

csv

Comma separated values. Each value is entered in a separate box

No attributes

comma-separated string

 

Code Block
languagejs
linenumberstrue
{
  "name": "Property1",
  "label": "My A1Date Property",
  "widget-type": "numbercsv",
  "widget-attributes": {
    "default": 1,
    "min": 1,
    "max": 100
  }
}

 

passwordbox

Default html password box.

NA

string

 

dsvDelimiter-separated values; each value is entered in a separate box

delimiter: delimiter used to separate the values

delimiter-separated string
Code Block
linenumberstrue
{
  
"name":
 "Property1",
 
 "label":
 "My 
Date Property",
  
"widget-type":
 "
csv",
  

datetime

Date time picker. Used to set date (in string) for any property

"widget-attributes": {
    "delimiter": ":"
  }
}

json-editor

Json editor to pretty-print and auto format JSON while typing

default: default serialized JSON value for the widget

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "datetimejson-editor",
  "widget-attributes": {
    "default": "current",": {
    "formatdefault": "MM-DD-YYYY "{ p1: value1}"
  }
}

 

 

csv

Comma separated values. Each value is entered in a separate box

delimiter (allows to change the delimiter to be any other symbol apart from ‘,’)

comma-separated javascript-editor,

python-editor

An editor to write Javscript (javascript-editor) or Python (python-editor) as value for property.

default: default string value for the widget

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "csvjson-editor",
  "widget-attributes": {
    "delimiterdefault": "function shouldFilter(input, context) {\n  return false;\n}"
  }
}

 

json-editor

Json editor to pretty-print and auto format JSON while typing

default

 

keyvalue

A key-value editor which allows you to construct map.

delimiter: delimiter for the key-value pairs
kv-delimiter: delimiter between key and value

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date PropertyMy Date Property",
  "widget-type":  "json-editorkeyvalue",
   "widget-attributes": {
    "delimiter": ",",
       "defaultkv-delimiter": "{ p1:"
value1}"   }
}

 

 

javascript-editor,

python-editor

An editor to write Javscript or Python as a value for a property.

default

string

keyvalue-dropdownSimilar to keyvalue widget, but with a drop-down value list
delimiter: delimiter for the key-value pairs
kv-delimiter: delimiter between key and value
dropdownOptions: list of drop-down options to display
string
Code Block
linenumberstrue
{
 
 "name":
 "Property1",
  
"label":
 "My Date Property",
 
 "widget-type":
 "
keyvalue",
  
"widget-attributes": {
    "delimiter": ",",
    "kv-delimiter": ":",
    "dropdownOptions": [ 
"
Option1", "Option2"]
  }
}

keyvalue

A key-value editor which allows you to construct map.

 

select

An HTML drop-down with a list of values; allows one choice from the list

values: list of values for the drop-down
default: default value from the list

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "keyvalue"
}

 

select

A html dropdown with a list of values. Allows to choose one from the list.

values, default

string

 
 "My Date Property",
  "widget-type": "keyvalue",
  "widget-attributes": {
    "values": ["Apples", "Oranges", "Bananas"],
    "default": "Bananas"
  }
}
dataset-selector, stream-selectorA type-ahead textbox with a list of datasets (dataset-selector) or streams (stream-selector) from the CDAP instanceNo attributesstring
Code Block
linenumberstrue
{
 
 "name":
 "Property1",
  
"label":
 "My Date Property",
  
"widget-type":
 
"
stream-selector"
}

ds-multiplevalues

A delimiter separated values widget that allows to specify a list of values separated by a delimiter.

numValues, values-delimiter, delimiter, placeholdersstring
Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Key Value Mapper",
  "widget-type": "ds-multiplevalues",
  "widget-attributes": {
    "delimiter": ",",
    "values-delimiter": ":",
    "numValues": "3",
    "placeholders": ["Input field", "Lookup", "Ouput field"]
  }
}

Versioning

...