-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
62 lines (53 loc) · 1.89 KB
/
version.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
55
56
57
58
59
60
61
62
package connect
import "encoding/json"
type BuildType string
const (
Alpha BuildType = "Alpha"
Beta BuildType = "Beta"
Rc BuildType = "Rc"
Final BuildType = "Final"
Patch BuildType = "Patch"
)
// ProductVersion - Product version, machine- and human-readable.
type ProductVersion struct {
ProductName string `json:"productName"` // e.g. "Kerio Connect"
Major int `json:"major"` // e.g. 7
Minor int `json:"minor"` // e.g. 4
Revision int `json:"revision"` // e.g. 0
Build int `json:"build"` // e.g. 4528
Order int `json:"order"` // e.g. 1 for alpha/beta/rc/patch 1
ReleaseType BuildType `json:"releaseType"` // e.g. Patch
DisplayNumber string `json:"displayNumber"` // e.g. "7.4.0 patch 1"
}
// Number, bumped with each API change. E.g. version 7.3.1 has a
// ApiVersion - higher or equal number as version 7.3.0 - equal if there's no change in API.
type ApiVersion int
// Informs about product version and API version.
// VersionGetProductVersion - Get product version.
func (s *ServerConnection) VersionGetProductVersion() (*ProductVersion, error) {
data, err := s.CallRaw("Version.getProductVersion", nil)
if err != nil {
return nil, err
}
productVersion := struct {
Result struct {
ProductVersion ProductVersion `json:"productVersion"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &productVersion)
return &productVersion.Result.ProductVersion, err
}
// VersionGetApiVersion - Get version of Administration API.
func (s *ServerConnection) VersionGetApiVersion() (*ApiVersion, error) {
data, err := s.CallRaw("Version.getApiVersion", nil)
if err != nil {
return nil, err
}
apiVersion := struct {
Result struct {
ApiVersion ApiVersion `json:"apiVersion"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &apiVersion)
return &apiVersion.Result.ApiVersion, err
}