role

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Filter

type Filter struct {
	OrgID  string
	Scopes []string
}

type PermissionService

type PermissionService interface {
	Get(ctx context.Context, id string) (permission.Permission, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	Delete(ctx context.Context, rel relation.Relation) error
}

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Role, error)
	GetByName(ctx context.Context, orgID, name string) (Role, error)
	List(ctx context.Context, f Filter) ([]Role, error)
	Upsert(ctx context.Context, role Role) (Role, error)
	Update(ctx context.Context, toUpdate Role) (Role, error)
	Delete(ctx context.Context, roleID string) error
}

type Role

type Role struct {
	ID          string
	OrgID       string
	Name        string
	Title       string
	Permissions []string
	State       State
	Scopes      []string // used for filtering
	Metadata    metadata.Metadata
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type Service

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

func NewService

func NewService(repository Repository, relationService RelationService, permissionService PermissionService) *Service

func (Service) Delete

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

func (Service) Get

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

func (Service) List

func (s Service) List(ctx context.Context, f Filter) ([]Role, error)

func (Service) Update

func (s Service) Update(ctx context.Context, toUpdate Role) (Role, error)

func (Service) Upsert

func (s Service) Upsert(ctx context.Context, toCreate Role) (Role, error)

type State

type State string
const (
	Enabled  State = "enabled"
	Disabled State = "disabled"
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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