Any reference to data-view should be unpacked server-side rather than client-side. Reference handling is an internal implementation that we do not want to expose to API consumers.
Without moving controls reference handling to the server, API consumers will have to know how to explicitly construct the references[i].name composite key for the dashboard to work correctly and we don't provide any validation to enforce referential integrity.
For example. The JSON object below shows how data-views in the controls are extracted into a references array currently in the dashboard serialized state. This is how API consumers would currently need to craft their request body when creating or updating dashboards via the API.
// control with data view (i.e. `index-pattern`) reference extracted using a composite key in the references with the `controls[i].id`.
{
"controls": [
{
"controlConfig": {
"fieldName": "geo.src",
"title": "Source Country",
"enhancements": {}
},
"id": "612f8db8-9ba9-41cf-a809-d133fe9b83a8",
"grow": true,
"order": 0,
"type": "optionsListControl",
"width": "small"
}
]
}
// references array
[ {
"name": "controlGroup_612f8db8-9ba9-41cf-a809-d133fe9b83a8:optionsListDataView",
"type": "index-pattern",
"id": "90943e30-9a47-11e8-b64d-95841ca0b247"
}]
Ideally, the request body would support keeping the data view in the controls state and let the server handle the extraction to references. This way the API consumer does not need to provide a references array.
{
"controls": [
{
"controlConfig": {
"dataViewId": "90943e30-9a47-11e8-b64d-95841ca0b247", // data view is provided directly in the state
"fieldName": "geo.src",
"title": "Source Country",
"enhancements": {}
},
"id": "612f8db8-9ba9-41cf-a809-d133fe9b83a8",
"grow": true,
"order": 0,
"type": "optionsListControl",
"width": "small"
}
]
}
Any reference to data-view should be unpacked server-side rather than client-side. Reference handling is an internal implementation that we do not want to expose to API consumers.
Without moving controls reference handling to the server, API consumers will have to know how to explicitly construct the
references[i].namecomposite key for the dashboard to work correctly and we don't provide any validation to enforce referential integrity.For example. The JSON object below shows how data-views in the controls are extracted into a references array currently in the dashboard serialized state. This is how API consumers would currently need to craft their request body when creating or updating dashboards via the API.
Ideally, the request body would support keeping the data view in the controls state and let the server handle the extraction to references. This way the API consumer does not need to provide a
referencesarray.{ "controls": [ { "controlConfig": { "dataViewId": "90943e30-9a47-11e8-b64d-95841ca0b247", // data view is provided directly in the state "fieldName": "geo.src", "title": "Source Country", "enhancements": {} }, "id": "612f8db8-9ba9-41cf-a809-d133fe9b83a8", "grow": true, "order": 0, "type": "optionsListControl", "width": "small" } ] }