feat(api): add pave spec to route /v1/spec and add seed to it
Exposes the API spec in pave format, which intends to show information about all API routes. Also pave V1SeedPOST and V1SpecGET
This commit is contained in:
parent
0c7009b16b
commit
7bf489315e
15 changed files with 152 additions and 25 deletions
16
api/api.go
16
api/api.go
|
@ -10,6 +10,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"codeberg.org/vlbeaudoin/voki"
|
||||
"git.agecem.com/agecem/agecem-org/apirequest"
|
||||
"git.agecem.com/agecem/agecem-org/apiresponse"
|
||||
"git.agecem.com/agecem/agecem-org/config"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -35,8 +36,8 @@ func New(client *http.Client, host, key string, port int, protocol string) (*API
|
|||
return &API{Voki: voki.New(client, host, key, port, protocol)}, nil
|
||||
}
|
||||
|
||||
func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (apiresponse.V1DocumentCreateResponse, error) {
|
||||
var response apiresponse.V1DocumentCreateResponse
|
||||
func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (apiresponse.V1DocumentCreate, error) {
|
||||
var response apiresponse.V1DocumentCreate
|
||||
endpoint := fmt.Sprintf("%s://%s:%d",
|
||||
a.Voki.Protocol,
|
||||
a.Voki.Host,
|
||||
|
@ -100,6 +101,15 @@ func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (
|
|||
return response, err
|
||||
}
|
||||
|
||||
func (a *API) ListBuckets() (response apiresponse.V1BucketListResponse, err error) {
|
||||
func (a *API) ListBuckets() (response apiresponse.V1BucketList, err error) {
|
||||
return response, a.Voki.Unmarshal(http.MethodGet, "/v1/bucket", nil, true, &response)
|
||||
}
|
||||
|
||||
func (a *API) Seed() (response apiresponse.V1SeedPOST, err error) {
|
||||
request, err := apirequest.NewV1SeedPOST()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return request.Request(a.Voki)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue