role

package
v0.6.19 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserType       = namespace.DefinitionUser.ID
	TeamMemberType = fmt.Sprintf("%s#%s", namespace.DefinitionTeam.ID, DefinitionTeamMember.ID)
)
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")
	ErrLogActivity   = errors.New("error while logging activity")
)
View Source
var DefinitionOrganizationAdmin = Role{
	Name:        "Organization Admin",
	ID:          "organization_admin",
	NamespaceID: namespace.DefinitionOrg.ID,
	Types:       []string{UserType, TeamMemberType},
}
View Source
var DefinitionProjectAdmin = Role{
	Name:        "Project Admin",
	ID:          "project_admin",
	NamespaceID: namespace.DefinitionProject.ID,
	Types:       []string{UserType, TeamMemberType},
}
View Source
var DefinitionTeamAdmin = Role{
	Name:        "Team Admin",
	ID:          "team_admin",
	NamespaceID: namespace.DefinitionTeam.ID,
	Types:       []string{UserType},
}
View Source
var DefinitionTeamMember = Role{
	Name:        "Team Member",
	ID:          "team_member",
	NamespaceID: namespace.DefinitionTeam.ID,
	Types:       []string{UserType},
}

Functions

This section is empty.

Types

type ActivityService added in v0.6.15

type ActivityService interface {
	Log(ctx context.Context, action string, actor activity.Actor, data any) error
}

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (Role, error)
	List(ctx context.Context) ([]Role, error)
	Create(ctx context.Context, role Role) (string, error)
	Update(ctx context.Context, toUpdate Role) (string, error)
}

type Role

type Role struct {
	ID          string
	Name        string
	Types       []string
	NamespaceID string
	Metadata    metadata.Metadata
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func GetOwnerRole

func GetOwnerRole(ns namespace.Namespace) Role

func (Role) ToRoleLogData added in v0.6.15

func (role Role) ToRoleLogData() RoleLogData

type RoleLogData added in v0.6.15

type RoleLogData struct {
	Entity      string   `mapstructure:"entity"`
	ID          string   `mapstructure:"id"`
	Name        string   `mapstructure:"name"`
	Types       []string `mapstructure:"types"`
	NamespaceID string   `mapstructure:"namespace_id"`
}

type Service

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

func NewService

func NewService(logger log.Logger, repository Repository, userService UserService, activityService ActivityService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, toCreate Role) (Role, 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) ([]Role, error)

func (Service) Update

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

type UserService added in v0.6.15

type UserService interface {
	FetchCurrentUser(ctx context.Context) (user.User, error)
}

Jump to

Keyboard shortcuts

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