update api docs

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-06-10 14:37:33 +08:00
committed by zryfish
parent e86b2a4dcc
commit 08877f950b
6 changed files with 29 additions and 17 deletions

View File

@@ -133,23 +133,23 @@ func addWebService(c *restful.Container) error {
Reads(CreateUserRequest{}). Reads(CreateUserRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.DELETE("/users/{name}"). ws.Route(ws.DELETE("/users/{username}").
To(iam.DeleteUser). To(iam.DeleteUser).
Doc("Remove a specified user."). Doc("Remove a specified user.").
Param(ws.PathParameter("name", "username")). Param(ws.PathParameter("username", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.PUT("/users/{name}"). ws.Route(ws.PUT("/users/{username}").
To(iam.UpdateUser). To(iam.UpdateUser).
Doc("Updates information about the specified user."). Doc("Updates information about the specified user.").
Param(ws.PathParameter("name", "username")). Param(ws.PathParameter("username", "username")).
Reads(UserUpdateRequest{}). Reads(UserUpdateRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users/{name}/log"). ws.Route(ws.GET("/users/{username}/log").
To(iam.UserLoginLog). To(iam.UserLoginLog).
Doc("This method is used to retrieve the \"login logs\" for the specified user."). Doc("This method is used to retrieve the \"login logs\" for the specified user.").
Param(ws.PathParameter("name", "username")). Param(ws.PathParameter("username", "username")).
Returns(http.StatusOK, ok, LoginLog{}). Returns(http.StatusOK, ok, LoginLog{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users"). ws.Route(ws.GET("/users").
@@ -296,7 +296,7 @@ func addWebService(c *restful.Container) error {
To(iam.RemoveUser). To(iam.RemoveUser).
Doc("Remove members from workspace."). Doc("Remove members from workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("name", "username")). Param(ws.PathParameter("username", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}"). ws.Route(ws.GET("/workspaces/{workspace}/members/{username}").

View File

@@ -60,7 +60,7 @@ func addWebService(c *restful.Container) error {
ok := "ok" ok := "ok"
webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}"). webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}").
To(resources.ListResources). To(resources.ListNamespacedResources).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Namespace level resource query"). Doc("Namespace level resource query").
Param(webservice.PathParameter("namespace", "which namespace")). Param(webservice.PathParameter("namespace", "which namespace")).
@@ -81,7 +81,7 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Cluster level resource query"). Doc("Cluster level resource query").
Param(webservice.PathParameter("resources", "cluster level resource type"))). Param(webservice.PathParameter("resources", "cluster level resource type")).
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). Param(webservice.QueryParameter(params.ConditionsParam, "query conditions").
Required(false). Required(false).
DataFormat("key=value,key~value"). DataFormat("key=value,key~value").
@@ -89,7 +89,7 @@ func addWebService(c *restful.Container) error {
Param(webservice.QueryParameter(params.PagingParam, "page"). Param(webservice.QueryParameter(params.PagingParam, "page").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1")) DefaultValue("limit=10,page=1")))
tags = []string{"Applications"} tags = []string{"Applications"}

View File

@@ -27,7 +27,7 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/tenant" "kubesphere.io/kubesphere/pkg/apiserver/tenant"
"kubesphere.io/kubesphere/pkg/models/devops" "kubesphere.io/kubesphere/pkg/models/devops"
"kubesphere.io/kubesphere/pkg/params" "kubesphere.io/kubesphere/pkg/params"
esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
"kubesphere.io/kubesphere/pkg/errors" "kubesphere.io/kubesphere/pkg/errors"
"kubesphere.io/kubesphere/pkg/models" "kubesphere.io/kubesphere/pkg/models"
@@ -59,7 +59,8 @@ func addWebService(c *restful.Container) error {
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}"). ws.Route(ws.GET("/workspaces/{workspace}").
To(tenant.DescribeWorkspace). To(tenant.DescribeWorkspace).
Doc("Get workspace detail"). Doc("Describe workspace").
Param(ws.PathParameter("workspace", "workspace name")).
Returns(http.StatusOK, ok, v1alpha1.Workspace{}). Returns(http.StatusOK, ok, v1alpha1.Workspace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/rules"). ws.Route(ws.GET("/workspaces/{workspace}/rules").
@@ -87,7 +88,7 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces"). ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces").
To(tenant.ListNamespaces). To(tenant.ListNamespacesByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "workspace member's username")). Param(ws.PathParameter("username", "workspace member's username")).
Doc("List the namespaces for the workspace member"). Doc("List the namespaces for the workspace member").
@@ -120,7 +121,7 @@ func addWebService(c *restful.Container) error {
Doc("List devops projects for the current user"). Doc("List devops projects for the current user").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops"). ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops").
To(tenant.ListDevopsProjects). To(tenant.ListDevopsProjectsByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("username", "workspace member's username")). Param(ws.PathParameter("username", "workspace member's username")).
Param(ws.QueryParameter(params.PagingParam, "page"). Param(ws.QueryParameter(params.PagingParam, "page").

View File

@@ -77,7 +77,7 @@ func CreateUser(req *restful.Request, resp *restful.Response) {
} }
func DeleteUser(req *restful.Request, resp *restful.Response) { func DeleteUser(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("name") username := req.PathParameter("username")
operator := req.HeaderParameter(constants.UserNameHeader) operator := req.HeaderParameter(constants.UserNameHeader)
@@ -98,7 +98,7 @@ func DeleteUser(req *restful.Request, resp *restful.Response) {
func UpdateUser(req *restful.Request, resp *restful.Response) { func UpdateUser(req *restful.Request, resp *restful.Response) {
usernameInPath := req.PathParameter("name") usernameInPath := req.PathParameter("username")
usernameInHeader := req.HeaderParameter(constants.UserNameHeader) usernameInHeader := req.HeaderParameter(constants.UserNameHeader)
var user models.User var user models.User
@@ -162,7 +162,7 @@ func isUserManager(username string) (bool, error) {
} }
func UserLoginLog(req *restful.Request, resp *restful.Response) { func UserLoginLog(req *restful.Request, resp *restful.Response) {
username := req.PathParameter("name") username := req.PathParameter("username")
logs, err := iam.LoginLog(username) logs, err := iam.LoginLog(username)
if err != nil { if err != nil {

View File

@@ -26,6 +26,10 @@ import (
"kubesphere.io/kubesphere/pkg/params" "kubesphere.io/kubesphere/pkg/params"
) )
func ListNamespacedResources(req *restful.Request, resp *restful.Response) {
ListResources(req, resp)
}
func ListResources(req *restful.Request, resp *restful.Response) { func ListResources(req *restful.Request, resp *restful.Response) {
namespace := req.PathParameter("namespace") namespace := req.PathParameter("namespace")
resourceName := req.PathParameter("resources") resourceName := req.PathParameter("resources")

View File

@@ -101,6 +101,9 @@ func DescribeWorkspace(req *restful.Request, resp *restful.Response) {
resp.WriteAsJson(result) resp.WriteAsJson(result)
} }
func ListNamespacesByUsername(req *restful.Request, resp *restful.Response) {
ListNamespaces(req, resp)
}
func ListNamespaces(req *restful.Request, resp *restful.Response) { func ListNamespaces(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")
@@ -208,6 +211,10 @@ func checkResourceQuotas(wokrspace *v1alpha1.Workspace) error {
return nil return nil
} }
func ListDevopsProjectsByUsername(req *restful.Request, resp *restful.Response) {
ListDevopsProjects(req, resp)
}
func ListDevopsProjects(req *restful.Request, resp *restful.Response) { func ListDevopsProjects(req *restful.Request, resp *restful.Response) {
workspace := req.PathParameter("workspace") workspace := req.PathParameter("workspace")