-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.go
59 lines (51 loc) · 1.45 KB
/
info.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
47
48
49
50
51
52
53
54
55
56
57
58
59
package capis
import (
"context"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)
type (
// BuildConfigurationResponse contains options used to build embeds.
BuildConfigurationResponse struct {
Data []struct {
Type ProductType `json:"type"`
Columns []struct {
Value string `json:"value"`
Label string `json:"label"`
} `json:"columns"`
Filters []struct {
Value string `json:"value"`
Label string `json:"label"`
Mutli bool `json:"multi"`
Choices []struct {
Value string `json:"value"`
Label string `json:"label"`
} `json:"choices"`
} `json:"filters"`
AvailableGroups []string `json:"available_groups"`
} `json:"data"`
}
)
// GetBuildConfiguration will query capis for the available options to
// build embeds with.
func (c *Client) GetBuildConfiguration(ctx context.Context) (*BuildConfigurationResponse, error) {
ctx, span := trace.StartSpan(ctx, "lwebco.de/go-capis/Client.GetBuildConfigurations")
defer span.End()
req, err := c.newRequest("GET", "/v1/info/build-configurations", nil)
if err != nil {
c.logError(err)
return nil, errors.Wrap(err, "unable to create request")
}
res, err := c.Do(req.WithContext(ctx))
if err != nil {
c.logError(err)
return nil, ErrUnreachable
}
defer res.Body.Close()
if err := statusCodeToError(res.StatusCode); err != nil {
c.logError(err)
return nil, err
}
var obj *BuildConfigurationResponse
return obj, unmarshalResponse(res, &obj)
}