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
[data views] REST endpoint for swapping saved object references #157665
Conversation
…na into data_views_swap_references
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very helpful addition!
request: { | ||
body: schema.object({ | ||
from_id: idSchema, | ||
from_type: schema.maybe(schema.string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_id
for consistency with from_id
search_id: schema.maybe(schema.oneOf([idSchema, schema.arrayOf(idSchema)])), | ||
search_type: schema.maybe(schema.string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about for_id
and for_type
? search
can be confused with a search query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, that does clarify things.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part does not save changes, right? Does it fit to the test description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this.
…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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! LGTM 👍
## 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
## 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
## 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
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-efg
references toxyz-123
Additional params -
Closes #153806