forked from vieter-v/vieter
feat(client): added client code for logs API
This commit is contained in:
parent
407b226955
commit
fa6603bd45
8 changed files with 81 additions and 29 deletions
42
src/client/logs.v
Normal file
42
src/client/logs.v
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue