controllers

package
v0.0.0-...-3c57ce0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractIDFromToken

func ExtractIDFromToken(c echo.Context) int64

ExtractIDFromToken extracts the `User` ID included inside the token from the current context

func FilterAdmin

func FilterAdmin(c echo.Context) *models.JSONError

FilterAdmin checks if the `User` has an administrator `Role`. If not, return an Unauthorized `JSONError`.

func FilterIDOrAdmin

func FilterIDOrAdmin(c echo.Context, id int64) *models.JSONError

FilterIDOrAdmin checks if the `User` is the same as the given `uid` or and admin. If not, return an Unauthorized `JSONError`.

Types

type AdminController

type AdminController struct {
	DB  *pg.DB
	Cfg *ini.File
}

AdminController -

func (*AdminController) CreateDevice

func (a *AdminController) CreateDevice(c echo.Context) error

CreateDevice - @description Add a `Device` into the database and prepare the necessary directory structure for deploying it. @id createDevice @tags admin @accept json @produce json @security jwt @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 @router /admin/device [post]

func (*AdminController) CreateUser

func (a *AdminController) CreateUser(c echo.Context) error

CreateUser - @description Create a new Rubus `User` and save it into the database. @id createUser @tags admin @summary Create a new user @accept json @produce json @security jwt @param RequestBody body models.NewUser true "All the fields are required, except for the `role` which will default to `user` if not specified, and the expiration date which can be null." @success 201 {object} models.User @router /admin/user [post]

func (*AdminController) DeleteDevice

func (a *AdminController) DeleteDevice(c echo.Context) error

DeleteDevice - @description Delete a `Device` from the database and remove its directory structure used for deployment. @id deleteDevice @tags admin @summary Delete a device @produce json @security jwt @param hostname query string true "The hostname of the device" @param deviceId query int64 true "The device's switch port" @success 204 @router /admin/device [delete]

func (*AdminController) DeleteUser

func (a *AdminController) DeleteUser(c echo.Context) error

DeleteUser - @description Delete the `User` with the given id @id deleteUser @tags admin @summary Delete a user @produce json @param id path int64 true "The id from the user to delete" @success 204 @router /admin/user/{id} [delete]

func (*AdminController) ListUser

func (a *AdminController) ListUser(c echo.Context) error

ListUser - @description Return a list containing all the `User` @id listUser @tags admin @summary List all the users @produce json @security jwt @success 200 {array} models.User "A JSON array listing all the users" @router /admin/user [get]

func (*AdminController) UpdateUserExpiration

func (a *AdminController) UpdateUserExpiration(c echo.Context) error

UpdateUserExpiration - @description Update the expiration date of a the`User` with the given id @id updateUser @tags admin @summary Set a new expiration date for a `User` @accept json @produce json @param id path int64 true "The id from the user to update" @param expiration query string true "The new expiration date" @success 200 @router /admin/user/{id}/expiration [post]

type AuthenticationController

type AuthenticationController struct {
	DB  *pg.DB
	Cfg *ini.File
}

AuthenticationController -

func (*AuthenticationController) Login

func (a *AuthenticationController) Login(c echo.Context) error

Login - @description Log a `User` into the system. @id login @tags authentication @summary Log a user in @accept json @produce json @param username query string true "The username used to login" @param password query string true "The password used to login" @success 200 {object} models.JWT "The token to authenticate the user" @router /login [get]

type DeviceController

type DeviceController struct {
	DB *pg.DB
}

DeviceController -

func (*DeviceController) Get

func (d *DeviceController) Get(c echo.Context) error

Get - @description Return the `Device` with the given `id`. @id getDevice @tags device @summary get a device by id @produce json @security jwt @param id path int true "The id of the `Device` to get" @success 200 {object} models.Device @router /device/{id} [get]

func (*DeviceController) ListDevice

func (d *DeviceController) ListDevice(c echo.Context) error

ListDevice - @description List all the `Device` @id listDevice @tags device @summary list all the devices @produce json @security jwt @success 200 {array} models.Device "A JSON array listing all the devices" @router /device [get]

func (*DeviceController) PowerOff

func (d *DeviceController) PowerOff(c echo.Context) error

PowerOff - @description Shuts down the `Device` on the given `port` @id powerOff @tags device @summary Shut down a device @produce json @security jwt @param id path int true "The device id to turn off" @success 204 @router /device/{id}/off [post]

func (*DeviceController) PowerOn

func (d *DeviceController) PowerOn(c echo.Context) error

PowerOn - @description Boot the `Device` with the given `id`. @id powerOn @tags device @summary Boot a device @produce json @security jwt @param id path int true "The device id to turn on" @success 204 @router /device/{id}/on [post]

type ProvisionerController

type ProvisionerController struct {
	DB *pg.DB
}

ProvisionerController -

func (*ProvisionerController) Acquire

func (p *ProvisionerController) Acquire(c echo.Context) error

Acquire - @description Set the `User` who made the request as the owner of the `Device`. @id acquire @tags device @summary acquire a device @produce json @security jwt @param id path int true "The id of the `Device` to acquire" @success 200 {object} models.Device @router /device/{id}/acquire [post]

func (*ProvisionerController) Deploy

func (p *ProvisionerController) Deploy(c echo.Context) error

Deploy - @description Configure the PXE boot for the `Device` and reboot it. @id deploy @tags device @summary deploy a device @produce json @security jwt @param id path int true "The device id to deploy" @success 204 @router /device/{id}/deploy [post]

func (*ProvisionerController) Release

func (p *ProvisionerController) Release(c echo.Context) error

Release - @description Remove the `Device`'s ownership from the `User` who made the request. @id release @tags device @summary release a device @produce json @security jwt @param id path int true "The device port to release" @success 200 {object} models.Device @router /device/{id}/release [post]

type UserController

type UserController struct {
	DB  *pg.DB
	Cfg *ini.File
}

UserController -

func (*UserController) DeleteMe

func (u *UserController) DeleteMe(c echo.Context) error

DeleteMe - @description Delete the `User` who made the request. @id deleteMe @tags user @summary delete the autenticated user @produce json @success 204 @router /user/me [delete]

func (*UserController) GetMe

func (u *UserController) GetMe(c echo.Context) error

GetMe - @description Return the `User` who made the request @id getMe @tags user @summary get the authenticated user @produce json @security jwt @success 200 {object} models.User "A JSON object describing a user" @router /user/me [get]

func (*UserController) UpdateMe

func (u *UserController) UpdateMe(c echo.Context) error

UpdateMe - @description Update the `User` who made the request. @id updateMe @tags user @summary update the authenticated user @accept json @produce json @param RequestBody 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 "A JSON object describing a user" @router /user/me [put]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL