[data views] REST endpoint for swapping saved object references#157665
Merged
mattkime merged 13 commits intoelastic:mainfrom Jul 6, 2023
Merged
[data views] REST endpoint for swapping saved object references#157665mattkime merged 13 commits intoelastic:mainfrom
mattkime merged 13 commits intoelastic:mainfrom
Conversation
…na into data_views_swap_references
Contributor
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
jughosta
reviewed
Jul 4, 2023
| request: { | ||
| body: schema.object({ | ||
| from_id: idSchema, | ||
| from_type: schema.maybe(schema.string()), |
Contributor
There was a problem hiding this comment.
What other types are supported? It could be that this endpoint should not be under data_views path then.
| body: schema.object({ | ||
| from_id: idSchema, | ||
| from_type: schema.maybe(schema.string()), | ||
| to: idSchema, |
Contributor
There was a problem hiding this comment.
to_id for consistency with from_id
Comment on lines
+63
to
+64
| search_id: schema.maybe(schema.oneOf([idSchema, schema.arrayOf(idSchema)])), | ||
| search_type: schema.maybe(schema.string()), |
Contributor
There was a problem hiding this comment.
How about for_id and for_type? search can be confused with a search query.
Contributor
Author
There was a problem hiding this comment.
thanks, that does clarify things.
Comment on lines
+84
to
+92
| const res2 = await supertest | ||
| .post(DATA_VIEW_SWAP_REFERENCES_PATH) | ||
| .set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION) | ||
| .send({ | ||
| from_id: dataViewId, | ||
| to: dataViewId, | ||
| }); | ||
|
|
||
| expect(res2.body.result.length).to.equal(1); |
Contributor
There was a problem hiding this comment.
This part does not save changes, right? Does it fit to the test description?
…na into data_views_swap_references
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @mattkime |
mattkime
added a commit
that referenced
this pull request
Aug 12, 2023
## Summary
Some simple dev UX improvements to the swap_references data views api -
```
POST /api/data_views/swap_references/_preview
{
"fromId" : "abcd-efg",
"toId" : "xyz-123"
}
returns
{
result: [{ id: "123", type: "visualization" }],
}
```
```
POST /api/data_views/swap_references
{
"fromId" : "abcd-efg",
"toId" : "xyz-123",
"delete" : true // optional, removes data view which is no longer referenced
}
returns
{
result: [{ id: "123", type: "visualization" }],
deleteStatus: {
remainingRefs: 0,
deletePerformed: true
}
```
Additional params -
```
fromType: string - specify the saved object type. Default is `index-pattern` for data view
forId: string | string[] - limit the affected saved objects to one or more by id
forType: string - limit the affected saved objects by type
```
Improves upon #157665
Docs will be created in follow up PR
jughosta
pushed a commit
to jughosta/kibana
that referenced
this pull request
Aug 14, 2023
## Summary
Some simple dev UX improvements to the swap_references data views api -
```
POST /api/data_views/swap_references/_preview
{
"fromId" : "abcd-efg",
"toId" : "xyz-123"
}
returns
{
result: [{ id: "123", type: "visualization" }],
}
```
```
POST /api/data_views/swap_references
{
"fromId" : "abcd-efg",
"toId" : "xyz-123",
"delete" : true // optional, removes data view which is no longer referenced
}
returns
{
result: [{ id: "123", type: "visualization" }],
deleteStatus: {
remainingRefs: 0,
deletePerformed: true
}
```
Additional params -
```
fromType: string - specify the saved object type. Default is `index-pattern` for data view
forId: string | string[] - limit the affected saved objects to one or more by id
forType: string - limit the affected saved objects by type
```
Improves upon elastic#157665
Docs will be created in follow up PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Managing large number of saved objects can be cumbersome. This api endpoint allows the management of references without clicking through a lot of different UIs.
For example -
This swaps all data view id
abcd-efgreferences toxyz-123Additional params -
Closes #153806