add list events
This commit is contained in:
@@ -46,7 +46,7 @@ func newOpenpitrixHandler(factory informers.InformerFactory, opClient op.Client)
|
||||
|
||||
func (h *openpitrixHandler) ListApplications(request *restful.Request, response *restful.Response) {
|
||||
limit, offset := params.ParsePaging(request)
|
||||
runtimeId := request.PathParameter("cluster")
|
||||
runtimeId := request.PathParameter("runtime")
|
||||
namespace := request.PathParameter("namespace")
|
||||
orderBy := params.GetStringValueWithDefault(request, params.OrderByParam, openpitrix.CreateTime)
|
||||
reverse := params.GetBoolValueWithDefault(request, params.ReverseParam, false)
|
||||
@@ -72,9 +72,9 @@ func (h *openpitrixHandler) ListApplications(request *restful.Request, response
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) DescribeApplication(req *restful.Request, resp *restful.Response) {
|
||||
clusterId := req.PathParameter("application")
|
||||
runtimeId := req.PathParameter("runtime")
|
||||
namespace := req.PathParameter("namespace")
|
||||
runtimeId := req.PathParameter("cluster")
|
||||
clusterId := req.PathParameter("application")
|
||||
|
||||
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
|
||||
|
||||
@@ -84,29 +84,12 @@ func (h *openpitrixHandler) DescribeApplication(req *restful.Request, resp *rest
|
||||
return
|
||||
}
|
||||
|
||||
//ns, err := h.informers.Core().V1().Namespaces().Lister().Get(namespace)
|
||||
//
|
||||
//if err != nil {
|
||||
// klog.Errorln(err)
|
||||
// api.HandleInternalError(resp, nil, err)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//runtimeId := ns.Annotations[constants.OpenPitrixRuntimeAnnotationKey]
|
||||
//
|
||||
//if runtimeId != app.Cluster.RuntimeId {
|
||||
// err = fmt.Errorf("rumtime not match %s,%s", app.Cluster.RuntimeId, runtimeId)
|
||||
// klog.V(4).Infoln(err)
|
||||
// api.HandleForbidden(resp, nil, err)
|
||||
// return
|
||||
//}
|
||||
|
||||
resp.WriteEntity(app)
|
||||
return
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) CreateApplication(req *restful.Request, resp *restful.Response) {
|
||||
runtimeId := req.PathParameter("cluster")
|
||||
runtimeId := req.PathParameter("runtime")
|
||||
namespace := req.PathParameter("namespace")
|
||||
var createClusterRequest openpitrix.CreateClusterRequest
|
||||
err := req.ReadEntity(&createClusterRequest)
|
||||
@@ -131,7 +114,7 @@ func (h *openpitrixHandler) CreateApplication(req *restful.Request, resp *restfu
|
||||
|
||||
func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restful.Response) {
|
||||
var modifyClusterAttributesRequest openpitrix.ModifyClusterAttributesRequest
|
||||
runtimeId := req.PathParameter("cluster")
|
||||
runtimeId := req.PathParameter("runtime")
|
||||
clusterId := req.PathParameter("application")
|
||||
namespace := req.PathParameter("namespace")
|
||||
err := req.ReadEntity(&modifyClusterAttributesRequest)
|
||||
@@ -168,7 +151,7 @@ func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restfu
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) DeleteApplication(req *restful.Request, resp *restful.Response) {
|
||||
runtimeId := req.PathParameter("cluster")
|
||||
runtimeId := req.PathParameter("runtime")
|
||||
clusterId := req.PathParameter("application")
|
||||
namespace := req.PathParameter("namespace")
|
||||
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
|
||||
@@ -198,7 +181,7 @@ func (h *openpitrixHandler) DeleteApplication(req *restful.Request, resp *restfu
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) UpgradeApplication(req *restful.Request, resp *restful.Response) {
|
||||
runtimeId := req.PathParameter("cluster")
|
||||
runtimeId := req.PathParameter("runtime")
|
||||
namespace := req.PathParameter("namespace")
|
||||
clusterId := req.PathParameter("application")
|
||||
var upgradeClusterRequest openpitrix.UpgradeClusterRequest
|
||||
@@ -850,6 +833,7 @@ func (h *openpitrixHandler) DescribeRepo(req *restful.Request, resp *restful.Res
|
||||
|
||||
resp.WriteEntity(result)
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) ListRepos(req *restful.Request, resp *restful.Response) {
|
||||
limit, offset := params.ParsePaging(req)
|
||||
orderBy := params.GetStringValueWithDefault(req, params.OrderByParam, openpitrix.CreateTime)
|
||||
@@ -873,6 +857,29 @@ func (h *openpitrixHandler) ListRepos(req *restful.Request, resp *restful.Respon
|
||||
resp.WriteEntity(result)
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) ListEvents(req *restful.Request, resp *restful.Response) {
|
||||
limit, offset := params.ParsePaging(req)
|
||||
orderBy := params.GetStringValueWithDefault(req, params.OrderByParam, openpitrix.CreateTime)
|
||||
reverse := params.GetBoolValueWithDefault(req, params.ReverseParam, false)
|
||||
conditions, err := params.ParseConditions(req)
|
||||
|
||||
if err != nil {
|
||||
klog.V(4).Infoln(err)
|
||||
api.HandleBadRequest(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.openpitrix.ListEvents(conditions, orderBy, reverse, limit, offset)
|
||||
|
||||
if err != nil {
|
||||
klog.Errorln(err)
|
||||
handleOpenpitrixError(resp, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp.WriteEntity(result)
|
||||
}
|
||||
|
||||
func (h *openpitrixHandler) ListRepoEvents(req *restful.Request, resp *restful.Response) {
|
||||
repoId := req.PathParameter("repo")
|
||||
limit, offset := params.ParsePaging(req)
|
||||
|
||||
@@ -43,7 +43,7 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
|
||||
webservice := runtime.NewWebService(GroupVersion)
|
||||
handler := newOpenpitrixHandler(factory, op)
|
||||
|
||||
webservice.Route(webservice.GET("/clusters/{cluster}/applications").
|
||||
webservice.Route(webservice.GET("/runtimes/{runtime}/applications").
|
||||
To(handler.ListApplications).
|
||||
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
@@ -52,13 +52,13 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
|
||||
Required(false).
|
||||
DataFormat("key=value,key~value").
|
||||
DefaultValue("")).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1")))
|
||||
|
||||
webservice.Route(webservice.GET("/clusters/{cluster}/namespaces/{namespace}/applications").
|
||||
webservice.Route(webservice.GET("/runtimes/{runtime}/namespaces/{namespace}/applications").
|
||||
To(handler.ListApplications).
|
||||
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
@@ -67,59 +67,59 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
|
||||
Required(false).
|
||||
DataFormat("key=value,key~value").
|
||||
DefaultValue("")).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")).
|
||||
Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1")))
|
||||
|
||||
webservice.Route(webservice.GET("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
|
||||
webservice.Route(webservice.GET("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
|
||||
To(handler.DescribeApplication).
|
||||
Returns(http.StatusOK, api.StatusOK, openpitrix2.Application{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
Doc("Describe the specified application of the namespace").
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")).
|
||||
Param(webservice.PathParameter("application", "application ID")))
|
||||
|
||||
webservice.Route(webservice.POST("/clusters/{cluster}/namespaces/{namespace}/applications").
|
||||
webservice.Route(webservice.POST("/runtimes/{runtime}/namespaces/{namespace}/applications").
|
||||
To(handler.CreateApplication).
|
||||
Doc("Deploy a new application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
Reads(openpitrix2.CreateClusterRequest{}).
|
||||
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")))
|
||||
|
||||
webservice.Route(webservice.PATCH("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
|
||||
webservice.Route(webservice.PATCH("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
|
||||
Consumes(mimePatch...).
|
||||
To(handler.ModifyApplication).
|
||||
Doc("Modify application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
Reads(openpitrix2.ModifyClusterAttributesRequest{}).
|
||||
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")).
|
||||
Param(webservice.PathParameter("application", "the id of the application cluster")))
|
||||
|
||||
webservice.Route(webservice.DELETE("/clusters/cluster/namespaces/{namespace}/applications/{application}").
|
||||
webservice.Route(webservice.DELETE("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
|
||||
To(handler.DeleteApplication).
|
||||
Doc("Delete the specified application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")).
|
||||
Param(webservice.PathParameter("application", "the id of the application cluster")))
|
||||
|
||||
webservice.Route(webservice.POST("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
|
||||
webservice.Route(webservice.POST("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
|
||||
Consumes(mimePatch...).
|
||||
To(handler.UpgradeApplication).
|
||||
Doc("Upgrade application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
|
||||
Reads(openpitrix2.UpgradeClusterRequest{}).
|
||||
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
|
||||
Param(webservice.PathParameter("cluster", "the id of cluster(runtime)")).
|
||||
Param(webservice.PathParameter("runtime", "the id of runtime")).
|
||||
Param(webservice.PathParameter("namespace", "the name of the project")).
|
||||
Param(webservice.PathParameter("application", "the id of the application cluster")))
|
||||
|
||||
@@ -347,6 +347,13 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
|
||||
Reads(openpitrix2.RepoActionRequest{}).
|
||||
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
|
||||
Param(webservice.PathParameter("repo", "repo id")))
|
||||
webservice.Route(webservice.GET("/events").
|
||||
To(handler.ListEvents).
|
||||
Doc("Get events").
|
||||
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions,connect multiple conditions with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").
|
||||
Required(false).
|
||||
DataFormat("key=%s,key~%s")).
|
||||
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}))
|
||||
webservice.Route(webservice.GET("/repos/{repo}/events").
|
||||
To(handler.ListRepoEvents).
|
||||
Doc("Get repository events").
|
||||
|
||||
Reference in New Issue
Block a user