Skip to content

[data views] swap_references api improvements#163225

Merged
mattkime merged 8 commits intoelastic:mainfrom
mattkime:data_view_swap_references_improvements
Aug 12, 2023
Merged

[data views] swap_references api improvements#163225
mattkime merged 8 commits intoelastic:mainfrom
mattkime:data_view_swap_references_improvements

Conversation

@mattkime
Copy link
Copy Markdown
Contributor

@mattkime mattkime commented Aug 5, 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

@mattkime mattkime changed the title preview to query param, snake to camel case in request body [data views] swap_references api improvements Aug 9, 2023
@mattkime mattkime self-assigned this Aug 9, 2023
@mattkime mattkime added Feature:Data Views Data Views code and UI - index patterns before 8.0 release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// labels Aug 9, 2023
@mattkime mattkime marked this pull request as ready for review August 9, 2023 22:39
@mattkime mattkime requested a review from a team as a code owner August 9, 2023 22:39
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Code-only review, changes look good to me 👍 just have one question regarding testing.

result: Array<{ id: string; type: string }>;
preview: boolean;
deleteSuccess?: boolean;
deleteStatus?: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a reliable way to test this functionality? It would be great to have a test that also covers what happens if the delete fails/has refs if possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a test. I realized that there's a simpler valid use case for this - when you swap some refs, but not all, and ask it to delete.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah that makes sense and covers exactly what I was looking for. Thanks!

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @mattkime

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

API improvements LGTM, thanks for the cleanup!

result: Array<{ id: string; type: string }>;
preview: boolean;
deleteSuccess?: boolean;
deleteStatus?: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah that makes sense and covers exactly what I was looking for. Thanks!

@mattkime mattkime merged commit cafaa92 into elastic:main Aug 12, 2023
@kibanamachine kibanamachine added v8.10.0 backport:skip This PR does not require backporting labels Aug 12, 2023
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
mattkime added a commit that referenced this pull request Jan 29, 2024
## Summary

Docs for the swap references api -
#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 29, 2024
## Summary

Docs for the swap references api -
elastic#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
(cherry picked from commit b371171)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 29, 2024
## Summary

Docs for the swap references api -
elastic#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
(cherry picked from commit b371171)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 29, 2024
## Summary

Docs for the swap references api -
elastic#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
(cherry picked from commit b371171)
kibanamachine added a commit that referenced this pull request Jan 29, 2024
# Backport

This will backport the following commits from `main` to `8.10`:
- [[data views] Swap references API docs
(#175183)](#175183)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthew
Kime","email":"matt@mattki.me"},"sourceCommit":{"committedDate":"2024-01-29T21:04:20Z","message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data
Views","release_note:skip","docs","Team:DataDiscovery","v8.10.0","v8.11.0","v8.12.0","v8.13.0"],"title":"[data
views] Swap references API
docs","number":175183,"url":"https://github.com/elastic/kibana/pull/175183","mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}},"sourceBranch":"main","suggestedTargetBranches":["8.10","8.11","8.12"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.11","label":"v8.11.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175183","number":175183,"mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}}]}]
BACKPORT-->

Co-authored-by: Matthew Kime <matt@mattki.me>
kibanamachine added a commit that referenced this pull request Jan 29, 2024
# Backport

This will backport the following commits from `main` to `8.12`:
- [[data views] Swap references API docs
(#175183)](#175183)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthew
Kime","email":"matt@mattki.me"},"sourceCommit":{"committedDate":"2024-01-29T21:04:20Z","message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data
Views","release_note:skip","docs","Team:DataDiscovery","v8.10.0","v8.11.0","v8.12.0","v8.13.0"],"title":"[data
views] Swap references API
docs","number":175183,"url":"https://github.com/elastic/kibana/pull/175183","mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}},"sourceBranch":"main","suggestedTargetBranches":["8.10","8.11","8.12"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.11","label":"v8.11.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175183","number":175183,"mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}}]}]
BACKPORT-->

Co-authored-by: Matthew Kime <matt@mattki.me>
kibanamachine added a commit that referenced this pull request Jan 29, 2024
# Backport

This will backport the following commits from `main` to `8.11`:
- [[data views] Swap references API docs
(#175183)](#175183)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthew
Kime","email":"matt@mattki.me"},"sourceCommit":{"committedDate":"2024-01-29T21:04:20Z","message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data
Views","release_note:skip","docs","Team:DataDiscovery","v8.10.0","v8.11.0","v8.12.0","v8.13.0"],"title":"[data
views] Swap references API
docs","number":175183,"url":"https://github.com/elastic/kibana/pull/175183","mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}},"sourceBranch":"main","suggestedTargetBranches":["8.10","8.11","8.12"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.11","label":"v8.11.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175183","number":175183,"mergeCommit":{"message":"[data
views] Swap references API docs (#175183)\n\n## Summary\r\n\r\nDocs for
the swap references api
-\r\nhttps://github.com//pull/163225\r\n\r\nThe docs are
on the terse side - I think this makes sense since this is\r\na tool
that should be used infrequently and only by people who use
saved\r\nobject references.\r\n\r\n---------\r\n\r\nCo-authored-by:
amyjtechwriter
<61687663+amyjtechwriter@users.noreply.github.com>\r\nCo-authored-by:
Davis McPhee
<davismcphee@hotmail.com>","sha":"b371171d86adc0bcd3a331be8526571370916330"}}]}]
BACKPORT-->

Co-authored-by: Matthew Kime <matt@mattki.me>
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

Docs for the swap references api -
elastic#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
## Summary

Docs for the swap references api -
elastic#163225

The docs are on the terse side - I think this makes sense since this is
a tool that should be used infrequently and only by people who use saved
object references.

---------

Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Data Views Data Views code and UI - index patterns before 8.0 release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants