permission

package
v0.8.41 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID     = errors.New("permission id is invalid")
	ErrNotExist      = errors.New("permission doesn't exist")
	ErrInvalidDetail = errors.New("invalid permission detail")
)

Functions

func AddNamespaceIfRequired added in v0.7.5

func AddNamespaceIfRequired(namespace string, name string) string

func ParsePermissionName

func ParsePermissionName(s string) string

Types

type Filter

type Filter struct {
	Namespace string
	Slugs     []string
}

type Permission

type Permission struct {
	ID          string
	Name        string
	Slug        string
	NamespaceID string
	Metadata    metadata.Metadata

	CreatedAt time.Time
	UpdatedAt time.Time
}

func (Permission) GenerateSlug

func (p Permission) GenerateSlug() string

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Permission, error)
	GetBySlug(ctx context.Context, id string) (Permission, error)
	Upsert(ctx context.Context, action Permission) (Permission, error)
	List(ctx context.Context, flt Filter) ([]Permission, error)
	Update(ctx context.Context, action Permission) (Permission, error)
	Delete(ctx context.Context, id string) error
}

type Service

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

func NewService

func NewService(repository Repository) *Service

func (Service) Delete

func (s Service) Delete(ctx context.Context, id string) error

Delete call over a service could be dangerous without removing all of its relations the method does not do it by default

func (Service) Get

func (s Service) Get(ctx context.Context, id string) (Permission, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]Permission, error)

func (Service) Update

func (s Service) Update(ctx context.Context, perm Permission) (Permission, error)

func (Service) Upsert

func (s Service) Upsert(ctx context.Context, perm Permission) (Permission, error)

Jump to

Keyboard shortcuts

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