Skip to content

Commit

Permalink
feat:MR 事件触发器支持 WIP TencentBlueKing#10683 webhook查询接口增加分页参数
Browse files Browse the repository at this point in the history
  • Loading branch information
hejieehe committed Sep 29, 2024
1 parent f1d0d4a commit 8e4be9c
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ open class GitApi {
private const val BRANCH_LIMIT = 200
private const val TAG_LIMIT = 200
private const val HOOK_LIMIT = 200
// 接口分页最大行数
const val MAX_PAGE_SIZE = 500
}

private fun getMessageByLocale(messageCode: String, params: Array<String>? = null): String {
Expand Down Expand Up @@ -339,9 +341,16 @@ open class GitApi {
}
}

fun getHooks(host: String, token: String, projectName: String): List<GitHook> {
fun getHooks(
host: String,
token: String,
projectName: String,
page: Int = 1,
pageSize: Int = MAX_PAGE_SIZE
): List<GitHook> {
try {
val request = get(host, token, "projects/${urlEncode(projectName)}/hooks", "")
val pageQueryStr = "page=$page&per_page=$pageSize"
val request = get(host, token, "projects/${urlEncode(projectName)}/hooks", pageQueryStr)
val result = JsonUtil.getObjectMapper().readValue<List<GitHook>>(
getBody(getMessageByLocale(CommonMessageCode.OPERATION_LIST_WEBHOOK), request)
)
Expand Down

0 comments on commit 8e4be9c

Please sign in to comment.