EventManager: add "on-demand" trigger

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-01-21 15:41:24 +01:00
parent 53f17b5715
commit 7b5bebc588
20 changed files with 410 additions and 49 deletions

View File

@@ -942,6 +942,25 @@ func GetEventRules(limit, offset int64, expectedStatusCode int) ([]dataprovider.
return rules, body, err
}
// RunOnDemandRule executes the specified on demand rule
func RunOnDemandRule(name string, expectedStatusCode int) ([]byte, error) {
resp, err := sendHTTPRequest(http.MethodPost, buildURLRelativeToBase(eventRulesPath, "run", url.PathEscape(name)),
nil, "application/json", getDefaultToken())
if err != nil {
return nil, err
}
defer resp.Body.Close()
b, err := getResponseBody(resp)
if err != nil {
return b, err
}
if err := checkResponse(resp.StatusCode, expectedStatusCode); err != nil {
return b, err
}
return b, nil
}
// GetQuotaScans gets active quota scans for users and checks the received HTTP Status code against expectedStatusCode.
func GetQuotaScans(expectedStatusCode int) ([]common.ActiveQuotaScan, []byte, error) {
var quotaScans []common.ActiveQuotaScan