* Collapses content in Kibana and APM APIs * Update docs/api/role-management/put.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/copy_saved_objects.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> * Update docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc Co-Authored-By: Lisa Cawley <lcawley@elastic.co> Co-authored-by: Lisa Cawley <lcawley@elastic.co>
161 lines
4.6 KiB
Text
161 lines
4.6 KiB
Text
[role="xpack"]
|
|
[[spaces-api-copy-saved-objects]]
|
|
=== Copy saved objects to space API
|
|
++++
|
|
<titleabbrev>Copy saved objects to space</titleabbrev>
|
|
++++
|
|
|
|
experimental[] Copy saved objects between spaces.
|
|
|
|
It also allows you to automatically copy related objects, so when you copy a `dashboard`, this can automatically copy over the
|
|
associated visualizations, index patterns, and saved searches, as required.
|
|
|
|
You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the
|
|
<<spaces-api-resolve-copy-saved-objects-conflicts, Resolve copy saved objects conflicts API>> to do this on a per-object basis.
|
|
|
|
[[spaces-api-copy-saved-objects-request]]
|
|
==== {api-request-title}
|
|
|
|
`POST <kibana host>:<port>/api/spaces/_copy_saved_objects`
|
|
|
|
`POST <kibana host>:<port>/s/<space_id>/api/spaces/_copy_saved_objects`
|
|
|
|
[[spaces-api-copy-saved-objects-path-params]]
|
|
==== {api-path-parms-title}
|
|
|
|
`space_id`::
|
|
(Optional, string) The ID of the space that contains the saved objects you want to copy. When `space_id` is unspecified in the URL, the default space is used.
|
|
|
|
[role="child_attributes"]
|
|
[[spaces-api-copy-saved-objects-request-body]]
|
|
==== {api-request-body-title}
|
|
|
|
`spaces`::
|
|
(Required, string array) The IDs of the spaces where you want to copy the specified objects.
|
|
|
|
`objects`::
|
|
(Required, object array) The saved objects to copy.
|
|
+
|
|
.Properties of `objects`
|
|
[%collapsible%open]
|
|
=====
|
|
`type`:::
|
|
(Required, string) The saved object type.
|
|
|
|
`id`:::
|
|
(Required, string) The saved object ID.
|
|
=====
|
|
|
|
`includeReferences`::
|
|
(Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target spaces. The default value is `false`.
|
|
|
|
`overwrite`::
|
|
(Optional, boolean) When set to `true`, all conflicts are automatically overidden. When a saved object with a matching `type` and `id` exists in the target space, that version is replaced with the version from the source space. The default value is `false`.
|
|
|
|
[role="child_attributes"]
|
|
[[spaces-api-copy-saved-objects-response-body]]
|
|
==== {api-response-body-title}
|
|
|
|
`<space_id>`::
|
|
(object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response.
|
|
+
|
|
.Properties of `<space_id>`
|
|
[%collapsible%open]
|
|
=====
|
|
`success`:::
|
|
(boolean) The copy operation was successful. When set to `false`, some objects may have been copied. For additional information, refer to the `successCount` and `errors` properties.
|
|
|
|
`successCount`:::
|
|
(number) The number of objects that successfully copied.
|
|
|
|
`errors`:::
|
|
(Optional, array) The errors that occurred during the copy operation. When errors are reported, the `success` flag is set to `false`.
|
|
+
|
|
.Properties of `errors`
|
|
[%collapsible%open]
|
|
======
|
|
`id`::::
|
|
(string) The saved object ID that failed to copy.
|
|
`type`::::
|
|
(string) The type of saved object that failed to copy.
|
|
`error`::::
|
|
(object) The error that caused the copy operation to fail.
|
|
+
|
|
.Properties of `error`
|
|
[%collapsible%open]
|
|
=======
|
|
`type`:::::
|
|
(string) The type of error. For example, `unsupported_type`, `missing_references`, or `unknown`. Errors marked as `conflict` may be resolved by using the <<spaces-api-resolve-copy-saved-objects-conflicts, Resolve copy saved objects conflicts API>>.
|
|
=======
|
|
======
|
|
=====
|
|
[[spaces-api-copy-saved-objects-example]]
|
|
==== {api-examples-title}
|
|
|
|
Copy a dashboard with the `my-dashboard` ID, including all references from the `default` space to the `marketing` and `sales` spaces:
|
|
|
|
[source,sh]
|
|
----
|
|
$ curl -X POST "localhost:5601/api/spaces/_copy_saved_objects"
|
|
{
|
|
"objects": [{
|
|
"type": "dashboard",
|
|
"id": "my-dashboard"
|
|
}],
|
|
"spaces": ["marketing", "sales"],
|
|
"includeReferences": true
|
|
}
|
|
----
|
|
// KIBANA
|
|
|
|
The API returns the following:
|
|
|
|
[source,sh]
|
|
----
|
|
{
|
|
"marketing": {
|
|
"success": true,
|
|
"successCount": 5
|
|
},
|
|
"sales": {
|
|
"success": false,
|
|
"successCount": 4,
|
|
"errors": [{
|
|
"id": "my-index-pattern",
|
|
"type": "index-pattern",
|
|
"error": {
|
|
"type": "conflict"
|
|
}
|
|
}]
|
|
}
|
|
}
|
|
----
|
|
|
|
The `marketing` space succeeds, but the `sales` space fails due to a conflict in the index pattern.
|
|
|
|
Copy a visualization with the `my-viz` ID from the `marketing` space to the `default` space:
|
|
|
|
[source,sh]
|
|
----
|
|
$ curl -X POST "localhost:5601/s/marketing/api/spaces/_copy_saved_objects"
|
|
{
|
|
"objects": [{
|
|
"type": "visualization",
|
|
"id": "my-viz"
|
|
}],
|
|
"spaces": ["default"]
|
|
}
|
|
----
|
|
// KIBANA
|
|
|
|
The API returns the following:
|
|
|
|
[source,sh]
|
|
----
|
|
{
|
|
"default": {
|
|
"success": true,
|
|
"successCount": 1
|
|
}
|
|
}
|
|
----
|