-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualization.go
45 lines (36 loc) · 1.09 KB
/
visualization.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:generate go run tools/withoutctx.go
package redash
import (
"context"
"fmt"
"time"
"github.com/winebarrel/redash-go/v2/internal/util"
)
type Visualization struct {
CreatedAt time.Time `json:"created_at"`
Description string `json:"description"`
ID int `json:"id"`
Name string `json:"name"`
Options any `json:"options"`
Query Query `json:"query"`
Type string `json:"type"`
UpdatedAt time.Time `json:"updated_at"`
}
type UpdateVisualizationInput struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Options any `json:"options,omitempty"`
Type string `json:"type,omitempty"`
}
func (client *Client) UpdateVisualization(ctx context.Context, id int, input *UpdateVisualizationInput) (*Visualization, error) {
res, close, err := client.Post(ctx, fmt.Sprintf("api/visualizations/%d", id), input)
defer close()
if err != nil {
return nil, err
}
viz := &Visualization{}
if err := util.UnmarshalBody(res, &viz); err != nil {
return nil, err
}
return viz, nil
}