-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcomponents.go
81 lines (63 loc) · 2.13 KB
/
components.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package api
import "fmt"
type ComponentsService struct {
client *Client
}
type ListComponentsResponse struct {
Data []LatestComponent `json:"data"`
Message string `json:"message"`
}
type LatestComponent struct {
Components []LatestComponentVersion `json:"components"`
}
type LatestComponentVersion struct {
Id int32 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Size int64 `json:"size"`
ComponentType string `json:"type"`
Deprecated bool `json:"deprecated"`
}
func (svc *ComponentsService) ListComponents(os string, arch string) (response ListComponentsResponse, err error) {
apiPath := fmt.Sprintf(apiV2Components, os, arch)
err = svc.client.RequestDecoder("GET", apiPath, nil, &response)
return
}
type ListComponentVersionsResponse struct {
Data []ComponentVersions `json:"data"`
}
type ComponentVersions struct {
Id int32 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Component_type string `json:"type"`
Deprecated bool `json:"deprecated"`
Versions []string `json:"versions"`
}
func (svc *ComponentsService) ListComponentVersions(id int32, os string, arch string) (
response ListComponentVersionsResponse,
err error) {
apiPath := fmt.Sprintf(apiV2ComponentsVersions, id, os, arch)
err = svc.client.RequestDecoder("GET", apiPath, nil, &response)
return
}
type FetchComponentResponse struct {
Data []Artifact `json:"data"`
}
type Artifact struct {
Id int32 `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Size int64 `json:"size"`
InstallMessage string `json:"installMessage"`
UpdateMessage string `json:"updateMessage"`
ArtifactUrl string `json:"artifact_url"`
}
func (svc *ComponentsService) FetchComponentArtifact(id int32, os string, arch string, version string) (
response FetchComponentResponse,
err error) {
apiPath := fmt.Sprintf(apiV2ComponentsFetch, id, os, arch, version)
err = svc.client.RequestDecoder("GET", apiPath, nil, &response)
return
}