/
vinyl.go
104 lines (96 loc) · 2.82 KB
/
vinyl.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package api
import (
"fmt"
log "github.com/sirupsen/logrus"
)
type VinylV0Project struct {
Type string
Id string
Attributes struct {
Name string
}
Relationships map[string]struct {
Links struct {
Self string
Related string
}
Data *struct {
Type string
Id string
}
}
}
type GetVinylV0ProjectsResponse struct {
Data []*VinylV0Project
Included []struct {
// TODO Type="branch" has different stuff than Type="entitlements"
Type string
Id string
Attributes map[string]interface{}
Relationships map[string]interface{}
Links struct {
Self struct {
HRef string
}
}
Meta *struct {
ETag string
InTrash bool `json:"in-trash"`
}
}
Meta struct {
Offset int
Limit int
Total int
}
}
func (client *Client) GetVinylV0Projects(offset int, limit int) (*GetVinylV0ProjectsResponse, error) {
result := &GetVinylV0ProjectsResponse{}
params := map[string]interface{}{
"include[project][]": []string{"entitlements", "main-branch", "project-preference", "user-default-branch"},
"page[offset]": []string{fmt.Sprintf("%d", offset)},
"page[limit]": []string{fmt.Sprintf("%d", limit)},
}
json, err := client.GetJson(params, result, "api/vinyl/common/v0/projects")
log.Tracef("vinyl json:\n%s\n\n", json)
return result, err
}
type GetVinylV0ProjectsRelationshipsRunsResponse struct {
Data []struct {
Type string
Id string
}
}
func (client *Client) GetVinylV0ProjectsRelationshipsRuns(projectId string) (*GetVinylV0ProjectsRelationshipsRunsResponse, error) {
result := &GetVinylV0ProjectsRelationshipsRunsResponse{}
params := map[string]interface{}{}
// "include[project][]": []string{"entitlements", "main-branch", "project-preference", "user-default-branch"},
// "page[offset]": []string{fmt.Sprintf("%d", offset)},
// "page[limit]": []string{fmt.Sprintf("%d", limit)},
//}
json, err := client.GetJson(params, result, "api/vinyl/common/v0/projects/%s/relationships/runs", projectId)
log.Tracef("vinyl json:\n%s\n\n", json)
return result, err
}
type GetVinylV0ProjectsRelatedRunsResponse struct {
Data []struct {
Type string
Id string
Attributes struct {
CompletedDate string `json:"completed-date"`
Segment bool
Status string
UploadId string `json:"upload-id"`
RunType string `json:"run-type"`
CreationDate string `json:"creation-date"`
Fingerprints []interface{}
}
}
}
func (client *Client) GetVinylV0ProjectsRelatedRuns(projectId string) (*GetVinylV0ProjectsRelatedRunsResponse, error) {
result := &GetVinylV0ProjectsRelatedRunsResponse{}
params := map[string]interface{}{}
json, err := client.GetJson(params, result, "api/vinyl/common/v0/projects/%s/related/runs", projectId)
log.Tracef("vinyl json:\n%s\n\n", json)
return result, err
}