diff --git a/internal/kojiapi/api/api.gen.go b/internal/kojiapi/api/api.gen.go index c4e198cb1..917fe607d 100644 --- a/internal/kojiapi/api/api.gen.go +++ b/internal/kojiapi/api/api.gen.go @@ -57,6 +57,11 @@ type Repository struct { Gpgkey string `json:"gpgkey"` } +// Status defines model for Status. +type Status struct { + Status string `json:"status"` +} + // PostComposeJSONBody defines parameters for PostCompose. type PostComposeJSONBody ComposeRequest @@ -71,6 +76,9 @@ type ServerInterface interface { // The status of a compose // (GET /compose/{id}) GetComposeId(ctx echo.Context, id string) error + // status + // (GET /status) + GetStatus(ctx echo.Context) error } // ServerInterfaceWrapper converts echo contexts to parameters. @@ -103,6 +111,15 @@ func (w *ServerInterfaceWrapper) GetComposeId(ctx echo.Context) error { return err } +// GetStatus converts echo context to params. +func (w *ServerInterfaceWrapper) GetStatus(ctx echo.Context) error { + var err error + + // Invoke the callback with all the unmarshalled arguments + err = w.Handler.GetStatus(ctx) + return err +} + // This is a simple interface which specifies echo.Route addition functions which // are present on both echo.Echo and echo.Group, since we want to allow using // either of them for path registration @@ -127,5 +144,6 @@ func RegisterHandlers(router EchoRouter, si ServerInterface) { router.POST("/compose", wrapper.PostCompose) router.GET("/compose/:id", wrapper.GetComposeId) + router.GET("/status", wrapper.GetStatus) } diff --git a/internal/kojiapi/api/openapi.yml b/internal/kojiapi/api/openapi.yml index 2989c10c0..3ebc6710d 100644 --- a/internal/kojiapi/api/openapi.yml +++ b/internal/kojiapi/api/openapi.yml @@ -7,6 +7,20 @@ info: name: Apache 2.0 url: 'https://www.apache.org/licenses/LICENSE-2.0.html' paths: + /status: + get: + summary: status + tags: [ ] + responses: + '200': + description: OK + headers: { } + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + operationId: GetStatus + description: Simple status handler to check whether the service is up. '/compose/{id}': get: summary: The status of a compose @@ -70,6 +84,14 @@ paths: type: string components: schemas: + Status: + required: + - status + properties: + status: + type: string + enum: + - OK ComposeStatus: required: - status diff --git a/internal/kojiapi/server.go b/internal/kojiapi/server.go index dd5eb5bf3..d77fcf462 100644 --- a/internal/kojiapi/server.go +++ b/internal/kojiapi/server.go @@ -247,6 +247,13 @@ func (h *apiHandlers) GetComposeId(ctx echo.Context, idstr string) error { return ctx.JSON(http.StatusOK, response) } +// GetStatus handles a /status GET request +func (h *apiHandlers) GetStatus(ctx echo.Context) error { + return ctx.JSON(http.StatusOK, &api.Status{ + Status: "OK", + }) +} + // A simple echo.Binder(), which only accepts application/json, but is more // strict than echo's DefaultBinder. It does not handle binding query // parameters either.