forked from vieter-v/vieter
refactor: apply new vfmt defaults
This commit is contained in:
parent
53f5b68d08
commit
5f21e256ee
24 changed files with 138 additions and 138 deletions
|
|
@ -37,10 +37,10 @@ fn (c &Client) send_request_raw(method Method, url string, params map[string]str
|
|||
full_url = '$full_url?$params_str'
|
||||
}
|
||||
|
||||
mut req := http.new_request(method, full_url, body) ?
|
||||
req.add_custom_header('X-Api-Key', c.api_key) ?
|
||||
mut req := http.new_request(method, full_url, body)?
|
||||
req.add_custom_header('X-Api-Key', c.api_key)?
|
||||
|
||||
res := req.do() ?
|
||||
res := req.do()?
|
||||
|
||||
return res
|
||||
}
|
||||
|
|
@ -53,15 +53,15 @@ fn (c &Client) send_request<T>(method Method, url string, params map[string]stri
|
|||
// send_request_with_body<T> calls send_request_raw_response & parses its
|
||||
// output as a Response<T> object.
|
||||
fn (c &Client) send_request_with_body<T>(method Method, url string, params map[string]string, body string) ?Response<T> {
|
||||
res_text := c.send_request_raw_response(method, url, params, body) ?
|
||||
data := json.decode(Response<T>, res_text) ?
|
||||
res_text := c.send_request_raw_response(method, url, params, body)?
|
||||
data := json.decode(Response<T>, res_text)?
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// send_request_raw_response returns the raw text response for an HTTP request.
|
||||
fn (c &Client) send_request_raw_response(method Method, url string, params map[string]string, body string) ?string {
|
||||
res := c.send_request_raw(method, url, params, body) ?
|
||||
res := c.send_request_raw(method, url, params, body)?
|
||||
|
||||
return res.text
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ import response { Response }
|
|||
|
||||
// get_git_repos returns the current list of repos.
|
||||
pub fn (c &Client) get_git_repos() ?[]GitRepo {
|
||||
data := c.send_request<[]GitRepo>(Method.get, '/api/repos', {}) ?
|
||||
data := c.send_request<[]GitRepo>(Method.get, '/api/repos', {})?
|
||||
|
||||
return data.data
|
||||
}
|
||||
|
||||
// get_git_repo returns the repo for a specific ID.
|
||||
pub fn (c &Client) get_git_repo(id int) ?GitRepo {
|
||||
data := c.send_request<GitRepo>(Method.get, '/api/repos/$id', {}) ?
|
||||
data := c.send_request<GitRepo>(Method.get, '/api/repos/$id', {})?
|
||||
|
||||
return data.data
|
||||
}
|
||||
|
|
@ -30,14 +30,14 @@ pub fn (c &Client) add_git_repo(url string, branch string, repo string, arch []s
|
|||
params['arch'] = arch.join(',')
|
||||
}
|
||||
|
||||
data := c.send_request<string>(Method.post, '/api/repos', params) ?
|
||||
data := c.send_request<string>(Method.post, '/api/repos', params)?
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// remove_git_repo removes the repo with the given ID from the server.
|
||||
pub fn (c &Client) remove_git_repo(id int) ?Response<string> {
|
||||
data := c.send_request<string>(Method.delete, '/api/repos/$id', {}) ?
|
||||
data := c.send_request<string>(Method.delete, '/api/repos/$id', {})?
|
||||
|
||||
return data
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ pub fn (c &Client) remove_git_repo(id int) ?Response<string> {
|
|||
// patch_git_repo sends a PATCH request to the given repo with the params as
|
||||
// payload.
|
||||
pub fn (c &Client) patch_git_repo(id int, params map[string]string) ?Response<string> {
|
||||
data := c.send_request<string>(Method.patch, '/api/repos/$id', params) ?
|
||||
data := c.send_request<string>(Method.patch, '/api/repos/$id', params)?
|
||||
|
||||
return data
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import time
|
|||
|
||||
// get_build_logs returns all build logs.
|
||||
pub fn (c &Client) get_build_logs() ?Response<[]BuildLog> {
|
||||
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', {}) ?
|
||||
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', {})?
|
||||
|
||||
return data
|
||||
}
|
||||
|
|
@ -18,21 +18,21 @@ pub fn (c &Client) get_build_logs_for_repo(repo_id int) ?Response<[]BuildLog> {
|
|||
'repo': repo_id.str()
|
||||
}
|
||||
|
||||
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', params) ?
|
||||
data := c.send_request<[]BuildLog>(Method.get, '/api/logs', params)?
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// get_build_log returns a specific build log.
|
||||
pub fn (c &Client) get_build_log(id int) ?Response<BuildLog> {
|
||||
data := c.send_request<BuildLog>(Method.get, '/api/logs/$id', {}) ?
|
||||
data := c.send_request<BuildLog>(Method.get, '/api/logs/$id', {})?
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// get_build_log_content returns the contents of the build log file.
|
||||
pub fn (c &Client) get_build_log_content(id int) ?string {
|
||||
data := c.send_request_raw_response(Method.get, '/api/logs/$id/content', {}, '') ?
|
||||
data := c.send_request_raw_response(Method.get, '/api/logs/$id/content', {}, '')?
|
||||
|
||||
return data
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ pub fn (c &Client) add_build_log(repo_id int, start_time time.Time, end_time tim
|
|||
'exitCode': exit_code.str()
|
||||
}
|
||||
|
||||
data := c.send_request_with_body<string>(Method.post, '/api/logs', params, content) ?
|
||||
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