add alerting rule bulk api

Signed-off-by: junotx <junotx@126.com>
This commit is contained in:
junotx
2021-02-22 18:11:49 +08:00
parent 390647c82a
commit 91f85254aa
10 changed files with 902 additions and 353 deletions

View File

@@ -102,6 +102,20 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
Returns(http.StatusOK, ksapi.StatusOK, nil).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.DELETE("/rules").
To(handler.handleDeleteCustomAlertingRules).
Doc("delete multiple cluster-level custom alerting rules").
Param(ws.QueryParameter("name", "rule name").CollectionFormat(restful.CollectionFormatMulti).AllowMultiple(true)).
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.BulkResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.POST("/bulk_rules").
To(handler.handleCreateOrUpdateCustomAlertingRules).
Doc("create or update cluster-level custom alerting rules in bulk").
Reads([]alertingv2alpha1.PostableAlertingRule{}).
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.BulkResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.PUT("/rules/{rule_name}").
To(handler.handleUpdateCustomAlertingRule).
Doc("update the cluster-level custom alerting rule with the specified name").
@@ -151,6 +165,13 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.DELETE("/namespaces/{namespace}/rules").
To(handler.handleDeleteCustomAlertingRules).
Doc("delete multiple custom alerting rules in the specified namespace").
Param(ws.QueryParameter("name", "rule name").CollectionFormat(restful.CollectionFormatMulti).AllowMultiple(true)).
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.BulkResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.POST("/namespaces/{namespace}/rules").
To(handler.handleCreateCustomAlertingRule).
Doc("create a custom alerting rule in the specified namespace").
@@ -158,6 +179,13 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
Returns(http.StatusOK, ksapi.StatusOK, "").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.POST("/namespaces/{namespace}/bulk_rules").
To(handler.handleCreateOrUpdateCustomAlertingRules).
Doc("create or update custom alerting rules in bulk in the specified namespace").
Reads([]alertingv2alpha1.PostableAlertingRule{}).
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.BulkResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
ws.Route(ws.PUT("/namespaces/{namespace}/rules/{rule_name}").
To(handler.handleUpdateCustomAlertingRule).
Doc("update the custom alerting rule with the specified name in the specified namespace").