-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspace_module.go
More file actions
35 lines (28 loc) · 1 KB
/
workspace_module.go
File metadata and controls
35 lines (28 loc) · 1 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
package api
import (
"context"
"encoding/json"
"fmt"
"net/http"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
)
type WorkspaceModule struct {
Client *Client
}
func (wmv WorkspaceModule) basePath(stackId, blockId, envId int64) string {
return fmt.Sprintf("/orgs/%s/stacks/%d/blocks/%d/envs/%d/module", wmv.Client.Config.OrgName, stackId, blockId, envId)
}
type UpdateWorkspaceModuleInput struct {
Module string `json:"module,omitempty"`
ModuleVersion string `json:"moduleVersion,omitempty"`
Connections types.ConnectionTargets `json:"connections,omitempty"`
}
func (wmv WorkspaceModule) Update(ctx context.Context, stackId, blockId, envId int64, moduleInput UpdateWorkspaceModuleInput) error {
raw, _ := json.Marshal(moduleInput)
res, err := wmv.Client.Do(ctx, http.MethodPut, wmv.basePath(stackId, blockId, envId), nil, nil, json.RawMessage(raw))
if err != nil {
return err
}
return response.Verify(res)
}