2022-12-12 22:09:57 +01:00
|
|
|
module client
|
|
|
|
|
|
|
|
import build { BuildConfig }
|
2022-12-13 22:03:04 +01:00
|
|
|
import web.response { Response }
|
2022-12-12 22:09:57 +01:00
|
|
|
|
2022-12-13 17:51:42 +01:00
|
|
|
// poll_jobs requests a list of new build jobs from the server.
|
2022-12-12 22:58:43 +01:00
|
|
|
pub fn (c &Client) poll_jobs(arch string, max int) ![]BuildConfig {
|
2022-12-12 22:09:57 +01:00
|
|
|
data := c.send_request<[]BuildConfig>(.get, '/api/v1/jobs/poll', {
|
2022-12-12 22:58:43 +01:00
|
|
|
'arch': arch
|
|
|
|
'max': max.str()
|
2022-12-12 22:09:57 +01:00
|
|
|
})!
|
|
|
|
|
|
|
|
return data.data
|
|
|
|
}
|
2022-12-13 22:03:04 +01:00
|
|
|
|
2022-12-14 16:03:57 +01:00
|
|
|
// queue_job adds a new one-time build job for the given target to the job
|
|
|
|
// queue.
|
2022-12-13 22:03:04 +01:00
|
|
|
pub fn (c &Client) queue_job(target_id int, arch string, force bool) !Response<string> {
|
|
|
|
data := c.send_request<string>(.post, '/api/v1/jobs/queue', {
|
|
|
|
'target': target_id.str()
|
|
|
|
'arch': arch
|
|
|
|
'force': force.str()
|
|
|
|
})!
|
|
|
|
|
|
|
|
return data
|
|
|
|
}
|