Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic server side export API for saved objects #30326

Merged
merged 68 commits into from
Mar 5, 2019

Conversation

mikecote
Copy link
Contributor

@mikecote mikecote commented Feb 6, 2019

PR implements the first steps of the saved object export API for #4759.

An endpoint id added under POST /api/saved_objects/_export that throws an error after 10,000 objects. The removal of the limit will come in a future PR when using streams to optimize scalability and performance. This basic PR will allow focus on the import aspect sooner as that will be more complex to solve.

Also a future PR will change the management UI to use the new API once import and export APIs are complete on the server side.

Dev-Docs

Added server side API for exporting saved objects

A new endpoint /api/saved_objects/_export now exists to export saved objects.

@mikecote mikecote added WIP Work in progress Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.2.0 labels Feb 6, 2019
@mikecote mikecote self-assigned this Feb 6, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@mikecote mikecote added the v8.0.0 label Feb 8, 2019
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>
@elasticmachine

This comment has been minimized.

@mikecote mikecote requested a review from spalger March 1, 2019 21:34
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM!

@elasticmachine

This comment has been minimized.

@epixa
Copy link
Contributor

epixa commented Mar 4, 2019

Why have two separate endpoints rather than a single endpoint with an optional types argument? The rationale might exist somewhere buried in the comments on this PR, but there were too many for me to go looking.

@mikecote
Copy link
Contributor Author

mikecote commented Mar 4, 2019

@epixa We had them as a single endpoint before but it served two different purposes. It could either export objects {type, id} or types (string[]) but never a mix of the two. After speaking with @spalger, we decided it would be easier to have two endpoints that make it clear what parameters are required and what to expect in return. Let me know if you see a concern.

@epixa
Copy link
Contributor

epixa commented Mar 4, 2019

@mikecote Can you add more details to the REST API docs changes in this PR that describe how you'd use each endpoint and such? It's just not clear to me what the diverging purpose is, but it sounds like I just don't understand what the endpoints do.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

LGTM from the security perspective. Thanks for creating all these tests @mikecote!

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mikecote mikecote added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Mar 5, 2019
@mikecote mikecote merged commit 399067a into elastic:master Mar 5, 2019
mikecote added a commit to mikecote/kibana that referenced this pull request Mar 5, 2019
* Initial work for new server side export API

* Revert UI changes, API only in this PR

* Remove whitespace at top of export.asciidoc

* Add tests around limitations

* Add comment

* Convert some files to typescript

* Move Boom.boomify to where the errors are created

* Use Boom.badRequest for now

* Fix lint issue

* Move files

* Update tests

* Add functional test

* Export all documents by default

* Update test assertions

* Use ~10000 saved objects in export api integration test

* Convert route to typescript, add content-type response header

* Move some tests to api_integration

* Use new sort and rename functions/variables

* Move tests to API integration

* Cleanup and finalize api integration tests

* Make type or objects required but not both in the same call

* Add spaces / security tests

* Add noTypeOrObjects to security / spaces tests

* Use json-stable-stringify and add tests for export ordering

* Address self feedback, add without kibana index test

* Only allow export API to export index-pattern, dashboard, visualization and search type objects

* Make import export size configurable and fix broken tests

* Fix broken tests

* Move test config to mock server

* Add more typescript types instead of using any

* Convert request from GET to POST

* Fix saved objects mixin test

* Update src/legacy/server/saved_objects/lib/export.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Apply PR feedback

* Fix lint error

* Update test snapshots due to jest upgrade

* Add error handling for bulkGet

* Split export API into two endpoints

* Update src/legacy/server/saved_objects/routes/export_by_type.test.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update docs/api/saved-objects/export_by_type.asciidoc

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update docs/api/saved-objects/export_by_type.asciidoc

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update src/legacy/server/saved_objects/routes/export_objects.test.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Apply PR feedback

* MockServer -> createMockServer

* Revert back to single API

* Re-apply PR feedback
mikecote added a commit that referenced this pull request Mar 5, 2019
* Initial work for new server side export API

* Revert UI changes, API only in this PR

* Remove whitespace at top of export.asciidoc

* Add tests around limitations

* Add comment

* Convert some files to typescript

* Move Boom.boomify to where the errors are created

* Use Boom.badRequest for now

* Fix lint issue

* Move files

* Update tests

* Add functional test

* Export all documents by default

* Update test assertions

* Use ~10000 saved objects in export api integration test

* Convert route to typescript, add content-type response header

* Move some tests to api_integration

* Use new sort and rename functions/variables

* Move tests to API integration

* Cleanup and finalize api integration tests

* Make type or objects required but not both in the same call

* Add spaces / security tests

* Add noTypeOrObjects to security / spaces tests

* Use json-stable-stringify and add tests for export ordering

* Address self feedback, add without kibana index test

* Only allow export API to export index-pattern, dashboard, visualization and search type objects

* Make import export size configurable and fix broken tests

* Fix broken tests

* Move test config to mock server

* Add more typescript types instead of using any

* Convert request from GET to POST

* Fix saved objects mixin test

* Update src/legacy/server/saved_objects/lib/export.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Apply PR feedback

* Fix lint error

* Update test snapshots due to jest upgrade

* Add error handling for bulkGet

* Split export API into two endpoints

* Update src/legacy/server/saved_objects/routes/export_by_type.test.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update docs/api/saved-objects/export_by_type.asciidoc

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update docs/api/saved-objects/export_by_type.asciidoc

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Update src/legacy/server/saved_objects/routes/export_objects.test.ts

Co-Authored-By: mikecote <mikecote@users.noreply.github.com>

* Apply PR feedback

* MockServer -> createMockServer

* Revert back to single API

* Re-apply PR feedback
@rayafratkina
Copy link
Contributor

@mikecote note that in order for release_note:dev_docs label to work properly you need to add a # Dev Docs section to the end of your PR description (see e.g. #28985). That way our automated tool can build the changes blog post from the PRs.

@mikecote
Copy link
Contributor Author

@rayafratkina good catch, that is a very cool feature! I will go through my PRs and fix accordingly.

@mikecote mikecote added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. and removed release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. labels Mar 25, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@mikecote mikecote mentioned this pull request Dec 14, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants