Merge branch 'master' into uuid-utils
This commit is contained in:
@@ -50,7 +50,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}").
|
||||
To(devopsapi.GetDevOpsProjectHandler).
|
||||
Doc("get devops project").
|
||||
Doc("Get devops project").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
|
||||
@@ -58,15 +58,16 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.PATCH("/devops/{devops}").
|
||||
To(devopsapi.UpdateProjectHandler).
|
||||
Doc("get devops project").
|
||||
Doc("Update devops project").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Reads(devops.DevOpsProject{}).
|
||||
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
|
||||
Writes(devops.DevOpsProject{}))
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/defaultroles").
|
||||
To(devopsapi.GetDevOpsProjectDefaultRoles).
|
||||
Doc("get devops project defaultroles").
|
||||
Doc("Get devops project default roles").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Returns(http.StatusOK, RespOK, []devops.Role{}).
|
||||
@@ -74,7 +75,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/members").
|
||||
To(devopsapi.GetDevOpsProjectMembersHandler).
|
||||
Doc("get devops project members").
|
||||
Doc("Get devops project members").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.QueryParameter(params.PagingParam, "page").
|
||||
@@ -89,7 +90,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/members/{members}").
|
||||
To(devopsapi.GetDevOpsProjectMemberHandler).
|
||||
Doc("get devops project member").
|
||||
Doc("Get devops project member").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("members", "member's username")).
|
||||
@@ -98,7 +99,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.POST("/devops/{devops}/members").
|
||||
To(devopsapi.AddDevOpsProjectMemberHandler).
|
||||
Doc("add devops project members").
|
||||
Doc("Add devops project members").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
|
||||
@@ -106,7 +107,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.PATCH("/devops/{devops}/members/{members}").
|
||||
To(devopsapi.UpdateDevOpsProjectMemberHandler).
|
||||
Doc("update devops project members").
|
||||
Doc("Update devops project members").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("members", "member's username")).
|
||||
@@ -115,7 +116,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.DELETE("/devops/{devops}/members/{members}").
|
||||
To(devopsapi.DeleteDevOpsProjectMemberHandler).
|
||||
Doc("delete devops project members").
|
||||
Doc("Delete devops project members").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("members", "member's username")).
|
||||
@@ -123,7 +124,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.POST("/devops/{devops}/pipelines").
|
||||
To(devopsapi.CreateDevOpsProjectPipelineHandler).
|
||||
Doc("add devops project pipeline").
|
||||
Doc("Add devops project pipeline").
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
|
||||
@@ -132,9 +133,9 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.PUT("/devops/{devops}/pipelines/{pipelines}").
|
||||
To(devopsapi.UpdateDevOpsProjectPipelineHandler).
|
||||
Doc("update devops project pipeline").
|
||||
Doc("Update devops project pipeline").
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("pipelines", "pipeline name")).
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
|
||||
Writes(devops.ProjectPipeline{}).
|
||||
@@ -142,49 +143,49 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/config").
|
||||
To(devopsapi.GetDevOpsProjectPipelineHandler).
|
||||
Doc("get devops project pipeline config").
|
||||
Doc("Get devops project pipeline config").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("pipelines", "pipeline name")).
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
|
||||
Writes(devops.ProjectPipeline{}))
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/sonarStatus").
|
||||
To(devopsapi.GetPipelineSonarStatusHandler).
|
||||
Doc("get devops project pipeline sonarStatus").
|
||||
Doc("Get devops project pipeline sonarStatus").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("pipelines", "pipeline name")).
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
|
||||
Writes([]devops.SonarStatus{}))
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/branches/{branches}/sonarStatus").
|
||||
To(devopsapi.GetMultiBranchesPipelineSonarStatusHandler).
|
||||
Doc("get devops project pipeline sonarStatus").
|
||||
Doc("Get devops project pipeline sonarStatus").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("pipelines", "pipeline name")).
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branches", "branch name")).
|
||||
Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
|
||||
Writes([]devops.SonarStatus{}))
|
||||
|
||||
webservice.Route(webservice.DELETE("/devops/{devops}/pipelines/{pipelines}").
|
||||
To(devopsapi.DeleteDevOpsProjectPipelineHandler).
|
||||
Doc("delete devops project pipeline").
|
||||
Doc("Delete devops project pipeline").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("pipelines", "pipeline name")))
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")))
|
||||
|
||||
webservice.Route(webservice.POST("/devops/{devops}/credentials").
|
||||
To(devopsapi.CreateDevOpsProjectCredentialHandler).
|
||||
Doc("add project credential pipeline").
|
||||
Doc("Add project credential pipeline").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Reads(devops.JenkinsCredential{}))
|
||||
|
||||
webservice.Route(webservice.PUT("/devops/{devops}/credentials/{credentials}").
|
||||
To(devopsapi.UpdateDevOpsProjectCredentialHandler).
|
||||
Doc("update project credential pipeline").
|
||||
Doc("Update project credential pipeline").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("credentials", "credential's Id")).
|
||||
@@ -199,7 +200,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/credentials/{credentials}").
|
||||
To(devopsapi.GetDevOpsProjectCredentialHandler).
|
||||
Doc("get project credential pipeline").
|
||||
Doc("Get project credential pipeline").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("credentials", "credential's Id")).
|
||||
@@ -210,7 +211,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/devops/{devops}/credentials").
|
||||
To(devopsapi.GetDevOpsProjectCredentialsHandler).
|
||||
Doc("get project credential pipeline").
|
||||
Doc("Get project credential pipeline").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("devops", "devops project's Id")).
|
||||
Param(webservice.PathParameter("credentials", "credential's Id")).
|
||||
@@ -219,12 +220,12 @@ func addWebService(c *restful.Container) error {
|
||||
Reads([]devops.JenkinsCredential{}))
|
||||
|
||||
// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}"
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}").
|
||||
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}").
|
||||
To(devopsapi.GetPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get DevOps Pipelines.").
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Doc("Get a Pipeline Inside a DevOps Project").
|
||||
Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("devops", "the name of devops project.")).
|
||||
Returns(http.StatusOK, RespOK, devops.Pipeline{}).
|
||||
Writes(devops.Pipeline{}))
|
||||
|
||||
@@ -233,16 +234,16 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.SearchPipelines).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Search DevOps resource.").
|
||||
Param(webservice.QueryParameter("q", "query pipelines").
|
||||
Param(webservice.QueryParameter("q", "query pipelines, condition for filtering.").
|
||||
Required(false).
|
||||
DataFormat("q=%s")).
|
||||
Param(webservice.QueryParameter("filter", "filter resource").
|
||||
Param(webservice.QueryParameter("filter", "Filter some types of jobs. e.g. no-folder,will not get a job of type folder").
|
||||
Required(false).
|
||||
DataFormat("filter=%s")).
|
||||
Param(webservice.QueryParameter("start", "start page").
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(false).
|
||||
DataFormat("start=%d")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.Pipeline{}).
|
||||
@@ -253,15 +254,15 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.SearchPipelineRuns).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Search DevOps Pipelines runs in branch.").
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.QueryParameter("start", "start page").
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(false).
|
||||
DataFormat("start=%d")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Param(webservice.QueryParameter("branch", "branch ").
|
||||
Param(webservice.QueryParameter("branch", "the name of branch, same as repository brnach, will be filter by branch.").
|
||||
Required(false).
|
||||
DataFormat("branch=%s")).
|
||||
Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}).
|
||||
@@ -271,12 +272,12 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}").
|
||||
To(devopsapi.GetBranchPipelineRun).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get DevOps Pipelines run in branch.").
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Doc("Get all runs in a branch").
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(false).
|
||||
DataFormat("start=%d")).
|
||||
Returns(http.StatusOK, RespOK, devops.BranchPipelineRun{}).
|
||||
@@ -286,12 +287,12 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes").
|
||||
To(devopsapi.GetPipelineRunNodesbyBranch).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get node on DevOps Pipelines run.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("limit", "limit").
|
||||
Doc("Get MultiBranch Pipeline run nodes.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d").
|
||||
DefaultValue("limit=10000")).
|
||||
@@ -304,13 +305,13 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipelines step log.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline runs node id")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline runs step id")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(true).
|
||||
DataFormat("start=%d").
|
||||
DefaultValue("start=0")))
|
||||
@@ -321,12 +322,12 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipelines step log.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline runs node id")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline runs step id")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(true).
|
||||
DataFormat("start=%d").
|
||||
DefaultValue("start=0")))
|
||||
@@ -336,7 +337,7 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.Validate).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Validate Github personal access token.").
|
||||
Param(webservice.PathParameter("scmId", "SCM id")).
|
||||
Param(webservice.PathParameter("scmId", "the id of SCM.")).
|
||||
Returns(http.StatusOK, RespOK, devops.Validates{}).
|
||||
Writes(devops.Validates{}))
|
||||
|
||||
@@ -345,8 +346,8 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetSCMOrg).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("List organizations of SCM").
|
||||
Param(webservice.PathParameter("scmId", "SCM id")).
|
||||
Param(webservice.QueryParameter("credentialId", "credential id for SCM").
|
||||
Param(webservice.PathParameter("scmId", "the id of SCM.")).
|
||||
Param(webservice.QueryParameter("credentialId", "credential id for SCM.").
|
||||
Required(true).
|
||||
DataFormat("credentialId=%s")).
|
||||
Returns(http.StatusOK, RespOK, []devops.SCMOrg{}).
|
||||
@@ -358,14 +359,14 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get SCM repositories in an organization").
|
||||
Param(webservice.PathParameter("scmId", "SCM id")).
|
||||
Param(webservice.PathParameter("organizationId", "organization Id, such as github username")).
|
||||
Param(webservice.QueryParameter("credentialId", "credential id for SCM").
|
||||
Param(webservice.PathParameter("organizationId", "organization Id, such as github username.")).
|
||||
Param(webservice.QueryParameter("credentialId", "credential id for SCM.").
|
||||
Required(true).
|
||||
DataFormat("credentialId=%s")).
|
||||
Param(webservice.QueryParameter("pageNumber", "page number").
|
||||
Param(webservice.QueryParameter("pageNumber", "the number of page.").
|
||||
Required(true).
|
||||
DataFormat("pageNumber=%d")).
|
||||
Param(webservice.QueryParameter("pageSize", "page size").
|
||||
Param(webservice.QueryParameter("pageSize", "the size of page.").
|
||||
Required(true).
|
||||
DataFormat("pageSize=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.OrgRepo{}).
|
||||
@@ -376,15 +377,15 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.StopBranchPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Stop pipeline in running").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep.").
|
||||
Required(false).
|
||||
DataFormat("blocking=%t").
|
||||
DefaultValue("blocking=false")).
|
||||
Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep").
|
||||
Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
|
||||
Required(false).
|
||||
DataFormat("timeOutInSecs=%d").
|
||||
DefaultValue("timeOutInSecs=10")).
|
||||
@@ -396,14 +397,14 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.StopPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Stop pipeline in running").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep.").
|
||||
Required(false).
|
||||
DataFormat("blocking=%t").
|
||||
DefaultValue("blocking=false")).
|
||||
Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep").
|
||||
Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
|
||||
Required(false).
|
||||
DataFormat("timeOutInSecs=%d").
|
||||
DefaultValue("timeOutInSecs=10")).
|
||||
@@ -415,10 +416,10 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.ReplayBranchPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Replay pipeline").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
|
||||
Writes(devops.ReplayPipe{}))
|
||||
|
||||
@@ -427,9 +428,9 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.ReplayPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Replay pipeline").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
|
||||
Writes(devops.ReplayPipe{}))
|
||||
|
||||
@@ -439,11 +440,11 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Pipelines run log.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(true).
|
||||
DataFormat("start=%d").
|
||||
DefaultValue("start=0")))
|
||||
@@ -454,10 +455,10 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Pipelines run log.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(true).
|
||||
DataFormat("start=%d").
|
||||
DefaultValue("start=0")))
|
||||
@@ -467,14 +468,14 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetBranchArtifacts).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline artifacts.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("start", "start page").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(false).
|
||||
DataFormat("start=%d")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
|
||||
@@ -485,13 +486,13 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetArtifacts).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline artifacts.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("start", "start page").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("start", "the count of item start.").
|
||||
Required(false).
|
||||
DataFormat("start=%d")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
|
||||
@@ -501,16 +502,16 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches").
|
||||
To(devopsapi.GetPipeBranch).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline of branch.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.QueryParameter("filter", "filter remote").
|
||||
Doc("Get MultiBranch pipeline branches.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.QueryParameter("filter", "filter remote scm. e.g. origin").
|
||||
Required(true).
|
||||
DataFormat("filter=%s")).
|
||||
Param(webservice.QueryParameter("start", "start").
|
||||
Param(webservice.QueryParameter("start", "the count of branches start.").
|
||||
Required(true).
|
||||
DataFormat("start=%d")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.QueryParameter("limit", "the count of branches limit.").
|
||||
Required(true).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.PipeBranch{}).
|
||||
@@ -523,12 +524,12 @@ func addWebService(c *restful.Container) error {
|
||||
Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build.").
|
||||
Reads(devops.CheckPlayload{}).
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline step id")))
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline step id, the one step in pipeline.")))
|
||||
|
||||
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}
|
||||
webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}").
|
||||
@@ -537,10 +538,10 @@ func addWebService(c *restful.Container) error {
|
||||
Doc("Pauses pipeline execution and allows the user to interact and control the flow of the build.").
|
||||
Reads(devops.CheckPlayload{}).
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.PathParameter("stepId", "pipeline step id")))
|
||||
|
||||
// match /job/project-8QnvykoJw4wZ/job/test-1/indexing/consoleText
|
||||
@@ -549,8 +550,8 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get index console log.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")))
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")))
|
||||
|
||||
// match /job/{projectName}/job/{pipelineName}/build?delay=0
|
||||
webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/scan").
|
||||
@@ -558,10 +559,10 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Start a build.").
|
||||
Produces("text/html; charset=utf-8").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.QueryParameter("delay", "delay time").
|
||||
Required(true).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.QueryParameter("delay", "will be delay time to scan.").
|
||||
Required(false).
|
||||
DataFormat("delay=%d")))
|
||||
|
||||
// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
|
||||
@@ -570,9 +571,9 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Run pipeline.").
|
||||
Reads(devops.RunPayload{}).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
|
||||
Writes(devops.QueuedBlueRun{}))
|
||||
|
||||
@@ -582,8 +583,8 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Run pipeline.").
|
||||
Reads(devops.RunPayload{}).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
|
||||
Writes(devops.QueuedBlueRun{}))
|
||||
|
||||
@@ -592,12 +593,12 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetBranchStepsStatus).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline steps status.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run name")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(true).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
|
||||
@@ -608,11 +609,11 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetStepsStatus).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline steps status.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run name")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(true).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
|
||||
@@ -622,7 +623,7 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/crumbissuer").
|
||||
To(devopsapi.GetCrumb).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get crumb").
|
||||
Doc("Get crumb issuer. A CrumbIssuer represents an algorithm to generate a nonce value, known as a crumb, to counter cross site request forgery exploits. Crumbs are typically hashes incorporating information that uniquely identifies an agent that sends a request, along with a guarded secret so that the crumb value cannot be forged by a third party.").
|
||||
Returns(http.StatusOK, RespOK, devops.Crumb{}).
|
||||
Writes(devops.Crumb{}))
|
||||
|
||||
@@ -643,7 +644,7 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Produces("application/json", "charset=utf-8").
|
||||
Doc("Check cron script compile.").
|
||||
Param(webservice.QueryParameter("value", "cpec value").
|
||||
Param(webservice.QueryParameter("value", "string of cron script.").
|
||||
Required(true).
|
||||
DataFormat("value=%s")).
|
||||
Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
|
||||
@@ -655,9 +656,9 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetPipelineRun).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get run pipeline in project.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id")).
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Returns(http.StatusOK, RespOK, devops.PipelineRun{}).
|
||||
Writes(devops.PipelineRun{}))
|
||||
|
||||
@@ -665,10 +666,10 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}").
|
||||
To(devopsapi.GetBranchPipeline).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Pipeline run in branch.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Doc("Get Pipeline run by branch.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach")).
|
||||
Returns(http.StatusOK, RespOK, devops.BranchPipeline{}).
|
||||
Writes(devops.BranchPipeline{}))
|
||||
|
||||
@@ -677,10 +678,10 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetPipelineRunNodes).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Pipeline run nodes.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.PipelineRunNodes{}).
|
||||
@@ -690,13 +691,13 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps").
|
||||
To(devopsapi.GetBranchNodeSteps).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get steps in node.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Doc("Get steps in node by branch.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
|
||||
@@ -707,11 +708,11 @@ func addWebService(c *restful.Container) error {
|
||||
To(devopsapi.GetNodeSteps).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get steps in node.").
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build")).
|
||||
Param(webservice.PathParameter("nodeId", "pipeline node id, the one node in pipeline.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(false).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
|
||||
@@ -723,9 +724,9 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Consumes("application/x-www-form-urlencoded").
|
||||
Produces("application/json", "charset=utf-8").
|
||||
Doc("Json to Jenkinsfile.").
|
||||
Doc("Convert json to jenkinsfile format. Usually the frontend uses json to edit jenkinsfile").
|
||||
Reads(devops.ReqJson{}).
|
||||
Returns(http.StatusOK, RespOK, devops.NodeSteps{}).
|
||||
Returns(http.StatusOK, RespOK, devops.ResJenkinsfile{}).
|
||||
Writes(devops.ResJenkinsfile{}))
|
||||
|
||||
// match /pipeline-model-converter/toJson
|
||||
@@ -734,7 +735,7 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Consumes("application/x-www-form-urlencoded").
|
||||
Produces("application/json", "charset=utf-8").
|
||||
Doc("Jenkinsfile to Json.").
|
||||
Doc("Convert jenkinsfile to json format. Usually the frontend uses json to edit jenkinsfile").
|
||||
Reads(devops.ReqJenkinsfile{}).
|
||||
Returns(http.StatusOK, RespOK, devops.ResJson{}).
|
||||
Writes(devops.ResJson{}))
|
||||
@@ -743,20 +744,20 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/notifycommit").
|
||||
To(devopsapi.GetNotifyCommit).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Notify Commit by GET HTTP method.").
|
||||
Doc("Get notification commit by HTTP GET method.").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.QueryParameter("url", "the url for webhook to push.").
|
||||
Param(webservice.QueryParameter("url", "url of git scm").
|
||||
Required(true).
|
||||
DataFormat("url=%s")))
|
||||
|
||||
// Gitlab or some other scm managers can only use HTTP method. match /git/notifyCommit/?url=
|
||||
webservice.Route(webservice.POST("/devops/notifycommit").
|
||||
To(devopsapi.GetNotifyCommit).
|
||||
To(devopsapi.PostNotifyCommit).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get Notify Commit by POST HTTP method.").
|
||||
Doc("Get notify commit by HTTP POST method.").
|
||||
Consumes("application/json").
|
||||
Produces("text/plain; charset=utf-8").
|
||||
Param(webservice.QueryParameter("url", "the url for webhook to push.").
|
||||
Param(webservice.QueryParameter("url", "url of git scm").
|
||||
Required(true).
|
||||
DataFormat("url=%s")))
|
||||
|
||||
@@ -769,12 +770,12 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodesdetail").
|
||||
To(devopsapi.GetBranchNodesDetail).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline nodes stages detail").
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Doc("Gives steps details inside a pipeline node by branch. For a Stage, the steps will include all the steps defined inside the stage.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(true).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
|
||||
@@ -784,12 +785,12 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodesdetail").
|
||||
To(devopsapi.GetNodesDetail).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get pipeline nodes stages detail").
|
||||
Param(webservice.PathParameter("pipelineName", "pipeline name")).
|
||||
Param(webservice.PathParameter("projectName", "devops project name")).
|
||||
Param(webservice.PathParameter("branchName", "pipeline branch name")).
|
||||
Param(webservice.PathParameter("runId", "pipeline runs id")).
|
||||
Param(webservice.QueryParameter("limit", "limit count").
|
||||
Doc("Gives steps details inside a pipeline node. For a Stage, the steps will include all the steps defined inside the stage.").
|
||||
Param(webservice.PathParameter("projectName", "the name of devops project.")).
|
||||
Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
|
||||
Param(webservice.PathParameter("branchName", "the name of branch, same as repository brnach.")).
|
||||
Param(webservice.PathParameter("runId", "pipeline run id, the unique id for a pipeline once build.")).
|
||||
Param(webservice.QueryParameter("limit", "the count of item limit.").
|
||||
Required(true).
|
||||
DataFormat("limit=%d")).
|
||||
Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/iam/policy"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const GroupName = "iam.kubesphere.io"
|
||||
@@ -39,15 +40,74 @@ var (
|
||||
AddToContainer = WebServiceBuilder.AddToContainer
|
||||
)
|
||||
|
||||
type UserUpdateRequest struct {
|
||||
Username string `json:"username" description:"username"`
|
||||
Email string `json:"email" description:"email address"`
|
||||
Lang string `json:"lang" description:"user's language setting, default is zh-CN"`
|
||||
Description string `json:"description" description:"user's description"`
|
||||
Password string `json:"password,omitempty" description:"this is necessary if you need to change your password"`
|
||||
CurrentPassword string `json:"current_password,omitempty" description:"this is necessary if you need to change your password"`
|
||||
ClusterRole string `json:"cluster_role" description:"user's cluster role"`
|
||||
}
|
||||
|
||||
type CreateUserRequest struct {
|
||||
Username string `json:"username" description:"username"`
|
||||
Email string `json:"email" description:"email address"`
|
||||
Lang string `json:"lang,omitempty" description:"user's language setting, default is zh-CN"`
|
||||
Description string `json:"description" description:"user's description"`
|
||||
Password string `json:"password" description:"password'"`
|
||||
ClusterRole string `json:"cluster_role" description:"user's cluster role"`
|
||||
}
|
||||
|
||||
type UserList struct {
|
||||
Items []struct {
|
||||
Username string `json:"username" description:"username"`
|
||||
Email string `json:"email" description:"email address"`
|
||||
Lang string `json:"lang,omitempty" description:"user's language setting, default is zh-CN"`
|
||||
Description string `json:"description" description:"user's description"`
|
||||
ClusterRole string `json:"cluster_role" description:"user's cluster role"`
|
||||
CreateTime time.Time `json:"create_time" description:"user creation time"`
|
||||
LastLoginTime time.Time `json:"last_login_time" description:"last login time"`
|
||||
} `json:"items" description:"paging data"`
|
||||
TotalCount int `json:"total_count" description:"total count"`
|
||||
}
|
||||
|
||||
type ClusterRoleList struct {
|
||||
Items []rbacv1.ClusterRole `json:"items" description:"paging data"`
|
||||
TotalCount int `json:"total_count" description:"total count"`
|
||||
}
|
||||
|
||||
type LoginLog struct {
|
||||
LoginTime string `json:"login_time" description:"last login time"`
|
||||
LoginIP string `json:"login_ip" description:"last login ip"`
|
||||
}
|
||||
|
||||
type RoleList struct {
|
||||
Items []rbacv1.Role `json:"items" description:"paging data"`
|
||||
TotalCount int `json:"total_count" description:"total count"`
|
||||
}
|
||||
|
||||
type InviteUserRequest struct {
|
||||
Username string `json:"username" description:"username"`
|
||||
WorkspaceRole string `json:"workspace_role" description:"user's workspace role'"`
|
||||
}
|
||||
|
||||
type DescribeWorkspaceUserResponse struct {
|
||||
Username string `json:"username" description:"username"`
|
||||
Email string `json:"email" description:"email address"`
|
||||
Lang string `json:"lang" description:"user's language setting, default is zh-CN"`
|
||||
Description string `json:"description" description:"user's description"`
|
||||
ClusterRole string `json:"cluster_role" description:"user's cluster role"`
|
||||
WorkspaceRole string `json:"workspace_role" description:"user's workspace role"`
|
||||
CreateTime time.Time `json:"create_time" description:"user creation time"`
|
||||
LastLoginTime time.Time `json:"last_login_time" description:"last login time"`
|
||||
}
|
||||
|
||||
func addWebService(c *restful.Container) error {
|
||||
tags := []string{"IAM"}
|
||||
ws := runtime.NewWebService(GroupVersion)
|
||||
|
||||
ok := "ok"
|
||||
pageableUserList := struct {
|
||||
Items []models.User `json:"items"`
|
||||
TotalCount int `json:"total_count"`
|
||||
}{}
|
||||
|
||||
ws.Route(ws.POST("/authenticate").
|
||||
To(iam.TokenReviewHandler).
|
||||
@@ -70,35 +130,32 @@ func addWebService(c *restful.Container) error {
|
||||
ws.Route(ws.POST("/users").
|
||||
To(iam.CreateUser).
|
||||
Doc("Create a user account.").
|
||||
Reads(models.User{}).
|
||||
Reads(CreateUserRequest{}).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.DELETE("/users/{name}").
|
||||
ws.Route(ws.DELETE("/users/{username}").
|
||||
To(iam.DeleteUser).
|
||||
Doc("Remove a specified user.").
|
||||
Param(ws.PathParameter("name", "username")).
|
||||
Param(ws.PathParameter("username", "username")).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.PUT("/users/{name}").
|
||||
ws.Route(ws.PUT("/users/{username}").
|
||||
To(iam.UpdateUser).
|
||||
Doc("Updates information about the specified user.").
|
||||
Param(ws.PathParameter("name", "username")).
|
||||
Reads(models.User{}).
|
||||
Param(ws.PathParameter("username", "username")).
|
||||
Reads(UserUpdateRequest{}).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/users/{name}/log").
|
||||
ws.Route(ws.GET("/users/{username}/log").
|
||||
To(iam.UserLoginLog).
|
||||
Doc("This method is used to retrieve the \"login logs\" for the specified user.").
|
||||
Param(ws.PathParameter("name", "username")).
|
||||
Returns(http.StatusOK, ok, struct {
|
||||
LoginTime string `json:"login_time"`
|
||||
LoginIP string `json:"login_ip"`
|
||||
}{}).
|
||||
Param(ws.PathParameter("username", "username")).
|
||||
Returns(http.StatusOK, ok, LoginLog{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/users").
|
||||
To(iam.ListUsers).
|
||||
Doc("List all users.").
|
||||
Returns(http.StatusOK, ok, pageableUserList).
|
||||
Returns(http.StatusOK, ok, UserList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/groups").
|
||||
To(iam.ListGroups).
|
||||
@@ -146,18 +203,12 @@ func addWebService(c *restful.Container) error {
|
||||
To(iam.ListRoles).
|
||||
Doc("This method is used to retrieve the roles that are assigned to the user in the specified namespace.").
|
||||
Param(ws.PathParameter("namespace", "kubernetes namespace")).
|
||||
Returns(http.StatusOK, ok, struct {
|
||||
Items []rbacv1.Role `json:"items"`
|
||||
TotalCount int `json:"total_count"`
|
||||
}{}).
|
||||
Returns(http.StatusOK, ok, RoleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/clusterroles").
|
||||
To(iam.ListClusterRoles).
|
||||
Doc("List all cluster roles.").
|
||||
Returns(http.StatusOK, ok, struct {
|
||||
Items []rbacv1.ClusterRole `json:"items"`
|
||||
TotalCount int `json:"total_count"`
|
||||
}{}).
|
||||
Returns(http.StatusOK, ok, ClusterRoleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/roles/{role}/users").
|
||||
To(iam.ListRoleUsers).
|
||||
@@ -176,7 +227,7 @@ func addWebService(c *restful.Container) error {
|
||||
To(iam.ListClusterRoleUsers).
|
||||
Doc("List all users that are bind the cluster role.").
|
||||
Param(ws.PathParameter("clusterrole", "cluster role name")).
|
||||
Returns(http.StatusOK, ok, pageableUserList).
|
||||
Returns(http.StatusOK, ok, UserList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/clusterroles/{clusterrole}/rules").
|
||||
To(iam.ListClusterRoleRules).
|
||||
@@ -212,10 +263,7 @@ func addWebService(c *restful.Container) error {
|
||||
To(iam.ListWorkspaceRoles).
|
||||
Doc("List all workspace roles.").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Returns(http.StatusOK, ok, struct {
|
||||
Items []rbacv1.ClusterRole `json:"items"`
|
||||
TotalCount int `json:"total_count"`
|
||||
}{}).
|
||||
Returns(http.StatusOK, ok, ClusterRoleList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/roles/{role}").
|
||||
To(iam.DescribeWorkspaceRole).
|
||||
@@ -235,20 +283,20 @@ func addWebService(c *restful.Container) error {
|
||||
To(iam.ListWorkspaceUsers).
|
||||
Doc("List all members in the specified workspace.").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Returns(http.StatusOK, ok, pageableUserList).
|
||||
Returns(http.StatusOK, ok, UserList{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.POST("/workspaces/{workspace}/members").
|
||||
To(iam.InviteUser).
|
||||
Doc("Invite members to a workspace.").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Reads(models.User{}).
|
||||
Reads(InviteUserRequest{}).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.DELETE("/workspaces/{workspace}/members/{username}").
|
||||
To(iam.RemoveUser).
|
||||
Doc("Remove members from workspace.").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("name", "username")).
|
||||
Param(ws.PathParameter("username", "username")).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}").
|
||||
@@ -256,7 +304,7 @@ func addWebService(c *restful.Container) error {
|
||||
Doc("Describes the specified user.").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("username", "username")).
|
||||
Returns(http.StatusOK, ok, models.User{}).
|
||||
Returns(http.StatusOK, ok, DescribeWorkspaceUserResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
c.Add(ws)
|
||||
return nil
|
||||
|
||||
@@ -24,9 +24,16 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/logging"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/filter"
|
||||
"kubesphere.io/kubesphere/pkg/models/log"
|
||||
esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
|
||||
fluentbitclient "kubesphere.io/kubesphere/pkg/simple/client/fluentbit"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "logging.kubesphere.io"
|
||||
const (
|
||||
GroupName = "logging.kubesphere.io"
|
||||
RespOK = "ok"
|
||||
)
|
||||
|
||||
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
|
||||
|
||||
@@ -37,178 +44,199 @@ var (
|
||||
|
||||
func addWebService(c *restful.Container) error {
|
||||
ws := runtime.NewWebService(GroupVersion)
|
||||
tags := []string{"Logging"}
|
||||
|
||||
ws.Route(ws.GET("/cluster").To(logging.LoggingQueryCluster).
|
||||
Filter(filter.Logging).
|
||||
Doc("cluster level log query").
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("workspaces", "workspaces specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workspace_query", "workspace query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against the cluster.").
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("workspaces", "List of workspaces the query will perform against, eg. wk-one,wk-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workspace_query", "List of keywords for filtering workspaces. Workspaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/workspaces/{workspace}").To(logging.LoggingQueryWorkspace).
|
||||
Filter(filter.Logging).
|
||||
Doc("workspace level log query").
|
||||
Param(ws.PathParameter("workspace", "workspace specify").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("namespaces", "namespaces specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespace_query", "namespace query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against a specific workspace.").
|
||||
Param(ws.PathParameter("workspace", "Perform query against a specific workspace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}").To(logging.LoggingQueryNamespace).
|
||||
Filter(filter.Logging).
|
||||
Doc("namespace level log query").
|
||||
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("workloads", "workloads specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "workload query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against a specific namespace.").
|
||||
Param(ws.PathParameter("namespace", "Perform query against a specific namespace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload}").To(logging.LoggingQueryWorkload).
|
||||
Filter(filter.Logging).
|
||||
Doc("workload level log query").
|
||||
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("workload", "workload specify").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("pods", "pods specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "pod query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against a specific workload.").
|
||||
Param(ws.PathParameter("namespace", "Specify the namespace of the workload.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("workload", "Perform query against a specific workload.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(logging.LoggingQueryPod).
|
||||
Filter(filter.Logging).
|
||||
Doc("pod level log query").
|
||||
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("containers", "containers specify").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "container query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against a specific pod.").
|
||||
Param(ws.PathParameter("namespace", "Specify the namespace of the pod.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Perform query against a specific pod.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(logging.LoggingQueryContainer).
|
||||
Filter(filter.Logging).
|
||||
Doc("container level log query").
|
||||
Param(ws.PathParameter("namespace", "namespace specify").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "pod specify").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("container", "container specify").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "operation: query statistics").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("log_query", "log query keywords").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "interval of time histogram").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "range start time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "range end time").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort", "sort method").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("from", "begin index of result returned").DataType("int").Required(true)).
|
||||
Param(ws.QueryParameter("size", "size of result returned").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Log query against a specific container.").
|
||||
Param(ws.PathParameter("namespace", "Specify the namespace of the pod.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the pod of the container.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("container", "Perform query against a specific container.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "query"}).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/fluentbit/filters").To(logging.LoggingQueryFluentbitFilters).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit filters query").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("List all Fluent bit filter plugins. This API is work-in-process.").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.POST("/fluentbit/filters").To(logging.LoggingUpdateFluentbitFilters).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit filters update").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Add a new Fluent bit filter plugin. This API is work-in-process.").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/fluentbit/outputs").To(logging.LoggingQueryFluentbitOutputs).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit outputs query").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("List all Fluent bit output plugins.").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}).
|
||||
Writes(log.FluentbitOutputsResult{}).
|
||||
Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.POST("/fluentbit/outputs").To(logging.LoggingInsertFluentbitOutput).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit outputs insert").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Add a new Fluent bit output plugin.").
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}).
|
||||
Reads(fluentbitclient.OutputPlugin{}).
|
||||
Writes(log.FluentbitOutputsResult{}).
|
||||
Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.POST("/fluentbit/outputs/{output}").To(logging.LoggingUpdateFluentbitOutput).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit outputs update").
|
||||
Param(ws.PathParameter("output", "output id").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Update a Fluent bit output plugin.").
|
||||
Param(ws.PathParameter("output", "ID of the output to update.").DataType("string").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}).
|
||||
Reads(fluentbitclient.OutputPlugin{}).
|
||||
Writes(log.FluentbitOutputsResult{}).
|
||||
Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.DELETE("/fluentbit/outputs/{output}").To(logging.LoggingDeleteFluentbitOutput).
|
||||
Filter(filter.Logging).
|
||||
Doc("log fluent-bit outputs delete").
|
||||
Param(ws.PathParameter("output", "output id").DataType("int").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Delete a Fluent bit output plugin.").
|
||||
Param(ws.PathParameter("output", "ID of the output to delete.").DataType("string").Required(true)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Logging", "setting"}).
|
||||
Writes(log.FluentbitOutputsResult{}).
|
||||
Returns(http.StatusOK, RespOK, log.FluentbitOutputsResult{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
|
||||
@@ -23,9 +23,14 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/monitoring"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/models/metrics"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "monitoring.kubesphere.io"
|
||||
const (
|
||||
GroupName = "monitoring.kubesphere.io"
|
||||
RespOK = "ok"
|
||||
)
|
||||
|
||||
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
|
||||
|
||||
@@ -37,220 +42,281 @@ var (
|
||||
func addWebService(c *restful.Container) error {
|
||||
ws := runtime.NewWebService(GroupVersion)
|
||||
|
||||
tags := []string{"Monitoring"}
|
||||
|
||||
ws.Route(ws.GET("/cluster").To(monitoring.MonitorCluster).
|
||||
Doc("monitor cluster level metrics").
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("cluster_cpu_utilisation")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Get cluster-level metrics.").
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. cluster_cpu|cluster_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "cluster"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/nodes").To(monitoring.MonitorNode).
|
||||
Doc("monitor nodes level metrics").
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("node_cpu_utilisation")).
|
||||
Param(ws.QueryParameter("resources_filter", "node re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/nodes").To(monitoring.MonitorAllNodes).
|
||||
Doc("Get node-level metrics.").
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Node filter in regexp pattern, eg. i-caojnter|i-cmu82ogj.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort nodes by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorNode).
|
||||
Doc("monitor specific node level metrics").
|
||||
Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("node_cpu_utilisation")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorSpecificNode).
|
||||
Doc("Get specific node metrics.").
|
||||
Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces").To(monitoring.MonitorNamespace).
|
||||
Doc("monitor namespaces level metrics").
|
||||
Param(ws.QueryParameter("resources_filter", "namespaces re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("namespace_memory_utilisation")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces").To(monitoring.MonitorAllNamespaces).
|
||||
Doc("Get namespace-level metrics.").
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Namespace filter in regexp pattern, eg. namespace-1|namespace-2.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort namespaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorNamespace).
|
||||
Doc("monitor specific namespace level metrics").
|
||||
Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("namespace_memory_utilisation")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorSpecificNamespace).
|
||||
Doc("Get specific namespace metrics.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. namespace_cpu|namespace_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorPod).
|
||||
Doc("monitor pods level metrics").
|
||||
Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("pod_memory_utilisation_wo_cache")).
|
||||
Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorAllPodsOfSpecificNamespace).
|
||||
Doc("Get pod-level metrics of a given namespace.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Pods filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(monitoring.MonitorPod).
|
||||
Doc("monitor specific pod level metrics").
|
||||
Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")).
|
||||
Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}").To(monitoring.MonitorSpecificPodOfSpecificNamespace).
|
||||
Doc("Get specific pod metrics.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorPod).
|
||||
Doc("monitor pods level metrics by nodeid").
|
||||
Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("i-k89a62il")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("pod_memory_utilisation_wo_cache")).
|
||||
Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorAllPodsOnSpecificNode).
|
||||
Doc("Get metrics of all pod on a specific node.").
|
||||
Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Pod filter in regexp pattern, eg. coredns-77b8449dc9-hd6gd|coredns-77b8449dc9-b4n74.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort pods by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/nodes/{node}/pods/{pod}").To(monitoring.MonitorPod).
|
||||
Doc("monitor specific pod level metrics by nodeid").
|
||||
Param(ws.PathParameter("node", "specific node").DataType("string").Required(true).DefaultValue("i-k89a62il")).
|
||||
Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/nodes/{node}/pods/{pod}").To(monitoring.MonitorSpecificPodOnSpecificNode).
|
||||
Doc("Get specific pod metrics under a given namespace.").
|
||||
Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. pod_cpu|pod_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/nodes/{node}/pods/{pod}/containers").To(monitoring.MonitorContainer).
|
||||
Doc("monitor specific pod level metrics by nodeid").
|
||||
Param(ws.PathParameter("node", "specific node").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("resources_filter", "container re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("pod_memory_utilisation_wo_cache")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/nodes/{node}/pods/{pod}/containers").To(monitoring.MonitorAllContainersOnSpecificNode).
|
||||
Doc("Get container-level metrics under a given node and pod.").
|
||||
Param(ws.PathParameter("node", "Specify the target node.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers").To(monitoring.MonitorContainer).
|
||||
Doc("monitor containers level metrics").
|
||||
Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")).
|
||||
Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("resources_filter", "container re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("container_memory_utilisation_wo_cache")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers").To(monitoring.MonitorAllContainersOfSpecificNamespace).
|
||||
Doc("Get container-level metrics under a given namespace and pod.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Container filter in regexp pattern.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort containers by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(monitoring.MonitorContainer).
|
||||
Doc("monitor specific container level metrics").
|
||||
Param(ws.PathParameter("namespace", "specific namespace").DataType("string").Required(true).DefaultValue("monitoring")).
|
||||
Param(ws.PathParameter("pod", "specific pod").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.PathParameter("container", "specific container").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_name", "metrics name cpu memory...").DataType("string").Required(true).DefaultValue("container_memory_utilisation_wo_cache")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/pods/{pod}/containers/{container}").To(monitoring.MonitorSpecificContainerOfSpecificNamespace).
|
||||
Doc("Get specific container metrics under a given node and pod.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("pod", "Specify the target pod.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("container", "Specify the target container.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. container_cpu|container_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
// Only use this api to monitor status of pods under the {workload}
|
||||
// To monitor a specific workload, try the next two apis with "resources_filter"
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}/{workload}").To(monitoring.MonitorWorkload).
|
||||
Doc("monitor specific workload level metrics").
|
||||
Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")).
|
||||
Param(ws.PathParameter("workload_kind", "workload kind").DataType("string").Required(true).DefaultValue("daemonset")).
|
||||
Param(ws.PathParameter("workload", "workload name").DataType("string").Required(true).DefaultValue("")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "max metric items in a page").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}/{workload}").To(monitoring.MonitorSpecificWorkload).
|
||||
Doc("Get specific workload metrics under a given namespace.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")).
|
||||
Param(ws.PathParameter("workload", "Specify the target workload.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workload_cpu|workload_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}").To(monitoring.MonitorWorkload).
|
||||
Doc("monitor specific workload kind level metrics").
|
||||
Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")).
|
||||
Param(ws.PathParameter("workload_kind", "workload kind").DataType("string").Required(true).DefaultValue("daemonset")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("openpitrix.*")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "max metric items in a page").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads/{workload_kind}").To(monitoring.MonitorAllWorkloadsOfSpecificKind).
|
||||
Doc("Get workload-level metrics of specific workload kind.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.PathParameter("workload_kind", "Specify the target workload kind. One of deployment, daemonset, statefulset. Other values will be interpreted as any of three.").DataType("string").Required(true).DefaultValue("(.*)")).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. node_cpu|node_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorWorkload).
|
||||
Doc("monitor all workload level metrics").
|
||||
Param(ws.PathParameter("namespace", "namespace").DataType("string").Required(true).DefaultValue("kube-system")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "pod re2 expression filter").DataType("string").Required(false).DefaultValue("")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorAllWorkloadsOfSpecificNamespace).
|
||||
Doc("Get workload-level metrics under a given namespace.").
|
||||
Param(ws.PathParameter("namespace", "Specify the target namespace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workload_cpu|workload_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Workload filter in regexp pattern.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort workloads by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
// list all namespace in this workspace by selected metrics
|
||||
ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorOneWorkspace).
|
||||
Doc("monitor workspaces level metrics").
|
||||
Param(ws.PathParameter("workspace", "workspace name").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("resources_filter", "namespaces filter").DataType("string").Required(false).DefaultValue("k.*")).
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("namespace_memory_utilisation_wo_cache")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorSpecificWorkspace).
|
||||
Doc("Get specific workspace metrics.").
|
||||
Param(ws.PathParameter("workspace", "Specify the target workspace.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workspace_cpu|workspace_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/workspaces").To(monitoring.MonitorAllWorkspaces).
|
||||
Doc("monitor workspaces level metrics").
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("workspace_memory_utilisation")).
|
||||
Param(ws.QueryParameter("resources_filter", "workspaces re2 expression filter").DataType("string").Required(false).DefaultValue(".*")).
|
||||
Param(ws.QueryParameter("sort_metric", "sort metric").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "ascending descending order").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "page number").DataType("string").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "metrics name cpu memory...in re2 regex").DataType("string").Required(false).DefaultValue("4")).
|
||||
Param(ws.QueryParameter("type", "rank, statistic").DataType("string").Required(false).DefaultValue("rank")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Get workspace-level metrics.").
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. workspace_cpu|workspace_memory.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("resources_filter", "Workspace filter in regexp pattern, eg. workspace_1|workspace_2.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_metric", "Sort workspaces by the specified metric. Valid only if type is rank.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("sort_type", "Sorting order, one of asc, desc. Valid only if type is rank.").DefaultValue("desc.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("page", "The number of paged results per metric. Default to return the whole metrics.").DataType("integer").Required(false).DefaultValue("1")).
|
||||
Param(ws.QueryParameter("limit", "Max count of items per page.").DataType("integer").Required(false).DefaultValue("5")).
|
||||
Param(ws.QueryParameter("type", "Additional operation to the result. One of rank, statistics.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
ws.Route(ws.GET("/components/{component}").To(monitoring.MonitorComponent).
|
||||
Doc("monitor component level metrics").
|
||||
Param(ws.QueryParameter("metrics_filter", "metrics names in re2 regex").DataType("string").Required(false).DefaultValue("")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)).
|
||||
Doc("Get service component-level metrics.").
|
||||
Param(ws.PathParameter("component", "Specify the target component. One of etcd, apiserver, scheduler, controller_manager, coredns, prometheus.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("metrics_filter", "Metrics filter in regexp pattern, eg. etcd_server_list|coredns_proxy.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("step", "Used to get metrics over a range of time. Query resolution step. eg. 10m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start", "Used to get metrics over a range of time. Start time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end", "Used to get metrics over a range of time. End time of query range. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("time", "Used to get metrics at a given time point. eg. 1559762729.").DataType("string").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "component"}).
|
||||
Writes(metrics.FormatedLevelMetric{}).
|
||||
Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/operations"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "operations.kubesphere.io"
|
||||
@@ -38,24 +39,24 @@ var (
|
||||
func addWebService(c *restful.Container) error {
|
||||
|
||||
tags := []string{"Operations"}
|
||||
|
||||
ok := "ok"
|
||||
webservice := runtime.NewWebService(GroupVersion)
|
||||
|
||||
webservice.Route(webservice.POST("/nodes/{node}/drainage").
|
||||
To(operations.DrainNode).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("").
|
||||
Doc("Drain node").
|
||||
Param(webservice.PathParameter("node", "node name")).
|
||||
Writes(errors.Error{}))
|
||||
Returns(http.StatusOK, ok, errors.Error{}))
|
||||
|
||||
webservice.Route(webservice.POST("/namespaces/{namespace}/jobs/{job}").
|
||||
To(operations.RerunJob).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Handle job operation").
|
||||
Doc("Job rerun").
|
||||
Param(webservice.PathParameter("job", "job name")).
|
||||
Param(webservice.PathParameter("namespace", "job's namespace")).
|
||||
Param(webservice.QueryParameter("a", "action")).
|
||||
Writes(""))
|
||||
Returns(http.StatusOK, ok, errors.Error{}))
|
||||
|
||||
c.Add(webservice)
|
||||
|
||||
|
||||
@@ -36,8 +36,11 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/applications"
|
||||
gitmodel "kubesphere.io/kubesphere/pkg/models/git"
|
||||
registriesmodel "kubesphere.io/kubesphere/pkg/models/registries"
|
||||
"kubesphere.io/kubesphere/pkg/models/status"
|
||||
"kubesphere.io/kubesphere/pkg/params"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "resources.kubesphere.io"
|
||||
@@ -54,9 +57,10 @@ func addWebService(c *restful.Container) error {
|
||||
webservice := runtime.NewWebService(GroupVersion)
|
||||
|
||||
tags := []string{"Namespace resources"}
|
||||
ok := "ok"
|
||||
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/{resources}").
|
||||
To(resources.ListResources).
|
||||
To(resources.ListNamespacedResources).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Namespace level resource query").
|
||||
Param(webservice.PathParameter("namespace", "which namespace")).
|
||||
@@ -68,16 +72,16 @@ func addWebService(c *restful.Container) error {
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1")).
|
||||
Writes(models.PageableResponse{}))
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}))
|
||||
|
||||
tags = []string{"Cluster resources"}
|
||||
|
||||
webservice.Route(webservice.GET("/{resources}").
|
||||
To(resources.ListResources).
|
||||
Writes(models.PageableResponse{}).
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
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").
|
||||
Required(false).
|
||||
DataFormat("key=value,key~value").
|
||||
@@ -85,13 +89,13 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.QueryParameter(params.PagingParam, "page").
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1"))
|
||||
DefaultValue("limit=10,page=1")))
|
||||
|
||||
tags = []string{"Applications"}
|
||||
|
||||
webservice.Route(webservice.GET("/applications").
|
||||
To(resources.ListApplication).
|
||||
Writes(models.PageableResponse{}).
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("List applications in cluster").
|
||||
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions").
|
||||
@@ -107,7 +111,7 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/applications").
|
||||
To(resources.ListNamespacedApplication).
|
||||
Writes(models.PageableResponse{}).
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("List applications").
|
||||
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions").
|
||||
@@ -122,24 +126,27 @@ func addWebService(c *restful.Container) error {
|
||||
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/applications/{cluster_id}").
|
||||
To(resources.DescribeApplication).
|
||||
Writes(applications.Application{}).
|
||||
Returns(http.StatusOK, ok, applications.Application{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Describe application").
|
||||
Param(webservice.PathParameter("namespace", "namespace name")).
|
||||
Param(webservice.PathParameter("cluster_id", "openpitrix cluster id")))
|
||||
Param(webservice.PathParameter("cluster_id", "application id")))
|
||||
|
||||
webservice.Route(webservice.POST("/namespaces/{namespace}/applications").
|
||||
To(resources.DeployApplication).
|
||||
Doc("Deploy application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(openpitrix.CreateClusterRequest{}).
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Param(webservice.PathParameter("namespace", "namespace name")))
|
||||
|
||||
webservice.Route(webservice.DELETE("/namespaces/{namespace}/applications/{cluster_id}").
|
||||
To(resources.DeleteApplication).
|
||||
Doc("Delete application").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(webservice.PathParameter("namespace", "namespace name")))
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Param(webservice.PathParameter("namespace", "namespace name")).
|
||||
Param(webservice.PathParameter("cluster_id", "application id")))
|
||||
|
||||
tags = []string{"User resources"}
|
||||
|
||||
@@ -148,13 +155,14 @@ func addWebService(c *restful.Container) error {
|
||||
Doc("get user's kubectl pod").
|
||||
Param(webservice.PathParameter("username", "username")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(models.PodInfo{}))
|
||||
Returns(http.StatusOK, ok, models.PodInfo{}))
|
||||
|
||||
webservice.Route(webservice.GET("/users/{username}/kubeconfig").
|
||||
Produces("text/plain").
|
||||
To(resources.GetKubeconfig).
|
||||
Doc("get users' kubeconfig").
|
||||
Param(webservice.PathParameter("username", "username")).
|
||||
Returns(http.StatusOK, ok, "").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
tags = []string{"Components"}
|
||||
@@ -163,18 +171,18 @@ func addWebService(c *restful.Container) error {
|
||||
To(components.GetComponents).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("").
|
||||
Writes(map[string]models.Component{}))
|
||||
Returns(http.StatusOK, ok, map[string]models.Component{}))
|
||||
webservice.Route(webservice.GET("/components/{component}").
|
||||
To(components.GetComponentStatus).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("").
|
||||
Param(webservice.PathParameter("component", "component name")).
|
||||
Writes(models.Component{}))
|
||||
Returns(http.StatusOK, ok, models.Component{}))
|
||||
webservice.Route(webservice.GET("/health").
|
||||
To(components.GetSystemHealthStatus).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("").
|
||||
Writes(map[string]int{}))
|
||||
Returns(http.StatusOK, ok, map[string]int{}))
|
||||
|
||||
tags = []string{"Quotas"}
|
||||
|
||||
@@ -182,13 +190,13 @@ func addWebService(c *restful.Container) error {
|
||||
To(quotas.GetClusterQuotas).
|
||||
Deprecate().
|
||||
Doc("get whole cluster's resource usage").
|
||||
Writes(models.ResourceQuota{}).
|
||||
Returns(http.StatusOK, ok, models.ResourceQuota{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/quotas").
|
||||
Doc("get specified namespace's resource quota and usage").
|
||||
Param(webservice.PathParameter("namespace", "namespace's name")).
|
||||
Writes(models.ResourceQuota{}).
|
||||
Returns(http.StatusOK, ok, models.ResourceQuota{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
To(quotas.GetNamespaceQuotas))
|
||||
|
||||
@@ -198,7 +206,8 @@ func addWebService(c *restful.Container) error {
|
||||
To(registries.RegistryVerify).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("docker registry verify").
|
||||
Writes(errors.Error{}))
|
||||
Reads(registriesmodel.AuthInfo{}).
|
||||
Returns(http.StatusOK, ok, errors.Error{}))
|
||||
|
||||
tags = []string{"Git"}
|
||||
webservice.Route(webservice.POST("/git/readverify").
|
||||
@@ -207,7 +216,7 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("secret git read verify").
|
||||
Reads(gitmodel.AuthInfo{}).
|
||||
Writes(errors.Error{}),
|
||||
Returns(http.StatusOK, ok, errors.Error{}),
|
||||
)
|
||||
tags = []string{"Revision"}
|
||||
|
||||
@@ -218,7 +227,7 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("daemonset", "daemonset's name")).
|
||||
Param(webservice.PathParameter("namespace", "daemonset's namespace")).
|
||||
Param(webservice.PathParameter("revision", "daemonset's revision")).
|
||||
Writes(appsv1.DaemonSet{}))
|
||||
Returns(http.StatusOK, ok, appsv1.DaemonSet{}))
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/deployments/{deployment}/revisions/{revision}").
|
||||
To(revisions.GetDeployRevision).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
@@ -226,7 +235,7 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("deployment", "deployment's name")).
|
||||
Param(webservice.PathParameter("namespace", "deployment's namespace")).
|
||||
Param(webservice.PathParameter("revision", "deployment's revision")).
|
||||
Writes(appsv1.ReplicaSet{}))
|
||||
Returns(http.StatusOK, ok, appsv1.ReplicaSet{}))
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/statefulsets/{statefulset}/revisions/{revision}").
|
||||
To(revisions.GetStatefulSetRevision).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
@@ -234,7 +243,7 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("statefulset", "statefulset's name")).
|
||||
Param(webservice.PathParameter("namespace", "statefulset's namespace")).
|
||||
Param(webservice.PathParameter("revision", "statefulset's revision")).
|
||||
Writes(appsv1.StatefulSet{}))
|
||||
Returns(http.StatusOK, ok, appsv1.StatefulSet{}))
|
||||
|
||||
tags = []string{"Router"}
|
||||
|
||||
@@ -242,7 +251,7 @@ func addWebService(c *restful.Container) error {
|
||||
To(routers.GetAllRouters).
|
||||
Doc("List all routers").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(corev1.Service{}))
|
||||
Returns(http.StatusOK, ok, corev1.Service{}))
|
||||
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/router").
|
||||
To(routers.GetRouter).
|
||||
@@ -273,11 +282,13 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/workloadstatuses").
|
||||
Doc("get abnormal workloads' count of whole cluster").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
|
||||
To(workloadstatuses.GetClusterResourceStatus))
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/workloadstatuses").
|
||||
Doc("get abnormal workloads' count of specified namespace").
|
||||
Param(webservice.PathParameter("namespace", "the name of namespace")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(http.StatusOK, ok, status.WorkLoadStatus{}).
|
||||
To(workloadstatuses.GetNamespacesResourceStatus))
|
||||
|
||||
c.Add(webservice)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/servicemesh/metrics"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/servicemesh/tracing"
|
||||
"kubesphere.io/kubesphere/pkg/errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "servicemesh.kubesphere.io"
|
||||
@@ -30,19 +30,21 @@ func addWebService(c *restful.Container) error {
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/metrics").
|
||||
To(metrics.GetServiceMetrics).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get app metrics from a specific namespace").
|
||||
Doc("Get service metrics from a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of the namespace")).
|
||||
Param(webservice.PathParameter("service", "name of the service")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
|
||||
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
|
||||
Param(webservice.QueryParameter("step", "metrics step")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")).
|
||||
Param(webservice.QueryParameter("reporter", "destination")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")).
|
||||
Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")).
|
||||
Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
|
||||
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
|
||||
Returns(http.StatusOK, "ok", MetricsResponse{}).
|
||||
Writes(MetricsResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get app metrics
|
||||
// Get /namespaces/{namespace}/apps/{app}/metrics
|
||||
@@ -51,17 +53,20 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get app metrics from a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of the namespace")).
|
||||
Param(webservice.PathParameter("app", "name of the workload label app value")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
|
||||
Param(webservice.PathParameter("app", "name of the app")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
|
||||
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
|
||||
Param(webservice.QueryParameter("step", "metrics step")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")).
|
||||
Param(webservice.QueryParameter("reporter", "destination")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")).
|
||||
Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")).
|
||||
Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
|
||||
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
|
||||
Returns(http.StatusOK, "ok", MetricsResponse{}).
|
||||
Writes(MetricsResponse{})).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
// Get workload metrics
|
||||
// Get /namespaces/{namespace}/workloads/{workload}/metrics
|
||||
@@ -71,16 +76,20 @@ func addWebService(c *restful.Container) error {
|
||||
Doc("Get workload metrics from a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)).
|
||||
Param(webservice.PathParameter("workload", "name of the workload").Required(true)).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
|
||||
Param(webservice.PathParameter("service", "name of the service")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
|
||||
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
|
||||
Param(webservice.QueryParameter("step", "metrics step")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")).
|
||||
Param(webservice.QueryParameter("reporter", "destination")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")).
|
||||
Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")).
|
||||
Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
|
||||
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
|
||||
Returns(http.StatusOK, "ok", MetricsResponse{}).
|
||||
Writes(MetricsResponse{})).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
// Get namespace metrics
|
||||
// Get /namespaces/{namespace}/metrics
|
||||
@@ -89,16 +98,19 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get workload metrics from a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of the namespace").Required(true)).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, e.g. request_count, request_duration, request_error_count")).
|
||||
Param(webservice.PathParameter("service", "name of the service")).
|
||||
Param(webservice.QueryParameter("filters[]", "type of metrics type, fetch all metrics when empty, e.g. request_count, request_duration, request_error_count").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which UNIX time to extract metrics")).
|
||||
Param(webservice.QueryParameter("duration", "metrics duration, in seconds")).
|
||||
Param(webservice.QueryParameter("step", "metrics step")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "metrics quantiles, 0.5, 0.9, 0.99")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "by which labels to group node, e.g. source_workload, destination_service_name")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol, http/tcp")).
|
||||
Param(webservice.QueryParameter("reporter", "destination")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("1800")).
|
||||
Param(webservice.QueryParameter("step", "step between graph data points, in seconds.").DefaultValue("15")).
|
||||
Param(webservice.QueryParameter("rateInterval", "metrics rate intervals, e.g. 20s").DefaultValue("1m")).
|
||||
Param(webservice.QueryParameter("direction", "traffic direction: 'inbound' or 'outbound'").DefaultValue("outbound")).
|
||||
Param(webservice.QueryParameter("quantiles[]", "list of quantiles to fetch, fetch no quantiles when empty. eg. 0.5, 0.9, 0.99").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
|
||||
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
|
||||
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
|
||||
Returns(http.StatusOK, "ok", MetricsResponse{}).
|
||||
Writes(MetricsResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get namespace graph
|
||||
// Get /namespaces/{namespace}/graph
|
||||
@@ -107,25 +119,31 @@ func addWebService(c *restful.Container) error {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get service graph for a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
|
||||
Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")).
|
||||
Param(webservice.QueryParameter("groupBy", "group nodes by kind")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which time point, default now")).
|
||||
Param(webservice.QueryParameter("injectServiceNodes", "whether to inject service ndoes")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("10m")).
|
||||
Param(webservice.QueryParameter("graphType", "type of the generated service graph. Available graph types: [app, service, versionedApp, workload].").DefaultValue("workload")).
|
||||
Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")).
|
||||
Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")).
|
||||
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
|
||||
Returns(http.StatusNotFound, "not found", NotFoundError{}).
|
||||
Returns(http.StatusOK, "ok", GraphResponse{}).
|
||||
Writes(GraphResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get namespaces graph, for multiple namespaces
|
||||
// Get /namespaces/graph
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/graph").
|
||||
webservice.Route(webservice.GET("/namespaces/graph").
|
||||
To(metrics.GetNamespacesGraph).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Doc("Get service graph for a specific namespace").
|
||||
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
|
||||
Param(webservice.QueryParameter("graphType", "type of the generated service graph, eg. ")).
|
||||
Param(webservice.QueryParameter("groupBy", "group nodes by kind")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which time point, default now")).
|
||||
Param(webservice.QueryParameter("injectServiceNodes", "whether to inject service ndoes")).
|
||||
Param(webservice.QueryParameter("namespaces", "names of namespaces")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Doc("Get graph from all namespaces").
|
||||
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("10m")).
|
||||
Param(webservice.QueryParameter("graphType", "type of the generated service graph. Available graph types: [app, service, versionedApp, workload].").DefaultValue("workload")).
|
||||
Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")).
|
||||
Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")).
|
||||
Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")).
|
||||
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
|
||||
Returns(http.StatusNotFound, "not found", NotFoundError{}).
|
||||
Returns(http.StatusOK, "ok", GraphResponse{}).
|
||||
Writes(GraphResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get namespace health
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/health").
|
||||
@@ -136,7 +154,10 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("type", "the type of health, app/service/workload, default app").DefaultValue("app")).
|
||||
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
|
||||
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
|
||||
Returns(http.StatusNotFound, "not found", NotFoundError{}).
|
||||
Returns(http.StatusOK, "ok", namespaceAppHealthResponse{}).
|
||||
Writes(namespaceAppHealthResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get workloads health
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/workloads/{workload}/health").
|
||||
@@ -147,7 +168,8 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("workload", "workload name").Required(true)).
|
||||
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
|
||||
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
ReturnsError(http.StatusOK, "ok", workloadHealthResponse{}).
|
||||
Writes(workloadHealthResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get app health
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/apps/{app}/health").
|
||||
@@ -158,7 +180,8 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("app", "app name").Required(true)).
|
||||
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
|
||||
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Returns(http.StatusOK, "ok", appHealthResponse{}).
|
||||
Writes(appHealthResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get service health
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/health").
|
||||
@@ -169,7 +192,8 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.PathParameter("service", "service name").Required(true)).
|
||||
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
|
||||
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
|
||||
Writes(errors.Error{})).Produces(restful.MIME_JSON)
|
||||
Returns(http.StatusOK, "ok", serviceHealthResponse{}).
|
||||
Writes(serviceHealthResponse{})).Produces(restful.MIME_JSON)
|
||||
|
||||
// Get service tracing
|
||||
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/traces").
|
||||
@@ -182,9 +206,8 @@ func addWebService(c *restful.Container) error {
|
||||
Param(webservice.QueryParameter("end", "end of time range want to query, in unix timestamp")).
|
||||
Param(webservice.QueryParameter("limit", "maximum tracing entries returned at one query, default 10").DefaultValue("10")).
|
||||
Param(webservice.QueryParameter("loopback", "loopback of duration want to query, e.g. 30m/1h/2d")).
|
||||
Param(webservice.QueryParameter("maxDuration", "maximum duration of tracing")).
|
||||
Param(webservice.QueryParameter("minDuration", "minimum duration of tracing")).
|
||||
Writes(errors.Error{}).
|
||||
Param(webservice.QueryParameter("maxDuration", "maximum duration of a request")).
|
||||
Param(webservice.QueryParameter("minDuration", "minimum duration of a request")).
|
||||
Consumes(restful.MIME_JSON).
|
||||
Produces(restful.MIME_JSON))
|
||||
|
||||
|
||||
54
pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go
Normal file
54
pkg/apis/servicemesh/metrics/v1alpha2/swagger-doc.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package v1alpha2
|
||||
|
||||
import (
|
||||
"github.com/kiali/kiali/graph/cytoscape"
|
||||
"github.com/kiali/kiali/models"
|
||||
"github.com/kiali/kiali/prometheus"
|
||||
)
|
||||
|
||||
/////////////////////
|
||||
// SWAGGER RESPONSES
|
||||
/////////////////////
|
||||
|
||||
// NoContent: the response is empty
|
||||
type NoContent struct {
|
||||
Status int32 `json:"status"`
|
||||
Reason error `json:"reason"`
|
||||
}
|
||||
|
||||
// BadRequestError: the client request is incorrect
|
||||
type BadRequestError struct {
|
||||
Status int32 `json:"status"`
|
||||
Reason error `json:"reason"`
|
||||
}
|
||||
|
||||
// NotFoundError is the error message that is generated when server could not find
|
||||
// what was requested
|
||||
type NotFoundError struct {
|
||||
Status int32 `json:"status"`
|
||||
Reason error `json:"reason"`
|
||||
}
|
||||
|
||||
type GraphResponse struct {
|
||||
cytoscape.Config
|
||||
}
|
||||
|
||||
type serviceHealthResponse struct {
|
||||
models.ServiceHealth
|
||||
}
|
||||
|
||||
type namespaceAppHealthResponse struct {
|
||||
models.NamespaceAppHealth
|
||||
}
|
||||
|
||||
type workloadHealthResponse struct {
|
||||
models.WorkloadHealth
|
||||
}
|
||||
|
||||
type appHealthResponse struct {
|
||||
models.AppHealth
|
||||
}
|
||||
|
||||
type MetricsResponse struct {
|
||||
prometheus.Metrics
|
||||
}
|
||||
@@ -20,12 +20,25 @@ package v1alpha2
|
||||
import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"github.com/emicklei/go-restful-openapi"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/tenant"
|
||||
"kubesphere.io/kubesphere/pkg/models/devops"
|
||||
"kubesphere.io/kubesphere/pkg/params"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/errors"
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const GroupName = "tenant.kubesphere.io"
|
||||
const (
|
||||
GroupName = "tenant.kubesphere.io"
|
||||
RespOK = "ok"
|
||||
)
|
||||
|
||||
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
|
||||
|
||||
@@ -36,79 +49,131 @@ var (
|
||||
|
||||
func addWebService(c *restful.Container) error {
|
||||
tags := []string{"Tenant"}
|
||||
ok := "ok"
|
||||
ws := runtime.NewWebService(GroupVersion)
|
||||
|
||||
ws.Route(ws.GET("/workspaces").
|
||||
To(tenant.ListWorkspaces).
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}).
|
||||
Doc("List workspace by user").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}").
|
||||
To(tenant.DescribeWorkspace).
|
||||
Doc("Get workspace detail").
|
||||
Doc("Describe workspace").
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Returns(http.StatusOK, ok, v1alpha1.Workspace{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/rules").
|
||||
To(tenant.ListWorkspaceRules).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Doc("List the rules for the current user").
|
||||
Returns(http.StatusOK, ok, models.SimpleRule{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/namespaces/{namespace}/rules").
|
||||
To(tenant.ListNamespaceRules).
|
||||
Param(ws.PathParameter("namespace", "namespace")).
|
||||
Doc("List the rules for the current user").
|
||||
Returns(http.StatusOK, ok, models.SimpleRule{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/devops/{devops}/rules").
|
||||
To(tenant.ListDevopsRules).
|
||||
Param(ws.PathParameter("devops", "devops project id")).
|
||||
Doc("List the rules for the current user").
|
||||
Returns(http.StatusOK, ok, models.SimpleRule{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/namespaces").
|
||||
To(tenant.ListNamespaces).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Doc("List the namespaces for the current user").
|
||||
Returns(http.StatusOK, ok, []v1.Namespace{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/namespaces").
|
||||
To(tenant.ListNamespaces).
|
||||
To(tenant.ListNamespacesByUsername).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("username", "workspace member's username")).
|
||||
Doc("List the namespaces for the workspace member").
|
||||
Returns(http.StatusOK, ok, []v1.Namespace{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.POST("/workspaces/{workspace}/namespaces").
|
||||
To(tenant.CreateNamespace).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Doc("Create namespace").
|
||||
Returns(http.StatusOK, ok, []v1.Namespace{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.DELETE("/workspaces/{workspace}/namespaces/{namespace}").
|
||||
To(tenant.DeleteNamespace).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("namespace", "namespace")).
|
||||
Doc("Delete namespace").
|
||||
Returns(http.StatusOK, ok, errors.Error{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/devops").
|
||||
To(tenant.ListDevopsProjects).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.QueryParameter(params.PagingParam, "page").
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1")).
|
||||
Param(ws.QueryParameter(params.ConditionsParam, "query conditions").
|
||||
Required(false).
|
||||
DataFormat("key=%s,key~%s")).
|
||||
Doc("List devops projects for the current user").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/workspaces/{workspace}/members/{username}/devops").
|
||||
To(tenant.ListDevopsProjects).
|
||||
To(tenant.ListDevopsProjectsByUsername).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("username", "workspace member's username")).
|
||||
Param(ws.QueryParameter(params.PagingParam, "page").
|
||||
Required(false).
|
||||
DataFormat("limit=%d,page=%d").
|
||||
DefaultValue("limit=10,page=1")).
|
||||
Param(ws.QueryParameter(params.ConditionsParam, "query conditions").
|
||||
Required(false).
|
||||
DataFormat("key=%s,key~%s")).
|
||||
Returns(http.StatusOK, ok, models.PageableResponse{}).
|
||||
Doc("List the devops projects for the workspace member").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.POST("/workspaces/{workspace}/devops").
|
||||
To(tenant.CreateDevopsProject).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Doc("Create devops project").
|
||||
Reads(devops.DevOpsProject{}).
|
||||
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.DELETE("/workspaces/{workspace}/devops/{id}").
|
||||
To(tenant.DeleteDevopsProject).
|
||||
Param(ws.PathParameter("workspace", "workspace name")).
|
||||
Param(ws.PathParameter("id", "devops project id")).
|
||||
Doc("Delete devops project").
|
||||
Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
ws.Route(ws.GET("/logging").
|
||||
To(tenant.LogQuery).
|
||||
Doc("Query cluster-level logs in a multi-tenants environment").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
Param(ws.QueryParameter("operation", "Query operation type. One of query, statistics, histogram.").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("workspaces", "List of workspaces the query will perform against, eg. wk-one,wk-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workspace_query", "List of keywords for filtering workspaces. Workspaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespaces", "List of namespaces the query will perform against, eg. ns-one,ns-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("namespace_query", "List of keywords for filtering namespaces. Namespaces whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workloads", "List of workloads the query will perform against, eg. wl-one,wl-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("workload_query", "List of keywords for filtering workloads. Workloads whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pods", "List of pods the query will perform against, eg. pod-one,pod-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("pod_query", "List of keywords for filtering pods. Pods whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("containers", "List of containers the query will perform against, eg. container-one,container-two").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("container_query", "List of keywords for filtering containers. Containers whose name contains at least one keyword will be matched for query. Non case-sensitive matching. eg. one,two.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("log_query", "List of keywords for filtering logs. The query returns log containing at least one keyword. Non case-sensitive matching. eg. err,INFO.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("interval", "Count logs at intervals. Valid only if operation is histogram. The unit can be ms(milliseconds), s(seconds), m(minutes), h(hours), d(days), w(weeks), M(months), q(quarters), y(years). eg. 30m.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("start_time", "Start time of query range, eg. 1559664000000.").DataType("string").Required(false)).
|
||||
Param(ws.QueryParameter("end_time", "End time of query range, eg. 1559664000000.").DataType("string").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("size", "Size of result to return.").DataType("integer").DefaultValue("10").Required(false)).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(esclient.Response{}).
|
||||
Returns(http.StatusOK, RespOK, esclient.Response{})).
|
||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
||||
Produces(restful.MIME_JSON)
|
||||
|
||||
c.Add(ws)
|
||||
return nil
|
||||
|
||||
@@ -23,11 +23,14 @@ import (
|
||||
log "github.com/golang/glog"
|
||||
"kubesphere.io/kubesphere/pkg/models/devops"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const jenkinsHeaderPre = "X-"
|
||||
|
||||
func GetPipeline(req *restful.Request, resp *restful.Response) {
|
||||
projectName := req.PathParameter("projectName")
|
||||
pipelineName := req.PathParameter("pipelineName")
|
||||
projectName := req.PathParameter("devops")
|
||||
pipelineName := req.PathParameter("pipelines")
|
||||
|
||||
res, err := devops.GetPipeline(projectName, pipelineName, req.Request)
|
||||
if err != nil {
|
||||
@@ -111,7 +114,9 @@ func GetBranchStepLog(req *restful.Request, resp *restful.Response) {
|
||||
return
|
||||
}
|
||||
for k, v := range header {
|
||||
resp.AddHeader(k, v[0])
|
||||
if strings.HasPrefix(k, jenkinsHeaderPre) {
|
||||
resp.AddHeader(k, v[0])
|
||||
}
|
||||
}
|
||||
resp.Write(res)
|
||||
}
|
||||
@@ -129,7 +134,9 @@ func GetStepLog(req *restful.Request, resp *restful.Response) {
|
||||
return
|
||||
}
|
||||
for k, v := range header {
|
||||
resp.AddHeader(k, v[0])
|
||||
if strings.HasPrefix(k, jenkinsHeaderPre) {
|
||||
resp.AddHeader(k, v[0])
|
||||
}
|
||||
}
|
||||
resp.Write(res)
|
||||
}
|
||||
@@ -578,6 +585,14 @@ func GetNotifyCommit(req *restful.Request, resp *restful.Response) {
|
||||
resp.Write(res)
|
||||
}
|
||||
|
||||
func PostNotifyCommit(req *restful.Request, resp *restful.Response) {
|
||||
res, err := devops.GetNotifyCommit(req.Request)
|
||||
if err != nil {
|
||||
parseErr(err, resp)
|
||||
return
|
||||
}
|
||||
resp.Write(res)
|
||||
}
|
||||
func GithubWebhook(req *restful.Request, resp *restful.Response) {
|
||||
res, err := devops.GithubWebhook(req.Request)
|
||||
if err != nil {
|
||||
|
||||
@@ -31,8 +31,8 @@ import (
|
||||
)
|
||||
|
||||
type RoleList struct {
|
||||
ClusterRoles []*v1.ClusterRole `json:"clusterRole" protobuf:"bytes,2,rep,name=clusterRoles"`
|
||||
Roles []*v1.Role `json:"roles" protobuf:"bytes,2,rep,name=roles"`
|
||||
ClusterRoles []*v1.ClusterRole `json:"clusterRole" description:"cluster role list"`
|
||||
Roles []*v1.Role `json:"roles" description:"role list"`
|
||||
}
|
||||
|
||||
func ListRoleUsers(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
@@ -30,24 +30,24 @@ import (
|
||||
)
|
||||
|
||||
type Spec struct {
|
||||
Token string `json:"token"`
|
||||
Token string `json:"token" description:"access token"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Authenticated bool `json:"authenticated"`
|
||||
User map[string]interface{} `json:"user,omitempty"`
|
||||
Authenticated bool `json:"authenticated" description:"is authenticated"`
|
||||
User map[string]interface{} `json:"user,omitempty" description:"user info"`
|
||||
}
|
||||
|
||||
type TokenReview struct {
|
||||
APIVersion string `json:"apiVersion"`
|
||||
Kind string `json:"kind"`
|
||||
APIVersion string `json:"apiVersion" description:"Kubernetes API version"`
|
||||
Kind string `json:"kind" description:"kind of the API object"`
|
||||
Spec *Spec `json:"spec,omitempty"`
|
||||
Status *Status `json:"status,omitempty"`
|
||||
Status *Status `json:"status,omitempty" description:"token review status"`
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username" description:"username"`
|
||||
Password string `json:"password" description:"password"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -77,7 +77,7 @@ func CreateUser(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)
|
||||
|
||||
@@ -98,7 +98,7 @@ func DeleteUser(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)
|
||||
var user models.User
|
||||
|
||||
@@ -162,7 +162,7 @@ func isUserManager(username string) (bool, error) {
|
||||
}
|
||||
|
||||
func UserLoginLog(req *restful.Request, resp *restful.Response) {
|
||||
username := req.PathParameter("name")
|
||||
username := req.PathParameter("username")
|
||||
logs, err := iam.LoginLog(username)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -23,6 +23,22 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/prometheus"
|
||||
)
|
||||
|
||||
func MonitorAllPodsOfSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorPod(request, response)
|
||||
}
|
||||
|
||||
func MonitorSpecificPodOfSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorPod(request, response)
|
||||
}
|
||||
|
||||
func MonitorAllPodsOnSpecificNode(request *restful.Request, response *restful.Response) {
|
||||
MonitorPod(request, response)
|
||||
}
|
||||
|
||||
func MonitorSpecificPodOnSpecificNode(request *restful.Request, response *restful.Response) {
|
||||
MonitorPod(request, response)
|
||||
}
|
||||
|
||||
func MonitorPod(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
podName := requestParams.PodName
|
||||
@@ -48,6 +64,18 @@ func MonitorPod(request *restful.Request, response *restful.Response) {
|
||||
}
|
||||
}
|
||||
|
||||
func MonitorAllContainersOnSpecificNode(request *restful.Request, response *restful.Response) {
|
||||
MonitorContainer(request, response)
|
||||
}
|
||||
|
||||
func MonitorAllContainersOfSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorContainer(request, response)
|
||||
}
|
||||
|
||||
func MonitorSpecificContainerOfSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorContainer(request, response)
|
||||
}
|
||||
|
||||
func MonitorContainer(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
metricName := requestParams.MetricsName
|
||||
@@ -67,6 +95,18 @@ func MonitorContainer(request *restful.Request, response *restful.Response) {
|
||||
|
||||
}
|
||||
|
||||
func MonitorSpecificWorkload(request *restful.Request, response *restful.Response) {
|
||||
MonitorWorkload(request, response)
|
||||
}
|
||||
|
||||
func MonitorAllWorkloadsOfSpecificKind(request *restful.Request, response *restful.Response) {
|
||||
MonitorWorkload(request, response)
|
||||
}
|
||||
|
||||
func MonitorAllWorkloadsOfSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorWorkload(request, response)
|
||||
}
|
||||
|
||||
func MonitorWorkload(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
|
||||
@@ -108,7 +148,7 @@ func MonitorAllWorkspaces(request *restful.Request, response *restful.Response)
|
||||
}
|
||||
}
|
||||
|
||||
func MonitorOneWorkspace(request *restful.Request, response *restful.Response) {
|
||||
func MonitorSpecificWorkspace(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
|
||||
tp := requestParams.Tp
|
||||
@@ -135,6 +175,14 @@ func MonitorOneWorkspace(request *restful.Request, response *restful.Response) {
|
||||
}
|
||||
}
|
||||
|
||||
func MonitorAllNamespaces(request *restful.Request, response *restful.Response) {
|
||||
MonitorNamespace(request, response)
|
||||
}
|
||||
|
||||
func MonitorSpecificNamespace(request *restful.Request, response *restful.Response) {
|
||||
MonitorNamespace(request, response)
|
||||
}
|
||||
|
||||
func MonitorNamespace(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
// multiple
|
||||
@@ -165,6 +213,14 @@ func MonitorCluster(request *restful.Request, response *restful.Response) {
|
||||
}
|
||||
}
|
||||
|
||||
func MonitorAllNodes(request *restful.Request, response *restful.Response) {
|
||||
MonitorNode(request, response)
|
||||
}
|
||||
|
||||
func MonitorSpecificNode(request *restful.Request, response *restful.Response) {
|
||||
MonitorNode(request, response)
|
||||
}
|
||||
|
||||
func MonitorNode(request *restful.Request, response *restful.Response) {
|
||||
requestParams := prometheus.ParseMonitoringRequestParams(request)
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/params"
|
||||
)
|
||||
|
||||
func ListNamespacedResources(req *restful.Request, resp *restful.Response) {
|
||||
ListResources(req, resp)
|
||||
}
|
||||
|
||||
func ListResources(req *restful.Request, resp *restful.Response) {
|
||||
namespace := req.PathParameter("namespace")
|
||||
resourceName := req.PathParameter("resources")
|
||||
|
||||
@@ -101,6 +101,9 @@ func DescribeWorkspace(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
resp.WriteAsJson(result)
|
||||
}
|
||||
func ListNamespacesByUsername(req *restful.Request, resp *restful.Response) {
|
||||
ListNamespaces(req, resp)
|
||||
}
|
||||
|
||||
func ListNamespaces(req *restful.Request, resp *restful.Response) {
|
||||
workspace := req.PathParameter("workspace")
|
||||
@@ -208,6 +211,10 @@ func checkResourceQuotas(wokrspace *v1alpha1.Workspace) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ListDevopsProjectsByUsername(req *restful.Request, resp *restful.Response) {
|
||||
ListDevopsProjects(req, resp)
|
||||
}
|
||||
|
||||
func ListDevopsProjects(req *restful.Request, resp *restful.Response) {
|
||||
|
||||
workspace := req.PathParameter("workspace")
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
package controller
|
||||
|
||||
import "kubesphere.io/kubesphere/pkg/controller/clusterrolebinding"
|
||||
|
||||
func init() {
|
||||
// AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
|
||||
//AddToManagerFuncs = append(AddToManagerFuncs, clusterrolebinding.Add)
|
||||
AddToManagerFuncs = append(AddToManagerFuncs, clusterrolebinding.Add)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
type Error struct {
|
||||
Message string `json:"message"`
|
||||
Message string `json:"message" description:"error message"`
|
||||
}
|
||||
|
||||
var None = Error{Message: "success"}
|
||||
|
||||
@@ -87,18 +87,18 @@ type CredentialResponse struct {
|
||||
TypeName string `json:"typeName"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Fingerprint *struct {
|
||||
FileName string `json:"fileName,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
FileName string `json:"file_name,omitempty" description:"credential's display name and description"`
|
||||
Hash string `json:"hash,omitempty" description:"credential's hash'"`
|
||||
Usage []*struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty" description:"jenkins pipeline full name"`
|
||||
Ranges struct {
|
||||
Ranges []*struct {
|
||||
Start int `json:"start,omitempty"`
|
||||
End int `json:"end,omitempty"`
|
||||
Start int `json:"start,omitempty" description:"start build number"`
|
||||
End int `json:"end,omitempty" description:"end build number"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"usage,omitempty"`
|
||||
} `json:"fingerprint,omitempty"`
|
||||
} `json:"ranges,omitempty" description:"all build num using credential"`
|
||||
} `json:"usage,omitempty" description:"all usage of credential"`
|
||||
} `json:"fingerprint,omitempty" description:"usage of credential"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
@@ -38,28 +38,28 @@ import (
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
Name string `json:"name"`
|
||||
RepoName string `json:"repoName"`
|
||||
Runtime string `json:"namespace"`
|
||||
RuntimeId string `json:"runtime_id"`
|
||||
Version string `json:"version"`
|
||||
VersionId string `json:"version_id"`
|
||||
Status string `json:"status"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
App string `json:"app"`
|
||||
AppId string `json:"app_id"`
|
||||
Description string `json:"description,omitempty"`
|
||||
WorkLoads *workLoads `json:"workloads,omitempty"`
|
||||
Services []v1.Service `json:"services,omitempty"`
|
||||
Ingresses []v1beta1.Ingress `json:"ingresses,omitempty"`
|
||||
ClusterID string `json:"cluster_id"`
|
||||
Name string `json:"name" description:"application name"`
|
||||
RepoName string `json:"repoName" description:"repo name"`
|
||||
Runtime string `json:"namespace" description:"namespace"`
|
||||
RuntimeId string `json:"runtime_id" description:"runtime id"`
|
||||
Version string `json:"version" description:"application version"`
|
||||
VersionId string `json:"version_id" description:"application version id"`
|
||||
Status string `json:"status" description:"application status"`
|
||||
UpdateTime time.Time `json:"updateTime" description:"update time"`
|
||||
CreateTime time.Time `json:"createTime" description:"create name"`
|
||||
App string `json:"app" description:"application template name"`
|
||||
AppId string `json:"app_id" description:"application template id"`
|
||||
Description string `json:"description,omitempty" description:"application description"`
|
||||
WorkLoads *workLoads `json:"workloads,omitempty" description:"application workloads"`
|
||||
Services []v1.Service `json:"services,omitempty" description:"application services"`
|
||||
Ingresses []v1beta1.Ingress `json:"ingresses,omitempty" description:"application ingresses"`
|
||||
ClusterID string `json:"cluster_id" description:"application id"`
|
||||
}
|
||||
|
||||
type workLoads struct {
|
||||
Deployments []appsv1.Deployment `json:"deployments,omitempty"`
|
||||
Statefulsets []appsv1.StatefulSet `json:"statefulsets,omitempty"`
|
||||
Daemonsets []appsv1.DaemonSet `json:"daemonsets,omitempty"`
|
||||
Deployments []appsv1.Deployment `json:"deployments,omitempty" description:"deployment list"`
|
||||
Statefulsets []appsv1.StatefulSet `json:"statefulsets,omitempty" description:"statefulset list"`
|
||||
Daemonsets []appsv1.DaemonSet `json:"daemonsets,omitempty" description:"daemonset list"`
|
||||
}
|
||||
|
||||
func ListApplication(runtimeId string, conditions *params.Conditions, limit, offset int) (*models.PageableResponse, error) {
|
||||
|
||||
@@ -79,8 +79,8 @@ const (
|
||||
)
|
||||
|
||||
type Role struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name" description:"role's name'"`
|
||||
Description string `json:"description" description:"role 's description'"`
|
||||
}
|
||||
|
||||
var DefaultRoles = []*Role{
|
||||
|
||||
@@ -68,10 +68,11 @@ func SearchPipelines(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+SearchPipelineRunUrl, projectName, pipelineName)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
@@ -82,7 +83,7 @@ func SearchPipelineRuns(projectName, pipelineName string, req *http.Request) ([]
|
||||
|
||||
func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchRunUrl, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -95,7 +96,7 @@ func GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, r
|
||||
|
||||
func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -108,7 +109,7 @@ func GetPipelineRunNodesbyBranch(projectName, pipelineName, branchName, runId st
|
||||
|
||||
func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, header, err := jenkinsClient(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -121,7 +122,7 @@ func GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, step
|
||||
|
||||
func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetStepLogUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId, stepId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, header, err := jenkinsClient(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -135,7 +136,7 @@ func GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *ht
|
||||
|
||||
func Validate(scmId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+ValidateUrl, scmId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -148,7 +149,7 @@ func Validate(scmId string, req *http.Request) ([]byte, error) {
|
||||
|
||||
func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetSCMOrgUrl+req.URL.RawQuery, scmId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -161,7 +162,7 @@ func GetSCMOrg(scmId string, req *http.Request) ([]byte, error) {
|
||||
|
||||
func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetOrgRepoUrl+req.URL.RawQuery, scmId, organizationId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -174,7 +175,7 @@ func GetOrgRepo(scmId, organizationId string, req *http.Request) ([]byte, error)
|
||||
|
||||
func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+StopBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -187,7 +188,7 @@ func StopBranchPipeline(projectName, pipelineName, branchName, runId string, req
|
||||
|
||||
func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+StopPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -200,7 +201,7 @@ func StopPipeline(projectName, pipelineName, runId string, req *http.Request) ([
|
||||
|
||||
func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+ReplayBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -213,7 +214,7 @@ func ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, r
|
||||
|
||||
func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+ReplayPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -226,7 +227,7 @@ func ReplayPipeline(projectName, pipelineName, runId string, req *http.Request)
|
||||
|
||||
func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchRunLogUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -239,7 +240,7 @@ func GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *h
|
||||
|
||||
func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetRunLogUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -252,7 +253,7 @@ func GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]by
|
||||
|
||||
func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -265,7 +266,7 @@ func GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req
|
||||
|
||||
func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetArtifactsUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -277,10 +278,10 @@ func GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([
|
||||
}
|
||||
|
||||
func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeBranchUrl, projectName, pipelineName)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
res, err := sendJenkinsRequest(baseUrl+req.URL.RawQuery, req)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
@@ -291,7 +292,7 @@ func GetPipeBranch(projectName, pipelineName string, req *http.Request) ([]byte,
|
||||
|
||||
func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+CheckBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId, stepId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -304,7 +305,7 @@ func CheckBranchPipeline(projectName, pipelineName, branchName, runId, nodeId, s
|
||||
|
||||
func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+CheckPipelineUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId, stepId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -317,7 +318,7 @@ func CheckPipeline(projectName, pipelineName, runId, nodeId, stepId string, req
|
||||
|
||||
func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetConsoleLogUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -330,7 +331,7 @@ func GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte,
|
||||
|
||||
func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+ScanBranchUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -343,7 +344,7 @@ func ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, er
|
||||
|
||||
func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+RunBranchPipelineUrl+req.URL.RawQuery, projectName, pipelineName, branchName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -356,7 +357,7 @@ func RunBranchPipeline(projectName, pipelineName, branchName string, req *http.R
|
||||
|
||||
func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+RunPipelineUrl+req.URL.RawQuery, projectName, pipelineName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -369,7 +370,7 @@ func RunPipeline(projectName, pipelineName string, req *http.Request) ([]byte, e
|
||||
|
||||
func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -382,7 +383,7 @@ func GetBranchStepsStatus(projectName, pipelineName, branchName, runId, nodeId s
|
||||
|
||||
func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetStepsStatusUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -395,7 +396,7 @@ func GetStepsStatus(projectName, pipelineName, runId, nodeId string, req *http.R
|
||||
|
||||
func GetCrumb(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GetCrumbUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -408,7 +409,7 @@ func GetCrumb(req *http.Request) ([]byte, error) {
|
||||
|
||||
func CheckScriptCompile(req *http.Request) ([]byte, error) {
|
||||
baseUrl := jenkins.Server + CheckScriptCompileUrl
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
req.SetBasicAuth(jenkins.Requester.BasicAuth.Username, jenkins.Requester.BasicAuth.Password)
|
||||
|
||||
resBody, err := sendJenkinsRequest(baseUrl, req)
|
||||
@@ -454,7 +455,7 @@ func CheckCron(req *http.Request) (*CheckCronRes, error) {
|
||||
|
||||
func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipelineRunUrl, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -467,7 +468,7 @@ func GetPipelineRun(projectName, pipelineName, runId string, req *http.Request)
|
||||
|
||||
func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeUrl, projectName, pipelineName, branchName)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -480,7 +481,7 @@ func GetBranchPipeline(projectName, pipelineName, branchName string, req *http.R
|
||||
|
||||
func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -493,7 +494,7 @@ func GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Requ
|
||||
|
||||
func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetBranchNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId, nodeId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -506,7 +507,7 @@ func GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId str
|
||||
|
||||
func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server+GetNodeStepsUrl+req.URL.RawQuery, projectName, pipelineName, runId, nodeId)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -519,7 +520,7 @@ func GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Req
|
||||
|
||||
func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJenkinsfileUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -532,7 +533,7 @@ func ToJenkinsfile(req *http.Request) ([]byte, error) {
|
||||
|
||||
func ToJson(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + ToJsonUrl)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -544,8 +545,8 @@ func ToJson(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GetNotifyCommitUrl + req.URL.RawQuery)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprint(jenkins.Server, GetNotifyCommitUrl, req.URL.RawQuery)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
req.Method = "GET"
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
@@ -558,8 +559,8 @@ func GetNotifyCommit(req *http.Request) ([]byte, error) {
|
||||
}
|
||||
|
||||
func GithubWebhook(req *http.Request) ([]byte, error) {
|
||||
baseUrl := fmt.Sprintf(jenkins.Server + GithubWebhookUrl + req.URL.RawQuery)
|
||||
log.Infof("Jenkins-url: " + baseUrl)
|
||||
baseUrl := fmt.Sprint(jenkins.Server, GithubWebhookUrl, req.URL.RawQuery)
|
||||
log.Info("Jenkins-url: " + baseUrl)
|
||||
|
||||
res, err := sendJenkinsRequest(baseUrl, req)
|
||||
if err != nil {
|
||||
@@ -572,7 +573,7 @@ func GithubWebhook(req *http.Request) ([]byte, error) {
|
||||
|
||||
func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, req *http.Request) ([]NodesDetail, error) {
|
||||
getNodesUrl := fmt.Sprintf(jenkins.Server+GetBranchPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, branchName, runId)
|
||||
log.Infof("getNodesUrl: " + getNodesUrl)
|
||||
log.Info("getNodesUrl: " + getNodesUrl)
|
||||
var wg sync.WaitGroup
|
||||
var nodesDetails []NodesDetail
|
||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||
@@ -619,7 +620,7 @@ func GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, r
|
||||
|
||||
func GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]NodesDetail, error) {
|
||||
getNodesUrl := fmt.Sprintf(jenkins.Server+GetPipeRunNodesUrl+req.URL.RawQuery, projectName, pipelineName, runId)
|
||||
log.Infof("getNodesUrl: " + getNodesUrl)
|
||||
log.Info("getNodesUrl: " + getNodesUrl)
|
||||
var wg sync.WaitGroup
|
||||
var nodesDetails []NodesDetail
|
||||
stepChan := make(chan *NodesStepsIndex, channelMaxCapacity)
|
||||
@@ -698,6 +699,7 @@ func jenkinsClient(baseUrl string, req *http.Request) ([]byte, http.Header, erro
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
log.Errorf("%+v", string(resBody))
|
||||
jkerr := new(JkError)
|
||||
jkerr.Code = resp.StatusCode
|
||||
jkerr.Message = http.StatusText(resp.StatusCode)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,11 +21,11 @@ const (
|
||||
)
|
||||
|
||||
type DevOpsProjectMembership struct {
|
||||
Username string `json:"username"`
|
||||
ProjectId string `json:"project_id" db:"project_id"`
|
||||
Role string `json:"role"`
|
||||
Status string `json:"status"`
|
||||
GrantBy string `json:"grand_by,omitempty"`
|
||||
Username string `json:"username" description:"member's username,username can uniquely identify a user"`
|
||||
ProjectId string `json:"project_id" db:"project_id" description:"the devops projects which project membership belongs to"`
|
||||
Role string `json:"role" description:"devops project membership's role type. e.g. owner '"`
|
||||
Status string `json:"status" description:"Desperated, status of project membership"`
|
||||
GrantBy string `json:"grand_by,omitempty" description:"Username of the user who assigned the role"`
|
||||
}
|
||||
|
||||
var DevOpsProjectMembershipColumns = GetColumnsFromStruct(&DevOpsProjectMembership{})
|
||||
|
||||
@@ -37,15 +37,23 @@ type PageableDevOpsProject struct {
|
||||
}
|
||||
|
||||
type DevOpsProject struct {
|
||||
ProjectId string `json:"project_id" db:"project_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Creator string `json:"creator"`
|
||||
CreateTime time.Time `json:"create_time"`
|
||||
Status string `json:"status"`
|
||||
Visibility string `json:"visibility,omitempty"`
|
||||
Extra string `json:"extra,omitempty"`
|
||||
Workspace string `json:"workspace"`
|
||||
ProjectId string `json:"project_id" db:"project_id" description:"ProjectId must be unique within a namespace, it is generated by kubesphere."`
|
||||
|
||||
Name string `json:"name" description:"DevOps Projects's Name'"`
|
||||
|
||||
Description string `json:"description,omitempty" description:"DevOps Projets's Description, used to describe the DevOps Project'"`
|
||||
|
||||
Creator string `json:"creator" description:"Creator's username'"`
|
||||
|
||||
CreateTime time.Time `json:"create_time" description:"DevOps Project's Creation time'"`
|
||||
|
||||
Status string `json:"status" description:"DevOps project's status. e.g. active"`
|
||||
|
||||
Visibility string `json:"visibility,omitempty" description:"Desperated Field"`
|
||||
|
||||
Extra string `json:"extra,omitempty" description:"Internal Use"`
|
||||
|
||||
Workspace string `json:"workspace" description:"The workspace to which the devops project belongs"`
|
||||
}
|
||||
|
||||
func NewDevOpsProject(name, description, creator, extra, workspace string) *DevOpsProject {
|
||||
|
||||
@@ -26,50 +26,49 @@ const (
|
||||
)
|
||||
|
||||
type JenkinsCredential struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
DisplayName string `json:"display_name,omitempty"`
|
||||
Id string `json:"id" description:"id of credential"`
|
||||
Type string `json:"type" description:"type of credential,such as ssh/kubeconfig"`
|
||||
DisplayName string `json:"display_name,omitempty" description:"credential's display name'"`
|
||||
Fingerprint *struct {
|
||||
FileName string `json:"file_name,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
FileName string `json:"file_name,omitempty" description:"credential's display name and description"`
|
||||
Hash string `json:"hash,omitempty" description:"credential's hash'"`
|
||||
Usage []*struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty" description:"jenkins pipeline full name"`
|
||||
Ranges struct {
|
||||
Ranges []*struct {
|
||||
Start int `json:"start,omitempty"`
|
||||
End int `json:"end,omitempty"`
|
||||
Start int `json:"start,omitempty" description:"start build number"`
|
||||
End int `json:"end,omitempty" description:"end build number"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"usage,omitempty"`
|
||||
} `json:"fingerprint,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
CreateTime *time.Time `json:"create_time,omitempty"`
|
||||
Creator string `json:"creator,omitempty"`
|
||||
UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty"`
|
||||
SshCredential *SshCredential `json:"ssh,omitempty"`
|
||||
SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty"`
|
||||
KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty"`
|
||||
} `json:"ranges,omitempty" description:"all build num using credential"`
|
||||
} `json:"usage,omitempty" description:"all usage of credential"`
|
||||
} `json:"fingerprint,omitempty" description:"usage of credential"`
|
||||
Description string `json:"description,omitempty" description:"credential's description'"`
|
||||
Domain string `json:"domain,omitempty" description:"credential's domain,In ks we only use the default domain, default '_''"`
|
||||
CreateTime *time.Time `json:"create_time,omitempty" description:"credential's create_time'"`
|
||||
Creator string `json:"creator,omitempty" description:"creator's username"`
|
||||
UsernamePasswordCredential *UsernamePasswordCredential `json:"username_password,omitempty" description:"username password credential struct"`
|
||||
SshCredential *SshCredential `json:"ssh,omitempty" description:"ssh credential struct"`
|
||||
SecretTextCredential *SecretTextCredential `json:"secret_text,omitempty" description:"secret_text credential struct"`
|
||||
KubeconfigCredential *KubeconfigCredential `json:"kubeconfig,omitempty" description:"kubeconfig credential struct"`
|
||||
}
|
||||
|
||||
type UsernamePasswordCredential struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Username string `json:"username,omitempty" description:"username of username_password credential"`
|
||||
Password string `json:"password,omitempty" description:"password of username_password credential"`
|
||||
}
|
||||
|
||||
type SshCredential struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Passphrase string `json:"passphrase,omitempty"`
|
||||
PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key"`
|
||||
Username string `json:"username,omitempty" description:"username of ssh credential"`
|
||||
Passphrase string `json:"passphrase,omitempty" description:"passphrase of ssh credential, password of ssh credential"`
|
||||
PrivateKey string `json:"private_key,omitempty" mapstructure:"private_key" description:"private key of ssh credential"`
|
||||
}
|
||||
|
||||
type SecretTextCredential struct {
|
||||
Secret string `json:"secret,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Secret string `json:"secret,omitempty" description:"secret content of credential"`
|
||||
}
|
||||
|
||||
type KubeconfigCredential struct {
|
||||
Content string `json:"content,omitempty"`
|
||||
Content string `json:"content,omitempty" description:"content of kubeconfig"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -205,7 +205,7 @@ func UpdateProjectCredential(projectId, credentialId string, credentialRequest *
|
||||
credentialId, err := jenkinsClient.UpdateSecretTextCredentialInFolder(credentialRequest.Domain,
|
||||
credentialId,
|
||||
credentialRequest.SecretTextCredential.Secret,
|
||||
credentialRequest.SecretTextCredential.Description,
|
||||
credentialRequest.Description,
|
||||
projectId)
|
||||
if err != nil {
|
||||
glog.Errorf("%+v", err)
|
||||
@@ -421,17 +421,17 @@ func formatCredentialResponse(
|
||||
response.DisplayName = jenkinsCredentialResponse.DisplayName
|
||||
if jenkinsCredentialResponse.Fingerprint != nil && jenkinsCredentialResponse.Fingerprint.Hash != "" {
|
||||
response.Fingerprint = &struct {
|
||||
FileName string `json:"file_name,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
FileName string `json:"file_name,omitempty" description:"credential's display name and description"`
|
||||
Hash string `json:"hash,omitempty" description:"credential's hash'"`
|
||||
Usage []*struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty" description:"jenkins pipeline full name"`
|
||||
Ranges struct {
|
||||
Ranges []*struct {
|
||||
Start int `json:"start,omitempty"`
|
||||
End int `json:"end,omitempty"`
|
||||
Start int `json:"start,omitempty" description:"start build number"`
|
||||
End int `json:"end,omitempty" description:"end build number"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"ranges,omitempty"`
|
||||
} `json:"usage,omitempty"`
|
||||
} `json:"ranges,omitempty" description:"all build num using credential"`
|
||||
} `json:"usage,omitempty" description:"all usage of credential"`
|
||||
}{}
|
||||
response.Fingerprint.FileName = jenkinsCredentialResponse.Fingerprint.FileName
|
||||
response.Fingerprint.Hash = jenkinsCredentialResponse.Fingerprint.Hash
|
||||
|
||||
@@ -53,99 +53,99 @@ type SonarStatus struct {
|
||||
}
|
||||
|
||||
type ProjectPipeline struct {
|
||||
Type string `json:"type"`
|
||||
Pipeline *NoScmPipeline `json:"pipeline,omitempty"`
|
||||
MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty"`
|
||||
Type string `json:"type" description:"type of devops pipeline, in scm or no scm"`
|
||||
Pipeline *NoScmPipeline `json:"pipeline,omitempty" description:"no scm pipeline structs"`
|
||||
MultiBranchPipeline *MultiBranchPipeline `json:"multi_branch_pipeline,omitempty" description:"in scm pipeline structs"`
|
||||
}
|
||||
|
||||
type NoScmPipeline struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"descriptio,omitempty"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty"`
|
||||
Parameters []*Parameter `json:"parameters,omitempty"`
|
||||
DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger"`
|
||||
RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger"`
|
||||
Jenkinsfile string `json:"jenkinsfile,omitempty"`
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"descriptio,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
Parameters []*Parameter `json:"parameters,omitempty" description:"Parameters define of pipeline,user could pass param when run pipeline"`
|
||||
DisableConcurrent bool `json:"disable_concurrent,omitempty" mapstructure:"disable_concurrent" description:"Whether to prohibit the pipeline from running in parallel"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
RemoteTrigger *RemoteTrigger `json:"remote_trigger,omitempty" mapstructure:"remote_trigger" description:"Remote api define to trigger pipeline run"`
|
||||
Jenkinsfile string `json:"jenkinsfile,omitempty" description:"Jenkinsfile's content'"`
|
||||
}
|
||||
|
||||
type MultiBranchPipeline struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger"`
|
||||
SourceType string `json:"source_type"`
|
||||
GitSource *GitSource `json:"git_source,omitempty"`
|
||||
GitHubSource *GithubSource `json:"github_source,omitempty"`
|
||||
SvnSource *SvnSource `json:"svn_source,omitempty"`
|
||||
SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty"`
|
||||
ScriptPath string `json:"script_path" mapstructure:"script_path"`
|
||||
Name string `json:"name" description:"name of pipeline"`
|
||||
Description string `json:"descriptio,omitempty" description:"description of pipeline"`
|
||||
Discarder *DiscarderProperty `json:"discarder,omitempty" description:"Discarder of pipeline, managing when to drop a pipeline"`
|
||||
TimerTrigger *TimerTrigger `json:"timer_trigger,omitempty" mapstructure:"timer_trigger" description:"Timer to trigger pipeline run"`
|
||||
SourceType string `json:"source_type" description:"type of scm, such as github/git/svn"`
|
||||
GitSource *GitSource `json:"git_source,omitempty" description:"git scm define"`
|
||||
GitHubSource *GithubSource `json:"github_source,omitempty" description:"github scm define"`
|
||||
SvnSource *SvnSource `json:"svn_source,omitempty" description:"multi branch svn scm define"`
|
||||
SingleSvnSource *SingleSvnSource `json:"single_svn_source,omitempty" description:"single branch svn scm define"`
|
||||
ScriptPath string `json:"script_path" mapstructure:"script_path" description:"script path in scm"`
|
||||
}
|
||||
|
||||
type GitSource struct {
|
||||
Url string `json:"url,omitempty" mapstructure:"url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"`
|
||||
DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter"`
|
||||
Url string `json:"url,omitempty" mapstructure:"url" description:"url of git source"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access git source"`
|
||||
DiscoverBranches bool `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Whether to discover a branch"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
type GithubSource struct {
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri"`
|
||||
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches"`
|
||||
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin"`
|
||||
DiscoverPRFromForks *GithubDiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter"`
|
||||
Owner string `json:"owner,omitempty" mapstructure:"owner" description:"owner of github repo"`
|
||||
Repo string `json:"repo,omitempty" mapstructure:"repo" description:"repo name of github repo"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access github source"`
|
||||
ApiUri string `json:"api_uri,omitempty" mapstructure:"api_uri" description:"The api url can specify the location of the github apiserver.For private cloud configuration"`
|
||||
DiscoverBranches int `json:"discover_branches,omitempty" mapstructure:"discover_branches" description:"Discover branch configuration"`
|
||||
DiscoverPRFromOrigin int `json:"discover_pr_from_origin,omitempty" mapstructure:"discover_pr_from_origin" description:"Discover origin PR configuration"`
|
||||
DiscoverPRFromForks *GithubDiscoverPRFromForks `json:"discover_pr_from_forks,omitempty" mapstructure:"discover_pr_from_forks" description:"Discover fork PR configuration"`
|
||||
CloneOption *GitCloneOption `json:"git_clone_option,omitempty" mapstructure:"git_clone_option" description:"advavced git clone options"`
|
||||
RegexFilter string `json:"regex_filter,omitempty" mapstructure:"regex_filter" description:"Regex used to match the name of the branch that needs to be run"`
|
||||
}
|
||||
|
||||
type GitCloneOption struct {
|
||||
Shallow bool `json:"shallow,omitempty" mapstructure:"shallow"`
|
||||
Timeout int `json:"timeout,omitempty" mapstructure:"timeout"`
|
||||
Depth int `json:"depth,omitempty" mapstructure:"depth"`
|
||||
Shallow bool `json:"shallow,omitempty" mapstructure:"shallow" description:"Whether to use git shallow clone"`
|
||||
Timeout int `json:"timeout,omitempty" mapstructure:"timeout" description:"git clone timeout mins"`
|
||||
Depth int `json:"depth,omitempty" mapstructure:"depth" description:"git clone depth"`
|
||||
}
|
||||
|
||||
type SvnSource struct {
|
||||
Remote string `json:"remote,omitempty"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"`
|
||||
Includes string `json:"includes,omitempty"`
|
||||
Excludes string `json:"excludes,omitempty"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
Includes string `json:"includes,omitempty" description:"branches to run pipeline"`
|
||||
Excludes string `json:"excludes,omitempty" description:"branches do not run pipeline"`
|
||||
}
|
||||
type SingleSvnSource struct {
|
||||
Remote string `json:"remote,omitempty"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id"`
|
||||
Remote string `json:"remote,omitempty" description:"remote address url"`
|
||||
CredentialId string `json:"credential_id,omitempty" mapstructure:"credential_id" description:"credential id to access svn source"`
|
||||
}
|
||||
|
||||
type GithubDiscoverPRFromForks struct {
|
||||
Strategy int `json:"strategy,omitempty" mapstructure:"strategy"`
|
||||
Trust int `json:"trust,omitempty" mapstructure:"trust"`
|
||||
Strategy int `json:"strategy,omitempty" mapstructure:"strategy" description:"github discover startegy"`
|
||||
Trust int `json:"trust,omitempty" mapstructure:"trust" description:"trust user type"`
|
||||
}
|
||||
|
||||
type DiscarderProperty struct {
|
||||
DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep"`
|
||||
NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep"`
|
||||
DaysToKeep string `json:"days_to_keep,omitempty" mapstructure:"days_to_keep" description:"days to keep pipeline"`
|
||||
NumToKeep string `json:"num_to_keep,omitempty" mapstructure:"num_to_keep" description:"nums to keep pipeline"`
|
||||
}
|
||||
|
||||
type Parameter struct {
|
||||
Name string `json:"name"`
|
||||
DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value"`
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Name string `json:"name" description:"name of param"`
|
||||
DefaultValue string `json:"default_value,omitempty" mapstructure:"default_value" description:"default value of param"`
|
||||
Type string `json:"type" description:"type of param"`
|
||||
Description string `json:"description,omitempty" description:"description of pipeline"`
|
||||
}
|
||||
|
||||
type TimerTrigger struct {
|
||||
// user in no scm job
|
||||
Cron string `json:"cron,omitempty"`
|
||||
Cron string `json:"cron,omitempty" description:"jenkins cron script"`
|
||||
|
||||
// use in multi-branch job
|
||||
Interval string `json:"interval,omitempty"`
|
||||
Interval string `json:"interval,omitempty" description:"interval ms"`
|
||||
}
|
||||
|
||||
type RemoteTrigger struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
Token string `json:"token,omitempty" description:"remote trigger token"`
|
||||
}
|
||||
|
||||
func replaceXmlVersion(config, oldVersion, targetVersion string) string {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type AuthInfo struct {
|
||||
RemoteUrl string `json:"remoteUrl"`
|
||||
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`
|
||||
RemoteUrl string `json:"remoteUrl" description:"git server url"`
|
||||
SecretRef *corev1.SecretReference `json:"secretRef,omitempty" description:"auth secret reference"`
|
||||
}
|
||||
|
||||
func GitReadVerify(namespace string, authInfo AuthInfo) error {
|
||||
|
||||
@@ -48,6 +48,6 @@ type FluentbitFiltersResult struct {
|
||||
}
|
||||
|
||||
type FluentbitOutputsResult struct {
|
||||
Status int `json:"status"`
|
||||
Outputs []fb.OutputPlugin `json:"outputs,omitempty"`
|
||||
Status int `json:"status" description:"response status"`
|
||||
Outputs []fb.OutputPlugin `json:"outputs,omitempty" description:"array of fluent bit output plugins"`
|
||||
}
|
||||
|
||||
@@ -47,19 +47,19 @@ const (
|
||||
)
|
||||
|
||||
type FormatedLevelMetric struct {
|
||||
MetricsLevel string `json:"metrics_level"`
|
||||
Results []FormatedMetric `json:"results"`
|
||||
MetricsLevel string `json:"metrics_level" description:"metrics level, eg. cluster"`
|
||||
Results []FormatedMetric `json:"results" description:"actual array of results"`
|
||||
}
|
||||
|
||||
type FormatedMetric struct {
|
||||
MetricName string `json:"metric_name,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Data FormatedMetricData `json:"data,omitempty"`
|
||||
MetricName string `json:"metric_name,omitempty" description:"metrics name, eg. scheduler_up_sum"`
|
||||
Status string `json:"status" description:"result status, one of error, success"`
|
||||
Data FormatedMetricData `json:"data,omitempty" description:"actual metrics result"`
|
||||
}
|
||||
|
||||
type FormatedMetricData struct {
|
||||
Result []map[string]interface{} `json:"result"`
|
||||
ResultType string `json:"resultType"`
|
||||
Result []map[string]interface{} `json:"result" description:"result presenting metric labels, a series of time points and their instant values"`
|
||||
ResultType string `json:"resultType" description:"result type, one of matrix, vector"`
|
||||
}
|
||||
|
||||
type MetricResultValues []MetricResultValue
|
||||
|
||||
@@ -28,9 +28,9 @@ import (
|
||||
)
|
||||
|
||||
type AuthInfo struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
ServerHost string `json:"serverhost"`
|
||||
Username string `json:"username" description:"username"`
|
||||
Password string `json:"password" description:"password"`
|
||||
ServerHost string `json:"serverhost" description:"registry server host"`
|
||||
}
|
||||
|
||||
const loginSuccess = "Login Succeeded"
|
||||
|
||||
@@ -26,14 +26,14 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/models/resources"
|
||||
)
|
||||
|
||||
type workLoadStatus struct {
|
||||
Namespace string `json:"namespace"`
|
||||
Count map[string]int `json:"data"`
|
||||
Items map[string]interface{} `json:"items,omitempty"`
|
||||
type WorkLoadStatus struct {
|
||||
Namespace string `json:"namespace" description:"namespace"`
|
||||
Count map[string]int `json:"data" description:"unhealthy workload count"`
|
||||
Items map[string]interface{} `json:"items,omitempty" description:"unhealthy workloads"`
|
||||
}
|
||||
|
||||
func GetNamespacesResourceStatus(namespace string) (*workLoadStatus, error) {
|
||||
res := workLoadStatus{Count: make(map[string]int), Namespace: namespace, Items: make(map[string]interface{})}
|
||||
func GetNamespacesResourceStatus(namespace string) (*WorkLoadStatus, error) {
|
||||
res := WorkLoadStatus{Count: make(map[string]int), Namespace: namespace, Items: make(map[string]interface{})}
|
||||
var notReadyList *models.PageableResponse
|
||||
var err error
|
||||
for _, resource := range []string{resources.Deployments, resources.StatefulSets, resources.DaemonSets, resources.PersistentVolumeClaims, resources.Jobs} {
|
||||
@@ -61,7 +61,7 @@ func GetNamespacesResourceStatus(namespace string) (*workLoadStatus, error) {
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func GetClusterResourceStatus() (*workLoadStatus, error) {
|
||||
func GetClusterResourceStatus() (*WorkLoadStatus, error) {
|
||||
|
||||
return GetNamespacesResourceStatus("")
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
)
|
||||
|
||||
type PageableResponse struct {
|
||||
Items []interface{} `json:"items"`
|
||||
TotalCount int `json:"total_count"`
|
||||
Items []interface{} `json:"items" description:"paging data"`
|
||||
TotalCount int `json:"total_count" description:"total count"`
|
||||
}
|
||||
|
||||
type Workspace struct {
|
||||
@@ -47,8 +47,8 @@ type Rule struct {
|
||||
}
|
||||
|
||||
type SimpleRule struct {
|
||||
Name string `json:"name"`
|
||||
Actions []string `json:"actions"`
|
||||
Name string `json:"name" description:"rule name"`
|
||||
Actions []string `json:"actions" description:"actions"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
@@ -82,26 +82,26 @@ type Group struct {
|
||||
}
|
||||
|
||||
type Component struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
SelfLink string `json:"selfLink"`
|
||||
Label interface{} `json:"label"`
|
||||
StartedAt time.Time `json:"startedAt"`
|
||||
TotalBackends int `json:"totalBackends"`
|
||||
HealthyBackends int `json:"healthyBackends"`
|
||||
Name string `json:"name" description:"component name"`
|
||||
Namespace string `json:"namespace" description:"namespace"`
|
||||
SelfLink string `json:"selfLink" description:"self link"`
|
||||
Label interface{} `json:"label" description:"labels"`
|
||||
StartedAt time.Time `json:"startedAt" description:"started time"`
|
||||
TotalBackends int `json:"totalBackends" description:"total backends"`
|
||||
HealthyBackends int `json:"healthyBackends" description:"healthy backends"`
|
||||
}
|
||||
|
||||
type PodInfo struct {
|
||||
Namespace string `json:"namespace"`
|
||||
Pod string `json:"pod"`
|
||||
Container string `json:"container"`
|
||||
Namespace string `json:"namespace" description:"namespace"`
|
||||
Pod string `json:"pod" description:"pod name"`
|
||||
Container string `json:"container" description:"container name"`
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
Token string `json:"access_token"`
|
||||
Token string `json:"access_token" description:"access token"`
|
||||
}
|
||||
|
||||
type ResourceQuota struct {
|
||||
Namespace string `json:"namespace"`
|
||||
Data corev1.ResourceQuotaStatus `json:"data"`
|
||||
Namespace string `json:"namespace" description:"namespace"`
|
||||
Data corev1.ResourceQuotaStatus `json:"data" description:"resource quota status"`
|
||||
}
|
||||
|
||||
@@ -137,12 +137,9 @@ type ContainerHighLightField struct {
|
||||
type EmptyField struct {
|
||||
}
|
||||
|
||||
// The aggs object holds two aggregations to be computed by Elasticsearch
|
||||
// ContainterAgg is a cardinality aggregation to calculate the count of distinct containers
|
||||
// StartTimeAgg is a top hits aggregation to retrieve the first record
|
||||
// StatisticsAggs, the struct for `aggs` of type Request, holds a cardinality aggregation for distinct container counting
|
||||
type StatisticsAggs struct {
|
||||
ContainerAgg ContainerAgg `json:"containers"`
|
||||
StartTimeAgg StartTimeAgg `json:"starttime"`
|
||||
}
|
||||
|
||||
type ContainerAgg struct {
|
||||
@@ -153,15 +150,6 @@ type AggField struct {
|
||||
Field string `json:"field"`
|
||||
}
|
||||
|
||||
type StartTimeAgg struct {
|
||||
TopHits TopHits `json:"top_hits"`
|
||||
}
|
||||
|
||||
type TopHits struct {
|
||||
Sort []Sort `json:"sort"`
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
type HistogramAggs struct {
|
||||
HistogramAgg HistogramAgg `json:"histogram"`
|
||||
}
|
||||
@@ -255,8 +243,7 @@ func createQueryRequest(param QueryParameters) (int, []byte, error) {
|
||||
if param.Operation == "statistics" {
|
||||
operation = OperationStatistics
|
||||
containerAgg := AggField{"kubernetes.docker_id.keyword"}
|
||||
startTimeAgg := TopHits{[]Sort{{Order{"asc"}}}, 1}
|
||||
statisticAggs := StatisticsAggs{ContainerAgg{containerAgg}, StartTimeAgg{startTimeAgg}}
|
||||
statisticAggs := StatisticsAggs{ContainerAgg{containerAgg}}
|
||||
request.Aggs = statisticAggs
|
||||
request.Size = 0
|
||||
} else if param.Operation == "histogram" {
|
||||
@@ -299,49 +286,49 @@ func createQueryRequest(param QueryParameters) (int, []byte, error) {
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Status int `json:"status"`
|
||||
Workspace string `json:"workspace,omitempty"`
|
||||
Shards Shards `json:"_shards"`
|
||||
Hits Hits `json:"hits"`
|
||||
Aggregations json.RawMessage `json:"aggregations"`
|
||||
Status int `json:"status" description:"query status"`
|
||||
Workspace string `json:"workspace,omitempty" description:"workspace the query was performed against"`
|
||||
Shards Shards `json:"_shards" description:"tells shard information"`
|
||||
Hits Hits `json:"hits" description:"search results"`
|
||||
Aggregations json.RawMessage `json:"aggregations" description:"aggregation results"`
|
||||
}
|
||||
|
||||
type Shards struct {
|
||||
Total int64 `json:"total"`
|
||||
Successful int64 `json:"successful"`
|
||||
Skipped int64 `json:"skipped"`
|
||||
Failed int64 `json:"failed"`
|
||||
Total int64 `json:"total" description:"tells how many shards were searched"`
|
||||
Successful int64 `json:"successful" description:"count of the successful searched shards"`
|
||||
Skipped int64 `json:"skipped" description:"count of the skipped searched shards"`
|
||||
Failed int64 `json:"failed" description:"count of the failed searched shards"`
|
||||
}
|
||||
|
||||
type Hits struct {
|
||||
Total int64 `json:"total"`
|
||||
Hits []Hit `json:"hits"`
|
||||
Total int64 `json:"total" description:"total number of documents matching our search criteria"`
|
||||
Hits []Hit `json:"hits" description:"actual array of search results"`
|
||||
}
|
||||
|
||||
type Hit struct {
|
||||
Source Source `json:"_source"`
|
||||
HighLight HighLight `json:"highlight"`
|
||||
Sort []int64 `json:"sort"`
|
||||
Source Source `json:"_source" description:"search result item"`
|
||||
HighLight HighLight `json:"highlight" description:"highlighted log fragment"`
|
||||
Sort []int64 `json:"sort" description:"sort key for results"`
|
||||
}
|
||||
|
||||
type Source struct {
|
||||
Log string `json:"log"`
|
||||
Time string `json:"time"`
|
||||
Kubernetes Kubernetes `json:"kubernetes"`
|
||||
Log string `json:"log" description:"the log message"`
|
||||
Time string `json:"time" description:"log timestamp"`
|
||||
Kubernetes Kubernetes `json:"kubernetes" description:"kubernetes addon information on the log"`
|
||||
}
|
||||
|
||||
type Kubernetes struct {
|
||||
Namespace string `json:"namespace_name"`
|
||||
Pod string `json:"pod_name"`
|
||||
Container string `json:"container_name"`
|
||||
Host string `json:"host"`
|
||||
Namespace string `json:"namespace_name" description:"the namespace the log is from"`
|
||||
Pod string `json:"pod_name" description:"the pod the log is from"`
|
||||
Container string `json:"container_name" description:"the container the log is from"`
|
||||
Host string `json:"host" description:"the node the log if from"`
|
||||
}
|
||||
|
||||
type HighLight struct {
|
||||
LogHighLights []string `json:"log,omitempty"`
|
||||
NamespaceHighLights []string `json:"kubernetes.namespace_name.keyword,omitempty"`
|
||||
PodHighLights []string `json:"kubernetes.pod_name.keyword,omitempty"`
|
||||
ContainerHighLights []string `json:"kubernetes.container_name.keyword,omitempty"`
|
||||
LogHighLights []string `json:"log,omitempty" description:"log messages to highlight"`
|
||||
NamespaceHighLights []string `json:"kubernetes.namespace_name.keyword,omitempty" description:"namespaces to highlight"`
|
||||
PodHighLights []string `json:"kubernetes.pod_name.keyword,omitempty" description:"pods to highlight"`
|
||||
ContainerHighLights []string `json:"kubernetes.container_name.keyword,omitempty" description:"containers to highlight"`
|
||||
}
|
||||
|
||||
type LogRecord struct {
|
||||
@@ -361,20 +348,15 @@ type ReadResult struct {
|
||||
Records []LogRecord `json:"records,omitempty"`
|
||||
}
|
||||
|
||||
// The aggregations object represents the return from an aggregation (see StatisticsAggs type)
|
||||
// StatisticsResponseAggregations, the struct for `aggregations` of type Reponse, holds return results from the aggregation StatisticsAggs
|
||||
type StatisticsResponseAggregations struct {
|
||||
ContainerCount ContainerCount `json:"containers"`
|
||||
StartTime StartTimeTopHit `json:"starttime"`
|
||||
ContainerCount ContainerCount `json:"containers"`
|
||||
}
|
||||
|
||||
type ContainerCount struct {
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
|
||||
type StartTimeTopHit struct {
|
||||
Hits Hits `json:"hits"`
|
||||
}
|
||||
|
||||
type HistogramAggregations struct {
|
||||
HistogramAggregation HistogramAggregation `json:"histogram"`
|
||||
}
|
||||
@@ -396,7 +378,6 @@ type HistogramRecord struct {
|
||||
type StatisticsResult struct {
|
||||
Containers int64 `json:"containers"`
|
||||
Logs int64 `json:"logs"`
|
||||
StartTime int64 `json:"starttime"`
|
||||
}
|
||||
|
||||
type HistogramResult struct {
|
||||
@@ -460,13 +441,14 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [
|
||||
if response.Status != 0 {
|
||||
//Elastic error, eg, es_rejected_execute_exception
|
||||
queryResult.Status = response.Status
|
||||
glog.Errorln("The query failed with no response")
|
||||
return &queryResult
|
||||
}
|
||||
|
||||
if response.Shards.Successful != response.Shards.Total {
|
||||
//Elastic some shards error
|
||||
queryResult.Status = http.StatusInternalServerError
|
||||
return &queryResult
|
||||
glog.Warningf("Not all shards succeed, successful shards: %d, skipped shards: %d, failed shards: %d",
|
||||
response.Shards.Successful, response.Shards.Skipped, response.Shards.Failed)
|
||||
}
|
||||
|
||||
switch operation {
|
||||
@@ -496,8 +478,7 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [
|
||||
queryResult.Status = http.StatusInternalServerError
|
||||
return &queryResult
|
||||
}
|
||||
queryResult.Statistics = &StatisticsResult{Containers: statisticsResponse.ContainerCount.Value,
|
||||
Logs: statisticsResponse.StartTime.Hits.Total, StartTime: statisticsResponse.StartTime.Hits.Hits[0].Sort[0]}
|
||||
queryResult.Statistics = &StatisticsResult{Containers: statisticsResponse.ContainerCount.Value, Logs: response.Hits.Total}
|
||||
|
||||
case OperationHistogram:
|
||||
var histogramResult HistogramResult
|
||||
@@ -583,6 +564,7 @@ func Query(param QueryParameters) *QueryResult {
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("http://%s:%s/%s*/_search", es.Host, es.Port, es.Index)
|
||||
|
||||
request, err := http.NewRequest("GET", url, bytes.NewBuffer(query))
|
||||
if err != nil {
|
||||
glog.Errorln(err)
|
||||
|
||||
@@ -64,24 +64,24 @@ type FluentBitStatus struct {
|
||||
|
||||
// Plugin struct for fluent-bit plugins
|
||||
type Plugin struct {
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Parameters []Parameter `json:"parameters"`
|
||||
Type string `json:"type" description:"output plugin type, eg. fluentbit-output-es"`
|
||||
Name string `json:"name" description:"output plugin name, eg. fluentbit-output-es"`
|
||||
Parameters []Parameter `json:"parameters" description:"output plugin configuration parameters"`
|
||||
}
|
||||
|
||||
// Fluent-bit output plugins
|
||||
type OutputPlugin struct {
|
||||
Plugin
|
||||
Id string `json:"id"`
|
||||
Enable bool `json:"enable"`
|
||||
Updatetime time.Time `json:"updatetime,omitempty"`
|
||||
Id string `json:"id,omitempty" description:"output plugin uuid"`
|
||||
Enable bool `json:"enable" description:"current output plugin status, one of true, false"`
|
||||
Updatetime time.Time `json:"updatetime,omitempty" description:"last updatetime of the output plugin"`
|
||||
}
|
||||
|
||||
// Parameter generic parameter type to handle values from different sources
|
||||
type Parameter struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" description:"configuration parameter key, eg. Name. refer to fluent bit official doc for more information."`
|
||||
ValueFrom *ValueFrom `json:"valueFrom,omitempty"`
|
||||
Value string `json:"value"`
|
||||
Value string `json:"value" description:"configuration parameter value, eg. es. refer to fluent bit official doc for more information."`
|
||||
}
|
||||
|
||||
// ValueFrom generic type to determine value origin
|
||||
|
||||
@@ -26,12 +26,12 @@ import (
|
||||
"github.com/emicklei/go-restful-openapi"
|
||||
"github.com/go-openapi/spec"
|
||||
"io/ioutil"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/iam/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/logging/install"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
"log"
|
||||
// Install apis
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/devops/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/iam/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/logging/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/monitoring/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/operations/install"
|
||||
_ "kubesphere.io/kubesphere/pkg/apis/resources/install"
|
||||
@@ -78,7 +78,7 @@ func enrichSwaggerObject(swo *spec.Swagger) {
|
||||
Contact: &spec.ContactInfo{
|
||||
Name: "kubesphere",
|
||||
Email: "kubesphere@yunify.com",
|
||||
URL: "kubesphere.io",
|
||||
URL: "https://kubesphere.io",
|
||||
},
|
||||
License: &spec.License{
|
||||
Name: "Apache",
|
||||
|
||||
Reference in New Issue
Block a user