data

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflict = errors.New("conflict")
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type CheckRequest

type CheckRequest struct {
	ID    string `json:"id"`
	Alias string `json:"alias"`

	Path   string `json:"path"`
	Method string `json:"method"`
}

type CheckResponse

type CheckResponse struct {
	Allowed bool `json:"allowed"`
}

type Database

type Database interface {
	GetUsers(req GetUserRequest) (*Response[[]User], error)
	GetUser(req GetUserRequest) (*User, error)
	CreateUser(user User) error
	DeleteUser(id string) error
	PutUser(user User) error
	PatchUser(user User) error

	GetPermissions(req GetPermissionRequest) (*Response[[]Permission], error)
	GetPermission(name string) (*Permission, error)
	CreatePermission(permission Permission) error
	DeletePermission(name string) error
	PutPermission(permission Permission) error

	GetRoles(req GetRoleRequest) (*Response[[]Role], error)
	GetRole(name string) (*Role, error)
	CreateRole(role Role) error
	PutRole(role Role) error
	DeleteRole(name string) error

	Check(req CheckRequest) (*CheckResponse, error)

	GetLMaps(req GetLMapRequest) (*Response[[]LMap], error)
	GetLMap(name string) (*LMap, error)
	CreateLMap(lmap LMap) error
	PutLMap(lmap LMap) error
	DeleteLMap(name string) error
}

type GetLMapRequest

type GetLMapRequest GetPermissionRequest

type GetPermissionRequest

type GetPermissionRequest struct {
	ID   string `json:"id"`
	Name string `json:"name"`

	Limit  int64 `json:"limit"`
	Offset int64 `json:"offset"`
}

type GetRoleRequest

type GetRoleRequest GetPermissionRequest

type GetUserRequest

type GetUserRequest struct {
	ID    string `json:"id"`
	Alias string `json:"alias"`

	Limit  int64 `json:"limit"`
	Offset int64 `json:"offset"`
}

type LMap

type LMap struct {
	Name string `json:"name" badgerhold:"unique"`
	Role string `json:"role"`
}

type Meta

type Meta struct {
	Offset         int64  `json:"offset,omitempty"`
	Limit          int64  `json:"limit,omitempty"`
	TotalItemCount uint64 `json:"total_item_count,omitempty"`
}

type Permission

type Permission struct {
	ID          string    `json:"id"          badgerhold:"unique"`
	Name        string    `json:"name"`
	Requests    []Request `json:"requests"`
	Description string    `json:"description"`
}

Permission is a struct that represents a permission table in the database.

type Request

type Request struct {
	Path    string   `json:"path"`
	Methods []string `json:"methods"`
}

type Response

type Response[T any] struct {
	Meta    Meta `json:"meta"`
	Payload T    `json:"payload"`
}

type Role

type Role struct {
	ID          string   `json:"id"          badgerhold:"unique"`
	Name        string   `json:"name"`
	Permissions []string `json:"permissions"`
}

Role is a struct that represents a role table in the database.

type User

type User struct {
	ID      string                 `json:"id"      badgerhold:"unique"`
	Alias   []string               `json:"alias"`
	Roles   []string               `json:"roles"`
	Details map[string]interface{} `json:"details"`
}

User is a struct that represents a user table in the database.

type UserExtended

type UserExtended struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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