Skip to content

Commit 6977163

Browse files
Merge pull request #32 from grafana/oncallIntegrationLabels
feat: Oncall integration labels
2 parents 9f05d31 + 743639d commit 6977163

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ go 1.16
55
require (
66
github.com/google/go-querystring v1.0.0
77
github.com/hashicorp/go-retryablehttp v0.7.7
8-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
98
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,5 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3333
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3434
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
3535
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
36-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s=
37-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
3836
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3937
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

integration.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Integration struct {
3535
Type string `json:"type"`
3636
DefaultRoute *DefaultRoute `json:"default_route"`
3737
Templates *Templates `json:"templates"`
38+
Labels []*Label `json:"labels"`
3839
}
3940

4041
type DefaultRoute struct {
@@ -83,6 +84,15 @@ type ImageURLTemplate struct {
8384
ImageURL *string `json:"image_url"`
8485
}
8586

87+
type Label struct {
88+
Key KeyValueName `json:"key"`
89+
Value KeyValueName `json:"value"`
90+
}
91+
92+
type KeyValueName struct {
93+
Name string `json:"name"`
94+
}
95+
8696
type ListIntegrationOptions struct {
8797
ListOptions
8898
}
@@ -136,6 +146,7 @@ type CreateIntegrationOptions struct {
136146
Type string `json:"type,omitempty"`
137147
Templates *Templates `json:"templates,omitempty"`
138148
DefaultRoute *DefaultRoute `json:"default_route,omitempty"`
149+
Labels []*Label `json:"labels,omitempty"`
139150
}
140151

141152
// CreateIntegration creates integration with type, team_id and optional given name.
@@ -163,6 +174,7 @@ type UpdateIntegrationOptions struct {
163174
TeamId string `json:"team_id"`
164175
Templates *Templates `json:"templates,omitempty"`
165176
DefaultRoute *DefaultRoute `json:"default_route,omitempty"`
177+
Labels []*Label `json:"labels,omitempty"`
166178
}
167179

168180
// UpdateIntegration updates integration with new templates, name and default route.

integration_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ var testIntegration = &Integration{
6060
nil,
6161
},
6262
},
63+
Labels: []*Label{
64+
&Label{
65+
Key: KeyValueName{
66+
Name: "Flip",
67+
},
68+
Value: KeyValueName{
69+
Name: "Flop",
70+
},
71+
},
72+
},
6373
}
6474

6575
var testIntegrationBody = `{
@@ -111,7 +121,17 @@ var testIntegrationBody = `{
111121
"title":null,
112122
"message":null
113123
}
114-
}
124+
},
125+
"labels":[
126+
{
127+
"key": {
128+
"name": "Flip"
129+
},
130+
"value": {
131+
"name": "Flop"
132+
}
133+
}
134+
]
115135
}`
116136

117137
func TestCreateIntegration(t *testing.T) {

0 commit comments

Comments
 (0)