/
transform.go
46 lines (38 loc) · 1015 Bytes
/
transform.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
46
package meroxa
import (
"context"
"encoding/json"
"net/http"
)
type Property struct {
Name string `json:"name"`
Required bool `json:"required"`
Type string `json:"type"`
}
// Transform represent the Meroxa Transform type within the Meroxa API
type Transform struct {
ID int `json:"id"`
Name string `json:"name"`
Required bool `json:"required"`
Description string `json:"description"`
Type string `json:"type"`
Properties []Property `json:"properties"`
}
// ListTransforms returns an array of Transforms (scoped to the calling user)
func (c *client) ListTransforms(ctx context.Context) ([]*Transform, error) {
path := "/v1/transforms"
resp, err := c.MakeRequest(ctx, http.MethodGet, path, nil, nil, nil)
if err != nil {
return nil, err
}
err = handleAPIErrors(resp)
if err != nil {
return nil, err
}
var tt []*Transform
err = json.NewDecoder(resp.Body).Decode(&tt)
if err != nil {
return nil, err
}
return tt, nil
}