This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
forked from yosida95/golang-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
computer.go
43 lines (34 loc) · 1.12 KB
/
computer.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
package gojenkins
import (
"fmt"
"net/url"
)
type Executable struct {
Number int `json:"number"`
Url string `json:"url"`
}
type Executor struct {
Idle bool `json:"idle"`
Number int `json:"number"`
Progress int `json:"progress"`
LikelyStuck bool `json:"likelyStuck"`
CurrentExecutable Executable `json:"currentExecutable"`
}
type Computer struct {
Name string `json:"displayName"`
NumExecutors int `json:"numExecutors"`
Idle bool `json:"idle"`
Offline bool `json:"offline"`
OfflineCauseReason string `json:"offlineCauseReason"`
TemporarilyOffline bool `json:"temporarilyOffline"`
Executors []Executor `json:"executors"`
}
func (jenkins *Jenkins) GetComputer(name string) (computer Computer, err error) {
err = jenkins.get(fmt.Sprintf("/computer/%s", name), nil, &computer, DefaultOptions)
return
}
func (jenkins *Jenkins) ComputerToggleOffline(name string, message string) error {
params := url.Values{}
params.Add("offlineMessage", message)
return jenkins.post(fmt.Sprintf("/computer/%s/toggleOffline", name), params, nil, Options{useApiEndPoint: false})
}