elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.57k stars 8.21k forks source link

[Dashboards API] Consider adding link relations (URLs) to API responses #195276

Open nickpeihl opened 3 weeks ago

nickpeihl commented 3 weeks ago

We should consider adding link relations in the responses from the Dashboards APIs, i.e. HATEOAS. This is a constraint of the REST specification that makes it easier for consumers to find and discover related endpoints.

For the Dashboards API, we would likely return URL paths to endpoints of other saved objects (references) used in the dashboard. A user might want to perform other requests against these URLs for more context. For example, a dashboard may have panels that use a logs-* data view. We could return the API endpoint for that data view so the user can understand how to perform other requests without needing to go to the API docs.

{
  "attributes": { ... },
  "links": {
    "data_views": [{
        "logs-*": "/api/data_views/data_view/<logs-uuid>"
    }]
  }
}
elasticmachine commented 3 weeks ago

Pinging @elastic/kibana-presentation (Team:Presentation)

nreese commented 3 weeks ago

I think instead, it would be more useful to include a url to the reference in the references definition. So something like this

references: [
    {
        "type": "index-pattern",
        "id": "90943e30-9a47-11e8-b64d-95841ca0b247",
        "name": "11:indexpattern-datasource-layer-28b89898-3feb-415a-8dd9-74d755ac7c2a"
        "url": "/api/data_views/data_view/90943e30-9a47-11e8-b64d-95841ca0b247"
    }
]