Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
0051703
POC for copy-to-space
legrego Jun 4, 2019
d6d18b0
fix typings
legrego Jun 5, 2019
a3109ce
update import/export tests
legrego Jun 5, 2019
9590fd2
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Jun 5, 2019
48cbd59
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Jul 9, 2019
6054610
fix merge from master
legrego Jul 9, 2019
9278c15
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Jul 15, 2019
3135f8b
reintroduce spaces SOC namespace check
legrego Jul 15, 2019
5b041e1
export new SOC typedefs
legrego Jul 15, 2019
53ae63e
fix import/export module resolution
legrego Jul 15, 2019
445c0f3
use new excludedWrappers option
legrego Jul 15, 2019
505b1f7
rename ImportError -> SavedObjectsImportError for exportability
legrego Jul 22, 2019
05b79ba
cleanup
legrego Jul 22, 2019
deb66b5
allow resolve_import_errors to accept an optional namespace
legrego Jul 22, 2019
357b6a8
additional core changes; allowing export to accept a namespace
legrego Jul 24, 2019
6e32fc3
api testing and security fixes
legrego Jul 24, 2019
cc459f9
implementing/testing the conflict resolution api
legrego Jul 25, 2019
0726f02
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Jul 25, 2019
934cc63
doc updates following merge
legrego Jul 25, 2019
ac64e6f
jest api tests
legrego Jul 30, 2019
32944cb
API docs
legrego Jul 30, 2019
760b373
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Jul 30, 2019
4cd5e15
fix typings
legrego Jul 30, 2019
b07722a
update snapshots
legrego Jul 30, 2019
7b74d0b
extract createEmptyFailureResponse
legrego Jul 31, 2019
cfad9d6
retrieve spaces user can 'copy to space' with
legrego Jul 31, 2019
c65228f
ts fixes
legrego Jul 31, 2019
1d484dc
make conflict resolution API public, with docs
legrego Aug 1, 2019
e7675f2
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 1, 2019
d8f7633
remove unused saved object action
legrego Aug 1, 2019
6e74bb0
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 1, 2019
174e3e4
fix merge
legrego Aug 1, 2019
2eab9c3
revert unnecessary change
legrego Aug 2, 2019
5d0fbc6
using new api doc format
legrego Aug 2, 2019
4a2c343
simplify conflict api payload
legrego Aug 2, 2019
ef90d0c
fix test
legrego Aug 2, 2019
e100185
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 8, 2019
f30fa33
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 8, 2019
ca9171d
reverting checkPrivilegesDynamically
legrego Aug 8, 2019
2828bde
adjusting API documentation
legrego Aug 8, 2019
90b2dac
removing hard-coded export size
legrego Aug 8, 2019
0f52952
move to FtrProviderContext
legrego Aug 8, 2019
a7ad6f5
additional tests
legrego Aug 13, 2019
a4b43d7
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 13, 2019
5f38425
testing canManageSavedObjects
legrego Aug 13, 2019
f169117
remove unused import
legrego Aug 13, 2019
a4d72e5
Update docs/api/saved-objects/copy_to_space.asciidoc
legrego Aug 14, 2019
e8023f2
removing deepClone from rereadable_stream
legrego Aug 14, 2019
f355861
moving docs
legrego Aug 14, 2019
42d5978
Merge branch 'spaces/copy-to-space-api' of github.com:legrego/kibana …
legrego Aug 14, 2019
79cc29f
read exported SO stream to completion
legrego Aug 14, 2019
7241dd6
reenable tests
legrego Aug 14, 2019
c8cccca
make API endpoints snake_case instead of camelCase
legrego Aug 14, 2019
b4ae5d2
removing explicit auth checks prior to initiating copy operation
legrego Aug 14, 2019
6b53969
improve error handling when thrown from wrapped Saved Objects Client
legrego Aug 15, 2019
6330858
make TS happy
legrego Aug 15, 2019
22ab280
Apply suggestions from code review
legrego Aug 15, 2019
eb12dd6
rename 'get space' purpose from 'copySavedObjects' to 'copySavedObjec…
legrego Aug 16, 2019
943cf95
prefixing RPC routes with an underscore
legrego Aug 16, 2019
5f57c7b
updating functional API tests
legrego Aug 16, 2019
4eca3f9
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 16, 2019
5a749e2
Merge branch 'spaces/copy-to-space-api' of github.com:legrego/kibana …
legrego Aug 16, 2019
3219006
apply doc suggestions
legrego Aug 16, 2019
683b207
move stream creation to utility function
legrego Aug 16, 2019
e5d7682
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 16, 2019
3eb982b
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 19, 2019
857034d
Update docs/api/spaces-management/get.asciidoc
legrego Aug 19, 2019
d8a82e9
cleaning up poorly named test spaces
legrego Aug 19, 2019
be26e69
removing unused error types
legrego Aug 19, 2019
21a5bca
improving spaces_client tests
legrego Aug 19, 2019
4e07b45
Apply suggestions from code review
legrego Aug 19, 2019
3d7c8b2
Merge branch 'spaces/copy-to-space-api' of github.com:legrego/kibana …
legrego Aug 19, 2019
c5d2b9e
uncommenting test suites
legrego Aug 19, 2019
9507ac7
ensure SOC is created without spaces wrapper
legrego Aug 20, 2019
1ee8e01
testing stream read errors
legrego Aug 20, 2019
393f8e6
testing readStreamToCompletion and createReadableStreamFromArray
legrego Aug 20, 2019
23fdb80
verify the correct number of spaces were copied into
legrego Aug 20, 2019
76dbdc0
add missing tests
legrego Aug 20, 2019
61df1e2
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 20, 2019
d913b59
fix test suite name
legrego Aug 20, 2019
0acb332
fixing test reference
legrego Aug 20, 2019
302230c
fix it again
legrego Aug 20, 2019
37ac143
addressing feedback
legrego Aug 21, 2019
5c467ba
Merge branch 'master' of github.com:elastic/kibana into spaces/copy-t…
legrego Aug 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/spaces-management.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ NOTE: You cannot access these endpoints via the Console in Kibana.
* <<spaces-api-put>>
* <<spaces-api-get>>
* <<spaces-api-delete>>
* <<spaces-api-copy-saved-objects>>
* <<spaces-api-resolve-copy-saved-objects-conflicts>>

include::spaces-management/post.asciidoc[]
include::spaces-management/put.asciidoc[]
include::spaces-management/get.asciidoc[]
include::spaces-management/delete.asciidoc[]
include::spaces-management/copy_saved_objects.asciidoc[]
include::spaces-management/resolve_copy_saved_objects_conflicts.asciidoc[]
288 changes: 288 additions & 0 deletions docs/api/spaces-management/copy_saved_objects.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
[role="xpack"]
[[spaces-api-copy-saved-objects]]
=== Copy Saved Objects to Space
++++
<titleabbrev>Copy Saved Objects to Space</titleabbrev>
++++

experimental[This functionality is *experimental* and may be changed or removed completely in a future release.]

Copies saved objects from one space to other spaces.

////
Use the appropriate heading levels for your book.
Add anchors for each section.
FYI: The section titles use attributes in case those terms change.
////

[[spaces-api-copy-saved-objects-request]]
==== {api-request-title}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of {api-request-title}, it should be Request or whatever title you want it to be. For the other Kibana APIs, I just used Request, but I'm always open for other ideas.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting, I thought the purpose of using {api-request-title} was to ensure the section titles were consistent across all docs, with a central definition. Am I misunderstanding this comment?

FYI: The section titles use attributes in case those terms change.

FWIW, it seems to be replacing the attributes correctly:
image

////
This section show the basic endpoint, without the body or optional parameters.
Variables should use <...> syntax.
If an API supports both PUT and POST, include both here.
////

`POST /api/spaces/_copy_saved_objects`

`POST /s/<space_id>/api/spaces/_copy_saved_objects`


////
[[spaces-api-copy-saved-objects-prereqs]]
==== {api-prereq-title}
////
////
Optional list of prerequisites.

For example:

* A snapshot of an index created in 5.x can be restored to 6.x. You must...
* If the {es} {security-features} are enabled, you must have `write`, `monitor`,
and `manage_follow_index` index privileges...
////


[[spaces-api-copy-saved-objects-desc]]
==== {api-description-title}

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.

////
Add a more detailed description the context.
Link to related APIs if appropriate.

Guidelines for parameter documentation
***************************************
* Use a definition list.
* End each definition with a period.
* Include whether the parameter is Optional or Required and the data type.
* Include default values as the last sentence of the first paragraph.
* Include a range of valid values, if applicable.
* If the parameter requires a specific delimiter for multiple values, say so.
* If the parameter supports wildcards, ditto.
* For large or nested objects, consider linking to a separate definition list.
***************************************
////


[[spaces-api-copy-saved-objects-path-params]]
==== {api-path-parms-title}
////
A list of all the parameters within the path of the endpoint (before the query string (?)).

For example:
`<follower_index>`::
(Required, string) Name of the follower index
////
`space_id`::
(Optional, string) Identifies the source space from which saved objects will be copied. If `space_id` is not specified in the URL, the default space is used.

////
[[spaces-api-copy-saved-objects-params]]
==== {api-query-parms-title}
////
////
A list of the parameters in the query string of the endpoint (after the ?).

For example:
`wait_for_active_shards`::
(Optional, integer) Specifies the number of shards to wait on being active before
responding. A shard must be restored from the leader index being active.
Restoring a follower shard requires transferring all the remote Lucene segment
files to the follower index. The default is `0`, which means waiting on none of
the shards to be active.
////

[[spaces-api-copy-saved-objects-request-body]]
==== {api-request-body-title}
////
A list of the properties you can specify in the body of the request.

For example:
`remote_cluster`::
(Required, string) The <<modules-remote-clusters,remote cluster>> that contains
the leader index.

`leader_index`::
(Required, string) The name of the index in the leader cluster to follow.
////
`spaces` ::
(Required, string array) The ids of the spaces the specified object(s) will be copied into.

`objects` ::
(Required, object array) The saved objects to copy.
`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 will be automatically overidden. If a saved object with a matching `type` and `id` exists in the target space, then that version will be replaced with the version from the source space. The default value is `false`.


[[spaces-api-copy-saved-objects-response-body]]
==== {api-response-body-title}
////
Response body is only required for detailed responses.

For example:
`auto_follow_stats`::
(object) An object representing stats for the auto-follow coordinator. This
object consists of the following fields:

`auto_follow_stats.number_of_successful_follow_indices`:::
(long) the number of indices that the auto-follow coordinator successfully
followed
...

////

`<space_id>`::
(object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space.
`success`:::
(boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to `false`. Consult the `successCount` and `errors` properties of the response for additional information.
`successCount`:::
(number) The number of objects that were successfully copied.
`errors`:::
(Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the `success` flag will be set to `false`.
`id`::::
(string) The saved object id which failed to copy.
`type`::::
(string) The type of saved object which failed to copy.
`error`::::
(object) The error which caused the copy operation to fail.
`type`:::::
(string) Indicates the type of error. May be one of: `conflict`, `unsupported_type`, `missing_references`, `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-response-codes]]
==== {api-response-codes-title}
////
////
Response codes are only required when needed to understand the response body.

For example:
`200`::
Indicates all listed indices or index aliases exist.

`404`::
Indicates one or more listed indices or index aliases **do not** exist.
////


[[spaces-api-copy-saved-objects-example]]
==== {api-examples-title}
////
Optional brief example.
Use an 'Examples' heading if you include multiple examples.


[source,js]
----
PUT /follower_index/_ccr/follow?wait_for_active_shards=1
{
"remote_cluster" : "remote_cluster",
"leader_index" : "leader_index",
"max_read_request_operation_count" : 1024,
"max_outstanding_read_requests" : 16,
"max_read_request_size" : "1024k",
"max_write_request_operation_count" : 32768,
"max_write_request_size" : "16k",
"max_outstanding_write_requests" : 8,
"max_write_buffer_count" : 512,
"max_write_buffer_size" : "512k",
"max_retry_delay" : "10s",
"read_poll_timeout" : "30s"
}
----
// CONSOLE
// TEST[setup:remote_cluster_and_leader_index]

The API returns the following result:

[source,js]
----
{
"follow_index_created" : true,
"follow_index_shards_acked" : true,
"index_following_started" : true
}
----
// TESTRESPONSE
////

The following example attempts to copy a dashboard with id `my-dashboard`, including all references from the `default` space to the `marketing` and `sales` spaces. The `marketing` space succeeds, while the `sales` space fails due to a conflict on the underlying index pattern:

[source,js]
----
POST /api/spaces/_copy_saved_objects
{
"objects": [{
"type": "dashboard",
"id": "my-dashboard"
}],
"spaces": ["marketing", "sales"],
"includeReferences": true
}
----
// KIBANA

The API returns the following result:

[source,js]
----
{
"marketing": {
"success": true,
"successCount": 5
},
"sales": {
"success": false,
"successCount": 4,
"errors": [{
"id": "my-index-pattern",
"type": "index-pattern",
"error": {
"type": "conflict"
}
}]
}
}
----

The following example successfully copies a visualization with id `my-viz` from the `marketing` space to the `default` space:

[source,js]
----
POST /s/marketing/api/spaces/_copy_saved_objects
{
"objects": [{
"type": "visualization",
"id": "my-viz"
}],
"spaces": ["default"]
}
----
// KIBANA

The API returns the following result:

[source,js]
----
{
"default": {
"success": true,
"successCount": 1
}
}
----
9 changes: 9 additions & 0 deletions docs/api/spaces-management/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ To retrieve all spaces, issue a GET request to the
[source,js]
--------------------------------------------------
GET /api/spaces/space
GET /api/spaces/space?purpose= copySavedObjectsIntoSpace
--------------------------------------------------
// KIBANA

===== Request Query Parameters
purpose (optional) :: Retrieve the available spaces for a specific purpose. This parameter only has an effect when security is enabled.
`any` (default) ::: Retrieves all spaces the user is authorized to access.
`copySavedObjectsIntoSpace` ::: Retrieves all spaces the user is authorized to copy saved objects into via Saved Objects Management.


===== Response

A successful call returns a response code of `200` and a response body containing a JSON
representation of the spaces.

If you are not authorized for any spaces for the provided `purpose`, then a response code of `403` will be returned.

[source,js]
--------------------------------------------------
[
Expand Down
Loading