register.go 38.6 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 137
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("pipelines", "pipeline name")).
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 148
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("pipelines", "pipeline name")).
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 157
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("pipelines", "pipeline name")).
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 166 167
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("pipelines", "pipeline name")).
		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 176
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("pipelines", "pipeline name")))
R
runzexia 已提交
177

R
runzexia 已提交
178 179
	webservice.Route(webservice.PUT("/devops/{devops}/pipelines").
		To(devopsapi.CreateDevOpsProjectPipelineHandler).
R
runzexia 已提交
180
		Doc("update devops project pipeline").
R
runzexia 已提交
181
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
182 183
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Reads(devops.ProjectPipeline{}))
184

R
runzexia 已提交
185 186 187
	webservice.Route(webservice.POST("/devops/{devops}/credentials").
		To(devopsapi.CreateDevOpsProjectCredentialHandler).
		Doc("add project credential pipeline").
188
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
189
		Param(webservice.PathParameter("devops", "devops project's Id")).
R
runzexia 已提交
190 191 192 193 194 195
		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 已提交
196 197
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")).
R
runzexia 已提交
198 199 200 201 202
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.DELETE("/devops/{devops}/credentials/{credentials}").
		To(devopsapi.DeleteDevOpsProjectCredentialHandler).
		Doc("delete project credential pipeline").
203
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
204 205
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")))
R
runzexia 已提交
206 207 208 209 210

	webservice.Route(webservice.GET("/devops/{devops}/credentials/{credentials}").
		To(devopsapi.GetDevOpsProjectCredentialHandler).
		Doc("get project credential pipeline").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
211 212 213 214
		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 已提交
215
		Returns(http.StatusOK, RespOK, devops.JenkinsCredential{}).
R
runzexia 已提交
216 217 218 219 220 221
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.GET("/devops/{devops}/credentials").
		To(devopsapi.GetDevOpsProjectCredentialsHandler).
		Doc("get project credential pipeline").
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
222 223 224
		Param(webservice.PathParameter("devops", "devops project's Id")).
		Param(webservice.PathParameter("credentials", "credential's Id")).
		Param(webservice.QueryParameter("domain", "credential's domain")).
R
runzexia 已提交
225
		Returns(http.StatusOK, RespOK, []devops.JenkinsCredential{}).
R
runzexia 已提交
226
		Reads([]devops.JenkinsCredential{}))
S
sunzhu 已提交
227 228 229

	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}").
230
		To(devopsapi.GetPipeline).
S
sunzhu 已提交
231 232 233
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get DevOps Pipelines.").
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
Z
Zhuxiaoyang 已提交
234
		Param(webservice.PathParameter("projectName", "devops project name")).
R
runzexia 已提交
235
		Returns(http.StatusOK, RespOK, devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
236
		Writes(devops.Pipeline{}))
S
sunzhu 已提交
237 238 239

	// match Jenkisn api: "jenkins_api/blue/rest/search"
	webservice.Route(webservice.GET("/devops/search").
240
		To(devopsapi.SearchPipelines).
S
sunzhu 已提交
241 242 243
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Search DevOps resource.").
		Param(webservice.QueryParameter("q", "query pipelines").
S
soulseen 已提交
244 245
			Required(false).
			DataFormat("q=%s")).
S
sunzhu 已提交
246
		Param(webservice.QueryParameter("filter", "filter resource").
S
soulseen 已提交
247 248
			Required(false).
			DataFormat("filter=%s")).
S
sunzhu 已提交
249
		Param(webservice.QueryParameter("start", "start page").
S
soulseen 已提交
250 251
			Required(false).
			DataFormat("start=%d")).
S
sunzhu 已提交
252
		Param(webservice.QueryParameter("limit", "limit count").
S
soulseen 已提交
253
			Required(false).
Z
Zhuxiaoyang 已提交
254
			DataFormat("limit=%d")).
R
runzexia 已提交
255
		Returns(http.StatusOK, RespOK, []devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
256
		Writes([]devops.Pipeline{}))
S
sunzhu 已提交
257 258 259

	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/runs/"
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/runs").
260
		To(devopsapi.SearchPipelineRuns).
S
sunzhu 已提交
261
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
262
		Doc("Search DevOps Pipelines runs in branch.").
S
sunzhu 已提交
263 264 265
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.QueryParameter("start", "start page").
S
soulseen 已提交
266 267
			Required(false).
			DataFormat("start=%d")).
S
sunzhu 已提交
268
		Param(webservice.QueryParameter("limit", "limit count").
S
soulseen 已提交
269
			Required(false).
Z
Zhuxiaoyang 已提交
270 271 272 273
			DataFormat("limit=%d")).
		Param(webservice.QueryParameter("branch", "branch ").
			Required(false).
			DataFormat("branch=%s")).
Z
Zhuxiaoyang 已提交
274 275
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}).
		Writes([]devops.BranchPipelineRun{}))
S
sunzhu 已提交
276 277 278

	// 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 已提交
279
		To(devopsapi.GetBranchPipelineRun).
S
sunzhu 已提交
280
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
281
		Doc("Get DevOps Pipelines run in branch.").
S
sunzhu 已提交
282 283 284
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("branchName", "pipeline branch name")).
Z
Zhuxiaoyang 已提交
285 286 287 288
		Param(webservice.PathParameter("runId", "pipeline runs id")).
		Param(webservice.QueryParameter("start", "start").
			Required(false).
			DataFormat("start=%d")).
Z
Zhuxiaoyang 已提交
289 290
		Returns(http.StatusOK, RespOK, devops.BranchPipelineRun{}).
		Writes(devops.BranchPipelineRun{}))
S
sunzhu 已提交
291 292 293

	// 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 已提交
294
		To(devopsapi.GetPipelineRunNodesbyBranch).
S
sunzhu 已提交
295 296 297 298 299 300 301 302 303
		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").
			Required(false).
			DataFormat("limit=%d").
Z
Zhuxiaoyang 已提交
304
			DefaultValue("limit=10000")).
Z
Zhuxiaoyang 已提交
305 306
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRunNodes{}).
		Writes([]devops.BranchPipelineRunNodes{}))
S
sunzhu 已提交
307 308 309

	// 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 已提交
310
		To(devopsapi.GetBranchStepLog).
S
sunzhu 已提交
311
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
312 313
		Doc("Get pipelines step log.").
		Produces("text/plain; charset=utf-8").
S
sunzhu 已提交
314 315 316 317 318 319 320 321 322 323 324
		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").
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
	// 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").
		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").
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

S
soulseen 已提交
341 342
	// match "/blue/rest/organizations/jenkins/scm/github/validate/"
	webservice.Route(webservice.PUT("/devops/scm/{scmId}/validate").
343
		To(devopsapi.Validate).
S
soulseen 已提交
344 345
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Validate Github personal access token.").
Z
Zhuxiaoyang 已提交
346
		Param(webservice.PathParameter("scmId", "SCM id")).
R
runzexia 已提交
347
		Returns(http.StatusOK, RespOK, devops.Validates{}).
Z
Zhuxiaoyang 已提交
348
		Writes(devops.Validates{}))
S
soulseen 已提交
349 350 351

	// match "/blue/rest/organizations/jenkins/scm/{scmId}/organizations/?credentialId=github"
	webservice.Route(webservice.GET("/devops/scm/{scmId}/organizations").
Z
Zhuxiaoyang 已提交
352
		To(devopsapi.GetSCMOrg).
S
soulseen 已提交
353 354 355
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("List organizations of SCM").
		Param(webservice.PathParameter("scmId", "SCM id")).
Z
Zhuxiaoyang 已提交
356 357 358
		Param(webservice.QueryParameter("credentialId", "credential id for SCM").
			Required(true).
			DataFormat("credentialId=%s")).
R
runzexia 已提交
359
		Returns(http.StatusOK, RespOK, []devops.SCMOrg{}).
Z
Zhuxiaoyang 已提交
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
		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")).
		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").
			Required(true).
			DataFormat("pageNumber=%d")).
		Param(webservice.QueryParameter("pageSize", "page size").
			Required(true).
			DataFormat("pageSize=%d")).
R
runzexia 已提交
378
		Returns(http.StatusOK, RespOK, []devops.OrgRepo{}).
Z
Zhuxiaoyang 已提交
379 380 381 382
		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 已提交
383
		To(devopsapi.StopBranchPipeline).
Z
Zhuxiaoyang 已提交
384 385 386 387 388 389 390 391 392 393 394 395 396 397
		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").
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep").
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
R
runzexia 已提交
398
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
Z
Zhuxiaoyang 已提交
399 400
		Writes(devops.StopPipe{}))

Z
Zhuxiaoyang 已提交
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
	// 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").
		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").
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep").
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
		Writes(devops.StopPipe{}))

Z
Zhuxiaoyang 已提交
420
	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/Replay/
Z
Zhuxiaoyang 已提交
421
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/replay").
Z
Zhuxiaoyang 已提交
422
		To(devopsapi.ReplayBranchPipeline).
Z
Zhuxiaoyang 已提交
423 424 425 426 427 428
		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")).
R
runzexia 已提交
429
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
Z
Zhuxiaoyang 已提交
430 431
		Writes(devops.ReplayPipe{}))

Z
Zhuxiaoyang 已提交
432 433 434 435 436 437 438 439 440 441 442
	// 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").
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.PathParameter("runId", "pipeline runs id")).
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
		Writes(devops.ReplayPipe{}))

Z
Zhuxiaoyang 已提交
443 444
	// 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 已提交
445
		To(devopsapi.GetBranchRunLog).
Z
Zhuxiaoyang 已提交
446 447 448 449 450 451 452 453
		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").
S
soulseen 已提交
454
			Required(true).
Z
Zhuxiaoyang 已提交
455 456 457
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
458 459 460 461 462 463 464 465 466 467 468 469 470 471
	// 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").
		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").
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

Z
Zhuxiaoyang 已提交
472 473
	// 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 已提交
474
		To(devopsapi.GetBranchArtifacts).
Z
Zhuxiaoyang 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
		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").
			Required(false).
			DataFormat("start=%d")).
		Param(webservice.QueryParameter("limit", "limit count").
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

Z
Zhuxiaoyang 已提交
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
	// 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.").
		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").
			Required(false).
			DataFormat("start=%d")).
		Param(webservice.QueryParameter("limit", "limit count").
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

Z
Zhuxiaoyang 已提交
507 508 509 510 511 512 513 514 515 516 517 518 519 520
	// 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.").
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.QueryParameter("filter", "filter remote").
			Required(true).
			DataFormat("filter=%s")).
		Param(webservice.QueryParameter("start", "start").
			Required(true).
			DataFormat("start=%d")).
		Param(webservice.QueryParameter("limit", "limit count").
S
soulseen 已提交
521
			Required(true).
Z
Zhuxiaoyang 已提交
522
			DataFormat("limit=%d")).
R
runzexia 已提交
523
		Returns(http.StatusOK, RespOK, []devops.PipeBranch{}).
Z
Zhuxiaoyang 已提交
524 525 526 527
		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 已提交
528
		To(devopsapi.CheckBranchPipeline).
Z
Zhuxiaoyang 已提交
529 530 531 532 533 534 535 536 537 538 539
		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").
		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")))

Z
Zhuxiaoyang 已提交
540 541 542 543 544 545 546 547 548 549 550 551 552
	// 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").
		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("stepId", "pipeline step id")))

Z
Zhuxiaoyang 已提交
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
	// 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").
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")))

	// 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").
		Param(webservice.PathParameter("projecFtName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.QueryParameter("delay", "delay time").
			Required(true).
			DataFormat("delay=%d")))

	// match /blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{}/runs/
Z
Zhuxiaoyang 已提交
575
	webservice.Route(webservice.POST("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/run").
Z
Zhuxiaoyang 已提交
576
		To(devopsapi.RunBranchPipeline).
Z
Zhuxiaoyang 已提交
577
		Metadata(restfulspec.KeyOpenAPITags, tags).
Z
Zhuxiaoyang 已提交
578
		Doc("Run pipeline.").
Z
Zhuxiaoyang 已提交
579 580 581 582
		Reads(devops.RunPayload{}).
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.PathParameter("branchName", "pipeline branch name")).
R
runzexia 已提交
583
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
Z
Zhuxiaoyang 已提交
584
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
585 586 587 588 589 590 591 592 593 594 595

	// 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{}).
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
596 597

	// match /pipeline_status/blue/rest/organizations/jenkins/pipelines/{projectName}/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/?limit=
Z
Zhuxiaoyang 已提交
598
	webservice.Route(webservice.GET("/devops/{projectName}/pipelines/{pipelineName}/branches/{branchName}/runs/{runId}/nodes/{nodeId}/steps/status").
Z
Zhuxiaoyang 已提交
599
		To(devopsapi.GetBranchStepsStatus).
Z
Zhuxiaoyang 已提交
600 601 602 603 604 605 606 607 608 609
		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").
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
610
		Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
Z
Zhuxiaoyang 已提交
611 612
		Writes([]devops.QueuedBlueRun{}))

Z
Zhuxiaoyang 已提交
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
	// 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.").
		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").
			Required(true).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, RespOK, []devops.QueuedBlueRun{}).
		Writes([]devops.QueuedBlueRun{}))

Z
Zhuxiaoyang 已提交
628
	// match /crumbIssuer/api/json/
Z
Zhuxiaoyang 已提交
629
	webservice.Route(webservice.GET("/devops/crumbissuer").
Z
Zhuxiaoyang 已提交
630 631 632
		To(devopsapi.GetCrumb).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get crumb").
R
runzexia 已提交
633
		Returns(http.StatusOK, RespOK, devops.Crumb{}).
Z
Zhuxiaoyang 已提交
634
		Writes(devops.Crumb{}))
S
soulseen 已提交
635

Z
Zhuxiaoyang 已提交
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
	// 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.").
		Reads("value=\"\"").
		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").
		Doc("Check pipeline script compile.").
		Param(webservice.QueryParameter("value", "cpec value").
			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.").
		Param(webservice.PathParameter("projectName", "devops project name")).
		Param(webservice.PathParameter("pipelineName", "pipeline name")).
		Param(webservice.PathParameter("runId", "pipeline run id")).
		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 已提交
673
		To(devopsapi.GetBranchPipeline).
Z
Zhuxiaoyang 已提交
674 675 676 677 678
		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")).
Z
Zhuxiaoyang 已提交
679 680
		Returns(http.StatusOK, RespOK, devops.BranchPipeline{}).
		Writes(devops.BranchPipeline{}))
Z
Zhuxiaoyang 已提交
681 682 683

	// 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 已提交
684
		To(devopsapi.GetPipelineRunNodes).
Z
Zhuxiaoyang 已提交
685 686 687 688 689 690 691 692
		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").
			Required(false).
			DataFormat("limit=%d")).
Z
Zhuxiaoyang 已提交
693 694
		Returns(http.StatusOK, RespOK, []devops.PipelineRunNodes{}).
		Writes([]devops.PipelineRunNodes{}))
Z
Zhuxiaoyang 已提交
695 696 697

	// 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 已提交
698
		To(devopsapi.GetBranchNodeSteps).
Z
Zhuxiaoyang 已提交
699 700 701 702 703 704 705 706 707 708
		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").
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
709
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
710 711
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
712 713 714 715 716 717 718 719 720 721 722 723
	// 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.").
		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").
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
724
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
725 726
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
727 728 729 730 731 732 733 734
	// 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").
		Doc("Json to Jenkinsfile.").
		Reads(devops.ReqJson{}).
R
runzexia 已提交
735
		Returns(http.StatusOK, RespOK, devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
736 737 738 739 740 741 742 743 744 745
		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").
		Doc("Jenkinsfile to Json.").
		Reads(devops.ReqJenkinsfile{}).
R
runzexia 已提交
746
		Returns(http.StatusOK, RespOK, devops.ResJson{}).
Z
Zhuxiaoyang 已提交
747 748
		Writes(devops.ResJson{}))

Z
Zhuxiaoyang 已提交
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
	// match /git/notifyCommit/?url=
	webservice.Route(webservice.GET("/devops/notifycommit").
		To(devopsapi.GetNotifyCommit).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Notify Commit by GET HTTP method.").
		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).
		Doc("Get Notify Commit by POST HTTP method.").
		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 已提交
775 776 777 778 779 780 781 782 783 784 785 786
	// 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).
		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").
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
787
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
788 789 790 791 792 793 794 795 796 797 798 799 800 801
		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).
		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").
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
802
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
803 804
		Writes(devops.NodesDetail{}))

S
sunzhu 已提交
805 806 807 808
	c.Add(webservice)

	return nil
}