com.tencent.devops.process.api.user.UserPipelineResource.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-process Show documentation
Show all versions of api-process Show documentation
Tencent blueking ci project
The newest version!
/*
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license.
*
* A copy of the MIT License is included in this file.
*
*
* Terms of the MIT License:
* ---------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.tencent.devops.process.api.user
import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID
import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.pipeline.Model
import com.tencent.devops.common.pipeline.pojo.MatrixPipelineInfo
import com.tencent.devops.common.pipeline.pojo.PipelineModelAndSetting
import com.tencent.devops.common.pipeline.pojo.setting.PipelineSetting
import com.tencent.devops.common.web.annotation.BkApiPermission
import com.tencent.devops.common.web.constant.BkApiHandleType
import com.tencent.devops.process.engine.pojo.PipelineInfo
import com.tencent.devops.process.engine.pojo.PipelineVersionWithInfo
import com.tencent.devops.process.pojo.Permission
import com.tencent.devops.process.pojo.Pipeline
import com.tencent.devops.process.pojo.PipelineCollation
import com.tencent.devops.process.pojo.PipelineCopy
import com.tencent.devops.process.pojo.PipelineId
import com.tencent.devops.process.pojo.PipelineName
import com.tencent.devops.process.pojo.PipelineRemoteToken
import com.tencent.devops.process.pojo.PipelineSortType
import com.tencent.devops.process.pojo.PipelineStageTag
import com.tencent.devops.process.pojo.PipelineStatus
import com.tencent.devops.process.pojo.app.PipelinePage
import com.tencent.devops.process.pojo.classify.PipelineViewAndPipelines
import com.tencent.devops.process.pojo.classify.PipelineViewPipelinePage
import com.tencent.devops.process.pojo.pipeline.BatchDeletePipeline
import com.tencent.devops.process.pojo.pipeline.PipelineCount
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import javax.validation.Valid
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
import javax.ws.rs.DefaultValue
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.POST
import javax.ws.rs.PUT
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
@Tag(name = "USER_PIPELINE", description = "用户-流水线资源")
@Path("/user/pipelines")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Suppress("ALL")
interface UserPipelineResource {
@Operation(summary = "用户是否拥有创建流水线权限")
@GET
// @Path("/projects/{projectId}/hasCreatePermission")
@Path("/{projectId}/hasCreatePermission")
fun hasCreatePermission(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String
): Result
@Operation(summary = "流水线名是否存在")
@GET
// @Path("/projects/{projectId}/pipelineExist")
@Path("/{projectId}/pipelineExist")
fun pipelineExist(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线名", required = true)
@QueryParam("pipelineName")
pipelineName: String
): Result
@Operation(summary = "拥有权限流水线列表")
@GET
// @Path("/projects/{projectId}/hasPermissionList")
@Path("/{projectId}/hasPermissionList")
fun hasPermissionList(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "对应权限", required = true, example = "")
@QueryParam("permission")
permission: Permission,
@Parameter(description = "排除流水线ID", required = false, example = "")
@QueryParam("excludePipelineId")
excludePipelineId: String?,
@Parameter(description = "第几页", required = false, example = "1")
@QueryParam("page")
page: Int?,
@Parameter(description = "每页多少条", required = false, example = "20")
@QueryParam("pageSize")
pageSize: Int?
): Result>
@Operation(summary = "新建流水线编排")
@POST
// @Path("/projects/{projectId}/createPipeline")
@Path("/{projectId}")
fun create(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "是否使用模板配置", required = false)
@QueryParam("useTemplateSettings")
useTemplateSettings: Boolean? = false,
@Parameter(description = "流水线模型", required = true)
pipeline: Model
): Result
@Operation(summary = "用户是否拥有流水线权限")
@GET
// @Path("/projects/{projectId}/pipelines/{pipelineId}/hasPermission")
@Path("/{projectId}/{pipelineId}/hasPermission")
fun hasPermission(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线模型", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "权限", required = true)
@QueryParam("permission")
permission: Permission
): Result
@Operation(summary = "复制流水线编排")
@POST
// @Path("/projects/{projectId}/pipelines/{pipelineId}/copy")
@Path("/{projectId}/{pipelineId}/copy")
fun copy(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线模型", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线COPY", required = true)
pipeline: PipelineCopy
): Result
@Operation(summary = "编辑流水线编排")
@PUT
// @Path("/projects/{projectId}/pipelines/{pipelineId}/")
@Path("/{projectId}/{pipelineId}/")
fun editPipeline(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线模型", required = true)
pipeline: Model
): Result
@Operation(summary = "编辑流水线编排以及设置")
@POST
// @Path("/projects/{projectId}/pipelines/{pipelineId}/saveAll")
@Path("/{projectId}/{pipelineId}/saveAll")
fun saveAll(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线模型与设置", required = true)
@Valid
modelAndSetting: PipelineModelAndSetting
): Result
@Operation(summary = "保存流水线设置")
@POST
// @Path("/projects/{projectId}/pipelines/{pipelineId}/saveSetting")
@Path("/{projectId}/{pipelineId}/saveSetting")
fun saveSetting(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线设置", required = true)
setting: PipelineSetting
): Result
@Operation(summary = "启用/禁用流水线(修改流水线的并发设置)")
@POST
@Path("/projects/{projectId}/pipelines/{pipelineId}/lock")
fun lockPipeline(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "开启true/锁定false", required = true)
@QueryParam("enable")
enable: Boolean
): Result
@Operation(summary = "获取流水线编排")
@GET
// @Path("/projects/{projectId}/pipelines/{pipelineId}/")
@Path("/{projectId}/{pipelineId}/")
fun get(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@QueryParam("draft")
@DefaultValue("false")
includeDraft: Boolean? = false
): Result
@Operation(summary = "获取流水线编排版本")
@GET
@Path("/{projectId}/{pipelineId}/{version}")
fun getVersion(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线编排版本", required = true)
@PathParam("version")
version: Int
): Result
@Operation(summary = "生成远程执行token")
@PUT
// @Path("/projects/{projectId}/pipelines/{pipelineId}/remoteToken")
@Path("/{projectId}/{pipelineId}/remoteToken")
fun generateRemoteToken(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String
): Result
@Operation(summary = "删除流水线编排")
@DELETE
@Path("/{projectId}/{pipelineId}/")
fun softDelete(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "项目ID", required = true)
@PathParam("projectId")
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String
): Result
@Operation(summary = "批量删除流水线编排")
@DELETE
@Path("/batchDelete")
fun batchDelete(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
batchDeletePipeline: BatchDeletePipeline
): Result