register.go 42.2 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
	tags := []string{"DevOps"}

	webservice.Route(webservice.GET("/devops/{devops}").
		To(devopsapi.GetDevOpsProjectHandler).
R
Ray Zhou 已提交
53
		Doc("Get the specified DevOps Project").
54
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
55
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
56
		Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
R
runzexia 已提交
57
		Writes(devops.DevOpsProject{}))
58 59 60

	webservice.Route(webservice.PATCH("/devops/{devops}").
		To(devopsapi.UpdateProjectHandler).
R
Ray Zhou 已提交
61
		Doc("Update the specified DevOps Project").
62
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
63
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
64
		Reads(devops.DevOpsProject{}).
R
runzexia 已提交
65
		Returns(http.StatusOK, RespOK, devops.DevOpsProject{}).
R
runzexia 已提交
66
		Writes(devops.DevOpsProject{}))
67 68 69

	webservice.Route(webservice.GET("/devops/{devops}/defaultroles").
		To(devopsapi.GetDevOpsProjectDefaultRoles).
R
Ray Zhou 已提交
70
		Doc("Get the build-in roles info of the specified DevOps project").
71
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
72
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
73
		Returns(http.StatusOK, RespOK, []devops.Role{}).
R
runzexia 已提交
74
		Writes([]devops.Role{}))
75 76 77

	webservice.Route(webservice.GET("/devops/{devops}/members").
		To(devopsapi.GetDevOpsProjectMembersHandler).
R
Ray Zhou 已提交
78
		Doc("Get the members of the specified DevOps project").
79
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
80
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
81 82 83 84 85 86 87
		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 已提交
88
		Returns(http.StatusOK, RespOK, []devops.DevOpsProjectMembership{}).
R
runzexia 已提交
89
		Writes([]devops.DevOpsProjectMembership{}))
90

R
runzexia 已提交
91
	webservice.Route(webservice.GET("/devops/{devops}/members/{member}").
92
		To(devopsapi.GetDevOpsProjectMemberHandler).
R
Ray Zhou 已提交
93
		Doc("Get the specified member of the DevOps project").
94
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
95 96
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("member", "member's username, e.g. admin")).
R
runzexia 已提交
97
		Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
R
runzexia 已提交
98
		Writes(devops.DevOpsProjectMembership{}))
99 100 101

	webservice.Route(webservice.POST("/devops/{devops}/members").
		To(devopsapi.AddDevOpsProjectMemberHandler).
R
Ray Zhou 已提交
102
		Doc("Add a member to the specified DevOps project").
103
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
104
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
105
		Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
R
runzexia 已提交
106 107
		Writes(devops.DevOpsProjectMembership{}))

R
runzexia 已提交
108
	webservice.Route(webservice.PATCH("/devops/{devops}/members/{member}").
R
runzexia 已提交
109
		To(devopsapi.UpdateDevOpsProjectMemberHandler).
R
Ray Zhou 已提交
110
		Doc("Update the specified member of the DevOps project").
R
runzexia 已提交
111
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
112 113
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("member", "member's username, e.g. admin")).
R
runzexia 已提交
114
		Returns(http.StatusOK, RespOK, devops.DevOpsProjectMembership{}).
R
runzexia 已提交
115 116 117
		Reads(devops.DevOpsProjectMembership{}).
		Writes(devops.DevOpsProjectMembership{}))

R
runzexia 已提交
118
	webservice.Route(webservice.DELETE("/devops/{devops}/members/{member}").
R
runzexia 已提交
119
		To(devopsapi.DeleteDevOpsProjectMemberHandler).
R
Ray Zhou 已提交
120
		Doc("Delete the specified member of the DevOps project").
R
runzexia 已提交
121
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
122 123
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("member", "member's username, e.g. admin")).
R
runzexia 已提交
124 125
		Writes(devops.DevOpsProjectMembership{}))

R
runzexia 已提交
126 127
	webservice.Route(webservice.POST("/devops/{devops}/pipelines").
		To(devopsapi.CreateDevOpsProjectPipelineHandler).
R
Ray Zhou 已提交
128 129
		Doc("Create a DevOps project pipeline").
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
130
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
131
		Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
R
runzexia 已提交
132 133 134
		Writes(devops.ProjectPipeline{}).
		Reads(devops.ProjectPipeline{}))

R
runzexia 已提交
135
	webservice.Route(webservice.PUT("/devops/{devops}/pipelines/{pipeline}").
R
runzexia 已提交
136
		To(devopsapi.UpdateDevOpsProjectPipelineHandler).
R
Ray Zhou 已提交
137 138 139
		Doc("Update the specified pipeline of the DevOps project").
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, e.g. sample-pipeline")).
R
runzexia 已提交
140
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
141 142 143
		Writes(devops.ProjectPipeline{}).
		Reads(devops.ProjectPipeline{}))

S
soulseen 已提交
144 145
	webservice.Route(webservice.DELETE("/devops/{devops}/pipelines/{pipeline}").
		To(devopsapi.DeleteDevOpsProjectPipelineHandler).
R
Ray Zhou 已提交
146
		Doc("Delete the specified pipeline of the DevOps project").
S
soulseen 已提交
147
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
148 149
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, e.g. sample-pipeline")))
S
soulseen 已提交
150

R
runzexia 已提交
151
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/config").
R
runzexia 已提交
152
		To(devopsapi.GetDevOpsProjectPipelineHandler).
R
Ray Zhou 已提交
153
		Doc("Get the configuration information of the specified pipeline of the DevOps Project").
R
runzexia 已提交
154
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
155 156
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, e.g. sample-pipeline")).
R
runzexia 已提交
157
		Returns(http.StatusOK, RespOK, devops.ProjectPipeline{}).
R
runzexia 已提交
158
		Writes(devops.ProjectPipeline{}))
R
runzexia 已提交
159

R
runzexia 已提交
160
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/sonarStatus").
R
runzexia 已提交
161
		To(devopsapi.GetPipelineSonarStatusHandler).
R
Ray Zhou 已提交
162
		Doc("Get the sonar quality information for the specified pipeline of the DevOps project").
R
runzexia 已提交
163
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
164
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
165
		Param(webservice.PathParameter("pipeline", "the name of pipeline, e.g. sample-pipeline")).
R
runzexia 已提交
166
		Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
R
runzexia 已提交
167
		Writes([]devops.SonarStatus{}))
R
runzexia 已提交
168

R
runzexia 已提交
169
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/branches/{branch}/sonarStatus").
R
runzexia 已提交
170
		To(devopsapi.GetMultiBranchesPipelineSonarStatusHandler).
R
Ray Zhou 已提交
171
		Doc("Get the sonar quality check information for the specified pipeline branch of the DevOps project").
R
runzexia 已提交
172
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
173
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
174 175
		Param(webservice.PathParameter("pipelines", "the name of pipeline, e.g. sample-pipeline")).
		Param(webservice.PathParameter("branch", "branch name, e.g. master")).
R
runzexia 已提交
176
		Returns(http.StatusOK, RespOK, []devops.SonarStatus{}).
R
runzexia 已提交
177
		Writes([]devops.SonarStatus{}))
R
runzexia 已提交
178 179 180

	webservice.Route(webservice.POST("/devops/{devops}/credentials").
		To(devopsapi.CreateDevOpsProjectCredentialHandler).
R
Ray Zhou 已提交
181
		Doc("Create a Credential in the specified DevOps project").
182
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
183
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
184 185
		Reads(devops.JenkinsCredential{}))

R
runzexia 已提交
186
	webservice.Route(webservice.PUT("/devops/{devops}/credentials/{credential}").
R
runzexia 已提交
187
		To(devopsapi.UpdateDevOpsProjectCredentialHandler).
R
Ray Zhou 已提交
188
		Doc("Update the specified credential of the DevOps project").
R
runzexia 已提交
189
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
190 191
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("credential", "credential's ID, e.g. dockerhub-id")).
R
runzexia 已提交
192 193
		Reads(devops.JenkinsCredential{}))

R
runzexia 已提交
194
	webservice.Route(webservice.DELETE("/devops/{devops}/credentials/{credential}").
R
runzexia 已提交
195
		To(devopsapi.DeleteDevOpsProjectCredentialHandler).
R
Ray Zhou 已提交
196
		Doc("Delete the specified credential of the DevOps project").
197
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
198 199
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("credential", "credential's ID, e.g. dockerhub-id")))
R
runzexia 已提交
200

R
runzexia 已提交
201
	webservice.Route(webservice.GET("/devops/{devops}/credentials/{credential}").
R
runzexia 已提交
202
		To(devopsapi.GetDevOpsProjectCredentialHandler).
R
Ray Zhou 已提交
203
		Doc("Get the specified credential of the DevOps project").
R
runzexia 已提交
204
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
205 206
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("credential", "credential's ID, e.g. dockerhub-id")).
R
runzexia 已提交
207
		Param(webservice.QueryParameter("content", "Get extra content, if not none will get credential's content")).
R
runzexia 已提交
208
		Returns(http.StatusOK, RespOK, devops.JenkinsCredential{}).
R
runzexia 已提交
209 210 211 212
		Reads(devops.JenkinsCredential{}))

	webservice.Route(webservice.GET("/devops/{devops}/credentials").
		To(devopsapi.GetDevOpsProjectCredentialsHandler).
R
Ray Zhou 已提交
213
		Doc("Get all credentials of the specified DevOps project").
R
runzexia 已提交
214
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
215
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
216
		Returns(http.StatusOK, RespOK, []devops.JenkinsCredential{}).
R
runzexia 已提交
217
		Reads([]devops.JenkinsCredential{}))
S
sunzhu 已提交
218

219 220
	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}").
221
		To(devopsapi.GetPipeline).
S
sunzhu 已提交
222
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
223
		Doc("Get the specified pipeline of the DevOps project").
224
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
Ray Zhou 已提交
225
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
R
runzexia 已提交
226
		Returns(http.StatusOK, RespOK, devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
227
		Writes(devops.Pipeline{}))
S
sunzhu 已提交
228 229

	// match Jenkisn api: "jenkins_api/blue/rest/search"
230
	webservice.Route(webservice.GET("/search").
231
		To(devopsapi.SearchPipelines).
S
sunzhu 已提交
232 233
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Search DevOps resource.").
S
soulseen 已提交
234
		Param(webservice.QueryParameter("q", "query pipelines, condition for filtering.").
S
soulseen 已提交
235 236
			Required(false).
			DataFormat("q=%s")).
R
runzexia 已提交
237
		Param(webservice.QueryParameter("filter", "Filter some types of jobs. e.g. no-folder,will not get a job of type folder").
S
soulseen 已提交
238 239
			Required(false).
			DataFormat("filter=%s")).
S
soulseen 已提交
240
		Param(webservice.QueryParameter("start", "the count of item start.").
S
soulseen 已提交
241 242
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
243
		Param(webservice.QueryParameter("limit", "the count of item limit.").
S
soulseen 已提交
244
			Required(false).
Z
Zhuxiaoyang 已提交
245
			DataFormat("limit=%d")).
R
runzexia 已提交
246
		Returns(http.StatusOK, RespOK, []devops.Pipeline{}).
Z
Zhuxiaoyang 已提交
247
		Writes([]devops.Pipeline{}))
S
sunzhu 已提交
248

249 250
	// match Jenkisn api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs").
251
		To(devopsapi.SearchPipelineRuns).
S
sunzhu 已提交
252
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
253
		Doc("Get all runs of the specified pipeline").
254
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
Ray Zhou 已提交
255 256
		Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.QueryParameter("start", "the item number the search starts from").
S
soulseen 已提交
257 258
			Required(false).
			DataFormat("start=%d")).
R
Ray Zhou 已提交
259
		Param(webservice.QueryParameter("limit", "the limit item count of the search").
S
soulseen 已提交
260
			Required(false).
Z
Zhuxiaoyang 已提交
261
			DataFormat("limit=%d")).
R
Ray Zhou 已提交
262
		Param(webservice.QueryParameter("branch", "the name of branch, same as repository branch, will be filtered by branch.").
Z
Zhuxiaoyang 已提交
263 264
			Required(false).
			DataFormat("branch=%s")).
Z
Zhuxiaoyang 已提交
265 266
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRun{}).
		Writes([]devops.BranchPipelineRun{}))
S
sunzhu 已提交
267

268 269
	// match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}").
Z
Zhuxiaoyang 已提交
270
		To(devopsapi.GetBranchPipelineRun).
S
sunzhu 已提交
271
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
272
		Doc("(MultiBranchesPipeline) Get all runs in a branch").
273 274 275 276
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
277
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
278 279
			Required(false).
			DataFormat("start=%d")).
Z
Zhuxiaoyang 已提交
280 281
		Returns(http.StatusOK, RespOK, devops.BranchPipelineRun{}).
		Writes(devops.BranchPipelineRun{}))
S
sunzhu 已提交
282

283 284
	// match Jenkins api "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/nodes"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes").
Z
Zhuxiaoyang 已提交
285
		To(devopsapi.GetPipelineRunNodesbyBranch).
S
sunzhu 已提交
286
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
287
		Doc("(MultiBranchesPipeline) Get run nodes.").
288 289 290 291
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
292
		Param(webservice.QueryParameter("limit", "the count of item limit.").
S
sunzhu 已提交
293 294
			Required(false).
			DataFormat("limit=%d").
Z
Zhuxiaoyang 已提交
295
			DefaultValue("limit=10000")).
Z
Zhuxiaoyang 已提交
296 297
		Returns(http.StatusOK, RespOK, []devops.BranchPipelineRunNodes{}).
		Writes([]devops.BranchPipelineRunNodes{}))
S
sunzhu 已提交
298

299 300
	// match "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}/log/?start=0"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}/log").
Z
Zhuxiaoyang 已提交
301
		To(devopsapi.GetBranchStepLog).
S
sunzhu 已提交
302
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
303
		Doc("(MultiBranchesPipeline) Get pipelines step log.").
Z
Zhuxiaoyang 已提交
304
		Produces("text/plain; charset=utf-8").
305 306 307 308 309 310
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
		Param(webservice.PathParameter("step", "pipeline step id, the one step in pipeline.")).
S
soulseen 已提交
311
		Param(webservice.QueryParameter("start", "the count of item start.").
S
sunzhu 已提交
312 313 314 315
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

316 317
	// match "/blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/nodes/{node}/steps/{step}/log/?start=0"
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}/log").
Z
Zhuxiaoyang 已提交
318 319 320 321
		To(devopsapi.GetStepLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipelines step log.").
		Produces("text/plain; charset=utf-8").
322 323 324 325 326
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
		Param(webservice.PathParameter("step", "pipeline step id, the one step in pipeline.")).
S
soulseen 已提交
327
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
328 329 330 331
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

S
soulseen 已提交
332
	// match "/blue/rest/organizations/jenkins/scm/github/validate/"
333
	webservice.Route(webservice.POST("/scms/{scm}/verify").
334
		To(devopsapi.Validate).
S
soulseen 已提交
335
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
Ray Zhou 已提交
336 337
		Doc("Validate the access token of the specified source configuration management (SCM) such as Github").
		Param(webservice.PathParameter("scm", "the SCM ID")).
R
runzexia 已提交
338
		Returns(http.StatusOK, RespOK, devops.Validates{}).
Z
Zhuxiaoyang 已提交
339
		Writes(devops.Validates{}))
S
soulseen 已提交
340

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

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

372 373
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/stop/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/stop").
Z
Zhuxiaoyang 已提交
374
		To(devopsapi.StopBranchPipeline).
Z
Zhuxiaoyang 已提交
375
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
376
		Doc("(MultiBranchesPipeline) Stop pipeline in running.").
377 378 379 380
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
381
		Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep.").
Z
Zhuxiaoyang 已提交
382 383 384
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
S
soulseen 已提交
385
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
Z
Zhuxiaoyang 已提交
386 387 388
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
R
runzexia 已提交
389
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
Z
Zhuxiaoyang 已提交
390 391
		Writes(devops.StopPipe{}))

392 393
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/stop/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/stop").
Z
Zhuxiaoyang 已提交
394 395 396
		To(devopsapi.StopPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Stop pipeline in running").
397 398 399
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
400
		Param(webservice.QueryParameter("blocking", "stop and between each retries will sleep.").
Z
Zhuxiaoyang 已提交
401 402 403
			Required(false).
			DataFormat("blocking=%t").
			DefaultValue("blocking=false")).
S
soulseen 已提交
404
		Param(webservice.QueryParameter("timeOutInSecs", "the time of stop and between each retries sleep.").
Z
Zhuxiaoyang 已提交
405 406 407 408 409 410
			Required(false).
			DataFormat("timeOutInSecs=%d").
			DefaultValue("timeOutInSecs=10")).
		Returns(http.StatusOK, RespOK, devops.StopPipe{}).
		Writes(devops.StopPipe{}))

411 412
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/Replay/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/replay").
Z
Zhuxiaoyang 已提交
413
		To(devopsapi.ReplayBranchPipeline).
Z
Zhuxiaoyang 已提交
414
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
415
		Doc("(MultiBranchesPipeline) Replay pipeline").
416 417 418 419
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
R
runzexia 已提交
420
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
Z
Zhuxiaoyang 已提交
421 422
		Writes(devops.ReplayPipe{}))

423 424
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/Replay/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/replay").
Z
Zhuxiaoyang 已提交
425 426 427
		To(devopsapi.ReplayPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Replay pipeline").
428 429 430
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
Z
Zhuxiaoyang 已提交
431 432 433
		Returns(http.StatusOK, RespOK, devops.ReplayPipe{}).
		Writes(devops.ReplayPipe{}))

434 435
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/log/?start=0
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/log").
Z
Zhuxiaoyang 已提交
436
		To(devopsapi.GetBranchRunLog).
Z
Zhuxiaoyang 已提交
437
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
438
		Doc("(MultiBranchesPipeline) Get Pipelines run log.").
Z
Zhuxiaoyang 已提交
439
		Produces("text/plain; charset=utf-8").
440 441 442 443
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
444
		Param(webservice.QueryParameter("start", "the count of item start.").
S
soulseen 已提交
445
			Required(true).
Z
Zhuxiaoyang 已提交
446 447 448
			DataFormat("start=%d").
			DefaultValue("start=0")))

449 450
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/log/?start=0
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/log").
Z
Zhuxiaoyang 已提交
451 452 453 454
		To(devopsapi.GetRunLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Pipelines run log.").
		Produces("text/plain; charset=utf-8").
455 456 457
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
458
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
459 460 461 462
			Required(true).
			DataFormat("start=%d").
			DefaultValue("start=0")))

463 464
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{branch}/runs/{run}/artifacts
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/artifacts").
Z
Zhuxiaoyang 已提交
465
		To(devopsapi.GetBranchArtifacts).
Z
Zhuxiaoyang 已提交
466
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
467
		Doc("(MultiBranchesPipeline) Get pipeline artifacts.").
468 469 470 471
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
472
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
473 474
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
475
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
476 477 478 479 480
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

481 482
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/{run}/artifacts
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/artifacts").
Z
Zhuxiaoyang 已提交
483 484 485
		To(devopsapi.GetArtifacts).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get pipeline artifacts.").
486 487 488
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
489
		Param(webservice.QueryParameter("start", "the count of item start.").
Z
Zhuxiaoyang 已提交
490 491
			Required(false).
			DataFormat("start=%d")).
S
soulseen 已提交
492
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
493 494 495 496 497
			Required(false).
			DataFormat("limit=%d")).
		Returns(http.StatusOK, "The filed of \"Url\" in response can download artifacts", []devops.Artifacts{}).
		Writes([]devops.Artifacts{}))

498 499
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/?filter=&start&limit=
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches").
Z
Zhuxiaoyang 已提交
500 501
		To(devopsapi.GetPipeBranch).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
502
		Doc("(MultiBranchesPipeline) Get pipeline branches.").
503 504
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
R
runzexia 已提交
505
		Param(webservice.QueryParameter("filter", "filter remote scm. e.g. origin").
Z
Zhuxiaoyang 已提交
506 507
			Required(true).
			DataFormat("filter=%s")).
R
runzexia 已提交
508
		Param(webservice.QueryParameter("start", "the count of branches start.").
Z
Zhuxiaoyang 已提交
509 510
			Required(true).
			DataFormat("start=%d")).
R
runzexia 已提交
511
		Param(webservice.QueryParameter("limit", "the count of branches limit.").
S
soulseen 已提交
512
			Required(true).
Z
Zhuxiaoyang 已提交
513
			DataFormat("limit=%d")).
R
runzexia 已提交
514
		Returns(http.StatusOK, RespOK, []devops.PipeBranch{}).
Z
Zhuxiaoyang 已提交
515 516
		Writes([]devops.PipeBranch{}))

517 518
	// /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps/{step}").
Z
Zhuxiaoyang 已提交
519
		To(devopsapi.CheckBranchPipeline).
Z
Zhuxiaoyang 已提交
520
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
521
		Doc("(MultiBranchesPipeline) Proceed/Break paused pipeline").
Z
Zhuxiaoyang 已提交
522 523
		Reads(devops.CheckPlayload{}).
		Produces("text/plain; charset=utf-8").
524 525 526 527 528 529 530 531 532
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
		Param(webservice.PathParameter("step", "pipeline step id, the one step in pipeline.")))

	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps/{step}").
Z
Zhuxiaoyang 已提交
533 534
		To(devopsapi.CheckPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
535
		Doc("Proceed/Break paused pipeline").
Z
Zhuxiaoyang 已提交
536 537
		Reads(devops.CheckPlayload{}).
		Produces("text/plain; charset=utf-8").
538 539 540 541 542
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
		Param(webservice.PathParameter("step", "pipeline step id")))
Z
Zhuxiaoyang 已提交
543

Z
Zhuxiaoyang 已提交
544
	// match /job/project-8QnvykoJw4wZ/job/test-1/indexing/consoleText
545
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/consolelog").
Z
Zhuxiaoyang 已提交
546 547 548 549
		To(devopsapi.GetConsoleLog).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get index console log.").
		Produces("text/plain; charset=utf-8").
550 551
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")))
Z
Zhuxiaoyang 已提交
552

553 554
	// match /job/{devops}/job/{pipeline}/build?delay=0
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/scan").
Z
Zhuxiaoyang 已提交
555 556
		To(devopsapi.ScanBranch).
		Metadata(restfulspec.KeyOpenAPITags, tags).
557
		Doc("Scan remote Repositorie, Start a build if have new branch.").
Z
Zhuxiaoyang 已提交
558
		Produces("text/html; charset=utf-8").
559 560
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
S
soulseen 已提交
561 562
		Param(webservice.QueryParameter("delay", "will be delay time to scan.").
			Required(false).
Z
Zhuxiaoyang 已提交
563 564
			DataFormat("delay=%d")))

565 566
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/branches/{}/runs/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/run").
Z
Zhuxiaoyang 已提交
567
		To(devopsapi.RunBranchPipeline).
Z
Zhuxiaoyang 已提交
568
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
569
		Doc("(MultiBranchesPipeline) Run pipeline.").
Z
Zhuxiaoyang 已提交
570
		Reads(devops.RunPayload{}).
571 572 573
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
R
runzexia 已提交
574
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
Z
Zhuxiaoyang 已提交
575
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
576

577 578
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/{pipeline}/runs/
	webservice.Route(webservice.POST("/devops/{devops}/pipelines/{pipeline}/run").
Z
Zhuxiaoyang 已提交
579 580 581 582
		To(devopsapi.RunPipeline).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Run pipeline.").
		Reads(devops.RunPayload{}).
583 584
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
Z
Zhuxiaoyang 已提交
585 586
		Returns(http.StatusOK, RespOK, devops.QueuedBlueRun{}).
		Writes(devops.QueuedBlueRun{}))
Z
Zhuxiaoyang 已提交
587 588

	// match /crumbIssuer/api/json/
589
	webservice.Route(webservice.GET("/crumbissuer").
Z
Zhuxiaoyang 已提交
590 591
		To(devopsapi.GetCrumb).
		Metadata(restfulspec.KeyOpenAPITags, tags).
R
runzexia 已提交
592
		Doc("Get crumb issuer. A CrumbIssuer represents an algorithm to generate a nonce value, known as a crumb, to counter cross site request forgery exploits. Crumbs are typically hashes incorporating information that uniquely identifies an agent that sends a request, along with a guarded secret so that the crumb value cannot be forged by a third party.").
R
runzexia 已提交
593
		Returns(http.StatusOK, RespOK, devops.Crumb{}).
Z
Zhuxiaoyang 已提交
594
		Writes(devops.Crumb{}))
S
soulseen 已提交
595

596 597 598 599 600 601 602 603 604 605 606
	// TODO are not used in this version. will be added in 2.1.0
	//// 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(devops.ReqScript{}).
	//	Returns(http.StatusOK, RespOK, devops.CheckScript{}).
	//	Writes(devops.CheckScript{}))
Z
Zhuxiaoyang 已提交
607 608

	// match /job/init-job/descriptorByName/hudson.triggers.TimerTrigger/checkSpec
609 610 611 612 613 614 615 616 617 618 619 620 621 622
	//webservice.Route(webservice.GET("/devops/check/cron").
	//	To(devopsapi.CheckCron).
	//	Metadata(restfulspec.KeyOpenAPITags, tags).
	//	Produces("application/json", "charset=utf-8").
	//	Doc("Check cron script compile.").
	//	Param(webservice.QueryParameter("value", "string of cron script.").
	//		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/{devops}/{pipeline}/runs/{run}/
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}").
Z
Zhuxiaoyang 已提交
623 624 625
		To(devopsapi.GetPipelineRun).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get run pipeline in project.").
626 627 628
		Param(webservice.PathParameter("devops", "the name of devops project")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
Z
Zhuxiaoyang 已提交
629 630 631
		Returns(http.StatusOK, RespOK, devops.PipelineRun{}).
		Writes(devops.PipelineRun{}))

632 633
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/branches/{branch}
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}").
Z
Zhuxiaoyang 已提交
634
		To(devopsapi.GetBranchPipeline).
Z
Zhuxiaoyang 已提交
635
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
636
		Doc("(MultiBranchesPipeline) Get Pipeline run by branch.").
637 638 639
		Param(webservice.PathParameter("devops", "the name of devops project")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach")).
Z
Zhuxiaoyang 已提交
640 641
		Returns(http.StatusOK, RespOK, devops.BranchPipeline{}).
		Writes(devops.BranchPipeline{}))
Z
Zhuxiaoyang 已提交
642

643 644
	// match /blue/rest/organizations/jenkins/pipelines/{devops}/pipelines/{pipeline}/runs/{run}/nodes/?limit=10000
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes").
Z
Zhuxiaoyang 已提交
645
		To(devopsapi.GetPipelineRunNodes).
Z
Zhuxiaoyang 已提交
646 647
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get Pipeline run nodes.").
648 649 650
		Param(webservice.PathParameter("devops", "the name of devops project")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build")).
S
soulseen 已提交
651
		Param(webservice.QueryParameter("limit", "the count of item limit").
Z
Zhuxiaoyang 已提交
652 653
			Required(false).
			DataFormat("limit=%d")).
Z
Zhuxiaoyang 已提交
654 655
		Returns(http.StatusOK, RespOK, []devops.PipelineRunNodes{}).
		Writes([]devops.PipelineRunNodes{}))
Z
Zhuxiaoyang 已提交
656 657

	// match /blue/rest/organizations/jenkins/pipelines/%s/%s/branches/%s/runs/%s/nodes/%s/steps/?limit=
658
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodes/{node}/steps").
Z
Zhuxiaoyang 已提交
659
		To(devopsapi.GetBranchNodeSteps).
Z
Zhuxiaoyang 已提交
660
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
661
		Doc("(MultiBranchesPipeline) Get steps in node by branch.").
662 663 664 665 666
		Param(webservice.PathParameter("devops", "the name of devops project")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
S
soulseen 已提交
667
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
668 669
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
670
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
671 672
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
673
	// match /blue/rest/organizations/jenkins/pipelines/%s/%s/runs/%s/nodes/%s/steps/?limit=
674
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps").
Z
Zhuxiaoyang 已提交
675 676 677
		To(devopsapi.GetNodeSteps).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Doc("Get steps in node.").
678 679 680 681
		Param(webservice.PathParameter("devops", "the name of devops project")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build")).
		Param(webservice.PathParameter("node", "pipeline node id, the one node in pipeline.")).
S
soulseen 已提交
682
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
683 684
			Required(false).
			DataFormat("limit=%d")).
R
runzexia 已提交
685
		Returns(http.StatusOK, RespOK, []devops.NodeSteps{}).
Z
Zhuxiaoyang 已提交
686 687
		Writes([]devops.NodeSteps{}))

Z
Zhuxiaoyang 已提交
688
	// match /pipeline-model-converter/toJenkinsfile
689
	webservice.Route(webservice.POST("/tojenkinsfile").
Z
Zhuxiaoyang 已提交
690 691 692 693
		To(devopsapi.ToJenkinsfile).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Consumes("application/x-www-form-urlencoded").
		Produces("application/json", "charset=utf-8").
S
soulseen 已提交
694
		Doc("Convert json to jenkinsfile format.").
Z
Zhuxiaoyang 已提交
695
		Reads(devops.ReqJson{}).
R
runzexia 已提交
696
		Returns(http.StatusOK, RespOK, devops.ResJenkinsfile{}).
Z
Zhuxiaoyang 已提交
697 698 699
		Writes(devops.ResJenkinsfile{}))

	// match /pipeline-model-converter/toJson
700
	webservice.Route(webservice.POST("/tojson").
Z
Zhuxiaoyang 已提交
701 702 703 704
		To(devopsapi.ToJson).
		Metadata(restfulspec.KeyOpenAPITags, tags).
		Consumes("application/x-www-form-urlencoded").
		Produces("application/json", "charset=utf-8").
S
soulseen 已提交
705
		Doc("Convert jenkinsfile to json format. Usually the frontend uses json to show or edit pipeline").
Z
Zhuxiaoyang 已提交
706
		Reads(devops.ReqJenkinsfile{}).
R
runzexia 已提交
707
		Returns(http.StatusOK, RespOK, devops.ResJson{}).
Z
Zhuxiaoyang 已提交
708 709
		Writes(devops.ResJson{}))

Z
Zhuxiaoyang 已提交
710
	// match /git/notifyCommit/?url=
711
	webservice.Route(webservice.GET("/webhook/git").
Z
Zhuxiaoyang 已提交
712 713
		To(devopsapi.GetNotifyCommit).
		Metadata(restfulspec.KeyOpenAPITags, tags).
714
		Doc("Get commit notification by HTTP GET method. Git webhook will request here.").
Z
Zhuxiaoyang 已提交
715
		Produces("text/plain; charset=utf-8").
R
runzexia 已提交
716
		Param(webservice.QueryParameter("url", "url of git scm").
Z
Zhuxiaoyang 已提交
717 718 719 720
			Required(true).
			DataFormat("url=%s")))

	// Gitlab or some other scm managers can only use HTTP method. match /git/notifyCommit/?url=
721
	webservice.Route(webservice.POST("/webhook/git").
R
runzexia 已提交
722
		To(devopsapi.PostNotifyCommit).
Z
Zhuxiaoyang 已提交
723
		Metadata(restfulspec.KeyOpenAPITags, tags).
724
		Doc("Get commit notification by HTTP POST method. Git webhook will request here.").
Z
Zhuxiaoyang 已提交
725 726
		Consumes("application/json").
		Produces("text/plain; charset=utf-8").
R
runzexia 已提交
727
		Param(webservice.QueryParameter("url", "url of git scm").
Z
Zhuxiaoyang 已提交
728 729 730
			Required(true).
			DataFormat("url=%s")))

731
	webservice.Route(webservice.POST("/webhook/github").
Z
Zhuxiaoyang 已提交
732 733
		To(devopsapi.GithubWebhook).
		Metadata(restfulspec.KeyOpenAPITags, tags).
734
		Doc("Get commit notification. Github webhook will request here."))
Z
Zhuxiaoyang 已提交
735

Z
Zhuxiaoyang 已提交
736
	// in scm get all steps in nodes.
737
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/branches/{branch}/runs/{run}/nodesdetail").
Z
Zhuxiaoyang 已提交
738 739
		To(devopsapi.GetBranchNodesDetail).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
740
		Doc("(MultiBranchesPipeline) Gives steps details inside a pipeline node by branch. For a Stage, the steps will include all the steps defined inside the stage.").
741 742 743 744
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
745
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
746 747
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
748
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
749 750 751
		Writes(devops.NodesDetail{}))

	// out of scm get all steps in nodes.
752
	webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/runs/{run}/nodesdetail").
Z
Zhuxiaoyang 已提交
753 754
		To(devopsapi.GetNodesDetail).
		Metadata(restfulspec.KeyOpenAPITags, tags).
S
soulseen 已提交
755
		Doc("Gives steps details inside a pipeline node. For a Stage, the steps will include all the steps defined inside the stage.").
756 757 758 759
		Param(webservice.PathParameter("devops", "DevOps Project's Id, e.g. project-RRRRAzLBlLEm")).
		Param(webservice.PathParameter("pipeline", "the name of pipeline, which helps to deliver continuous integration continuous deployment.")).
		Param(webservice.PathParameter("branch", "the name of branch, same as repository brnach.")).
		Param(webservice.PathParameter("run", "pipeline run id, the unique id for a pipeline once build.")).
S
soulseen 已提交
760
		Param(webservice.QueryParameter("limit", "the count of item limit.").
Z
Zhuxiaoyang 已提交
761 762
			Required(true).
			DataFormat("limit=%d")).
R
runzexia 已提交
763
		Returns(http.StatusOK, RespOK, []devops.NodesDetail{}).
Z
Zhuxiaoyang 已提交
764 765
		Writes(devops.NodesDetail{}))

S
sunzhu 已提交
766 767 768 769
	c.Add(webservice)

	return nil
}