register.go 51.7 KB
Newer Older
S
sunzhu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*

  Copyright 2019 The KubeSphere Authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

R
update  
runzexia 已提交
17
*/
18

S
sunzhu 已提交
19 20 21 22 23 24
package v1alpha2

import (
	"github.com/emicklei/go-restful"
	"github.com/emicklei/go-restful-openapi"
	"k8s.io/apimachinery/pkg/runtime/schema"
25
	devopsapi "kubesphere.io/kubesphere/pkg/apiserver/devops"
S
sunzhu 已提交
26
	"kubesphere.io/kubesphere/pkg/apiserver/runtime"
27
	"kubesphere.io/kubesphere/pkg/models/devops"
R
runzexia 已提交
28

R
runzexia 已提交
29
	"kubesphere.io/kubesphere/pkg/params"
R
runzexia 已提交
30
	"net/http"
S
sunzhu 已提交
31 32
)

R
runzexia 已提交
33 34 35 36
const (
	GroupName = "devops.kubesphere.io"
	RespOK    = "ok"
)
S
sunzhu 已提交
37 38 39 40 41 42 43 44 45

var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}

var (
	WebServiceBuilder = runtime.NewContainerBuilder(addWebService)
	AddToContainer    = WebServiceBuilder.AddToContainer
)

func addWebService(c *restful.Container) error {
46

S
sunzhu 已提交
47 48
	webservice := runtime.NewWebService(GroupVersion)

49 50 51 52 53 54
	tags := []string{"DevOps"}

	webservice.Route(webservice.GET("/devops/{devops}").
		To(devopsapi.GetDevOpsProjectHandler).
		Doc("get devops project").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
55
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
56
		Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
R
runzexia 已提交
57
		Writes(devops.DevOpsProject{}))
58 59 60 61 62

	webservice.Route(webservice.PATCH("/devops/{devops}").
		To(devopsapi.UpdateProjectHandler).
		Doc("get devops project").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
63
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
64
		Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
R
runzexia 已提交
65
		Writes(devops.DevOpsProject{}))
66 67 68 69 70

	webservice.Route(webservice.GET("/devops/{devops}/defaultroles").
		To(devopsapi.GetDevOpsProjectDefaultRoles).
		Doc("get devops project defaultroles").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
71
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
72
		Returns(http.StatusOK, RespOK, []devops.Role{}).
R
runzexia 已提交
73
		Writes([]devops.Role{}))
74 75 76 77 78

	webservice.Route(webservice.GET("/devops/{devops}/members").
		To(devopsapi.GetDevOpsProjectMembersHandler).
		Doc("get devops project members").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
79 80 81 82 83 84 85 86
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.QueryParameter(params.PagingParam, "page").
			Required(false).
			DataFormat("limit=%d,page=%d").
			DefaultValue("limit=10,page=1")).
		Param(webservice.QueryParameter(params.ConditionsParam, "query conditions").
			Required(false).
			DataFormat("key=%s,key~%s")).
R
runzexia 已提交
87
		Returns(http.StatusOK, RespOK, []devops.DevOpsProjectMembership{}).
R
runzexia 已提交
88
		Writes([]devops.DevOpsProjectMembership{}))
89 90 91 92 93

	webservice.Route(webservice.GET("/devops/{devops}/members/{members}").
		To(devopsapi.GetDevOpsProjectMemberHandler).
		Doc("get devops project member").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
94 95
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("members", "member's username")).
R
runzexia 已提交
96
		Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
R
runzexia 已提交
97
		Writes(devops.DevOpsProjectMembership{}))
98 99 100 101 102

	webservice.Route(webservice.POST("/devops/{devops}/members").
		To(devopsapi.AddDevOpsProjectMemberHandler).
		Doc("add devops project members").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
103
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
104
		Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
R
runzexia 已提交
105 106 107 108 109 110
		Writes(devops.DevOpsProjectMembership{}))

	webservice.Route(webservice.PATCH("/devops/{devops}/members/{members}").
		To(devopsapi.UpdateDevOpsProjectMemberHandler).
		Doc("update devops project members").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
111 112
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("members", "member's username")).
R
runzexia 已提交
113 114 115 116 117 118 119
		Reads(devops.DevOpsProjectMembership{}).
		Writes(devops.DevOpsProjectMembership{}))

	webservice.Route(webservice.DELETE("/devops/{devops}/members/{members}").
		To(devopsapi.DeleteDevOpsProjectMemberHandler).
		Doc("delete devops project members").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
120 121
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("members", "member's username")).
R
runzexia 已提交
122 123
		Writes(devops.DevOpsProjectMembership{}))

R
runzexia 已提交
124 125 126
	webservice.Route(webservice.POST("/devops/{devops}/pipelines").
		To(devopsapi.CreateDevOpsProjectPipelineHandler).
		Doc("add devops project pipeline").
R
runzexia 已提交
127
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
128
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
129
		Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
R
runzexia 已提交
130 131 132
		Writes(devops.ProjectPipeline{}).
		Reads(devops.ProjectPipeline{}))

R
runzexia 已提交
133 134
	webservice.Route(webservice.PUT("/devops/{devops}/pipelines/{pipelines}").
		To(devopsapi.UpdateDevOpsProjectPipelineHandler).
R
runzexia 已提交
135
		Doc("update devops project pipeline").
R
runzexia 已提交
136
		Param(webservice.PathParameter("devops", "devops project's Id")).
S
soulseen 已提交
137
		Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
runzexia 已提交
138
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
139
		Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
R
runzexia 已提交
140 141 142
		Writes(devops.ProjectPipeline{}).
		Reads(devops.ProjectPipeline{}))

R
runzexia 已提交
143 144 145 146
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/config").
		To(devopsapi.GetDevOpsProjectPipelineHandler).
		Doc("get devops project pipeline config").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
147
		Param(webservice.PathParameter("devops", "devops project's Id")).
S
soulseen 已提交
148
		Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
runzexia 已提交
149
		Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
R
runzexia 已提交
150
		Writes(devops.ProjectPipeline{}))
R
runzexia 已提交
151

R
runzexia 已提交
152 153 154 155
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/sonarStatus").
		To(devopsapi.GetPipelineSonarStatusHandler).
		Doc("get devops project pipeline sonarStatus").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
156
		Param(webservice.PathParameter("devops", "devops project's Id")).
S
soulseen 已提交
157
		Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
runzexia 已提交
158
		Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
R
runzexia 已提交
159
		Writes([]devops.SonarStatus{}))
R
runzexia 已提交
160

R
runzexia 已提交
161 162 163 164
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/branches/{branches}/sonarStatus").
		To(devopsapi.GetMultiBranchesPipelineSonarStatusHandler).
		Doc("get devops project pipeline sonarStatus").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
165
		Param(webservice.PathParameter("devops", "devops project's Id")).
S
soulseen 已提交
166
		Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
runzexia 已提交
167
		Param(webservice.PathParameter("branches", "branch name")).
R
runzexia 已提交
168
		Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
R
runzexia 已提交
169
		Writes([]devops.SonarStatus{}))
R
runzexia 已提交
170

R
runzexia 已提交
171 172 173
	webservice.Route(webservice.DELETE("/devops/{devops}/pipelines/{pipelines}").
		To(devopsapi.DeleteDevOpsProjectPipelineHandler).
		Doc("delete devops project pipeline").
R
runzexia 已提交
174
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
175
		Param(webservice.PathParameter("devops", "devops project's Id")).
S
soulseen 已提交
176
		Param(webservice.PathParameter("pipelines", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")))
R
runzexia 已提交
177 178 179 180

	webservice.Route(webservice.POST("/devops/{devops}/credentials").
		To(devopsapi.CreateDevOpsProjectCredentialHandler).
		Doc("add project credential pipeline").
181
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
182
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
183 184 185 186 187 188
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.PUT("/devops/{devops}/credentials/{credentials}").
		To(devopsapi.UpdateDevOpsProjectCredentialHandler).
		Doc("update project credential pipeline").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
189 190
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")).
R
runzexia 已提交
191 192 193 194 195
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.DELETE("/devops/{devops}/credentials/{credentials}").
		To(devopsapi.DeleteDevOpsProjectCredentialHandler).
		Doc("delete project credential pipeline").
196
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
197 198
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")))
R
runzexia 已提交
199 200 201 202 203

	webservice.Route(webservice.GET("/devops/{devops}/credentials/{credentials}").
		To(devopsapi.GetDevOpsProjectCredentialHandler).
		Doc("get project credential pipeline").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
204 205 206 207
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")).
		Param(webservice.QueryParameter("domain", "credential's domain")).
		Param(webservice.QueryParameter("content", "get additional content")).
R
runzexia 已提交
208
		Returns(http.StatusOK, RespOK, devops.JenkinsCredential{}).
R
runzexia 已提交
209 210 211 212 213 214
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.GET("/devops/{devops}/credentials").
		To(devopsapi.GetDevOpsProjectCredentialsHandler).
		Doc("get project credential pipeline").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
215 216 217
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")).
		Param(webservice.QueryParameter("domain", "credential's domain")).
R
runzexia 已提交
218
		Returns(http.StatusOK, RespOK, []devops.JenkinsCredential{}).
R
runzexia 已提交
219
		Reads([]devops.JenkinsCredential{}))
S
sunzhu 已提交
220 221 222

	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}").
223
		To(devopsapi.GetPipeline).
S
sunzhu 已提交
224 225
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get DevOps Pipelines.").
S
soulseen 已提交
226 227
		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, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
R
runzexia 已提交
228
		Returns(http.StatusOK, RespOK, devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
229
		Writes(devops.Pipeline{}))
S
sunzhu 已提交
230 231 232

	// match Jenkisn api: "jenkins_api/blue/rest/search"
	webservice.Route(webservice.GET("/devops/search").
233
		To(devopsapi.SearchPipelines).
S
sunzhu 已提交
234 235
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Search DevOps resource.").
S
soulseen 已提交
236
		Param(webservice.QueryParameter("q", "query pipelines, condition for filtering.").
S
soulseen 已提交
237 238
			Required(false).
			DataFormat("q=%s")).
S
soulseen 已提交
239
		Param(webservice.QueryParameter("filter", "Condition for filteringfilter folders or not..").
S
soulseen 已提交
240 241
			Required(false).
			DataFormat("filter=%s")).
S
soulseen 已提交
242
		Param(webservice.QueryParameter("start", "the count of item start.").
S
soulseen 已提交
243 244
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
245
		Param(webservice.QueryParameter("limit", "the count of item limit.").
S
soulseen 已提交
246
			Required(false).
Z
Zhuxiaoyang 已提交
247
			DataFormat("limit=%d")).
R
runzexia 已提交
248
		Returns(http.StatusOK, RespOK, []devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
249
		Writes([]devops.Pipeline{}))
S
sunzhu 已提交
250 251 252

	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs").
253
		To(devopsapi.SearchPipelineRuns).
S
sunzhu 已提交
254
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
255
		Doc("Search DevOps Pipelines runs in branch.").
S
soulseen 已提交
256 257 258
		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, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		Param(webservice.QueryParameter("start", "the count of item start.").
S
soulseen 已提交
259 260
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
261
		Param(webservice.QueryParameter("limit", "the count of item limit.").
S
soulseen 已提交
262
			Required(false).
Z
Zhuxiaoyang 已提交
263
			DataFormat("limit=%d")).
S
soulseen 已提交
264
		Param(webservice.QueryParameter("branch", "the name of branch, same as repository brnach, will be filter by branch.").
Z
Zhuxiaoyang 已提交
265 266
			Required(false).
			DataFormat("branch=%s")).
Z
Zhuxiaoyang 已提交
267 268
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}).
		Writes([]devops.BranchPipelineRun{}))
S
sunzhu 已提交
269 270 271

	// match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}").
Z
Zhuxiaoyang 已提交
272
		To(devopsapi.GetBranchPipelineRun).
S
sunzhu 已提交
273
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
274
		Doc("Get DevOps Pipelines run in branch.").
S
soulseen 已提交
275 276 277 278 279
		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, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
280 281
			Required(false).
			DataFormat("start=%d")).
Z
Zhuxiaoyang 已提交
282 283
		Returns(http.StatusOK, RespOK, devops.BranchPipelineRun{}).
		Writes(devops.BranchPipelineRun{}))
S
sunzhu 已提交
284 285 286

	// match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes").
Z
Zhuxiaoyang 已提交
287
		To(devopsapi.GetPipelineRunNodesbyBranch).
S
sunzhu 已提交
288 289
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get node on DevOps Pipelines run.").
S
soulseen 已提交
290 291 292 293 294
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
S
sunzhu 已提交
295 296
			Required(false).
			DataFormat("limit=%d").
Z
Zhuxiaoyang 已提交
297
			DefaultValue("limit=10000")).
Z
Zhuxiaoyang 已提交
298 299
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRunNodes{}).
		Writes([]devops.BranchPipelineRunNodes{}))
S
sunzhu 已提交
300 301 302

	// match "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log/?start=0"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log").
Z
Zhuxiaoyang 已提交
303
		To(devopsapi.GetBranchStepLog).
S
sunzhu 已提交
304
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
305 306
		Doc("Get pipelines step log.").
		Produces("text/plain; charset=utf-8").
S
soulseen 已提交
307 308 309 310 311 312 313
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
S
sunzhu 已提交
314 315 316 317
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
318 319 320 321 322 323
	// match "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log/?start=0"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}/log").
		To(devopsapi.GetStepLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipelines step log.").
		Produces("text/plain; charset=utf-8").
S
soulseen 已提交
324 325 326 327 328 329
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
330 331 332 333
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

S
soulseen 已提交
334 335
	// match "/blue/rest/organizations/jenkins/scm/github/validate/"
	webservice.Route(webservice.PUT("/devops/scm/{scmId}/validate").
336
		To(devopsapi.Validate).
S
soulseen 已提交
337 338
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Validate Github personal access token.").
S
soulseen 已提交
339
		Param(webservice.PathParameter("scmId", "the id of SCM.")).
R
runzexia 已提交
340
		Returns(http.StatusOK, RespOK, devops.Validates{}).
Z
Zhuxiaoyang 已提交
341
		Writes(devops.Validates{}))
S
soulseen 已提交
342 343 344

	// match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/?credentialId=github"
	webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations").
Z
Zhuxiaoyang 已提交
345
		To(devopsapi.GetSCMOrg).
S
soulseen 已提交
346 347
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("List organizations of SCM").
S
soulseen 已提交
348 349
		Param(webservice.PathParameter("scmId", "the id of SCM.")).
		Param(webservice.QueryParameter("credentialId", "credential id for SCM.").
Z
Zhuxiaoyang 已提交
350 351
			Required(true).
			DataFormat("credentialId=%s")).
R
runzexia 已提交
352
		Returns(http.StatusOK, RespOK, []devops.SCMOrg{}).
Z
Zhuxiaoyang 已提交
353 354 355 356 357 358 359 360
		Writes([]devops.SCMOrg{}))

	// match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/{organizationId}/repositories/?credentialId=&pageNumber&pageSize="
	webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations/{organizationId}/repositories").
		To(devopsapi.GetOrgRepo).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get SCM repositories in an organization").
		Param(webservice.PathParameter("scmId", "SCM id")).
S
soulseen 已提交
361 362
		Param(webservice.PathParameter("organizationId", "organization Id, such as github username.")).
		Param(webservice.QueryParameter("credentialId", "credential id for SCM.").
Z
Zhuxiaoyang 已提交
363 364
			Required(true).
			DataFormat("credentialId=%s")).
S
soulseen 已提交
365
		Param(webservice.QueryParameter("pageNumber", "the number of page.").
Z
Zhuxiaoyang 已提交
366 367
			Required(true).
			DataFormat("pageNumber=%d")).
S
soulseen 已提交
368
		Param(webservice.QueryParameter("pageSize", "the size of page.").
Z
Zhuxiaoyang 已提交
369 370
			Required(true).
			DataFormat("pageSize=%d")).
R
runzexia 已提交
371
		Returns(http.StatusOK, RespOK, []devops.OrgRepo{}).
Z
Zhuxiaoyang 已提交
372 373 374 375
		Writes([]devops.OrgRepo{}))

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/stop/
	webservice.Route(webservice.PUT("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/stop").
Z
Zhuxiaoyang 已提交
376
		To(devopsapi.StopBranchPipeline).
Z
Zhuxiaoyang 已提交
377 378
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Stop pipeline in running").
S
soulseen 已提交
379 380 381 382 383
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
384 385 386
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
S
soulseen 已提交
387
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
Z
Zhuxiaoyang 已提交
388 389 390
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
R
runzexia 已提交
391
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
Z
Zhuxiaoyang 已提交
392 393
		Writes(devops.StopPipe{}))

Z
Zhuxiaoyang 已提交
394 395 396 397 398
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/stop/
	webservice.Route(webservice.PUT("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/stop").
		To(devopsapi.StopPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Stop pipeline in running").
S
soulseen 已提交
399 400 401 402
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
403 404 405
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
S
soulseen 已提交
406
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
Z
Zhuxiaoyang 已提交
407 408 409 410 411 412
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
		Writes(devops.StopPipe{}))

Z
Zhuxiaoyang 已提交
413
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/Replay/
Z
Zhuxiaoyang 已提交
414
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/replay").
Z
Zhuxiaoyang 已提交
415
		To(devopsapi.ReplayBranchPipeline).
Z
Zhuxiaoyang 已提交
416 417
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Replay pipeline").
S
soulseen 已提交
418 419 420 421
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")).
R
runzexia 已提交
422
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
Z
Zhuxiaoyang 已提交
423 424
		Writes(devops.ReplayPipe{}))

Z
Zhuxiaoyang 已提交
425 426 427 428 429
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/Replay/
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/replay").
		To(devopsapi.ReplayPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Replay pipeline").
S
soulseen 已提交
430 431 432
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")).
Z
Zhuxiaoyang 已提交
433 434 435
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
		Writes(devops.ReplayPipe{}))

Z
Zhuxiaoyang 已提交
436 437
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/log/?start=0
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/log").
Z
Zhuxiaoyang 已提交
438
		To(devopsapi.GetBranchRunLog).
Z
Zhuxiaoyang 已提交
439 440 441
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Pipelines run log.").
		Produces("text/plain; charset=utf-8").
S
soulseen 已提交
442 443 444 445 446
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
S
soulseen 已提交
447
			Required(true).
Z
Zhuxiaoyang 已提交
448 449 450
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
451 452 453 454 455 456
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/log/?start=0
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/log").
		To(devopsapi.GetRunLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Pipelines run log.").
		Produces("text/plain; charset=utf-8").
S
soulseen 已提交
457 458 459 460
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
461 462 463 464
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
465 466
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/artifacts
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/artifacts").
Z
Zhuxiaoyang 已提交
467
		To(devopsapi.GetBranchArtifacts).
Z
Zhuxiaoyang 已提交
468 469
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline artifacts.").
S
soulseen 已提交
470 471 472 473 474
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
475 476
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
477
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
478 479 480 481 482
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

Z
Zhuxiaoyang 已提交
483 484 485 486 487
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/artifacts
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/artifacts").
		To(devopsapi.GetArtifacts).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline artifacts.").
S
soulseen 已提交
488 489 490 491
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
492 493
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
494
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
495 496 497 498 499
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

Z
Zhuxiaoyang 已提交
500 501 502 503 504
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/?filter=&start&limit=
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches").
		To(devopsapi.GetPipeBranch).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline of branch.").
S
soulseen 已提交
505 506
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
Z
Zhuxiaoyang 已提交
507 508 509
		Param(webservice.QueryParameter("filter", "filter remote").
			Required(true).
			DataFormat("filter=%s")).
S
soulseen 已提交
510
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
511 512
			Required(true).
			DataFormat("start=%d")).
S
soulseen 已提交
513
		Param(webservice.QueryParameter("limit", "the count of item limit.").
S
soulseen 已提交
514
			Required(true).
Z
Zhuxiaoyang 已提交
515
			DataFormat("limit=%d")).
R
runzexia 已提交
516
		Returns(http.StatusOK, RespOK, []devops.PipeBranch{}).
Z
Zhuxiaoyang 已提交
517 518 519 520
		Writes([]devops.PipeBranch{}))

	// /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/{stepId}").
Z
Zhuxiaoyang 已提交
521
		To(devopsapi.CheckBranchPipeline).
Z
Zhuxiaoyang 已提交
522 523 524 525
		Metadata(restfulspec.KeyOpenAPITags, tags).
		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").
S
soulseen 已提交
526 527 528 529 530 531
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")))
Z
Zhuxiaoyang 已提交
532

Z
Zhuxiaoyang 已提交
533 534 535 536 537 538 539
	// 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}").
		To(devopsapi.CheckPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		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").
S
soulseen 已提交
540 541 542 543
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")).
Z
Zhuxiaoyang 已提交
544 545
		Param(webservice.PathParameter("stepId", "pipeline step id")))

Z
Zhuxiaoyang 已提交
546 547 548 549 550 551
	// match /job/project-8QnvykoJw4wZ/job/test-1/indexing/consoleText
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/console/log").
		To(devopsapi.GetConsoleLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get index console log.").
		Produces("text/plain; charset=utf-8").
S
soulseen 已提交
552 553
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")))
Z
Zhuxiaoyang 已提交
554 555 556 557 558 559 560

	// match /job/{projectName}/job/{pipelineName}/build?delay=0
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/scan").
		To(devopsapi.ScanBranch).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Start a build.").
		Produces("text/html; charset=utf-8").
S
soulseen 已提交
561 562 563 564
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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).
Z
Zhuxiaoyang 已提交
565 566 567
			DataFormat("delay=%d")))

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
Z
Zhuxiaoyang 已提交
568
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run").
Z
Zhuxiaoyang 已提交
569
		To(devopsapi.RunBranchPipeline).
Z
Zhuxiaoyang 已提交
570
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
571
		Doc("Run pipeline.").
Z
Zhuxiaoyang 已提交
572
		Reads(devops.RunPayload{}).
S
soulseen 已提交
573 574 575
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")).
R
runzexia 已提交
576
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
Z
Zhuxiaoyang 已提交
577
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
578 579 580 581 582 583 584

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/run").
		To(devopsapi.RunPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Run pipeline.").
		Reads(devops.RunPayload{}).
S
soulseen 已提交
585 586
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		Param(webservice.PathParameter("pipelineName", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
Z
Zhuxiaoyang 已提交
587 588
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
589 590

	// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit=
Z
Zhuxiaoyang 已提交
591
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status").
Z
Zhuxiaoyang 已提交
592
		To(devopsapi.GetBranchStepsStatus).
Z
Zhuxiaoyang 已提交
593 594
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline steps status.").
S
soulseen 已提交
595 596 597 598 599 600
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
601 602
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
603
		Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
Z
Zhuxiaoyang 已提交
604 605
		Writes([]devops.QueuedBlueRun{}))

Z
Zhuxiaoyang 已提交
606 607 608 609 610
	// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/nodes/?limit=
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps/status").
		To(devopsapi.GetStepsStatus).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline steps status.").
S
soulseen 已提交
611 612 613 614 615
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
616 617 618 619 620
			Required(true).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
		Writes([]devops.QueuedBlueRun{}))

Z
Zhuxiaoyang 已提交
621
	// match /crumbIssuer/api/json/
Z
Zhuxiaoyang 已提交
622
	webservice.Route(webservice.GET("/devops/crumbissuer").
Z
Zhuxiaoyang 已提交
623 624
		To(devopsapi.GetCrumb).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
625
		Doc("Get crumb issuer.").
R
runzexia 已提交
626
		Returns(http.StatusOK, RespOK, devops.Crumb{}).
Z
Zhuxiaoyang 已提交
627
		Writes(devops.Crumb{}))
S
soulseen 已提交
628

Z
Zhuxiaoyang 已提交
629 630 631 632 633 634 635
	// match /job/init-job/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile
	webservice.Route(webservice.POST("/devops/check/scriptcompile").
		To(devopsapi.CheckScriptCompile).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Consumes("application/x-www-form-urlencoded", "charset=utf-8").
		Produces("application/json", "charset=utf-8").
		Doc("Check pipeline script compile.").
S
soulseen 已提交
636
		Reads(devops.ReqScript{}).
Z
Zhuxiaoyang 已提交
637 638 639 640 641 642 643 644
		Returns(http.StatusOK, RespOK, devops.CheckScript{}).
		Writes(devops.CheckScript{}))

	// match /job/init-job/descriptorByName/hudson.triggers.TimerTrigger/checkSpec
	webservice.Route(webservice.GET("/devops/check/cron").
		To(devopsapi.CheckCron).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Produces("application/json", "charset=utf-8").
S
soulseen 已提交
645
		Doc("Check cron script compile.").
S
soulseen 已提交
646
		Param(webservice.QueryParameter("value", "string of cron script.").
Z
Zhuxiaoyang 已提交
647 648 649 650 651 652 653 654 655 656 657
			Required(true).
			DataFormat("value=%s")).
		Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
		Returns(http.StatusOK, RespOK, devops.CheckCronRes{}).
		Writes(devops.CheckCronRes{}))

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/{runId}/
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}").
		To(devopsapi.GetPipelineRun).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get run pipeline in project.").
S
soulseen 已提交
658 659 660
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.")).
Z
Zhuxiaoyang 已提交
661 662 663 664 665
		Returns(http.StatusOK, RespOK, devops.PipelineRun{}).
		Writes(devops.PipelineRun{}))

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}").
Z
Zhuxiaoyang 已提交
666
		To(devopsapi.GetBranchPipeline).
Z
Zhuxiaoyang 已提交
667
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
668 669 670 671
		Doc("Get Pipeline run by branch.").
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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")).
Z
Zhuxiaoyang 已提交
672 673
		Returns(http.StatusOK, RespOK, devops.BranchPipeline{}).
		Writes(devops.BranchPipeline{}))
Z
Zhuxiaoyang 已提交
674 675 676

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/?limit=10000
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes").
Z
Zhuxiaoyang 已提交
677
		To(devopsapi.GetPipelineRunNodes).
Z
Zhuxiaoyang 已提交
678 679
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Pipeline run nodes.").
S
soulseen 已提交
680 681 682 683
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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").
Z
Zhuxiaoyang 已提交
684 685
			Required(false).
			DataFormat("limit=%d")).
Z
Zhuxiaoyang 已提交
686 687
		Returns(http.StatusOK, RespOK, []devops.PipelineRunNodes{}).
		Writes([]devops.PipelineRunNodes{}))
Z
Zhuxiaoyang 已提交
688 689 690

	// match /blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/?limit=
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps").
Z
Zhuxiaoyang 已提交
691
		To(devopsapi.GetBranchNodeSteps).
Z
Zhuxiaoyang 已提交
692
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
693 694 695 696 697 698 699
		Doc("Get steps in node by branch.").
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
700 701
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
702
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
703 704
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
705 706 707 708 709
	// match /blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?limit=
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodes/{nodeId}/steps").
		To(devopsapi.GetNodeSteps).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get steps in node.").
S
soulseen 已提交
710 711 712 713 714
		Param(webservice.PathParameter("projectName", "the name of devops project, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
715 716
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
717
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
718 719
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
720 721 722 723 724 725
	// match /pipeline-model-converter/toJenkinsfile
	webservice.Route(webservice.POST("/devops/tojenkinsfile").
		To(devopsapi.ToJenkinsfile).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Consumes("application/x-www-form-urlencoded").
		Produces("application/json", "charset=utf-8").
S
soulseen 已提交
726
		Doc("Convert json to jenkinsfile format.").
Z
Zhuxiaoyang 已提交
727
		Reads(devops.ReqJson{}).
R
runzexia 已提交
728
		Returns(http.StatusOK, RespOK, devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
729 730 731 732 733 734 735 736
		Writes(devops.ResJenkinsfile{}))

	// match /pipeline-model-converter/toJson
	webservice.Route(webservice.POST("/devops/tojson").
		To(devopsapi.ToJson).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Consumes("application/x-www-form-urlencoded").
		Produces("application/json", "charset=utf-8").
S
soulseen 已提交
737
		Doc("Convert jenkinsfile to json format.").
Z
Zhuxiaoyang 已提交
738
		Reads(devops.ReqJenkinsfile{}).
R
runzexia 已提交
739
		Returns(http.StatusOK, RespOK, devops.ResJson{}).
Z
Zhuxiaoyang 已提交
740 741
		Writes(devops.ResJson{}))

Z
Zhuxiaoyang 已提交
742 743 744 745
	// match /git/notifyCommit/?url=
	webservice.Route(webservice.GET("/devops/notifycommit").
		To(devopsapi.GetNotifyCommit).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
746
		Doc("Get notify commit by GET HTTP method.").
Z
Zhuxiaoyang 已提交
747 748 749 750 751 752 753 754 755
		Produces("text/plain; charset=utf-8").
		Param(webservice.QueryParameter("url", "the url for webhook to push.").
			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).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
756
		Doc("Get notify commit by POST HTTP method.").
Z
Zhuxiaoyang 已提交
757 758 759 760 761 762 763 764 765 766 767
		Consumes("application/json").
		Produces("text/plain; charset=utf-8").
		Param(webservice.QueryParameter("url", "the url for webhook to push.").
			Required(true).
			DataFormat("url=%s")))

	webservice.Route(webservice.POST("/devops/github/webhook").
		To(devopsapi.GithubWebhook).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("receive webhook request."))

Z
Zhuxiaoyang 已提交
768 769 770 771
	// in scm get all steps in nodes.
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodesdetail").
		To(devopsapi.GetBranchNodesDetail).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
772 773 774 775 776 777
		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, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
778 779
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
780
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
781 782 783 784 785 786
		Writes(devops.NodesDetail{}))

	// out of scm get all steps in nodes.
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs/{runId}/nodesdetail").
		To(devopsapi.GetNodesDetail).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
787 788 789 790 791 792
		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, the project set of software development practices that combines software development (Dev) and information technology operations (Ops) to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.")).
		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.").
Z
Zhuxiaoyang 已提交
793 794
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
795
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
796 797
		Writes(devops.NodesDetail{}))

S
sunzhu 已提交
798 799 800 801
	c.Add(webservice)

	return nil
}