forked from vieter-v/vieter
refactor: renamed codebase to "targets"
This commit is contained in:
parent
faec08f846
commit
102a7f8899
19 changed files with 205 additions and 191 deletions
|
|
@ -13,10 +13,10 @@ pub fn (c &Client) get_build_logs(filter BuildLogFilter) ?Response<[]BuildLog> {
|
|||
return data
|
||||
}
|
||||
|
||||
// get_build_logs_for_repo returns all build logs for a given repo.
|
||||
pub fn (c &Client) get_build_logs_for_repo(repo_id int) ?Response<[]BuildLog> {
|
||||
// get_build_logs_for_target returns all build logs for a given target.
|
||||
pub fn (c &Client) get_build_logs_for_target(target_id int) ?Response<[]BuildLog> {
|
||||
params := {
|
||||
'repo': repo_id.str()
|
||||
'repo': target_id.str()
|
||||
}
|
||||
|
||||
data := c.send_request<[]BuildLog>(Method.get, '/api/v1/logs', params)?
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
module client
|
||||
|
||||
import models { GitRepo, GitRepoFilter }
|
||||
import models { Target, TargetFilter }
|
||||
import net.http { Method }
|
||||
import response { Response }
|
||||
|
||||
// get_targets returns a list of GitRepo's, given a filter object.
|
||||
pub fn (c &Client) get_targets(filter GitRepoFilter) ?[]GitRepo {
|
||||
// get_targets returns a list of targets, given a filter object.
|
||||
pub fn (c &Client) get_targets(filter TargetFilter) ?[]Target {
|
||||
params := models.params_from(filter)
|
||||
data := c.send_request<[]GitRepo>(Method.get, '/api/v1/targets', params)?
|
||||
data := c.send_request<[]Target>(Method.get, '/api/v1/targets', params)?
|
||||
|
||||
return data.data
|
||||
}
|
||||
|
||||
// get_all_targets retrieves *all* GitRepo's from the API using the default
|
||||
// get_all_targets retrieves *all* targs from the API using the default
|
||||
// limit.
|
||||
pub fn (c &Client) get_all_targets() ?[]GitRepo {
|
||||
mut repos := []GitRepo{}
|
||||
pub fn (c &Client) get_all_targets() ?[]Target {
|
||||
mut targets := []Target{}
|
||||
mut offset := u64(0)
|
||||
|
||||
for {
|
||||
sub_repos := c.get_targets(offset: offset)?
|
||||
sub_targets := c.get_targets(offset: offset)?
|
||||
|
||||
if sub_repos.len == 0 {
|
||||
if sub_targets.len == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
repos << sub_repos
|
||||
targets << sub_targets
|
||||
|
||||
offset += u64(sub_repos.len)
|
||||
offset += u64(sub_targets.len)
|
||||
}
|
||||
|
||||
return repos
|
||||
return targets
|
||||
}
|
||||
|
||||
// get_target returns the repo for a specific ID.
|
||||
pub fn (c &Client) get_target(id int) ?GitRepo {
|
||||
data := c.send_request<GitRepo>(Method.get, '/api/v1/targets/$id', {})?
|
||||
// get_target returns the target for a specific id.
|
||||
pub fn (c &Client) get_target(id int) ?Target {
|
||||
data := c.send_request<Target>(Method.get, '/api/v1/targets/$id', {})?
|
||||
|
||||
return data.data
|
||||
}
|
||||
|
||||
// add_target adds a new repo to the server.
|
||||
// add_target adds a new target to the server.
|
||||
pub fn (c &Client) add_target(url string, branch string, repo string, arch []string) ?Response<string> {
|
||||
mut params := {
|
||||
'url': url
|
||||
|
|
@ -57,14 +57,14 @@ pub fn (c &Client) add_target(url string, branch string, repo string, arch []str
|
|||
return data
|
||||
}
|
||||
|
||||
// remove_target removes the repo with the given ID from the server.
|
||||
// remove_target removes the target with the given id from the server.
|
||||
pub fn (c &Client) remove_target(id int) ?Response<string> {
|
||||
data := c.send_request<string>(Method.delete, '/api/v1/targets/$id', {})?
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// patch_target sends a PATCH request to the given repo with the params as
|
||||
// patch_target sends a PATCH request to the given target with the params as
|
||||
// payload.
|
||||
pub fn (c &Client) patch_target(id int, params map[string]string) ?Response<string> {
|
||||
data := c.send_request<string>(Method.patch, '/api/v1/targets/$id', params)?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue