-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkspace_changes.go
39 lines (31 loc) · 1.21 KB
/
workspace_changes.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
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 WorkspaceChanges struct {
Client *Client
}
func (wc WorkspaceChanges) basePath(stackId, blockId, envId int64) string {
return fmt.Sprintf("/orgs/%s/stacks/%d/blocks/%d/envs/%d/changes", wc.Client.Config.OrgName, stackId, blockId, envId)
}
func (wc WorkspaceChanges) changePath(stackId, blockId, envId, changeId int64) string {
return fmt.Sprintf("/orgs/%s/stacks/%d/blocks/%d/envs/%d/changes/%d", wc.Client.Config.OrgName, stackId, blockId, envId, changeId)
}
func (wc WorkspaceChanges) List(ctx context.Context, stackId, blockId, envId int64) (*types.WorkspaceChangeset, error) {
res, err := wc.Client.Do(ctx, http.MethodPost, wc.basePath(stackId, blockId, envId), nil, nil, nil)
if err != nil {
return nil, err
}
return response.ReadJsonPtr[types.WorkspaceChangeset](res)
}
func (wc WorkspaceChanges) Destroy(ctx context.Context, stackId, blockId, envId, changeId int64) error {
res, err := wc.Client.Do(ctx, http.MethodDelete, wc.changePath(stackId, blockId, envId, changeId), nil, nil, nil)
if err != nil {
return err
}
return response.Verify(res)
}