-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathprebuilds.go
More file actions
50 lines (44 loc) · 1.57 KB
/
Copy pathprebuilds.go
File metadata and controls
50 lines (44 loc) · 1.57 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
38
39
40
41
42
43
44
45
46
47
48
49
50
package codersdk
import (
"context"
"net/http"
)
// PrebuildsSystemUserID is the UUID of the Coder prebuilds system
// user. Prebuilt workspaces are owned by this user until they are
// claimed; build #1 of a claimed workspace remains attributed to
// this user as the initiator forever, which is how callers can
// recognize a prebuild claim after the fact.
const PrebuildsSystemUserID = "c42fdf75-3097-471c-8c33-fb52454d81c0"
type PrebuildsSettings struct {
ReconciliationPaused bool `json:"reconciliation_paused"`
}
// GetPrebuildsSettings retrieves the prebuilds settings, which currently just describes whether all
// prebuild reconciliation is paused.
func (c *Client) GetPrebuildsSettings(ctx context.Context) (PrebuildsSettings, error) {
res, err := c.Request(ctx, http.MethodGet, "/api/v2/prebuilds/settings", nil)
if err != nil {
return PrebuildsSettings{}, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return PrebuildsSettings{}, ReadBodyAsError(res)
}
var settings PrebuildsSettings
return settings, ReadBodyAsJSON(res, &settings)
}
// PutPrebuildsSettings modifies the prebuilds settings, which currently just controls whether all
// prebuild reconciliation is paused.
func (c *Client) PutPrebuildsSettings(ctx context.Context, settings PrebuildsSettings) error {
res, err := c.Request(ctx, http.MethodPut, "/api/v2/prebuilds/settings", settings)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode == http.StatusNotModified {
return nil
}
if res.StatusCode != http.StatusOK {
return ReadBodyAsError(res)
}
return nil
}