forked from vieter-v/vieter
Compare commits
4 Commits
7ad5830e9f
...
95441bdea0
| Author | SHA1 | Date |
|---|---|---|
|
|
95441bdea0 | |
|
|
aea83c38ef | |
|
|
fc6d3909d2 | |
|
|
e734e658a0 |
|
|
@ -17,7 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
* CLI flags to take advantage of above API improvements
|
* CLI flags to take advantage of above API improvements
|
||||||
* Added CLI command to generate all man pages
|
* Added CLI command to generate all man pages
|
||||||
* PKGBUILDs now install man pages
|
* PKGBUILDs now install man pages
|
||||||
* CLI man pages are now hosted on https://rustybever.be
|
* Hosted CLI man pages ([vieter(1)](https://rustybever.be/man/vieter/vieter.1.html))
|
||||||
|
* Proper HTTP API docs ([link](https://rustybever.be/docs/vieter/api/))
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ curl \
|
||||||
https://example.com/api/repos?offset=10&limit=20
|
https://example.com/api/repos?offset=10&limit=20
|
||||||
```
|
```
|
||||||
|
|
||||||
> JSON Output format
|
> JSON output format
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +63,7 @@ curl \
|
||||||
https://example.com/api/repos/15
|
https://example.com/api/repos/15
|
||||||
```
|
```
|
||||||
|
|
||||||
> JSON Output format
|
> JSON output format
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ curl \
|
||||||
"url": "https://aur.archlinux.org/discord-ptb.git",
|
"url": "https://aur.archlinux.org/discord-ptb.git",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"repo": "bur",
|
"repo": "bur",
|
||||||
"schedule": " 0 3",
|
"schedule": "0 3",
|
||||||
"arch": [
|
"arch": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
|
@ -95,7 +95,7 @@ Get info about a specific Git repository.
|
||||||
|
|
||||||
Parameter | Description
|
Parameter | Description
|
||||||
--------- | -----------
|
--------- | -----------
|
||||||
repo | ID of requested repo
|
id | ID of requested repo
|
||||||
|
|
||||||
## Create a new repo
|
## Create a new repo
|
||||||
|
|
||||||
|
|
@ -121,7 +121,13 @@ Modify the data of an existing Git repository.
|
||||||
|
|
||||||
### HTTP Request
|
### HTTP Request
|
||||||
|
|
||||||
`PATCH /api/repos`
|
`PATCH /api/repos/:id`
|
||||||
|
|
||||||
|
### URL Parameters
|
||||||
|
|
||||||
|
Parameter | Description
|
||||||
|
--------- | -----------
|
||||||
|
id | ID of requested repo
|
||||||
|
|
||||||
### Query Parameters
|
### Query Parameters
|
||||||
|
|
||||||
|
|
@ -145,4 +151,4 @@ Remove a Git repository from the server.
|
||||||
|
|
||||||
Parameter | Description
|
Parameter | Description
|
||||||
--------- | -----------
|
--------- | -----------
|
||||||
repo | ID of repo to remove
|
id | ID of repo to remove
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
# Build Logs
|
||||||
|
|
||||||
|
<aside class="notice">
|
||||||
|
|
||||||
|
All routes in this section require authentication.
|
||||||
|
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
Endpoints for interacting with stored build logs.
|
||||||
|
|
||||||
|
## List logs
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl \
|
||||||
|
-H 'X-Api-Key: secret' \
|
||||||
|
https://example.com/api/logs?offset=10&limit=20
|
||||||
|
```
|
||||||
|
|
||||||
|
> JSON output format
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"message": "",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"repo_id": 3,
|
||||||
|
"start_time": 1652008554,
|
||||||
|
"end_time": 1652008559,
|
||||||
|
"arch": "x86_64",
|
||||||
|
"exit_code": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Retrieve a list of build logs.
|
||||||
|
|
||||||
|
### HTTP Request
|
||||||
|
|
||||||
|
`GET /api/logs`
|
||||||
|
|
||||||
|
### Query Parameters
|
||||||
|
|
||||||
|
Parameter | Description
|
||||||
|
--------- | -----------
|
||||||
|
limit | Maximum amount of results to return.
|
||||||
|
offset | Offset of results.
|
||||||
|
repo | Only return builds published to this repository.
|
||||||
|
before | Only return logs started before this time (UTC epoch)
|
||||||
|
after | Only return logs started after this time (UTC epoch)
|
||||||
|
arch | Only return logs built on this architecture
|
||||||
|
exit_codes | Comma-separated list of exit codes to limit result to; using `!` as a prefix makes it exclude that value. For example, `1,2` only returns logs with status code 1 or 2, while `!1,!2` returns those that don't have 1 or 2 as the result.
|
||||||
|
|
||||||
|
|
||||||
|
## Get build log
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl \
|
||||||
|
-H 'X-Api-Key: secret' \
|
||||||
|
https://example.com/api/logs/15
|
||||||
|
```
|
||||||
|
|
||||||
|
> JSON output format
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"id": 1,
|
||||||
|
"repo_id": 3,
|
||||||
|
"start_time": 1652008554,
|
||||||
|
"end_time": 1652008559,
|
||||||
|
"arch": "x86_64",
|
||||||
|
"exit_code": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Retrieve info about a specific build log.
|
||||||
|
|
||||||
|
### HTTP Request
|
||||||
|
|
||||||
|
`GET /api/logs/:id`
|
||||||
|
|
||||||
|
### URL Parameters
|
||||||
|
|
||||||
|
Parameter | Description
|
||||||
|
--------- | -----------
|
||||||
|
id | ID of requested log
|
||||||
|
|
||||||
|
## Get log contents
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl \
|
||||||
|
-H 'X-Api-Key: secret' \
|
||||||
|
https://example.com/api/logs/15/content
|
||||||
|
```
|
||||||
|
|
||||||
|
Retrieve the contents of a build log. The response is the build log in
|
||||||
|
plaintext.
|
||||||
|
|
||||||
|
### HTTP Request
|
||||||
|
|
||||||
|
`GET /api/logs/:id/content`
|
||||||
|
|
||||||
|
### URL Parameters
|
||||||
|
|
||||||
|
Parameter | Description
|
||||||
|
--------- | -----------
|
||||||
|
id | ID of requested log
|
||||||
|
|
||||||
|
## Publish build log
|
||||||
|
|
||||||
|
<aside class="warning">
|
||||||
|
|
||||||
|
You should probably not use this endpoint, as it's used by the build system to
|
||||||
|
publish its logs.
|
||||||
|
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
Publish a new build log to the server.
|
||||||
|
|
||||||
|
### HTTP Request
|
||||||
|
|
||||||
|
`POST /api/logs`
|
||||||
|
|
||||||
|
### Query parameters
|
||||||
|
|
||||||
|
Parameter | Description
|
||||||
|
--------- | -----------
|
||||||
|
id | ID of requested log
|
||||||
|
startTime | Start time of the build (UTC epoch)
|
||||||
|
endTime | End time of the build (UTC epoch)
|
||||||
|
arch | Architecture on which the build was done
|
||||||
|
exitCode | Exit code of the build container
|
||||||
|
|
||||||
|
### Request body
|
||||||
|
|
||||||
|
Plaintext contents of the build log.
|
||||||
|
|
@ -66,5 +66,5 @@ fn (c &Client) send_request_with_body<T>(method Method, url string, params map[s
|
||||||
fn (c &Client) send_request_raw_response(method Method, url string, params map[string]string, body string) ?string {
|
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
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ pub fn (c &Client) get_build_log_content(id int) ?string {
|
||||||
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> {
|
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 := {
|
params := {
|
||||||
'repo': repo_id.str()
|
'repo': repo_id.str()
|
||||||
'startTime': start_time.str()
|
'startTime': start_time.unix_time().str()
|
||||||
'endTime': end_time.str()
|
'endTime': end_time.unix_time().str()
|
||||||
'arch': arch
|
'arch': arch
|
||||||
'exitCode': exit_code.str()
|
'exitCode': exit_code.str()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,19 @@ fn (mut app App) post_log() web.Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse query params
|
// Parse query params
|
||||||
start_time := parse_query_time(app.query['startTime']) or {
|
start_time_int := app.query['startTime'].int()
|
||||||
|
|
||||||
|
if start_time_int == 0 {
|
||||||
return app.json(http.Status.bad_request, new_response('Invalid or missing start time.'))
|
return app.json(http.Status.bad_request, new_response('Invalid or missing start time.'))
|
||||||
}
|
}
|
||||||
|
start_time := time.unix(start_time_int)
|
||||||
|
|
||||||
end_time := parse_query_time(app.query['endTime']) or {
|
end_time_int := app.query['endTime'].int()
|
||||||
|
|
||||||
|
if end_time_int == 0 {
|
||||||
return app.json(http.Status.bad_request, new_response('Invalid or missing end time.'))
|
return app.json(http.Status.bad_request, new_response('Invalid or missing end time.'))
|
||||||
}
|
}
|
||||||
|
end_time := time.unix(end_time_int)
|
||||||
|
|
||||||
if 'exitCode' !in app.query {
|
if 'exitCode' !in app.query {
|
||||||
return app.json(http.Status.bad_request, new_response('Missing exit code.'))
|
return app.json(http.Status.bad_request, new_response('Missing exit code.'))
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@ pub const (
|
||||||
|
|
||||||
http_302 = http.new_response(
|
http_302 = http.new_response(
|
||||||
status: .found
|
status: .found
|
||||||
text: '302 Found'
|
body: '302 Found'
|
||||||
header: headers_close
|
header: headers_close
|
||||||
)
|
)
|
||||||
http_400 = http.new_response(
|
http_400 = http.new_response(
|
||||||
status: .bad_request
|
status: .bad_request
|
||||||
text: '400 Bad Request'
|
body: '400 Bad Request'
|
||||||
header: http.new_header(
|
header: http.new_header(
|
||||||
key: .content_type
|
key: .content_type
|
||||||
value: 'text/plain'
|
value: 'text/plain'
|
||||||
|
|
@ -38,7 +38,7 @@ pub const (
|
||||||
)
|
)
|
||||||
http_404 = http.new_response(
|
http_404 = http.new_response(
|
||||||
status: .not_found
|
status: .not_found
|
||||||
text: '404 Not Found'
|
body: '404 Not Found'
|
||||||
header: http.new_header(
|
header: http.new_header(
|
||||||
key: .content_type
|
key: .content_type
|
||||||
value: 'text/plain'
|
value: 'text/plain'
|
||||||
|
|
@ -46,7 +46,7 @@ pub const (
|
||||||
)
|
)
|
||||||
http_500 = http.new_response(
|
http_500 = http.new_response(
|
||||||
status: .internal_server_error
|
status: .internal_server_error
|
||||||
text: '500 Internal Server Error'
|
body: '500 Internal Server Error'
|
||||||
header: http.new_header(
|
header: http.new_header(
|
||||||
key: .content_type
|
key: .content_type
|
||||||
value: 'text/plain'
|
value: 'text/plain'
|
||||||
|
|
@ -209,7 +209,7 @@ pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bo
|
||||||
|
|
||||||
mut resp := http.Response{
|
mut resp := http.Response{
|
||||||
header: header.join(web.headers_close)
|
header: header.join(web.headers_close)
|
||||||
text: res
|
body: res
|
||||||
}
|
}
|
||||||
resp.set_version(.v1_1)
|
resp.set_version(.v1_1)
|
||||||
resp.set_status(ctx.status)
|
resp.set_status(ctx.status)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue