api

package
v0.0.0-...-865a493 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(db storage.Provider, log *logr.Logger) gin.HandlerFunc

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

func CheckPermissions

func CheckPermissions(user *types.User, targetPermissions []string) bool

func CommonElems

func CommonElems(first, second []string) bool

func EnsurePermissions

func EnsurePermissions(perms []string, user string) []string

func GetCurrentUser

func GetCurrentUser(c *gin.Context) *types.User

func IsValidID

func IsValidID(id string) bool

IsValidID determines if an ID is valid

func IsValidIDFragment

func IsValidIDFragment(id string) bool

IsValidIDFragment determines if a string is a valid ID fragment

func NewObjectFromFile

func NewObjectFromFile[T any](fileName string) (*T, error)

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is the API object

func Create

func Create(db storage.Provider, log *logr.Logger, statusUpdateJob *StatusUpdateJob) *API

Create is the API host

func (*API) Serve

func (api *API) Serve() *gin.Engine

Serve the API

type ErrorWithCode

type ErrorWithCode struct {
	Message string
	Code    int
}

ErrorWithCode for http results

func (*ErrorWithCode) Error

func (e *ErrorWithCode) Error() string

Error message

type ModifyUserRolesArgs

type ModifyUserRolesArgs struct {
	// contains filtered or unexported fields
}

type MonitorController

type MonitorController struct {
	// contains filtered or unexported fields
}

MonitorController actions

func (*MonitorController) Get

func (m *MonitorController) Get(c *gin.Context)

Get a monitor by its Id

func (*MonitorController) GetAll

func (m *MonitorController) GetAll(c *gin.Context)

GetAll monitors, paginated

func (*MonitorController) Init

func (m *MonitorController) Init(db storage.Provider, log *logr.Logger)

Init -ialize the controller

func (*MonitorController) Post

func (m *MonitorController) Post(c *gin.Context)

Post a new monitor

func (*MonitorController) Put

func (m *MonitorController) Put(c *gin.Context)

Put an existing monitor.

type RoleController

type RoleController struct {
	// contains filtered or unexported fields
}

UserController actions

func (*RoleController) Add

func (t *RoleController) Add(c *gin.Context)

func (*RoleController) GetAll

func (t *RoleController) GetAll(c *gin.Context)

GetAll roles, paginated

func (*RoleController) Init

func (t *RoleController) Init(db storage.Provider, log *logr.Logger)

Init -ialize the controller

func (*RoleController) Update

func (t *RoleController) Update(c *gin.Context)

type StatusUpdateJob

type StatusUpdateJob struct {
	StatusChan chan string
	ExitChan   chan int
	// contains filtered or unexported fields
}

func NewStatusUpdateJob

func NewStatusUpdateJob(log *logr.Logger) *StatusUpdateJob

func (*StatusUpdateJob) Run

func (j *StatusUpdateJob) Run()

type TargetController

type TargetController struct {
	// contains filtered or unexported fields
}

TargetController actions

func (*TargetController) Delete

func (t *TargetController) Delete(c *gin.Context)

Deletes a target by its ID

func (*TargetController) Get

func (t *TargetController) Get(c *gin.Context)

Get a target by its ID

func (*TargetController) GetAll

func (t *TargetController) GetAll(c *gin.Context)

GetAll targets, paginated and filtered

func (*TargetController) Init

func (t *TargetController) Init(db storage.Provider, log *logr.Logger)

Init -ialize the controller

func (*TargetController) Patch

func (t *TargetController) Patch(c *gin.Context)

Patch the target status

func (*TargetController) Post

func (t *TargetController) Post(c *gin.Context)

Post a new target

func (*TargetController) Put

func (t *TargetController) Put(c *gin.Context)

Put an existing target.

type UserController

type UserController struct {
	// contains filtered or unexported fields
}

UserController actions

func (*UserController) CreateToken

func (t *UserController) CreateToken(c *gin.Context)

func (*UserController) GetAll

func (t *UserController) GetAll(c *gin.Context)

GetAll users, paginated

func (*UserController) Init

func (t *UserController) Init(db storage.Provider, log *logr.Logger)

Init -ialize the controller

func (*UserController) Login

func (t *UserController) Login(c *gin.Context)

Get a target by its ID

func (*UserController) Register

func (t *UserController) Register(c *gin.Context)

func (*UserController) Update

func (t *UserController) Update(c *gin.Context)

type UserRolesModifyFunc

type UserRolesModifyFunc func([]string, string) []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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