@@ -41,10 +41,24 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
promResourceClient promresourcesclient.Interface, ruleClient alerting.RuleClient,
|
||||
option *alerting.Options) error {
|
||||
|
||||
handler := newHandler(informers, promResourceClient, ruleClient, option)
|
||||
|
||||
ws := runtime.NewWebService(GroupVersion)
|
||||
|
||||
if informers == nil || promResourceClient == nil || ruleClient == nil || option == nil {
|
||||
h := func(req *restful.Request, resp *restful.Response) {
|
||||
ksapi.HandleBadRequest(resp, nil, alertingv2alpha1.ErrAlertingAPIV2NotEnabled)
|
||||
return
|
||||
}
|
||||
ws.Route(ws.GET("/{path:*}").To(h).Returns(http.StatusOK, ksapi.StatusOK, nil))
|
||||
ws.Route(ws.PUT("/{path:*}").To(h).Returns(http.StatusOK, ksapi.StatusOK, nil))
|
||||
ws.Route(ws.POST("/{path:*}").To(h).Returns(http.StatusOK, ksapi.StatusOK, nil))
|
||||
ws.Route(ws.DELETE("/{path:*}").To(h).Returns(http.StatusOK, ksapi.StatusOK, nil))
|
||||
ws.Route(ws.PATCH("/{path:*}").To(h).Returns(http.StatusOK, ksapi.StatusOK, nil))
|
||||
container.Add(ws)
|
||||
return nil
|
||||
}
|
||||
|
||||
handler := newHandler(informers, promResourceClient, ruleClient, option)
|
||||
|
||||
ws.Route(ws.GET("/rules").
|
||||
To(handler.handleListCustomAlertingRules).
|
||||
Doc("list the cluster-level custom alerting rules").
|
||||
@@ -54,7 +68,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("sort_field", "sort field, one of `name`, `lastEvaluation`, `evaluationTime`")).
|
||||
Param(ws.QueryParameter("sort_type", "sort type, one of `asc`, `desc`")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.GettableAlertingRuleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -64,7 +78,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Doc("list the alerts of the cluster-level custom alerting rules").
|
||||
Param(ws.QueryParameter("state", "state, one of `firing`, `pending`, `inactive`")).
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -78,7 +92,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
ws.Route(ws.GET("/rules/{rule_name}/alerts").
|
||||
To(handler.handleListCustomRuleAlerts).
|
||||
Doc("list the alerts of the cluster-level custom alerting rule with the specified name").
|
||||
Returns(http.StatusOK, ksapi.StatusOK, []alertingv2alpha1.Alert{}).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
|
||||
ws.Route(ws.POST("/rules").
|
||||
@@ -110,7 +124,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("sort_field", "sort field, one of `name`, `lastEvaluation`, `evaluationTime`")).
|
||||
Param(ws.QueryParameter("sort_type", "sort type, one of `asc`, `desc`")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.GettableAlertingRuleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -120,7 +134,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Doc("list the alerts of the custom alerting rules in the specified namespace.").
|
||||
Param(ws.QueryParameter("state", "state, one of `firing`, `pending`, `inactive`")).
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -134,7 +148,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/rules/{rule_name}/alerts").
|
||||
To(handler.handleListCustomRuleAlerts).
|
||||
Doc("get the alerts of the custom alerting rule with the specified name in the specified namespace").
|
||||
Returns(http.StatusOK, ksapi.StatusOK, []alertingv2alpha1.Alert{}).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
|
||||
ws.Route(ws.POST("/namespaces/{namespace}/rules").
|
||||
@@ -166,7 +180,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("sort_field", "sort field, one of `name`, `lastEvaluation`, `evaluationTime`")).
|
||||
Param(ws.QueryParameter("sort_type", "sort type, one of `asc`, `desc`")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.GettableAlertingRuleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -176,7 +190,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
Doc("list the alerts of the builtin(non-custom) rules").
|
||||
Param(ws.QueryParameter("state", "state, one of `firing`, `pending`, `inactive`")).
|
||||
Param(ws.QueryParameter("label_filters", "label filters, concatenating multiple filters with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").DataFormat("key=%s,key~%s")).
|
||||
Param(ws.QueryParameter("offset", "offset of the result set").DataType("integer").DefaultValue("0")).
|
||||
Param(ws.QueryParameter("page", "page of the result set").DataType("integer").DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "limit size of the result set").DataType("integer").DefaultValue("10")).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
@@ -190,7 +204,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
|
||||
ws.Route(ws.GET("/builtin/rules/{rule_id}/alerts").
|
||||
To(handler.handleListBuiltinRuleAlerts).
|
||||
Doc("list the alerts of the builtin(non-custom) alerting rule with the specified id").
|
||||
Returns(http.StatusOK, ksapi.StatusOK, []alertingv2alpha1.Alert{}).
|
||||
Returns(http.StatusOK, ksapi.StatusOK, alertingv2alpha1.AlertList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.AlertingTag}))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
Reference in New Issue
Block a user