Update Dashboard Widget
Update a widget’s fields within this dashboard, using copy-on-write for shared widgets.
If the widget belongs only to this dashboard it is updated in place; if it is
referenced by more than one dashboard, a new widget is created with the updates
applied and swapped into this dashboard’s widget_order, leaving the other
dashboards’ copy untouched. The widget must already be in this dashboard’s
widget_order, otherwise the call is rejected. The result is recomputed
synchronously when the query changes or when the widget was cloned; otherwise the
existing cached result is returned. For table widgets, conditional-formatting
column references are re-resolved against the (possibly updated) query on each save.
The dashboard must exist and not be archived.
Update Dashboard Widget
package main
import (
"context"
"fmt"
"github.com/scaleapi/sgp-dev-go"
"github.com/scaleapi/sgp-dev-go/option"
)
func main() {
client := sgpdev.NewClient(
option.WithAPIKey("My API Key"),
option.WithAccountID("My Account ID"),
)
evaluationDashboardWidgetWithResult, err := client.EvaluationDashboards.Widgets.Update(
context.TODO(),
"widget_id",
sgpdev.EvaluationDashboardWidgetUpdateParams{
DashboardID: "dashboard_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", evaluationDashboardWidgetWithResult.ID)
}
{
"id": "id",
"account_id": "account_id",
"created_at": "2019-12-27T18:11:19.117Z",
"title": "title",
"type": "bar",
"config": {
"foo": "bar"
},
"object": "evaluation_widget",
"query": {
"select": [
{
"expression": {
"column": "column",
"source": "source",
"type": "COLUMN"
},
"alias": "alias"
}
],
"evaluation_ids": [
"string"
],
"filter": {
"conditions": [
{
"column": "column",
"operator": "=",
"source": "source",
"value": "string"
}
],
"logicalOperators": [
"AND"
]
},
"groupBy": [
"string"
],
"latest_only": true,
"limit": 1,
"orderBy": [
{
"column": "column",
"direction": "ASC",
"source": "source"
}
]
},
"result": {
"id": "id",
"computation_status": "computation_status",
"widget_id": "widget_id",
"computed_at": "2019-12-27T18:11:19.117Z",
"computed_result": {
"foo": "bar"
},
"error_message": "error_message"
}
}Returns Examples
{
"id": "id",
"account_id": "account_id",
"created_at": "2019-12-27T18:11:19.117Z",
"title": "title",
"type": "bar",
"config": {
"foo": "bar"
},
"object": "evaluation_widget",
"query": {
"select": [
{
"expression": {
"column": "column",
"source": "source",
"type": "COLUMN"
},
"alias": "alias"
}
],
"evaluation_ids": [
"string"
],
"filter": {
"conditions": [
{
"column": "column",
"operator": "=",
"source": "source",
"value": "string"
}
],
"logicalOperators": [
"AND"
]
},
"groupBy": [
"string"
],
"latest_only": true,
"limit": 1,
"orderBy": [
{
"column": "column",
"direction": "ASC",
"source": "source"
}
]
},
"result": {
"id": "id",
"computation_status": "computation_status",
"widget_id": "widget_id",
"computed_at": "2019-12-27T18:11:19.117Z",
"computed_result": {
"foo": "bar"
},
"error_message": "error_message"
}
}