roles

package
v0.4.0-rc.15 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound               = xerror.NotFound(xerror.Role)
	ErrSlugAlreadyExists      = xerror.AlreadyExists(xerror.Role)
	ErrCannotDeleteSystemRole = xerror.CannotDeleteDefault(xerror.Role)
	ErrUserNotMember          = xerror.NotFound(xerror.UserMember)
)

Functions

This section is empty.

Types

type CreateParams

type CreateParams struct {
	OrgSlug   slug.Slug
	Slug      slug.Slug
	Name      string
	IsDefault bool
}

type DeleteParams

type DeleteParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
}

type Repository

type Repository interface {
	ListRoleGrants(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug) ([]model.RoleGrant, error)
	CreateRoleGrant(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, grant model.NewRoleGrant) (*model.RoleGrant, error)
	RevokeRoleGrant(ctx context.Context, tx postgres.DBTX, orgSlug, grantSlug slug.Slug) (slug.Slug, error)
	Create(ctx context.Context, tx postgres.DBTX, params *CreateParams) (*Role, error)
	EnsureDefault(ctx context.Context, tx postgres.DBTX, params *CreateParams) (*Role, error)
	FindBySlug(ctx context.Context, tx postgres.DBTX, orgSlug, roleSlug slug.Slug) (*Role, error)
	ListByOrganization(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug slug.Slug,
		req model.ListRequest,
		includeDeleted bool,
		onlyDeleted bool,
	) ([]*Role, error)
	GetUserPermissionsInOrg(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, userSlug slug.Slug,
	) ([]*UserPermission, error)
	Update(ctx context.Context, tx postgres.DBTX, params *UpdateParams) error
	Delete(ctx context.Context, tx postgres.DBTX, params *DeleteParams) error
	Restore(ctx context.Context, tx postgres.DBTX, params *RestoreParams) error
}

func NewRepository

func NewRepository() Repository

func NewRepositoryWithLogging

func NewRepositoryWithLogging(base Repository, logger *slog.Logger) Repository

NewRepositoryWithLogging wraps base with method completion logging.

type RepositoryWithLogging

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

RepositoryWithLogging implements Repository with method completion logging.

func (RepositoryWithLogging) Create

func (_d RepositoryWithLogging) Create(ctx context.Context, tx postgres.DBTX, params *CreateParams) (rp1 *Role, err error)

Create implements Repository.

func (RepositoryWithLogging) CreateRoleGrant

func (_d RepositoryWithLogging) CreateRoleGrant(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, grant model.NewRoleGrant) (rp1 *model.RoleGrant, err error)

CreateRoleGrant implements Repository.

func (RepositoryWithLogging) Delete

func (_d RepositoryWithLogging) Delete(ctx context.Context, tx postgres.DBTX, params *DeleteParams) (err error)

Delete implements Repository.

func (RepositoryWithLogging) EnsureDefault

func (_d RepositoryWithLogging) EnsureDefault(ctx context.Context, tx postgres.DBTX, params *CreateParams) (rp1 *Role, err error)

EnsureDefault implements Repository.

func (RepositoryWithLogging) FindBySlug

func (_d RepositoryWithLogging) FindBySlug(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, roleSlug slug.Slug) (rp1 *Role, err error)

FindBySlug implements Repository.

func (RepositoryWithLogging) GetUserPermissionsInOrg

func (_d RepositoryWithLogging) GetUserPermissionsInOrg(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, userSlug slug.Slug) (upa1 []*UserPermission, err error)

GetUserPermissionsInOrg implements Repository.

func (RepositoryWithLogging) ListByOrganization

func (_d RepositoryWithLogging) ListByOrganization(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, req model.ListRequest, includeDeleted bool, onlyDeleted bool) (rpa1 []*Role, err error)

ListByOrganization implements Repository.

func (RepositoryWithLogging) ListRoleGrants

func (_d RepositoryWithLogging) ListRoleGrants(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug) (ra1 []model.RoleGrant, err error)

ListRoleGrants implements Repository.

func (RepositoryWithLogging) Restore

func (_d RepositoryWithLogging) Restore(ctx context.Context, tx postgres.DBTX, params *RestoreParams) (err error)

Restore implements Repository.

func (RepositoryWithLogging) RevokeRoleGrant

func (_d RepositoryWithLogging) RevokeRoleGrant(ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, grantSlug slug.Slug) (s1 slug.Slug, err error)

RevokeRoleGrant implements Repository.

func (RepositoryWithLogging) Update

func (_d RepositoryWithLogging) Update(ctx context.Context, tx postgres.DBTX, params *UpdateParams) (err error)

Update implements Repository.

type RestoreParams

type RestoreParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
}

type Role

type Role struct {
	Slug      slug.Slug
	Name      string
	IsDefault bool
	DeletedAt *time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

type UpdateParams

type UpdateParams struct {
	OrgSlug slug.Slug
	Slug    slug.Slug
	Name    string
}

type UserPermission

type UserPermission struct {
	Resource string
	Action   string
}

Jump to

Keyboard shortcuts

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