-
Notifications
You must be signed in to change notification settings - Fork 34
Implemented the alert logs API #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b4fa36a
to
bf240d9
Compare
bf240d9
to
08edb4a
Compare
@@ -381,3 +381,104 @@ func TestGetAlert(t *testing.T) { | |||
t.Errorf("Wrong data for alert: %v", alert) | |||
} | |||
} | |||
|
|||
func TestFindAlertLogs(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[should] Missing test for FindAlertLogsByNextID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alerts.go
Outdated
func (c *Client) FindAlertLogs(alertId string) (*AlertLogsResp, error) { | ||
path := fmt.Sprintf("/api/v0/alerts/%s/logs", alertId) | ||
return requestGet[AlertLogsResp](c, path) | ||
} | ||
|
||
// FindAlertLogsByNextID finds alert logs by next id. | ||
func (c *Client) FindAlertLogsByNextID(alertId, nextId string) (*AlertLogsResp, error) { | ||
params := url.Values{} | ||
params.Set("nextId", nextId) | ||
path := fmt.Sprintf("/api/v0/alerts/%s/logs", alertId) | ||
return requestGetWithParams[AlertLogsResp](c, path, params) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter limit
cannot be set in these functions.
limit
cannot be set in FindAlerts
either, but I am not confident that it is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to use params for request as struct
Implemented alert logs API for the client.
https://mackerel.io/ja/blog/entry/weekly/20250220#:~:text=mackerel.io-,%E3%82%A2%E3%83%A9%E3%83%BC%E3%83%88%E3%81%AE%E3%83%AD%E3%82%B0%E3%82%92%E5%8F%96%E5%BE%97%E3%81%A7%E3%81%8D%E3%82%8BAPI%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F,-%E3%82%A2%E3%83%A9%E3%83%BC%E3%83%88ID%E3%81%8B%E3%82%89
https://mackerel.io/api-docs/entry/alerts#logs