Skip to content

Commit 55f9e1c

Browse files
Adds API docs for Saved Objects Bulk Update (elastic#127687) (elastic#127769)
Co-authored-by: Joe Portner <[email protected]> (cherry picked from commit 1cff513) Co-authored-by: Christiane (Tina) Heiligers <[email protected]>
1 parent ccdb18f commit 55f9e1c

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

docs/api/saved-objects.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The following saved objects APIs are available:
2222

2323
* <<saved-objects-api-update, Update object API>> to update the attributes for existing {kib} saved objects
2424

25+
* <<saved-objects-api-bulk-update, Bulk update objects API>> to update the attributes for multiple existing {kib} saved objects
26+
2527
* <<saved-objects-api-delete, Delete object API>> to remove {kib} saved objects
2628

2729
* <<saved-objects-api-export, Export objects API>> to retrieve sets of saved objects that you want to import into {kib}
@@ -38,6 +40,7 @@ include::saved-objects/find.asciidoc[]
3840
include::saved-objects/create.asciidoc[]
3941
include::saved-objects/bulk_create.asciidoc[]
4042
include::saved-objects/update.asciidoc[]
43+
include::saved-objects/bulk_update.asciidoc[]
4144
include::saved-objects/delete.asciidoc[]
4245
include::saved-objects/export.asciidoc[]
4346
include::saved-objects/import.asciidoc[]
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[[saved-objects-api-bulk-update]]
2+
=== Bulk update object API
3+
++++
4+
<titleabbrev>Bulk update objects</titleabbrev>
5+
++++
6+
7+
experimental[] Update the attributes for multiple existing {kib} saved objects.
8+
9+
[[saved-objects-api-bulk-update-request]]
10+
==== Request
11+
12+
`PUT <kibana host>:<port>/api/saved_objects/_bulk_update`
13+
14+
`PUT <kibana host>:<port>/s/<space_id>/api/saved_objects/_bulk_update`
15+
16+
[[saved-objects-api-bulk-update-path-params]]
17+
==== Path parameters
18+
19+
`space_id`::
20+
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.
21+
22+
[[saved-objects-api-bulk-update-request-body]]
23+
==== Request body
24+
25+
`type`::
26+
(Required, string) Valid options include `visualization`, `dashboard`, `search`, `index-pattern`, `config`.
27+
28+
`id`::
29+
(Required, string) The object ID to update.
30+
31+
`attributes`::
32+
(Required, object) The data to persist.
33+
+
34+
WARNING: When you update, attributes are not validated, which allows you to pass arbitrary and ill-formed data into the API and break {kib}. Make sure any data that you send to the API is properly formed.
35+
36+
`references`::
37+
(Optional, array) Objects with `name`, `id`, and `type` properties that describe the other saved objects this object references. To refer to the other saved object, use `name` in the attributes, but never the `id`, which automatically updates during migrations or import/export.
38+
39+
`version`::
40+
(Optional, number) Ensures the version matches that of the persisted object.
41+
42+
`namespace`:: (Optional, string) Identifier for the space in which to update this object. If this is defined, it will supersede the space ID that is in the URL.
43+
44+
[[saved-objects-api-bulk-update-codes]]
45+
==== Response code
46+
47+
`200`::
48+
Indicates a successful call. Note, this HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual
49+
objects will be returned in the response body. Refer to the example below for details.
50+
51+
[[saved-objects-api-bulk-update-example]]
52+
==== Example
53+
54+
Update three saved objects, where one of them does not exist:
55+
56+
[source,sh]
57+
--------------------------------------------------
58+
$ curl -X PUT api/saved_objects/_bulk_update
59+
[
60+
{
61+
type: 'visualization',
62+
id: 'not an id',
63+
attributes: {
64+
title: 'An existing visualization',
65+
},
66+
},
67+
{
68+
type: 'dashboard',
69+
id: 'be3733a0-9efe-11e7-acb3-3dab96693fab',
70+
attributes: {
71+
title: 'An existing dashboard',
72+
},
73+
{
74+
type: 'index-pattern',
75+
id: 'logstash-*',
76+
attributes: { title: 'my-logstash-pattern' }
77+
}
78+
]
79+
--------------------------------------------------
80+
// KIBANA
81+
82+
The API returns the following:
83+
84+
[source,sh]
85+
--------------------------------------------------
86+
[
87+
{
88+
"type": "visualization",
89+
"id": "not an id",
90+
"error": {
91+
"statusCode": 404,
92+
"error": "Not Found",
93+
"message": "Saved object [visualization/not an id] not found",
94+
},
95+
},
96+
{
97+
"type": "dashboard",
98+
"id": "be3733a0-9efe-11e7-acb3-3dab96693fab",
99+
"version": 2,
100+
"attributes": {
101+
"title": "An existing dashboard",
102+
},
103+
},
104+
{
105+
"type": "index-pattern",
106+
"id": "logstash-*",
107+
"attributes": {
108+
"title": "my-logstash-pattern",
109+
}
110+
}
111+
]
112+
--------------------------------------------------

0 commit comments

Comments
 (0)