add apis for switch the notification language (#5088)
add apis for switch the notification lanaguae Signed-off-by: wanjunlei <wanjunlei@kubesphere.io>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
package v2beta2
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/emicklei/go-restful"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
@@ -118,6 +120,27 @@ func (h *handler) UpdateResource(req *restful.Request, resp *restful.Response) {
|
||||
handleResponse(req, resp, updated, err)
|
||||
}
|
||||
|
||||
func (h *handler) PatchResource(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
user := req.PathParameter("user")
|
||||
resource := req.PathParameter("resources")
|
||||
name := req.PathParameter("name")
|
||||
|
||||
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, "") {
|
||||
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(req.Request.Body)
|
||||
if err != nil {
|
||||
api.HandleBadRequest(resp, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
patched, err := h.operator.Patch(user, resource, name, data)
|
||||
handleResponse(req, resp, patched, err)
|
||||
}
|
||||
|
||||
func (h *handler) DeleteResource(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
user := req.PathParameter("user")
|
||||
|
||||
@@ -69,7 +69,7 @@ func AddToContainer(
|
||||
To(h.ListResource).
|
||||
Doc("list the notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter("resources", "known values include notificationmanagers, configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.QueryParameter(query.ParameterName, "name used for filtering").Required(false)).
|
||||
Param(ws.QueryParameter(query.ParameterLabelSelector, "label selector used for filtering").Required(false)).
|
||||
Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, email, feishu, slack, webhook, wechat").Required(false)).
|
||||
@@ -83,7 +83,7 @@ func AddToContainer(
|
||||
To(h.GetResource).
|
||||
Doc("get the specified notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter("resources", "known values include notificationmanagers, configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter(query.ParameterName, "the name of the resource")).
|
||||
Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, feishu, email, slack, webhook, wechat").Required(false)).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
@@ -92,14 +92,22 @@ func AddToContainer(
|
||||
To(h.CreateResource).
|
||||
Doc("create a notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter("resources", "known values include notificationmanagers, configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
|
||||
ws.Route(ws.PUT("/{resources}/{name}").
|
||||
To(h.UpdateResource).
|
||||
Doc("update the specified notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter("resources", "known values include notificationmanagers, configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter(query.ParameterName, "the name of the resource")).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
|
||||
ws.Route(ws.PATCH("/{resources}/{name}").
|
||||
To(h.PatchResource).
|
||||
Doc("patch the specified notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("resources", "known values include notificationmanagers, configs, receivers, secrets, routers, silences, configmaps")).
|
||||
Param(ws.PathParameter(query.ParameterName, "the name of the resource")).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
|
||||
@@ -154,6 +162,15 @@ func AddToContainer(
|
||||
Param(ws.PathParameter(query.ParameterName, "the name of the resource")).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
|
||||
ws.Route(ws.PATCH("/users/{user}/{resources}/{name}").
|
||||
To(h.PatchResource).
|
||||
Doc("Patch the specified notification resources").
|
||||
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
|
||||
Param(ws.PathParameter("user", "user name")).
|
||||
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")).
|
||||
Param(ws.PathParameter(query.ParameterName, "the name of the resource")).
|
||||
Returns(http.StatusOK, api.StatusOK, nil))
|
||||
|
||||
ws.Route(ws.DELETE("/users/{user}/{resources}/{name}").
|
||||
To(h.DeleteResource).
|
||||
Doc("delete the specified notification resources").
|
||||
|
||||
Reference in New Issue
Block a user