Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminController ¶
type AdminController struct {
beego.Controller
}
Operations which require administrative rights
func (*AdminController) CreateDevice ¶
func (a *AdminController) CreateDevice()
@Title AddDevice @Description Add a `Device` into the database and prepare the necessary directory structure for deploying it. @Param hostname query string true "The hostname of the device" @Param port query string true "The device's switch port" @Success 201 {object} models.Device @Failure 409 { "message": "conflict" } @Failure 500 { "message": "Internal Server Error" } @router /device [post]
func (*AdminController) CreateUser ¶
func (a *AdminController) CreateUser()
@Title CreateUser @Description Create a new Rubus `User` and save it into the database. @Param body body models.NewUser true "All the fields are required, except for the `role` which will default to `user` if not specified." @Success 201 {object} models.User @Failure 409 { "message": "conflict" } @Failure 500 { "message": "Internal Server Error" } @router /user [post]
func (*AdminController) DeleteDevice ¶
func (a *AdminController) DeleteDevice()
@Title DeleteDevice @Description Delete a `Device` from the database and remove its directory structure used for deployment. @Param hostname query string true "The hostname of the device" @Param deviceId query int64 true "The device's switch port" @Success 204 @Failure 400 { "message": "Bad Request Error" } @Failure 404 { "message": "Not Found" } @Failure 500 { "message": "Internal Server Error" } @router /device [delete]
type DeviceController ¶
type DeviceController struct {
beego.Controller
}
Operations about devices such as provisioning or deployment
func (*DeviceController) Get ¶
func (d *DeviceController) Get()
@Title GetDevice @Description Return the `Device` with the given `deviceId`. @Param deviceId path int true "The id of the `Device` to get" @Success 200 {object} models.Device @Failure 400 { "message": "Bad Request Error" } @Failure 404 { "message": "User does not exists" } @Failure 500 { "message": "Internal Server Error" } @router /:deviceId [get]
func (*DeviceController) ListDevice ¶
func (d *DeviceController) ListDevice()
@Title ListDevice @Description List all the `Device`. @Success 200 {object} []models.Device @Failure 500 { "message": "Internal Server Error" } @router / [get]
func (*DeviceController) PowerOff ¶
func (d *DeviceController) PowerOff()
PowerOff shuts down the `Device` on the given `port` @Title PowerOff @Description Shut down the `Device` with the given `deviceId`. @Param deviceId path int true "The device id to turn off" @Success 204 @router /:deviceId/off [post]
func (*DeviceController) PowerOn ¶
func (d *DeviceController) PowerOn()
@Title PowerOn @Description Boot the `Device` with the given `deviceId`. @Param deviceId path int true "The device id to turn on" @Success 204 @router /:deviceId/on [post]
type ErrorController ¶
type ErrorController struct {
beego.Controller
}
ErrorController serves JSON error to the client
func (*ErrorController) ErrorBadRequest ¶
func (c *ErrorController) ErrorBadRequest()
ErrorBadRequest serves a 400 Bad Request Error
func (*ErrorController) ErrorJSONError ¶
func (c *ErrorController) ErrorJSONError()
ErrorJSONError serves an error with a JSON message
type ProvisionerController ¶
type ProvisionerController struct {
beego.Controller
}
Operations about devices, such as provisioning or deployment
func (*ProvisionerController) Acquire ¶
func (p *ProvisionerController) Acquire()
@Title Acquire @Description Set the `User` who made the request as the owner of the `Device`. @Param deviceId path int true "The id of the `Device` to acquire" @Success 200 {object} models.Device @router /:deviceId/acquire [post]
func (*ProvisionerController) Deploy ¶
func (p *ProvisionerController) Deploy()
@Title Deploy @Description Configure the PXE boot for the `Device` and reboot it. @Param deviceId path int true "The device id to deploy" @Success 204 @router /:deviceId/deploy [post]
func (*ProvisionerController) Release ¶
func (p *ProvisionerController) Release()
@Title Release @Description Remove the `Device`'s ownership from the `User` who made the request. @Param deviceId path int true "The device port to release" @Success 200 {object} models.Device @router /:deviceId/release [post]
type UserController ¶
type UserController struct {
beego.Controller
}
Operations about Users
func (*UserController) DeleteMe ¶
func (u *UserController) DeleteMe()
@Title DeleteMe @Description Delete the `User` who made the request. @Success 200 @Failure 400 { "message": "Bad Request Error" } @Failure 404 { "message": "User does not exists" } @Failure 500 { "message": "Internal Server Error" } @router /me [delete]
func (*UserController) GetMe ¶
func (u *UserController) GetMe()
@Title GetMe @Description Return the `User` who made the request. @Success 200 {object} models.User @Failure 400 { "message": "Bad Request Error" } @Failure 404 { "message": "User does not exists" } @Failure 500 { "message": "Internal Server Error" } @router /me [get]
func (*UserController) ListUser ¶
func (u *UserController) ListUser()
@Title ListUser @Description List all the `User`. @Success 200 {object} []models.User @Failure 500 { "message": "Internal Server Error" } @router / [get]
func (*UserController) Login ¶
func (u *UserController) Login()
@Title Login @Description Log a `User` into the system. @Param username query string true "The username used to login" @Param password query string true "The password used to login" @Success 200 { "token": "string" } @Failure 401 { "message": "Unauthorized" } @Failure 500 { "message": "Internal Server Error" } @router /login [get]
func (*UserController) UpdateMe ¶
func (u *UserController) UpdateMe()
@Title UpdateMe @Description Update the `User` who made the request. @Param body body models.PutUser true "the `User` fields which can be updated. Giving all the fields is not mendatory, but at least one of them is required." @Success 200 {object} models.User @Failure 400 { "message": "Bad Request Error" } @Failure 404 { "message": "User does not exists" } @Failure 409 { "message": "conflict" } @Failure 500 { "message": "Internal Server Error" } @router /me [put]