Skip to content

Commit

Permalink
feat: OpenApi提供转发Turbo编译加速上报资源统计数据接口 TencentBlueKing#10508
Browse files Browse the repository at this point in the history
  • Loading branch information
eazence committed Jun 13, 2024
1 parent d66cb5d commit 975d156
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/ci/core/openapi/api-openapi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
api(project(":core:project:api-project"))
api(project(":core:metrics:api-metrics"))
api("com.tencent.devops:devops-boot-starter-api")
api("com.tencent.bk.devops.turbo:api-turbo:0.0.6-RELEASE") {
api("com.tencent.bk.devops.turbo:api-turbo:0.0.7-SNAPSHOT") {
isTransitive = false
}
api(project(":core:dispatch:api-dispatch-docker"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
package com.tencent.devops.openapi.api.apigw.v4

import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_PROJECT_ID
import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.turbo.pojo.TurboPlanModel
import com.tencent.devops.turbo.pojo.TurboRecordModel
import com.tencent.devops.turbo.vo.ProjectResourceUsageVO
import com.tencent.devops.turbo.vo.ResourceCostSummary
import com.tencent.devops.turbo.vo.TurboPlanDetailVO
import com.tencent.devops.turbo.vo.TurboPlanStatRowVO
import com.tencent.devops.turbo.vo.TurboRecordHistoryVO
Expand Down Expand Up @@ -153,4 +155,46 @@ interface ApigwTurboResourceV4 {
@QueryParam("pageSize")
pageSize: Int?
): Response<Page<ProjectResourceUsageVO>>

@GET
@Operation(
summary = "触发项目资源统计上报任务",
tags = ["v4_app_server_resources_upload_auto", "v4_user_server_resources_upload_auto"]
)
@Path("/triggerAutoUpload/{month}")
fun triggerAutoUpload(
@Parameter(description = "用户信息")
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@Parameter(description = "项目id")
@HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID)
projectId: String,
@Parameter(description = "所属周期月份")
@PathParam("month")
month: String,
@Parameter(description = "起始统计日期")
@QueryParam(value = "startDate")
startDate: String?,
@Parameter(description = "截止统计日期")
@QueryParam("endDate")
endDate: String?,
): Response<Boolean>

@GET
@Operation(
summary = "手动上报项目资源统计数据",
tags = ["v4_app_server_resources_upload_manual", "v4_user_server_resources_upload_manual"]
)
@Path("/manualUpload")
fun triggerManualUpload(
@Parameter(description = "用户信息")
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@Parameter(description = "项目id")
@HeaderParam(AUTH_HEADER_DEVOPS_PROJECT_ID)
projectId: String,
@Parameter(description = "待上报的数据")
@Valid
summary: ResourceCostSummary
): Response<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package com.tencent.devops.openapi.resources.apigw.v4
import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.api.util.DateTimeUtil
import com.tencent.devops.common.api.util.JsonUtil
import com.tencent.devops.common.client.Client
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.openapi.api.apigw.v4.ApigwTurboResourceV4
Expand All @@ -37,6 +38,7 @@ import com.tencent.devops.turbo.api.IServiceTurboController
import com.tencent.devops.turbo.pojo.TurboPlanModel
import com.tencent.devops.turbo.pojo.TurboRecordModel
import com.tencent.devops.turbo.vo.ProjectResourceUsageVO
import com.tencent.devops.turbo.vo.ResourceCostSummary
import com.tencent.devops.turbo.vo.TurboPlanDetailVO
import com.tencent.devops.turbo.vo.TurboPlanStatRowVO
import com.tencent.devops.turbo.vo.TurboRecordHistoryVO
Expand Down Expand Up @@ -134,4 +136,26 @@ class ApigwTurboResourceV4Impl @Autowired constructor(
return client.getSpringMvc(IServiceResourceStatController::class)
.getSummary(startDate, endDate, pageNum, pageSize)
}

override fun triggerAutoUpload(
userId: String,
projectId: String,
month: String,
startDate: String?,
endDate: String?
): Response<Boolean> {
logger.info("OPENAPI_TURBO_V4|triggerAutoUpload: $userId|$projectId|$month|$startDate|$endDate")
return client.getSpringMvc(IServiceResourceStatController::class)
.triggerAutoUpload(userId, projectId, month, startDate, endDate)
}

override fun triggerManualUpload(
userId: String,
projectId: String,
summary: ResourceCostSummary
): Response<Boolean> {
logger.info("OPENAPI_TURBO_V4|triggerManualUpload: $userId|$projectId|${JsonUtil.toJson(summary)}")
return client.getSpringMvc(IServiceResourceStatController::class)
.triggerManualUpload(userId, projectId, summary)
}
}

0 comments on commit 975d156

Please sign in to comment.