Skip to content

Commit

Permalink
return ID in the api group info
Browse files Browse the repository at this point in the history
Signed-off-by: Yijie Qin <[email protected]>
  • Loading branch information
qinxx108 committed Jul 6, 2023
1 parent 8640e7e commit e16034e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ func (api *API) getAlertGroupInfoListHandler(params alertgroupinfolist_ops.GetAl
ag := &open_api_models.AlertGroupInfo{
Receiver: &open_api_models.Receiver{Name: &alertGroup.Receiver},
Labels: ModelLabelSetToAPILabelSet(alertGroup.Labels),
ID: &alertGroup.ID,
}

previousAgID = &alertGroup.ID
Expand Down
8 changes: 4 additions & 4 deletions api/v2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,28 @@ func TestGetAlertGroupInfosHandler(t *testing.T) {
{
convertIntToPointerInt64(int64(1)),
nil,
`{"alertGroupInfoList":[{"labels":{"alertname":"TestingAlert","service":"api"},"receiver":{"name":"testing"}}],"nextToken":"478b4114226224a35910d449fdba8186ebfb441f"}`,
`{"alertGroupInfoList":[{"id":"478b4114226224a35910d449fdba8186ebfb441f","labels":{"alertname":"TestingAlert","service":"api"},"receiver":{"name":"testing"}}],"nextToken":"478b4114226224a35910d449fdba8186ebfb441f"}`,
200,
},
// One item to return, has next token.
{
convertIntToPointerInt64(int64(1)),
convertStringToPointer("478b4114226224a35910d449fdba8186ebfb441f"),
`{"alertGroupInfoList":[{"labels":{"alertname":"HighErrorRate","cluster":"bb","service":"api"},"receiver":{"name":"prod"}}],"nextToken":"7f4084a078a3fe29d6de82fad15af8f1411e803f"}`,
`{"alertGroupInfoList":[{"id":"7f4084a078a3fe29d6de82fad15af8f1411e803f","labels":{"alertname":"HighErrorRate","cluster":"bb","service":"api"},"receiver":{"name":"prod"}}],"nextToken":"7f4084a078a3fe29d6de82fad15af8f1411e803f"}`,
200,
},
// Five item to return, has next token.
{
convertIntToPointerInt64(int64(5)),
convertStringToPointer("7f4084a078a3fe29d6de82fad15af8f1411e803f"),
`{"alertGroupInfoList":[{"labels":{"alertname":"OtherAlert"},"receiver":{"name":"prod"}},{"labels":{"alertname":"HighErrorRate","cluster":"aa","service":"api"},"receiver":{"name":"prod"}}]}`,
`{"alertGroupInfoList":[{"id":"d525244929240cbdb75a497913c1890ab8de1962","labels":{"alertname":"OtherAlert"},"receiver":{"name":"prod"}},{"id":"d73984d43949112ae1ea59dcc5af4af7b630a5b1","labels":{"alertname":"HighErrorRate","cluster":"aa","service":"api"},"receiver":{"name":"prod"}}]}`,
200,
},
// Return all results.
{
nil,
nil,
`{"alertGroupInfoList":[{"labels":{"alertname":"TestingAlert","service":"api"},"receiver":{"name":"testing"}},{"labels":{"alertname":"HighErrorRate","cluster":"bb","service":"api"},"receiver":{"name":"prod"}},{"labels":{"alertname":"OtherAlert"},"receiver":{"name":"prod"}},{"labels":{"alertname":"HighErrorRate","cluster":"aa","service":"api"},"receiver":{"name":"prod"}}]}`,
`{"alertGroupInfoList":[{"id":"478b4114226224a35910d449fdba8186ebfb441f","labels":{"alertname":"TestingAlert","service":"api"},"receiver":{"name":"testing"}},{"id":"7f4084a078a3fe29d6de82fad15af8f1411e803f","labels":{"alertname":"HighErrorRate","cluster":"bb","service":"api"},"receiver":{"name":"prod"}},{"id":"d525244929240cbdb75a497913c1890ab8de1962","labels":{"alertname":"OtherAlert"},"receiver":{"name":"prod"}},{"id":"d73984d43949112ae1ea59dcc5af4af7b630a5b1","labels":{"alertname":"HighErrorRate","cluster":"aa","service":"api"},"receiver":{"name":"prod"}}]}`,
200,
},
} {
Expand Down
17 changes: 17 additions & 0 deletions api/v2/models/alert_group_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,12 @@ definitions:
$ref: '#/definitions/labelSet'
receiver:
$ref: '#/definitions/receiver'
id:
type: string
required:
- labels
- receiver
- id
alertStatus:
type: object
properties:
Expand Down
12 changes: 10 additions & 2 deletions api/v2/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e16034e

Please sign in to comment.