Add more swagger annotations to apiserver
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
This commit is contained in:
parent
fbee4d4cbd
commit
98e415bf11
6 changed files with 390 additions and 2 deletions
|
|
@ -222,6 +222,21 @@ func (a *APIController) MetricsTokenHandler(w http.ResponseWriter, r *http.Reque
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route POST /auth/login login Login
|
||||
//
|
||||
// Logs in a user and returns a JWT token.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: Body
|
||||
// description: Login information.
|
||||
// type: PasswordLoginParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: JWTResponse
|
||||
// 400: APIErrorResponse
|
||||
//
|
||||
// LoginHandler returns a jwt token
|
||||
func (a *APIController) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var loginInfo runnerParams.PasswordLoginParams
|
||||
|
|
@ -253,6 +268,20 @@ func (a *APIController) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route POST /first-run first-run FirstRun
|
||||
//
|
||||
// Initialize the first run of the controller.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: Body
|
||||
// description: Create a new user.
|
||||
// type: NewUserParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: User
|
||||
// 400: APIErrorResponse
|
||||
func (a *APIController) FirstRunHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if a.auth.IsInitialized() {
|
||||
err := gErrors.NewConflictError("already initialized")
|
||||
|
|
@ -279,6 +308,13 @@ func (a *APIController) FirstRunHandler(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /credentials credentials ListCredentials
|
||||
//
|
||||
// List all credentials.
|
||||
//
|
||||
// Responses:
|
||||
// 200: Credentials
|
||||
// 400: APIErrorResponse
|
||||
func (a *APIController) ListCredentials(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
creds, err := a.r.ListCredentials(ctx)
|
||||
|
|
@ -293,6 +329,13 @@ func (a *APIController) ListCredentials(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /providers providers ListProviders
|
||||
//
|
||||
// List all providers.
|
||||
//
|
||||
// Responses:
|
||||
// 200: Providers
|
||||
// 400: APIErrorResponse
|
||||
func (a *APIController) ListProviders(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
providers, err := a.r.ListProviders(ctx)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,20 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route GET /pools/{poolID}/instances instances ListPoolInstances
|
||||
//
|
||||
// List runner instances in a pool.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: poolID
|
||||
// description: Runner pool ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Instances
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) ListPoolInstancesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
|
|
@ -176,6 +190,20 @@ func (a *APIController) ListRepoInstancesHandler(w http.ResponseWriter, r *http.
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /organizations/{orgID}/instances organizations instances ListOrgInstances
|
||||
//
|
||||
// List organization instances.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Instances
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) ListOrgInstancesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,20 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route POST /organizations organizations CreateOrg
|
||||
//
|
||||
// Create organization with the parameters given.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: Body
|
||||
// description: Parameters used when creating the organization.
|
||||
// type: CreateOrgParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Organization
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) CreateOrgHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -48,6 +62,13 @@ func (a *APIController) CreateOrgHandler(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /organizations organizations ListOrgs
|
||||
//
|
||||
// List organizations.
|
||||
//
|
||||
// Responses:
|
||||
// 200: Organizations
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) ListOrgsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -64,6 +85,20 @@ func (a *APIController) ListOrgsHandler(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /organizations/{orgID} organizations GetOrg
|
||||
//
|
||||
// Get organization by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: ID of the organization to fetch.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Organization
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) GetOrgByIDHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -93,6 +128,19 @@ func (a *APIController) GetOrgByIDHandler(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route DELETE /organizations/{orgID} organizations DeleteOrg
|
||||
//
|
||||
// Delete organization by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: ID of the organization to delete.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) DeleteOrgHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -120,6 +168,26 @@ func (a *APIController) DeleteOrgHandler(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
}
|
||||
|
||||
// swagger:route PUT /organizations/{orgID} organizations UpdateOrg
|
||||
//
|
||||
// Update organization with the parameters given.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: ID of the organization to update.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: Body
|
||||
// description: Parameters used when updating the organization.
|
||||
// type: UpdateEntityParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Organization
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -155,6 +223,26 @@ func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route POST /organizations/{orgID}/pools organizations pools CreateOrgPool
|
||||
//
|
||||
// Create organization pool with the parameters given.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: Body
|
||||
// description: Parameters used when creating the organization pool.
|
||||
// type: CreatePoolParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pool
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) CreateOrgPoolHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -191,6 +279,20 @@ func (a *APIController) CreateOrgPoolHandler(w http.ResponseWriter, r *http.Requ
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /organizations/{orgID}/pools organizations pools ListOrgPools
|
||||
//
|
||||
// List organization pools.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pools
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) ListOrgPoolsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
|
|
@ -219,6 +321,26 @@ func (a *APIController) ListOrgPoolsHandler(w http.ResponseWriter, r *http.Reque
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /organizations/{orgID}/pools/{poolID} organizations pools GetOrgPool
|
||||
//
|
||||
// Get organization pool by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: poolID
|
||||
// description: Pool ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pool
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) GetOrgPoolHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
|
|
@ -248,6 +370,25 @@ func (a *APIController) GetOrgPoolHandler(w http.ResponseWriter, r *http.Request
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route DELETE /organizations/{orgID}/pools/{poolID} organizations pools DeleteOrgPool
|
||||
//
|
||||
// Delete organization pool by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: poolID
|
||||
// description: ID of the organization pool to delete.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) DeleteOrgPoolHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -276,6 +417,32 @@ func (a *APIController) DeleteOrgPoolHandler(w http.ResponseWriter, r *http.Requ
|
|||
|
||||
}
|
||||
|
||||
// swagger:route PUT /organizations/{orgID}/pools/{poolID} organizations pools UpdateOrgPool
|
||||
//
|
||||
// Update organization pool with the parameters given.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: orgID
|
||||
// description: Organization ID.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: poolID
|
||||
// description: ID of the organization pool to update.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: Body
|
||||
// description: Parameters used when updating the organization pool.
|
||||
// type: UpdatePoolParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pool
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) UpdateOrgPoolHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route GET /pools pools ListPools
|
||||
//
|
||||
// List all pools.
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pools
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) ListAllPoolsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -43,6 +50,20 @@ func (a *APIController) ListAllPoolsHandler(w http.ResponseWriter, r *http.Reque
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route GET /pools/{poolID} pools GetPool
|
||||
//
|
||||
// Get pool by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: poolID
|
||||
// description: ID of the pool to fetch.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pool
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) GetPoolByIDHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -74,6 +95,19 @@ func (a *APIController) GetPoolByIDHandler(w http.ResponseWriter, r *http.Reques
|
|||
}
|
||||
}
|
||||
|
||||
// swagger:route DELETE /pools/{poolID} pools DeletePool
|
||||
//
|
||||
// Delete pool by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: poolID
|
||||
// description: ID of the pool to delete.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) DeletePoolByIDHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
@ -100,6 +134,26 @@ func (a *APIController) DeletePoolByIDHandler(w http.ResponseWriter, r *http.Req
|
|||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
// swagger:route PUT /pools/{poolID} pools UpdatePool
|
||||
//
|
||||
// Update pool by ID.
|
||||
//
|
||||
// Parameters:
|
||||
// + name: poolID
|
||||
// description: ID of the pool to update.
|
||||
// type: string
|
||||
// in: path
|
||||
// required: true
|
||||
//
|
||||
// + name: Body
|
||||
// description: Parameters to update the pool with.
|
||||
// type: UpdatePoolParams
|
||||
// in: body
|
||||
// required: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: Pool
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) UpdatePoolByIDHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,75 @@
|
|||
# NOTE: The purpose of these definitions is to reuse the existing golang
|
||||
# types from GARM packages.
|
||||
definitions:
|
||||
Instances:
|
||||
User:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: User
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
NewUserParams:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: NewUserParams
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
PasswordLoginParams:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: PasswordLoginParams
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
JWTResponse:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: JWTResponse
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
Credentials:
|
||||
type: array
|
||||
x-go-type:
|
||||
type: Credentials
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
items:
|
||||
$ref: '#/definitions/GithubCredentials'
|
||||
GithubCredentials:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: GithubCredentials
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
Providers:
|
||||
type: array
|
||||
x-go-type:
|
||||
type: Providers
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
items:
|
||||
$ref: '#/definitions/Provider'
|
||||
Provider:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: Provider
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
Instances:
|
||||
type: array
|
||||
x-go-type:
|
||||
type: Instances
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
items:
|
||||
$ref: '#/definitions/Instance'
|
||||
Instance:
|
||||
type: object
|
||||
x-go-type:
|
||||
|
|
@ -16,12 +78,14 @@ definitions:
|
|||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
Pools:
|
||||
type: object
|
||||
type: array
|
||||
x-go-type:
|
||||
type: Pools
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
items:
|
||||
$ref: '#/definitions/Pool'
|
||||
Pool:
|
||||
type: object
|
||||
x-go-type:
|
||||
|
|
@ -52,6 +116,29 @@ definitions:
|
|||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
Organizations:
|
||||
type: array
|
||||
x-go-type:
|
||||
type: Organizations
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
items:
|
||||
$ref: '#/definitions/Organization'
|
||||
Organization:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: Organization
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
CreateOrgParams:
|
||||
type: object
|
||||
x-go-type:
|
||||
type: CreateOrgParams
|
||||
import:
|
||||
package: github.com/cloudbase/garm/params
|
||||
alias: garm_params
|
||||
UpdateEntityParams:
|
||||
type: object
|
||||
x-go-type:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue