-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_configs.go
More file actions
33 lines (28 loc) · 888 Bytes
/
run_configs.go
File metadata and controls
33 lines (28 loc) · 888 Bytes
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
package api
import (
"context"
"fmt"
"github.com/google/uuid"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
"net/http"
)
type RunConfigs struct {
Client *Client
}
func (c RunConfigs) runConfigPath(stackId int64, workspaceUid uuid.UUID) string {
return fmt.Sprintf("orgs/%s/stacks/%d/workspaces/%s/run-configs/latest", c.Client.Config.OrgName, stackId, workspaceUid)
}
func (c RunConfigs) GetLatest(ctx context.Context, stackId int64, workspaceUid uuid.UUID) (*types.RunConfig, error) {
res, err := c.Client.Do(ctx, http.MethodGet, c.runConfigPath(stackId, workspaceUid), nil, nil, nil)
if err != nil {
return nil, err
}
var runConfig types.RunConfig
if err := response.ReadJson(res, &runConfig); response.IsNotFoundError(err) {
return nil, nil
} else if err != nil {
return nil, err
}
return &runConfig, nil
}