feat(client): added client code for logs API

This commit is contained in:
Jef Roosens 2022-05-07 19:38:28 +02:00
parent 407b226955
commit fa6603bd45
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
8 changed files with 81 additions and 29 deletions

42
src/client/logs.v Normal file
View file

@ -0,0 +1,42 @@
module client
import db { BuildLog }
import net.http { Method }
import response { Response }
import time
pub fn (c &Client) get_build_logs() ?Response<[]BuildLog> {
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', {}) ?
return data
}
pub fn (c &Client) get_build_logs_for_repo(repo_id int) ?Response<[]BuildLog> {
params := {
'repo': repo_id.str()
}
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', params) ?
return data
}
pub fn (c &Client) get_build_log(id int) ?Response<BuildLog> {
data := c.send_request<BuildLog>(Method.get, '/api/logs/$id', {}) ?
return data
}
pub fn (c &Client) add_build_log(repo_id int, start_time time.Time, end_time time.Time, arch string, exit_code int, content string) ?Response<string> {
params := {
'repo': repo_id.str()
'startTime': start_time.str()
'endTime': end_time.str()
'arch': arch
'exitCode': exit_code.str()
}
data := c.send_request_with_body<string>(Method.post, '/api/logs', params, content) ?
return data
}