kibana/docs/api/data-views/update-fields.asciidoc
Matthew Kime 5d8a7920c1
[data views] Add data view REST api docs, keep deprecated equivalents (#123111)
* add data view api docs, keep deprecated equivalents

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-02-02 13:37:16 -06:00

105 lines
2.3 KiB
Text

[[data-views-fields-api-update]]
=== Update data view fields API
++++
<titleabbrev>Update data view fields metadata</titleabbrev>
++++
experimental[] Update fields presentation metadata, such as `count`,
`customLabel`, and `format`. You can update multiple fields in one request. Updates
are merged with persisted metadata. To remove existing metadata, specify `null` as the value.
[[data-views-fields-api-update-request]]
==== Request
`POST <kibana host>:<port>/api/data_views/data_view/<id>/fields`
`POST <kibana host>:<port>/s/<space_id>/api/data_views/data_view/<id>/fields`
[[data-views-fields-api-update-path-params]]
==== Path parameters
`space_id`::
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.
`id`::
(Required, string) The ID of the data view fields you want to update.
[[data-views-fields-api-update-request-body]]
==== Request body
`fields`::
(Required, object) the field object
[[data-views-fields-api-update-errors-codes]]
==== Response code
`200`::
Indicates a successful call.
[[data-views-fields-api-update-example]]
==== Examples
Set popularity `count` for field `foo`:
[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/data-view/my-view/fields
{
"fields": {
"foo": {
"count": 123
}
}
}
--------------------------------------------------
// KIBANA
Update multiple metadata fields in one request:
[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/data-view/my-view/fields
{
"fields": {
"foo": {
"count": 123,
"customLabel": "Foo"
},
"bar": {
"customLabel": "Bar"
}
}
}
--------------------------------------------------
// KIBANA
Use `null` value to delete metadata:
[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/data-view/my-pattern/fields
{
"fields": {
"foo": {
"customLabel": null
}
}
}
--------------------------------------------------
// KIBANA
The endpoint returns the updated data view object:
[source,sh]
--------------------------------------------------
{
"data_view": {
}
}
--------------------------------------------------