未验证 提交 3a225f12 编写于 作者: R rayzhou2017 提交者: GitHub

Merge pull request #516 from wansir/api-docs

docs: update api docs
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/iam" "kubesphere.io/kubesphere/pkg/apiserver/iam"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/errors" "kubesphere.io/kubesphere/pkg/errors"
"kubesphere.io/kubesphere/pkg/models" "kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/iam/policy" "kubesphere.io/kubesphere/pkg/models/iam/policy"
...@@ -104,7 +105,6 @@ type DescribeWorkspaceUserResponse struct { ...@@ -104,7 +105,6 @@ type DescribeWorkspaceUserResponse struct {
} }
func addWebService(c *restful.Container) error { func addWebService(c *restful.Container) error {
tags := []string{"IAM"}
ws := runtime.NewWebService(GroupVersion) ws := runtime.NewWebService(GroupVersion)
ok := "ok" ok := "ok"
...@@ -114,194 +114,162 @@ func addWebService(c *restful.Container) error { ...@@ -114,194 +114,162 @@ func addWebService(c *restful.Container) error {
Doc("TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver."). Doc("TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.").
Reads(iam.TokenReview{}). Reads(iam.TokenReview{}).
Returns(http.StatusOK, ok, iam.TokenReview{}). Returns(http.StatusOK, ok, iam.TokenReview{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.POST("/login"). ws.Route(ws.POST("/login").
To(iam.Login). To(iam.Login).
Doc("KubeSphere APIs support token-based authentication via the Authtoken request header. The POST Login API is used to retrieve the authentication token. After the authentication token is obtained, it must be inserted into the Authtoken header for all requests."). Doc("KubeSphere APIs support token-based authentication via the Authtoken request header. The POST Login API is used to retrieve the authentication token. After the authentication token is obtained, it must be inserted into the Authtoken header for all requests.").
Reads(iam.LoginRequest{}). Reads(iam.LoginRequest{}).
Returns(http.StatusOK, ok, models.Token{}). Returns(http.StatusOK, ok, models.Token{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.GET("/users/{user}"). ws.Route(ws.GET("/users/{user}").
To(iam.DescribeUser). To(iam.DescribeUser).
Doc("Describe the specified user."). Doc("Describe the specified user.").
Param(ws.PathParameter("user", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, models.User{}). Returns(http.StatusOK, ok, models.User{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.POST("/users"). ws.Route(ws.POST("/users").
To(iam.CreateUser). To(iam.CreateUser).
Doc("Create a user account."). Doc("Create a user account.").
Reads(CreateUserRequest{}). Reads(CreateUserRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.DELETE("/users/{user}"). ws.Route(ws.DELETE("/users/{user}").
To(iam.DeleteUser). To(iam.DeleteUser).
Doc("Delete a specified user."). Doc("Delete a specified user.").
Param(ws.PathParameter("user", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.PUT("/users/{user}"). ws.Route(ws.PUT("/users/{user}").
To(iam.UpdateUser). To(iam.UpdateUser).
Doc("Update information about the specified user."). Doc("Update information about the specified user.").
Param(ws.PathParameter("user", "username")). Param(ws.PathParameter("user", "username")).
Reads(UserUpdateRequest{}). Reads(UserUpdateRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.GET("/users/{user}/logs"). ws.Route(ws.GET("/users/{user}/logs").
To(iam.UserLoginLogs). To(iam.UserLoginLogs).
Doc("Retrieve the \"login logs\" for the specified user."). Doc("Retrieve the \"login logs\" for the specified user.").
Param(ws.PathParameter("user", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, LoginLog{}). Returns(http.StatusOK, ok, LoginLog{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.GET("/users"). ws.Route(ws.GET("/users").
To(iam.ListUsers). To(iam.ListUsers).
Doc("List all users."). Doc("List all users.").
Returns(http.StatusOK, ok, UserList{}). Returns(http.StatusOK, ok, UserList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.IdentityManagementTag}))
ws.Route(ws.GET("/groups").
To(iam.ListGroups).
Doc("List all user groups.").
Returns(http.StatusOK, ok, []models.Group{}))
ws.Route(ws.GET("/groups/{group}").
To(iam.DescribeGroup).
Doc("Describe the specified user group.").
Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, models.Group{}))
ws.Route(ws.GET("/groups/{group}/users").
To(iam.ListGroupUsers).
Doc("List all users in the specified user group.").
Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, []models.User{}))
ws.Route(ws.POST("/groups").
To(iam.CreateGroup).
Doc("Create a user group.").
Reads(models.Group{}).
Returns(http.StatusOK, ok, models.Group{}))
ws.Route(ws.DELETE("/groups/{group}").
To(iam.DeleteGroup).
Doc("Delete a user group.").
Param(ws.PathParameter("group", "user group path separated by colon.")).
Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.PUT("/groups/{group}").
To(iam.UpdateGroup).
Doc("Update information about the user group.").
Param(ws.PathParameter("group", "user group path separated by colon.")).
Reads(models.Group{}).
Returns(http.StatusOK, ok, models.Group{}).
Metadata(restfulspec.KeyOpenAPITags, tags))
ws.Route(ws.GET("/users/{user}/roles"). ws.Route(ws.GET("/users/{user}/roles").
To(iam.ListUserRoles). To(iam.ListUserRoles).
Doc("Retrieve all the roles that are assigned to the user."). Doc("Retrieve all the roles that are assigned to the user.").
Param(ws.PathParameter("user", "username")). Param(ws.PathParameter("user", "username")).
Returns(http.StatusOK, ok, iam.RoleList{}). Returns(http.StatusOK, ok, iam.RoleList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/namespaces/{namespace}/roles"). ws.Route(ws.GET("/namespaces/{namespace}/roles").
To(iam.ListRoles). To(iam.ListRoles).
Doc("Retrieve the roles that are assigned to the user in the specified namespace."). Doc("Retrieve the roles that are assigned to the user in the specified namespace.").
Param(ws.PathParameter("namespace", "kubernetes namespace")). Param(ws.PathParameter("namespace", "kubernetes namespace")).
Returns(http.StatusOK, ok, RoleList{}). Returns(http.StatusOK, ok, RoleList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/clusterroles"). ws.Route(ws.GET("/clusterroles").
To(iam.ListClusterRoles). To(iam.ListClusterRoles).
Doc("List all cluster roles."). Doc("List all cluster roles.").
Returns(http.StatusOK, ok, ClusterRoleList{}). Returns(http.StatusOK, ok, ClusterRoleList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/users"). ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/users").
To(iam.ListRoleUsers). To(iam.ListRoleUsers).
Doc("Retrieve the users that are bound to the role in the specified namespace."). Doc("Retrieve the users that are bound to the role in the specified namespace.").
Param(ws.PathParameter("namespace", "kubernetes namespace")). Param(ws.PathParameter("namespace", "kubernetes namespace")).
Param(ws.PathParameter("role", "role name")). Param(ws.PathParameter("role", "role name")).
Returns(http.StatusOK, ok, []models.User{}). Returns(http.StatusOK, ok, []models.User{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/namespaces/{namespace}/users"). ws.Route(ws.GET("/namespaces/{namespace}/users").
To(iam.ListNamespaceUsers). To(iam.ListNamespaceUsers).
Doc("List all users in the specified namespace."). Doc("List all users in the specified namespace.").
Param(ws.PathParameter("namespace", "kubernetes namespace")). Param(ws.PathParameter("namespace", "kubernetes namespace")).
Returns(http.StatusOK, ok, []models.User{}). Returns(http.StatusOK, ok, []models.User{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/clusterroles/{clusterrole}/users"). ws.Route(ws.GET("/clusterroles/{clusterrole}/users").
To(iam.ListClusterRoleUsers). To(iam.ListClusterRoleUsers).
Doc("List all users that are bound to the specified cluster role."). Doc("List all users that are bound to the specified cluster role.").
Param(ws.PathParameter("clusterrole", "cluster role name")). Param(ws.PathParameter("clusterrole", "cluster role name")).
Returns(http.StatusOK, ok, UserList{}). Returns(http.StatusOK, ok, UserList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/clusterroles/{clusterrole}/rules"). ws.Route(ws.GET("/clusterroles/{clusterrole}/rules").
To(iam.ListClusterRoleRules). To(iam.ListClusterRoleRules).
Doc("List all policy rules of the specified cluster role."). Doc("List all policy rules of the specified cluster role.").
Param(ws.PathParameter("clusterrole", "cluster role name")). Param(ws.PathParameter("clusterrole", "cluster role name")).
Returns(http.StatusOK, ok, []models.SimpleRule{}). Returns(http.StatusOK, ok, []models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/rules"). ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/rules").
To(iam.ListRoleRules). To(iam.ListRoleRules).
Doc("List all policy rules of the specified role in the given namespace."). Doc("List all policy rules of the specified role in the given namespace.").
Param(ws.PathParameter("namespace", "kubernetes namespace")). Param(ws.PathParameter("namespace", "kubernetes namespace")).
Param(ws.PathParameter("role", "role name")). Param(ws.PathParameter("role", "role name")).
Returns(http.StatusOK, ok, []models.SimpleRule{}). Returns(http.StatusOK, ok, []models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/devops/{devops}/roles/{role}/rules"). ws.Route(ws.GET("/devops/{devops}/roles/{role}/rules").
To(iam.ListDevopsRoleRules). To(iam.ListDevopsRoleRules).
Doc("List all policy rules of the specified role in the given devops project."). Doc("List all policy rules of the specified role in the given devops project.").
Param(ws.PathParameter("devops", "devops project ID")). Param(ws.PathParameter("devops", "devops project ID")).
Param(ws.PathParameter("role", "devops role name")). Param(ws.PathParameter("role", "devops role name")).
Returns(http.StatusOK, ok, []models.SimpleRule{}). Returns(http.StatusOK, ok, []models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/rulesmapping/clusterroles"). ws.Route(ws.GET("/rulesmapping/clusterroles").
To(iam.ClusterRulesMapping). To(iam.ClusterRulesMapping).
Doc("Get the mapping relationships between cluster roles and policy rules."). Doc("Get the mapping relationships between cluster roles and policy rules.").
Returns(http.StatusOK, ok, policy.ClusterRoleRuleMapping). Returns(http.StatusOK, ok, policy.ClusterRoleRuleMapping).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/rulesmapping/roles"). ws.Route(ws.GET("/rulesmapping/roles").
To(iam.RulesMapping). To(iam.RulesMapping).
Doc("Get the mapping relationships between namespaced roles and policy rules."). Doc("Get the mapping relationships between namespaced roles and policy rules.").
Returns(http.StatusOK, ok, policy.RoleRuleMapping). Returns(http.StatusOK, ok, policy.RoleRuleMapping).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/workspaces/{workspace}/roles"). ws.Route(ws.GET("/workspaces/{workspace}/roles").
To(iam.ListWorkspaceRoles). To(iam.ListWorkspaceRoles).
Doc("List all workspace roles."). Doc("List all workspace roles.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Returns(http.StatusOK, ok, ClusterRoleList{}). Returns(http.StatusOK, ok, ClusterRoleList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}"). ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}").
To(iam.DescribeWorkspaceRole). To(iam.DescribeWorkspaceRole).
Doc("Describe the workspace role."). Doc("Describe the workspace role.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("role", "workspace role name")). Param(ws.PathParameter("role", "workspace role name")).
Returns(http.StatusOK, ok, rbacv1.ClusterRole{}). Returns(http.StatusOK, ok, rbacv1.ClusterRole{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}/rules"). ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}/rules").
To(iam.ListWorkspaceRoleRules). To(iam.ListWorkspaceRoleRules).
Doc("List all policy rules of the specified workspace role."). Doc("List all policy rules of the specified workspace role.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("role", "workspace role name")). Param(ws.PathParameter("role", "workspace role name")).
Returns(http.StatusOK, ok, []models.SimpleRule{}). Returns(http.StatusOK, ok, []models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/workspaces/{workspace}/members"). ws.Route(ws.GET("/workspaces/{workspace}/members").
To(iam.ListWorkspaceUsers). To(iam.ListWorkspaceUsers).
Doc("List all members in the specified workspace."). Doc("List all members in the specified workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Returns(http.StatusOK, ok, UserList{}). Returns(http.StatusOK, ok, UserList{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.POST("/workspaces/{workspace}/members"). ws.Route(ws.POST("/workspaces/{workspace}/members").
To(iam.InviteUser). To(iam.InviteUser).
Doc("Invite members to the workspace."). Doc("Invite members to the workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Reads(InviteUserRequest{}). Reads(InviteUserRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.DELETE("/workspaces/{workspace}/members/{member}"). ws.Route(ws.DELETE("/workspaces/{workspace}/members/{member}").
To(iam.RemoveUser). To(iam.RemoveUser).
Doc("Remove members from the workspace."). Doc("Remove members from the workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("member", "username")). Param(ws.PathParameter("member", "username")).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
ws.Route(ws.GET("/workspaces/{workspace}/members/{member}"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}").
To(iam.DescribeWorkspaceUser). To(iam.DescribeWorkspaceUser).
Doc("Describe the specified user in the given workspace."). Doc("Describe the specified user in the given workspace.").
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("member", "username")). Param(ws.PathParameter("member", "username")).
Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}). Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.AccessManagementTag}))
c.Add(ws) c.Add(ws)
return nil return nil
} }
...@@ -42,6 +42,7 @@ func addWebService(c *restful.Container) error { ...@@ -42,6 +42,7 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.POST("/nodes/{node}/drainage"). webservice.Route(webservice.POST("/nodes/{node}/drainage").
To(operations.DrainNode). To(operations.DrainNode).
Deprecate().
Doc("Drain node"). Doc("Drain node").
Param(webservice.PathParameter("node", "node name")). Param(webservice.PathParameter("node", "node name")).
Returns(http.StatusOK, ok, errors.Error{})) Returns(http.StatusOK, ok, errors.Error{}))
...@@ -49,6 +50,7 @@ func addWebService(c *restful.Container) error { ...@@ -49,6 +50,7 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}"). webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}").
To(operations.RerunJob). To(operations.RerunJob).
Doc("Job rerun"). Doc("Job rerun").
Deprecate().
Param(webservice.PathParameter("job", "job name")). Param(webservice.PathParameter("job", "job name")).
Param(webservice.PathParameter("namespace", "job's namespace")). Param(webservice.PathParameter("namespace", "job's namespace")).
Param(webservice.QueryParameter("a", "action")). Param(webservice.QueryParameter("a", "action")).
......
...@@ -33,6 +33,7 @@ import ( ...@@ -33,6 +33,7 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/routers" "kubesphere.io/kubesphere/pkg/apiserver/routers"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/workloadstatuses" "kubesphere.io/kubesphere/pkg/apiserver/workloadstatuses"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/errors" "kubesphere.io/kubesphere/pkg/errors"
"kubesphere.io/kubesphere/pkg/models" "kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/models/applications" "kubesphere.io/kubesphere/pkg/models/applications"
...@@ -57,71 +58,70 @@ func addWebService(c *restful.Container) error { ...@@ -57,71 +58,70 @@ func addWebService(c *restful.Container) error {
webservice := runtime.NewWebService(GroupVersion) webservice := runtime.NewWebService(GroupVersion)
tags := []string{"Namespace resources"}
ok := "ok" ok := "ok"
webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}"). webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}").
To(resources.ListNamespacedResources). To(resources.ListNamespacedResources).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Namespace level resource query"). Doc("Namespace level resource query").
Param(webservice.PathParameter("namespace", "which namespace")). Param(webservice.PathParameter("namespace", "which namespace")).
Param(webservice.PathParameter("resources", "namespace level resource type")). Param(webservice.PathParameter("resources", "namespace level resource type, e.g. pods,jobs,configmaps,services.")).
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). 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). Required(false).
DataFormat("key=%s,key~%s")). DataFormat("key=%s,key~%s")).
Param(webservice.QueryParameter(params.PagingParam, "page"). Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1")). DefaultValue("limit=10,page=1")).
Param(webservice.QueryParameter(params.ReverseParam, "sort parameters, e.g. reverse=true")).
Param(webservice.QueryParameter(params.OrderByParam, "sort parameters, e.g. orderBy=createTime")).
Returns(http.StatusOK, ok, models.PageableResponse{})) Returns(http.StatusOK, ok, models.PageableResponse{}))
webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}"). webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}").
To(operations.RerunJob). To(operations.RerunJob).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Rerun job whether the job is complete or not"). Doc("Rerun job whether the job is complete or not").
Param(webservice.PathParameter("job", "job name")). Param(webservice.PathParameter("job", "job name")).
Param(webservice.PathParameter("namespace", "job's namespace")). Param(webservice.PathParameter("namespace", "job's namespace")).
Param(webservice.QueryParameter("a", "action")). Param(webservice.QueryParameter("a", "action")).
Returns(http.StatusOK, ok, errors.Error{})) Returns(http.StatusOK, ok, errors.Error{}))
tags = []string{"Cluster resources"}
webservice.Route(webservice.GET("/{resources}"). webservice.Route(webservice.GET("/{resources}").
To(resources.ListResources). To(resources.ListResources).
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}).
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, e.g. nodes,workspaces,storageclasses,clusterroles.")).
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). 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). Required(false).
DataFormat("key=value,key~value"). DataFormat("key=value,key~value").
DefaultValue("")). DefaultValue("")).
Param(webservice.QueryParameter(params.PagingParam, "page"). Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1"))) DefaultValue("limit=10,page=1")).
Param(webservice.QueryParameter(params.ReverseParam, "sort parameters, e.g. reverse=true")).
Param(webservice.QueryParameter(params.OrderByParam, "sort parameters, e.g. orderBy=createTime")))
webservice.Route(webservice.POST("/nodes/{node}/drainage"). webservice.Route(webservice.POST("/nodes/{node}/drainage").
To(operations.DrainNode). To(operations.DrainNode).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}).
Doc("Drain node"). Doc("Drain node").
Param(webservice.PathParameter("node", "node name")). Param(webservice.PathParameter("node", "node name")).
Returns(http.StatusOK, ok, errors.Error{})) Returns(http.StatusOK, ok, errors.Error{}))
tags = []string{"Applications"}
webservice.Route(webservice.GET("/applications"). webservice.Route(webservice.GET("/applications").
To(resources.ListApplication). To(resources.ListApplication).
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}).
Doc("List all applications deployed in the cluster"). Doc("List applications in cluster").
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). 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). Required(false).
DataFormat("key=value,key~value"). DataFormat("key=value,key~value").
DefaultValue("")). DefaultValue("")).
Param(webservice.QueryParameter("cluster_id", "cluster ID")). Param(webservice.QueryParameter("cluster_id", "equivalent to application unique ID")).
Param(webservice.QueryParameter("runtime_id", "runtime ID")). Param(webservice.QueryParameter("runtime_id", "runtime id initialization when namespace is created, means which namespace")).
Param(webservice.QueryParameter(params.PagingParam, "page"). Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1"))) DefaultValue("limit=10,page=1")))
...@@ -129,14 +129,14 @@ func addWebService(c *restful.Container) error { ...@@ -129,14 +129,14 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.GET("/namespaces/{namespace}/applications"). webservice.Route(webservice.GET("/namespaces/{namespace}/applications").
To(resources.ListNamespacedApplication). To(resources.ListNamespacedApplication).
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("List all applications within the specified namespace"). Doc("List all applications within the specified namespace").
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions"). 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). Required(false).
DataFormat("key=value,key~value"). DataFormat("key=value,key~value").
DefaultValue("")). DefaultValue("")).
Param(webservice.PathParameter("namespace", "namespace name")). Param(webservice.PathParameter("namespace", "namespace")).
Param(webservice.QueryParameter(params.PagingParam, "page"). Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false). Required(false).
DataFormat("limit=%d,page=%d"). DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1"))) DefaultValue("limit=10,page=1")))
...@@ -144,7 +144,7 @@ func addWebService(c *restful.Container) error { ...@@ -144,7 +144,7 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{application}"). webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{application}").
To(resources.DescribeApplication). To(resources.DescribeApplication).
Returns(http.StatusOK, ok, applications.Application{}). Returns(http.StatusOK, ok, applications.Application{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Describe the specified application of the namespace"). Doc("Describe the specified application of the namespace").
Param(webservice.PathParameter("namespace", "namespace name")). Param(webservice.PathParameter("namespace", "namespace name")).
Param(webservice.PathParameter("application", "application ID"))) Param(webservice.PathParameter("application", "application ID")))
...@@ -152,7 +152,7 @@ func addWebService(c *restful.Container) error { ...@@ -152,7 +152,7 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.POST("/namespaces/{namespace}/applications"). webservice.Route(webservice.POST("/namespaces/{namespace}/applications").
To(resources.DeployApplication). To(resources.DeployApplication).
Doc("Deploy a new application"). Doc("Deploy a new application").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Reads(openpitrix.CreateClusterRequest{}). Reads(openpitrix.CreateClusterRequest{}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Param(webservice.PathParameter("namespace", "namespace name"))) Param(webservice.PathParameter("namespace", "namespace name")))
...@@ -160,18 +160,16 @@ func addWebService(c *restful.Container) error { ...@@ -160,18 +160,16 @@ func addWebService(c *restful.Container) error {
webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{application}"). webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{application}").
To(resources.DeleteApplication). To(resources.DeleteApplication).
Doc("Delete the specified application"). Doc("Delete the specified application").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Param(webservice.PathParameter("namespace", "namespace name")). Param(webservice.PathParameter("namespace", "namespace name")).
Param(webservice.PathParameter("application", "application ID"))) Param(webservice.PathParameter("application", "application ID")))
tags = []string{"User resources"}
webservice.Route(webservice.GET("/users/{user}/kubectl"). webservice.Route(webservice.GET("/users/{user}/kubectl").
To(resources.GetKubectl). To(resources.GetKubectl).
Doc("get user's kubectl pod"). Doc("get user's kubectl pod").
Param(webservice.PathParameter("user", "username")). Param(webservice.PathParameter("user", "username")).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.UserResourcesTag}).
Returns(http.StatusOK, ok, models.PodInfo{})) Returns(http.StatusOK, ok, models.PodInfo{}))
webservice.Route(webservice.GET("/users/{user}/kubeconfig"). webservice.Route(webservice.GET("/users/{user}/kubeconfig").
...@@ -180,66 +178,56 @@ func addWebService(c *restful.Container) error { ...@@ -180,66 +178,56 @@ func addWebService(c *restful.Container) error {
Doc("get users' kubeconfig"). Doc("get users' kubeconfig").
Param(webservice.PathParameter("user", "username")). Param(webservice.PathParameter("user", "username")).
Returns(http.StatusOK, ok, ""). Returns(http.StatusOK, ok, "").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.UserResourcesTag}))
tags = []string{"Components"}
webservice.Route(webservice.GET("/components"). webservice.Route(webservice.GET("/components").
To(components.GetComponents). To(components.GetComponents).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ComponentStatusTag}).
Doc("List the system components."). Doc("List the system components.").
Returns(http.StatusOK, ok, map[string]models.Component{})) Returns(http.StatusOK, ok, map[string]models.Component{}))
webservice.Route(webservice.GET("/components/{component}"). webservice.Route(webservice.GET("/components/{component}").
To(components.GetComponentStatus). To(components.GetComponentStatus).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ComponentStatusTag}).
Doc("Describe the specified system component."). Doc("Describe the specified system component.").
Param(webservice.PathParameter("component", "component name")). Param(webservice.PathParameter("component", "component name")).
Returns(http.StatusOK, ok, models.Component{})) Returns(http.StatusOK, ok, models.Component{}))
webservice.Route(webservice.GET("/componenthealth"). webservice.Route(webservice.GET("/componenthealth").
To(components.GetSystemHealthStatus). To(components.GetSystemHealthStatus).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ComponentStatusTag}).
Doc("Get the health status of system components."). Doc("Get the health status of system components.").
Returns(http.StatusOK, ok, map[string]int{})) Returns(http.StatusOK, ok, map[string]int{}))
tags = []string{"Quotas"}
webservice.Route(webservice.GET("/quotas"). webservice.Route(webservice.GET("/quotas").
To(quotas.GetClusterQuotas). To(quotas.GetClusterQuotas).
Deprecate().
Doc("get whole cluster's resource usage"). Doc("get whole cluster's resource usage").
Returns(http.StatusOK, ok, models.ResourceQuota{}). Returns(http.StatusOK, ok, models.ResourceQuota{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}))
webservice.Route(webservice.GET("/namespaces/{namespace}/quotas"). webservice.Route(webservice.GET("/namespaces/{namespace}/quotas").
Doc("get specified namespace's resource quota and usage"). Doc("get specified namespace's resource quota and usage").
Param(webservice.PathParameter("namespace", "namespace's name")). Param(webservice.PathParameter("namespace", "namespace's name")).
Returns(http.StatusOK, ok, models.ResourceQuota{}). Returns(http.StatusOK, ok, models.ResourceQuota{}).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
To(quotas.GetNamespaceQuotas)) To(quotas.GetNamespaceQuotas))
tags = []string{"Registries"}
webservice.Route(webservice.POST("registry/verify"). webservice.Route(webservice.POST("registry/verify").
To(registries.RegistryVerify). To(registries.RegistryVerify).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.VerificationTag}).
Doc("docker registry verify"). Doc("docker registry verify").
Reads(registriesmodel.AuthInfo{}). Reads(registriesmodel.AuthInfo{}).
Returns(http.StatusOK, ok, errors.Error{})) Returns(http.StatusOK, ok, errors.Error{}))
tags = []string{"Git"}
webservice.Route(webservice.POST("git/verify"). webservice.Route(webservice.POST("git/verify").
To( To(git.GitReadVerify).
git.GitReadVerify). Metadata(restfulspec.KeyOpenAPITags, []string{constants.VerificationTag}).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Verify that the kubernetes secret has read access to the git repository"). Doc("Verify that the kubernetes secret has read access to the git repository").
Reads(gitmodel.AuthInfo{}). Reads(gitmodel.AuthInfo{}).
Returns(http.StatusOK, ok, errors.Error{}), Returns(http.StatusOK, ok, errors.Error{}),
) )
tags = []string{"Revision"}
webservice.Route(webservice.GET("/namespaces/{namespace}/daemonsets/{daemonset}/revisions/{revision}"). webservice.Route(webservice.GET("/namespaces/{namespace}/daemonsets/{daemonset}/revisions/{revision}").
To(revisions.GetDaemonSetRevision). To(revisions.GetDaemonSetRevision).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Handle daemonset operation"). Doc("Handle daemonset operation").
Param(webservice.PathParameter("daemonset", "daemonset's name")). Param(webservice.PathParameter("daemonset", "daemonset's name")).
Param(webservice.PathParameter("namespace", "daemonset's namespace")). Param(webservice.PathParameter("namespace", "daemonset's namespace")).
...@@ -247,7 +235,7 @@ func addWebService(c *restful.Container) error { ...@@ -247,7 +235,7 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, appsv1.DaemonSet{})) Returns(http.StatusOK, ok, appsv1.DaemonSet{}))
webservice.Route(webservice.GET("/namespaces/{namespace}/deployments/{deployment}/revisions/{revision}"). webservice.Route(webservice.GET("/namespaces/{namespace}/deployments/{deployment}/revisions/{revision}").
To(revisions.GetDeployRevision). To(revisions.GetDeployRevision).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Handle deployment operation"). Doc("Handle deployment operation").
Param(webservice.PathParameter("deployment", "deployment's name")). Param(webservice.PathParameter("deployment", "deployment's name")).
Param(webservice.PathParameter("namespace", "deployment's namespace")). Param(webservice.PathParameter("namespace", "deployment's namespace")).
...@@ -255,56 +243,52 @@ func addWebService(c *restful.Container) error { ...@@ -255,56 +243,52 @@ func addWebService(c *restful.Container) error {
Returns(http.StatusOK, ok, appsv1.ReplicaSet{})) Returns(http.StatusOK, ok, appsv1.ReplicaSet{}))
webservice.Route(webservice.GET("/namespaces/{namespace}/statefulsets/{statefulset}/revisions/{revision}"). webservice.Route(webservice.GET("/namespaces/{namespace}/statefulsets/{statefulset}/revisions/{revision}").
To(revisions.GetStatefulSetRevision). To(revisions.GetStatefulSetRevision).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Handle statefulset operation"). Doc("Handle statefulset operation").
Param(webservice.PathParameter("statefulset", "statefulset's name")). Param(webservice.PathParameter("statefulset", "statefulset's name")).
Param(webservice.PathParameter("namespace", "statefulset's namespace")). Param(webservice.PathParameter("namespace", "statefulset's namespace")).
Param(webservice.PathParameter("revision", "statefulset's revision")). Param(webservice.PathParameter("revision", "statefulset's revision")).
Returns(http.StatusOK, ok, appsv1.StatefulSet{})) Returns(http.StatusOK, ok, appsv1.StatefulSet{}))
tags = []string{"Router"}
webservice.Route(webservice.GET("/routers"). webservice.Route(webservice.GET("/routers").
To(routers.GetAllRouters). To(routers.GetAllRouters).
Doc("List all routers"). Doc("List all routers").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}).
Returns(http.StatusOK, ok, corev1.Service{})) Returns(http.StatusOK, ok, corev1.Service{}))
webservice.Route(webservice.GET("/namespaces/{namespace}/router"). webservice.Route(webservice.GET("/namespaces/{namespace}/router").
To(routers.GetRouter). To(routers.GetRouter).
Doc("List router of a specified project"). Doc("List router of a specified project").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Param(webservice.PathParameter("namespace", "name of the project"))) Param(webservice.PathParameter("namespace", "name of the project")))
webservice.Route(webservice.DELETE("/namespaces/{namespace}/router"). webservice.Route(webservice.DELETE("/namespaces/{namespace}/router").
To(routers.DeleteRouter). To(routers.DeleteRouter).
Doc("List router of a specified project"). Doc("List router of a specified project").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Param(webservice.PathParameter("namespace", "name of the project"))) Param(webservice.PathParameter("namespace", "name of the project")))
webservice.Route(webservice.POST("/namespaces/{namespace}/router"). webservice.Route(webservice.POST("/namespaces/{namespace}/router").
To(routers.CreateRouter). To(routers.CreateRouter).
Doc("Create a router for a specified project"). Doc("Create a router for a specified project").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Param(webservice.PathParameter("namespace", "name of the project"))) Param(webservice.PathParameter("namespace", "name of the project")))
webservice.Route(webservice.PUT("/namespaces/{namespace}/router"). webservice.Route(webservice.PUT("/namespaces/{namespace}/router").
To(routers.UpdateRouter). To(routers.UpdateRouter).
Doc("Update a router for a specified project"). Doc("Update a router for a specified project").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Param(webservice.PathParameter("namespace", "name of the project"))) Param(webservice.PathParameter("namespace", "name of the project")))
tags = []string{"WorkloadStatus"}
webservice.Route(webservice.GET("/abnormalworkloads"). webservice.Route(webservice.GET("/abnormalworkloads").
Doc("get abnormal workloads' count of whole cluster"). Doc("get abnormal workloads' count of whole cluster").
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterResourcesTag}).
Returns(http.StatusOK, ok, status.WorkLoadStatus{}). Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
To(workloadstatuses.GetClusterAbnormalWorkloads)) To(workloadstatuses.GetClusterAbnormalWorkloads))
webservice.Route(webservice.GET("/namespaces/{namespace}/abnormalworkloads"). webservice.Route(webservice.GET("/namespaces/{namespace}/abnormalworkloads").
Doc("get abnormal workloads' count of specified namespace"). Doc("get abnormal workloads' count of specified namespace").
Param(webservice.PathParameter("namespace", "the name of namespace")). Param(webservice.PathParameter("namespace", "the name of namespace")).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Returns(http.StatusOK, ok, status.WorkLoadStatus{}). Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
To(workloadstatuses.GetNamespacedAbnormalWorkloads)) To(workloadstatuses.GetNamespacedAbnormalWorkloads))
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1" "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/tenant" "kubesphere.io/kubesphere/pkg/apiserver/tenant"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models/devops" "kubesphere.io/kubesphere/pkg/models/devops"
"kubesphere.io/kubesphere/pkg/params" "kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/simple/client/elasticsearch" "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
...@@ -48,7 +49,6 @@ var ( ...@@ -48,7 +49,6 @@ var (
) )
func addWebService(c *restful.Container) error { func addWebService(c *restful.Container) error {
tags := []string{"Tenant"}
ok := "ok" ok := "ok"
ws := runtime.NewWebService(GroupVersion) ws := runtime.NewWebService(GroupVersion)
...@@ -56,57 +56,57 @@ func addWebService(c *restful.Container) error { ...@@ -56,57 +56,57 @@ func addWebService(c *restful.Container) error {
To(tenant.ListWorkspaces). To(tenant.ListWorkspaces).
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Doc("List workspace by user"). Doc("List workspace by user").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}"). ws.Route(ws.GET("/workspaces/{workspace}").
To(tenant.DescribeWorkspace). To(tenant.DescribeWorkspace).
Doc("Describe workspace"). Doc("Describe workspace").
Param(ws.PathParameter("workspace", "workspace name")). 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, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}/rules"). ws.Route(ws.GET("/workspaces/{workspace}/rules").
To(tenant.ListWorkspaceRules). To(tenant.ListWorkspaceRules).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Doc("List the rules for the current user"). Doc("List the rules for the current user").
Returns(http.StatusOK, ok, models.SimpleRule{}). Returns(http.StatusOK, ok, models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/namespaces/{namespace}/rules"). ws.Route(ws.GET("/namespaces/{namespace}/rules").
To(tenant.ListNamespaceRules). To(tenant.ListNamespaceRules).
Param(ws.PathParameter("namespace", "namespace")). Param(ws.PathParameter("namespace", "namespace")).
Doc("List the rules for the current user"). Doc("List the rules for the current user").
Returns(http.StatusOK, ok, models.SimpleRule{}). Returns(http.StatusOK, ok, models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/devops/{devops}/rules"). ws.Route(ws.GET("/devops/{devops}/rules").
To(tenant.ListDevopsRules). To(tenant.ListDevopsRules).
Param(ws.PathParameter("devops", "devops project id")). Param(ws.PathParameter("devops", "devops project id")).
Doc("List the rules for the current user"). Doc("List the rules for the current user").
Returns(http.StatusOK, ok, models.SimpleRule{}). Returns(http.StatusOK, ok, models.SimpleRule{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}/namespaces"). ws.Route(ws.GET("/workspaces/{workspace}/namespaces").
To(tenant.ListNamespaces). To(tenant.ListNamespaces).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Doc("List the namespaces for the current user"). Doc("List the namespaces for the current user").
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/namespaces"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/namespaces").
To(tenant.ListNamespacesByUsername). To(tenant.ListNamespacesByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("member", "workspace member's username")). Param(ws.PathParameter("member", "workspace member's username")).
Doc("List the namespaces for the workspace member"). Doc("List the namespaces for the workspace member").
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.POST("/workspaces/{workspace}/namespaces"). ws.Route(ws.POST("/workspaces/{workspace}/namespaces").
To(tenant.CreateNamespace). To(tenant.CreateNamespace).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Doc("Create namespace"). Doc("Create namespace").
Returns(http.StatusOK, ok, []v1.Namespace{}). Returns(http.StatusOK, ok, []v1.Namespace{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.DELETE("/workspaces/{workspace}/namespaces/{namespace}"). ws.Route(ws.DELETE("/workspaces/{workspace}/namespaces/{namespace}").
To(tenant.DeleteNamespace). To(tenant.DeleteNamespace).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("namespace", "namespace")). Param(ws.PathParameter("namespace", "namespace")).
Doc("Delete namespace"). Doc("Delete namespace").
Returns(http.StatusOK, ok, errors.Error{}). Returns(http.StatusOK, ok, errors.Error{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}/devops"). ws.Route(ws.GET("/workspaces/{workspace}/devops").
To(tenant.ListDevopsProjects). To(tenant.ListDevopsProjects).
...@@ -119,7 +119,7 @@ func addWebService(c *restful.Container) error { ...@@ -119,7 +119,7 @@ func addWebService(c *restful.Container) error {
Required(false). Required(false).
DataFormat("key=%s,key~%s")). DataFormat("key=%s,key~%s")).
Doc("List devops projects for the current user"). Doc("List devops projects for the current user").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/devops"). ws.Route(ws.GET("/workspaces/{workspace}/members/{member}/devops").
To(tenant.ListDevopsProjectsByUsername). To(tenant.ListDevopsProjectsByUsername).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
...@@ -133,21 +133,21 @@ func addWebService(c *restful.Container) error { ...@@ -133,21 +133,21 @@ func addWebService(c *restful.Container) error {
DataFormat("key=%s,key~%s")). DataFormat("key=%s,key~%s")).
Returns(http.StatusOK, ok, models.PageableResponse{}). Returns(http.StatusOK, ok, models.PageableResponse{}).
Doc("List the devops projects for the workspace member"). Doc("List the devops projects for the workspace member").
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.POST("/workspaces/{workspace}/devops"). ws.Route(ws.POST("/workspaces/{workspace}/devops").
To(tenant.CreateDevopsProject). To(tenant.CreateDevopsProject).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Doc("Create devops project"). Doc("Create devops project").
Reads(devops.DevOpsProject{}). Reads(devops.DevOpsProject{}).
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{devops}"). ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{devops}").
To(tenant.DeleteDevopsProject). To(tenant.DeleteDevopsProject).
Param(ws.PathParameter("workspace", "workspace name")). Param(ws.PathParameter("workspace", "workspace name")).
Param(ws.PathParameter("devops", "devops project id")). Param(ws.PathParameter("devops", "devops project id")).
Doc("Delete devops project"). Doc("Delete devops project").
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}). Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
Metadata(restfulspec.KeyOpenAPITags, tags)) Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}))
ws.Route(ws.GET("/logs"). ws.Route(ws.GET("/logs").
To(tenant.LogQuery). To(tenant.LogQuery).
Doc("Query cluster-level logs in a multi-tenants environment"). Doc("Query cluster-level logs in a multi-tenants environment").
...@@ -169,7 +169,7 @@ func addWebService(c *restful.Container) error { ...@@ -169,7 +169,7 @@ func addWebService(c *restful.Container) error {
Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)). Param(ws.QueryParameter("sort", "Sort log by time. One of acs, desc.").DataType("string").DefaultValue("desc").Required(false)).
Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)). Param(ws.QueryParameter("from", "Beginning index of result to return. Use this option together with size.").DataType("integer").DefaultValue("0").Required(false)).
Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)). Param(ws.QueryParameter("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
Metadata(restfulspec.KeyOpenAPITags, tags). Metadata(restfulspec.KeyOpenAPITags, []string{constants.TenantResourcesTag}).
Writes(esclient.Response{}). Writes(esclient.Response{}).
Returns(http.StatusOK, RespOK, esclient.Response{})). Returns(http.StatusOK, RespOK, esclient.Response{})).
Consumes(restful.MIME_JSON, restful.MIME_XML). Consumes(restful.MIME_JSON, restful.MIME_XML).
......
...@@ -48,6 +48,15 @@ const ( ...@@ -48,6 +48,15 @@ const (
DevopsReporter = "reporter" DevopsReporter = "reporter"
UserNameHeader = "X-Token-Username" UserNameHeader = "X-Token-Username"
TenantResourcesTag = "Tenant Resources"
IdentityManagementTag = "Identity Management"
AccessManagementTag = "Access Management"
NamespaceResourcesTag = "Namespace Resources"
ClusterResourcesTag = "Cluster Resources"
ComponentStatusTag = "Component Status"
VerificationTag = "Verification"
UserResourcesTag = "User Resources"
) )
var ( var (
......
...@@ -132,12 +132,6 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res ...@@ -132,12 +132,6 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res
// The object is being deleted // The object is being deleted
if sliceutil.HasString(instance.ObjectMeta.Finalizers, finalizer) { if sliceutil.HasString(instance.ObjectMeta.Finalizers, finalizer) {
// our finalizer is present, so lets handle our external dependency // our finalizer is present, so lets handle our external dependency
if err := r.deleteGroup(instance); err != nil {
// if fail to delete the external dependency here, return with error
// so that it can be retried
return reconcile.Result{}, err
}
if err := r.deleteDevOpsProjects(instance); err != nil { if err := r.deleteDevOpsProjects(instance); err != nil {
return reconcile.Result{}, err return reconcile.Result{}, err
} }
...@@ -167,10 +161,6 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res ...@@ -167,10 +161,6 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res
return reconcile.Result{}, err return reconcile.Result{}, err
} }
//if err = r.createGroup(instance); err != nil {
// return reconcile.Result{}, err
//}
if err = r.createWorkspaceRoleBindings(instance); err != nil { if err = r.createWorkspaceRoleBindings(instance); err != nil {
return reconcile.Result{}, err return reconcile.Result{}, err
} }
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"github.com/go-openapi/spec" "github.com/go-openapi/spec"
"io/ioutil" "io/ioutil"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/constants"
"log" "log"
// Install apis // Install apis
_ "kubesphere.io/kubesphere/pkg/apis/devops/install" _ "kubesphere.io/kubesphere/pkg/apis/devops/install"
...@@ -62,6 +63,33 @@ func generateSwaggerJson() { ...@@ -62,6 +63,33 @@ func generateSwaggerJson() {
swagger := restfulspec.BuildSwagger(config) swagger := restfulspec.BuildSwagger(config)
swagger.Info.Extensions = make(spec.Extensions)
swagger.Info.Extensions.Add("x-tagGroups", []struct {
Name string `json:"name"`
Tags []string `json:"tags"`
}{
{
Name: "IAM",
Tags: []string{constants.IdentityManagementTag, constants.AccessManagementTag},
},
{
Name: "Resources",
Tags: []string{constants.ClusterResourcesTag, constants.NamespaceResourcesTag, constants.UserResourcesTag},
},
{
Name: "Monitoring",
Tags: []string{constants.ComponentStatusTag},
},
{
Name: "Tenant",
Tags: []string{constants.TenantResourcesTag},
},
{
Name: "Other",
Tags: []string{constants.VerificationTag},
},
})
data, _ := json.Marshal(swagger) data, _ := json.Marshal(swagger)
err := ioutil.WriteFile(output, data, 420) err := ioutil.WriteFile(output, data, 420)
if err != nil { if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册