error rates

This commit is contained in:
boufni95 2025-01-09 17:42:54 +00:00
parent 4aeb565596
commit 16d4198364
13 changed files with 323 additions and 9 deletions

View file

@ -78,6 +78,7 @@ type Client struct {
GetAppUserLNURLInfo func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error)
GetAppsMetrics func(req AppsMetricsRequest) (*AppsMetrics, error)
GetDebitAuthorizations func() (*DebitAuthorizations, error)
GetErrorStats func() (*ErrorStats, error)
GetHttpCreds func() (*HttpCreds, error)
GetInviteLinkState func(req GetInviteTokenStateRequest) (*GetInviteTokenStateResponse, error)
GetLNURLChannelLink func() (*LnurlLinkResponse, error)
@ -758,6 +759,32 @@ func NewClient(params ClientParams) *Client {
}
return &res, nil
},
GetErrorStats: func() (*ErrorStats, error) {
auth, err := params.RetrieveMetricsAuth()
if err != nil {
return nil, err
}
finalRoute := "/api/reports/errors"
body := []byte{}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return nil, err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return nil, err
}
if result.Status == "ERROR" {
return nil, fmt.Errorf(result.Reason)
}
res := ErrorStats{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
// server streaming method: GetHttpCreds not implemented
GetInviteLinkState: func(req GetInviteTokenStateRequest) (*GetInviteTokenStateResponse, error) {
auth, err := params.RetrieveAdminAuth()

View file

@ -250,6 +250,18 @@ type EncryptionExchangeRequest struct {
type EnrollAdminTokenRequest struct {
Admin_token string `json:"admin_token"`
}
type ErrorStat struct {
Errors int64 `json:"errors"`
From_unix int64 `json:"from_unix"`
Total int64 `json:"total"`
}
type ErrorStats struct {
Past10m *ErrorStat `json:"past10m"`
Past1h *ErrorStat `json:"past1h"`
Past1m *ErrorStat `json:"past1m"`
Past24h *ErrorStat `json:"past24h"`
Past6h *ErrorStat `json:"past6h"`
}
type FrequencyRule struct {
Amount int64 `json:"amount"`
Interval IntervalType `json:"interval"`