-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_syncs.go
More file actions
35 lines (29 loc) · 996 Bytes
/
block_syncs.go
File metadata and controls
35 lines (29 loc) · 996 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
34
35
package api
import (
"context"
"encoding/json"
"fmt"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
"net/http"
)
type BlockSyncs struct {
Client *Client
}
type BlockSyncPayload struct {
Blocks []types.Block `json:"blocks"`
RepoName string `json:"repoName"`
SkipCapabilities bool `json:"skipCapabilities"`
}
func (s BlockSyncs) basePath(stackId, envId int64) string {
return fmt.Sprintf("orgs/%s/stacks/%d/envs/%d/block_syncs", s.Client.Config.OrgName, stackId, envId)
}
// Create - POST /orgs/:orgName/stacks/:stack_id/block_syncs
func (s BlockSyncs) Create(ctx context.Context, stackId, envId int64, payload BlockSyncPayload) ([]types.Block, error) {
rawPayload, _ := json.Marshal(payload)
res, err := s.Client.Do(ctx, http.MethodPost, s.basePath(stackId, envId), nil, nil, json.RawMessage(rawPayload))
if err != nil {
return nil, err
}
return response.ReadJsonVal[[]types.Block](res)
}