-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilds.go
More file actions
37 lines (31 loc) · 1.12 KB
/
builds.go
File metadata and controls
37 lines (31 loc) · 1.12 KB
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
package api
import (
"context"
"fmt"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
"net/http"
)
type Builds struct {
Client *Client
}
func (d Builds) basePath(stackId, appId, envId int64) string {
return fmt.Sprintf("orgs/%s/stacks/%d/apps/%d/envs/%d/builds", d.Client.Config.OrgName, stackId, appId, envId)
}
func (d Builds) path(stackId, appId, envId, buildId int64) string {
return fmt.Sprintf("orgs/%s/stacks/%d/apps/%d/envs/%d/builds/%d", d.Client.Config.OrgName, stackId, appId, envId, buildId)
}
func (d Builds) List(ctx context.Context, stackId, appId, envId int64) ([]*types.Build, error) {
res, err := d.Client.Do(ctx, http.MethodGet, d.basePath(stackId, appId, envId), nil, nil, nil)
if err != nil {
return nil, err
}
return response.ReadJsonVal[[]*types.Build](res)
}
func (d Builds) Get(ctx context.Context, stackId, appId, envId, buildId int64) (*types.Build, error) {
res, err := d.Client.Do(ctx, http.MethodGet, d.path(stackId, appId, envId, buildId), nil, nil, nil)
if err != nil {
return nil, err
}
return response.ReadJsonPtr[types.Build](res)
}