-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_service.go
More file actions
122 lines (107 loc) · 4.88 KB
/
system_service.go
File metadata and controls
122 lines (107 loc) · 4.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Get system details, and perform some management actions, such as restarting, and initiating a database migration (as part of a system upgrade).
package sonarapi
import (
"net/http"
)
type SystemService struct {
client *Client
}
type LogLevel string
const (
LogLevelInfo LogLevel = "INFO"
LogLevelDebug LogLevel = "DEBUG"
LogLevelTrace LogLevel = "TRACE"
)
type Cause struct {
Message string `json:"message,omitempty"`
StartedAt string `json:"startedAt,omitempty"`
State string `json:"state,omitempty"`
}
type SystemHealthObject struct {
Causes []*Cause `json:"causes,omitempty"`
Health string `json:"health,omitempty"`
Nodes []*Node `json:"nodes,omitempty"`
}
type Node struct {
Causes []*Cause `json:"causes,omitempty"`
Health string `json:"health,omitempty"`
Host string `json:"host,omitempty"`
Name string `json:"name,omitempty"`
Port int64 `json:"port,omitempty"`
StartedAt string `json:"startedAt,omitempty"`
Type string `json:"type,omitempty"`
}
type SystemStatusObject struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Version string `json:"version,omitempty"`
}
type SystemUpgradesObject struct {
UpdateCenterRefresh string `json:"updateCenterRefresh,omitempty"`
Upgrades []*Upgrade `json:"upgrades,omitempty"`
}
type Incompatible struct {
Category string `json:"category,omitempty"`
Description string `json:"description,omitempty"`
EditionBundled bool `json:"editionBundled,omitempty"`
Key string `json:"key,omitempty"`
License string `json:"license,omitempty"`
Name string `json:"name,omitempty"`
OrganizationName string `json:"organizationName,omitempty"`
OrganizationURL string `json:"organizationUrl,omitempty"`
}
type UpgradePlugins struct {
Incompatible []*Incompatible `json:"incompatible,omitempty"`
RequireUpdate []*RequireUpdate `json:"requireUpdate,omitempty"`
}
type RequireUpdate struct {
Category string `json:"category,omitempty"`
Description string `json:"description,omitempty"`
EditionBundled bool `json:"editionBundled,omitempty"`
Key string `json:"key,omitempty"`
License string `json:"license,omitempty"`
Name string `json:"name,omitempty"`
OrganizationName string `json:"organizationName,omitempty"`
OrganizationURL string `json:"organizationUrl,omitempty"`
TermsAndConditionsURL string `json:"termsAndConditionsUrl,omitempty"`
Version string `json:"version,omitempty"`
}
type Upgrade struct {
ChangeLogURL string `json:"changeLogUrl,omitempty"`
Description string `json:"description,omitempty"`
DownloadURL string `json:"downloadUrl,omitempty"`
Plugins *UpgradePlugins `json:"plugins,omitempty"`
ReleaseDate string `json:"releaseDate,omitempty"`
Version string `json:"version,omitempty"`
}
type SystemChangeLogLevelOption struct {
Level LogLevel `url:"level,omitempty"` // Description:"The new level. Be cautious: DEBUG, and even more TRACE, may have performance impacts.",ExampleValue:""
}
// Health Provide health status of SonarQube.<p>Require 'Administer System' permission or authentication with passcode</p><p> <ul> <li>GREEN: SonarQube is fully operational</li> <li>YELLOW: SonarQube is usable, but it needs attention in order to be fully operational</li> <li>RED: SonarQube is not operational</li> </ul></p>
func (s *SystemService) Health() (v *SystemHealthObject, resp *http.Response, err error) {
path := s.client.url + "/api/system/health"
req, err := http.NewRequest("GET", path, nil)
if err != nil {
return
}
v = new(SystemHealthObject)
resp, err = s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return
}
// Status Get state information about SonarQube.<p>status: the running status <ul> <li>STARTING: SonarQube Web Server is up and serving some Web Services (eg. api/system/status) but initialization is still ongoing</li> <li>UP: SonarQube instance is up and running</li> <li>DOWN: SonarQube instance is up but not running because migration has failed (refer to WS /api/system/migrate_db for details) or some other reason (check logs).</li> <li>RESTARTING: SonarQube instance is still up but a restart has been requested (refer to WS /api/system/restart for details).</li> <li>DB_MIGRATION_NEEDED: database migration is required. DB migration can be started using WS /api/system/migrate_db.</li> <li>DB_MIGRATION_RUNNING: DB migration is running (refer to WS /api/system/migrate_db for details)</li> </ul></p>
func (s *SystemService) Status() (v *SystemStatusObject, resp *http.Response, err error) {
path := s.client.url + "/api/system/status"
req, err := http.NewRequest("GET", path, nil)
if err != nil {
return
}
v = new(SystemStatusObject)
resp, err = s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return
}