data

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 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")
	ErrInvalidRequest = errors.New("invalid request")
)

Functions

func CompareSlices added in v0.7.3

func CompareSlices(a, b []string) bool

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[[]UserExtended], error)
	GetUser(req GetUserRequest) (*UserExtended, error)
	CreateUser(user User) error
	DeleteUser(id string) error
	PutUser(user User) error
	PatchUser(user User) error

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

	GetRoles(req GetRoleRequest) (*Response[[]Role], error)
	GetRole(id string) (*Role, error)
	CreateRole(role Role) error
	PutRole(role Role) error
	DeleteRole(id string) error
	PatchRole(role Role) 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

	LMapRoleIDs() LMapRoleIDs
}

type GetLMapRequest

type GetLMapRequest struct {
	Name string `json:"name"`

	RoleIDs []string `json:"role_ids"`

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

type GetPermissionRequest

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

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

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

type GetRoleRequest

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

	PermissionIDs []string `json:"permission_ids"`
	RoleIDs       []string `json:"role_ids"`

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

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

type GetUserRequest

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

	RoleIDs []string `json:"role_ids"`

	UID   string `json:"uid"`
	Name  string `json:"name"`
	Email string `json:"email"`

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

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

	Extend bool `json:"extend"`
}

type LMap

type LMap struct {
	Name    string   `json:"name"     badgerhold:"unique"`
	RoleIDs []string `json:"role_ids"`
}

type LMapRoleIDs added in v0.7.3

type LMapRoleIDs interface {
	Get(names []string) ([]string, error)
}

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 ResponseCreate added in v0.7.3

type ResponseCreate struct {
	ID      string `json:"id"`
	Message string `json:"message"`
}

type Role

type Role struct {
	ID            string                 `json:"id"             badgerhold:"unique"`
	Name          string                 `json:"name"`
	PermissionIDs []string               `json:"permission_ids"`
	RoleIDs       []string               `json:"role_ids"`
	Data          map[string]interface{} `json:"data"`
}

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"`
	RoleIDs     []string               `json:"role_ids"`
	SyncRoleIDs []string               `json:"sync_role_ids"`
	Details     map[string]interface{} `json:"details"`
}

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

type UserExtended

type UserExtended struct {
	User

	Roles       []string      `json:"roles,omitempty"`
	Permissions []string      `json:"permissions,omitempty"`
	Datas       []interface{} `json:"datas,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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