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

[Dashboards] Handle tag reference inject/extract on server #210619

Open
nickpeihl opened this issue Feb 11, 2025 · 0 comments
Open

[Dashboards] Handle tag reference inject/extract on server #210619

nickpeihl opened this issue Feb 11, 2025 · 0 comments
Assignees
Labels
Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas

Comments

@nickpeihl
Copy link
Member

nickpeihl commented Feb 11, 2025

For Dashboards-as-code, specifically the Dashboard HTTP API, we want to remove the consumer concern for saved object references. This means the pre-save and pre-load hooks for extracting and injecting references should be moved to each plugin's StorageHandler rather than by the UI as they are now.

Consider the following examples of creating a dashboard with tags using the Dashboard HTTP API.

Current workflow for creating a dashboard with tags

Assumes the "foo" and "bar" tag saved objects already exist and the consumer knows the saved object id for both. If the saved objects for the referenced tags do not already exist, they will not be created which results in dangling references.


POST kbn:/api/dashboards/dashboard
{
    "attributes": {
        "title": "my empty dashboard with tags"
    },
    "references": [
      {
        "type": "tag",
        "id": "75474dd0-fec8-4d7d-b935-767257be09d6", // corresponds to "foo" tag
        "name": "tag-ref-75474dd0-fec8-4d7d-b935-767257be09d6"
      },
      {
        "type": "tag",
        "id": "2e4f5f21-4f1c-4f89-abc5-bf4c9537f7da", // corresponds to "bar" tag
        "name": "tag-ref-2e4f5f21-4f1c-4f89-abc5-bf4c9537f7da"
      }
    ],
}
Preferred workflow for creating a dashboard with tags

In this example, the consumer does not need to know the saved object id of the tags. They add an array of tags for their dashboard and the tags are automatically referenced during the StorageHandler's create method and added to the saved object. When loading the dashboard, the tags are dereferenced from the saved object and populate the "tags" array.

If the tag does not exist, we return an error and maybe a suggestion for how to create the tag using the /api/saved_objects_tagging/tags/create endpoint.

POST kbn:/api/dashboards/dashboard
{
    "attributes": {
        "title": "my empty dashboard with tags",
        "tags": ["foo", "bar"]
    }
}

@nickpeihl nickpeihl self-assigned this Feb 11, 2025
@botelastic botelastic bot added the needs-team Issues missing a team label label Feb 11, 2025
@nickpeihl nickpeihl added the Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas label Feb 11, 2025
@botelastic botelastic bot removed the needs-team Issues missing a team label label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

No branches or pull requests

1 participant