Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OpenApi提供转发Turbo编译加速上报资源统计数据接口 #10508 #10521

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,40 @@ interface ApigwTurboResourceV4 {
@QueryParam("pageSize")
pageSize: Int?
): Response<Page<ProjectResourceUsageVO>>

@GET
@Operation(summary = "触发项目资源统计上报任务", tags = ["v4_app_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>

@POST
@Operation(summary = "手动上报项目资源统计数据", tags = ["v4_app_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)
}
}
Loading