/
casc.go
54 lines (46 loc) · 1.26 KB
/
casc.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package client
import "net/http"
// CASCManager is the client of configuration as code
type CASCManager struct {
JenkinsCore
}
// Export exports the config of configuration-as-code
func (c *CASCManager) Export() (config string, err error) {
var (
data []byte
statusCode int
)
if statusCode, data, err = c.Request(http.MethodPost, "/configuration-as-code/export",
nil, nil); err == nil &&
statusCode != 200 {
err = c.ErrorHandle(statusCode, data)
}
config = string(data)
return
}
// Schema get the schema of configuration-as-code
func (c *CASCManager) Schema() (schema string, err error) {
var (
data []byte
statusCode int
)
if statusCode, data, err = c.Request(http.MethodPost, "/configuration-as-code/schema",
nil, nil); err == nil &&
statusCode != 200 {
err = c.ErrorHandle(statusCode, data)
}
schema = string(data)
return
}
// Reload reload the config of configuration-as-code
func (c *CASCManager) Reload() (err error) {
_, err = c.RequestWithoutData(http.MethodPost, "/configuration-as-code/reload",
nil, nil, 200)
return
}
// Apply apply the config of configuration-as-code
func (c *CASCManager) Apply() (err error) {
_, err = c.RequestWithoutData(http.MethodPost, "/configuration-as-code/apply",
nil, nil, 200)
return
}