Copy Saved Objects to Spaces API#38014
Conversation
x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.ts
Outdated
Show resolved
Hide resolved
|
retest |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💚 Build Succeeded |
x-pack/plugins/security/server/lib/authorization/check_privileges_dynamically.ts
Outdated
Show resolved
Hide resolved
...ty/server/lib/authorization/privileges/feature_privilege_builder/saved_objects_management.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.ts
Outdated
Show resolved
Hide resolved
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
|
Retest |
💚 Build Succeeded |
|
@kobelb thanks for the test review - much appreciated! I think I've addressed all of your feedback if you're able to take another look. |
|
If there are additional non-critical findings with the tests, I would prefer to merge this sooner rather than later in order to get #39002 in a reviewable state ASAP. We can address findings in a followup post-FF |
| attributes: {}, | ||
| }, | ||
| ], | ||
| importSavedObjectsImpl: opts => { |
There was a problem hiding this comment.
Overwriting this removes this check expect(objectsToImport).toEqual(setupOpts.objects);.
There was a problem hiding this comment.
It does... my thinking here was that it wasn't creating any meaningful gaps, since the override is only used to test specific failure conditions. I'll update regardless.
| `); | ||
|
|
||
| expect((savedObjectsService.importExport.importSavedObjects as jest.Mock).mock.calls) | ||
| .toMatchInlineSnapshot(` |
There was a problem hiding this comment.
Personally, I'm not overly fond of using jest's snapshots for stuff like this... It requires that we supplement it with another expectation and can lead to hard to understand failures. I don't necessarily think we need to change this now, but I'd prefer we have an offline discussion with @azasypkin to figure out when/where we want to use the snapshotting functionality in the future.
| attributes: {}, | ||
| }, | ||
| ], | ||
| resolveImportErrorsImpl: opts => { |
There was a problem hiding this comment.
Specifying this removes this check: expect(objectsToResolve).toEqual(setupOpts.objects); from above.
| describe('useRbacForRequest is true', () => { | ||
| test(`throws Boom.forbidden when user isn't authorized for any spaces`, async () => { | ||
| const username = Symbol(); | ||
| test(`ignores the provided purpose`, async () => { |
There was a problem hiding this comment.
Should we be throwing an error when there's an invalid purpose when useRbac is false? It feels like this would be more consistent.
There was a problem hiding this comment.
Sure, I'm fine either way
💔 Build Failed |
|
retest |
1 similar comment
|
retest |
💔 Build Failed |
💔 Build Failed |
|
retest |
💚 Build Succeeded |
Summary
Introduces an API to allow saved objects to be copied from one space to other spaces.
The API design closely follows the Import & Resolve Import Errors Saved Objects APIs, with the following notable exception:
The "resolve import errors" api allows callers to replace references to index patterns and saved searches. The corresponding Copy saved objects "conflict resolution" endpoint does not allow for such behavior, as the primary consumer (the UI) would need a way to do a cross-space search of these objects. While we could technically put something in place, a more holistic solution would be preferred, such as #27003
Copy saved objects endpoints:
POST /api/spaces/_copy_saved_objects- copy objects from thedefaultspace.POST /s/my-space/api/spaces/_copy_saved_objects- copy objects from themy-spacespace.Sample request payload
Copy saved objects "conflict resolution" endpoints:
POST /api/spaces/_resolve_copy_saved_objects_errors- resolve copy conflicts from thedefaultspace.POST /s/my-space/api/spaces/_resolve_copy_saved_objects_errors- resolve copy conflicts from themy-spacespace.Sample request payload