-
Notifications
You must be signed in to change notification settings - Fork 13
/
maturity.go
66 lines (58 loc) · 1.46 KB
/
maturity.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
package opslevel
type CategoryBreakdown struct {
Category Category
Level Level
}
type MaturityReport struct {
CategoryBreakdown []CategoryBreakdown
OverallLevel Level
}
type ServiceMaturity struct {
Name string
MaturityReport MaturityReport
}
// Get Given a 'category' name returns the 'Level'
func (s *MaturityReport) Get(category string) *Level {
for _, breakdown := range s.CategoryBreakdown {
if category == breakdown.Category.Name {
return &breakdown.Level
}
}
return nil
}
func (c *Client) GetServiceMaturityWithAlias(alias string) (*ServiceMaturity, error) {
var q struct {
Account struct {
Service ServiceMaturity `graphql:"service(alias:$service)"`
}
}
v := PayloadVariables{
"service": alias,
}
err := c.Query(&q, v)
return &q.Account.Service, HandleErrors(err, nil)
}
func (c *Client) ListServicesMaturity() ([]ServiceMaturity, error) {
var q struct {
Account struct {
Services struct {
Nodes []ServiceMaturity
PageInfo PageInfo
} `graphql:"services(after: $after, first: $first)"`
}
}
v := c.InitialPageVariables()
var output []ServiceMaturity
if err := c.Query(&q, v); err != nil {
return nil, err
}
output = append(output, q.Account.Services.Nodes...)
for q.Account.Services.PageInfo.HasNextPage {
v["after"] = q.Account.Services.PageInfo.End
if err := c.Query(&q, v); err != nil {
return nil, err
}
output = append(output, q.Account.Services.Nodes...)
}
return output, nil
}