authz

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypeRole = "role"

Variables

This section is empty.

Functions

func CreateHandler added in v0.11.0

func CreateHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error

func DeleteHandler added in v0.11.0

func DeleteHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error

func GetHandler added in v0.11.0

func GetHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error

func ListHandler added in v0.11.0

func ListHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error

func UpdateHandler added in v0.11.0

func UpdateHandler(svc RoleService, w http.ResponseWriter, r *http.Request) error

Types

type Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectId() int64
	GetRoleId() string
	GetName() *string
	SetName(*string)
	GetDescription() *string
	SetDescription(*string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	ToRoleSpec() *RoleSpec
}

type MySQLRepository

type MySQLRepository struct {
	database.SQLRepository
}

func NewMySQLRepository

func NewMySQLRepository(db *database.MySQL) MySQLRepository

func (MySQLRepository) Create

func (repo MySQLRepository) Create(ctx context.Context, role Model) (int64, error)

func (MySQLRepository) DeleteByRoleId

func (repo MySQLRepository) DeleteByRoleId(ctx context.Context, roleId string) error

func (MySQLRepository) GetById

func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)

func (MySQLRepository) GetByRoleId

func (repo MySQLRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)

func (MySQLRepository) UpdateByRoleId

func (repo MySQLRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error

type PostgresRepository added in v0.4.0

type PostgresRepository struct {
	database.SQLRepository
}

func NewPostgresRepository added in v0.4.0

func NewPostgresRepository(db *database.Postgres) PostgresRepository

func (PostgresRepository) Create added in v0.4.0

func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)

func (PostgresRepository) DeleteByRoleId added in v0.4.0

func (repo PostgresRepository) DeleteByRoleId(ctx context.Context, roleId string) error

func (PostgresRepository) GetById added in v0.4.0

func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)

func (PostgresRepository) GetByRoleId added in v0.4.0

func (repo PostgresRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)

func (PostgresRepository) List added in v0.4.0

func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)

func (PostgresRepository) UpdateByRoleId added in v0.4.0

func (repo PostgresRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error

type Role

type Role struct {
	ID          int64      `mysql:"id" postgres:"id" sqlite:"id"`
	ObjectId    int64      `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
	RoleId      string     `mysql:"roleId" postgres:"role_id" sqlite:"roleId"`
	Name        *string    `mysql:"name" postgres:"name" sqlite:"name"`
	Description *string    `mysql:"description" postgres:"description" sqlite:"description"`
	CreatedAt   time.Time  `mysql:"createdAt" postgres:"created_at" sqlite:"createdAt"`
	UpdatedAt   time.Time  `mysql:"updatedAt" postgres:"updated_at" sqlite:"updatedAt"`
	DeletedAt   *time.Time `mysql:"deletedAt" postgres:"deleted_at" sqlite:"deletedAt"`
}

func (Role) GetCreatedAt added in v0.8.0

func (role Role) GetCreatedAt() time.Time

func (Role) GetDeletedAt added in v0.8.0

func (role Role) GetDeletedAt() *time.Time

func (Role) GetDescription added in v0.8.0

func (role Role) GetDescription() *string

func (Role) GetID added in v0.8.0

func (role Role) GetID() int64

func (Role) GetName added in v0.8.0

func (role Role) GetName() *string

func (Role) GetObjectId added in v0.8.0

func (role Role) GetObjectId() int64

func (Role) GetRoleId added in v0.8.0

func (role Role) GetRoleId() string

func (Role) GetUpdatedAt added in v0.8.0

func (role Role) GetUpdatedAt() time.Time

func (*Role) SetDescription added in v0.8.0

func (role *Role) SetDescription(newDescription *string)

func (*Role) SetName added in v0.8.0

func (role *Role) SetName(newName *string)

func (Role) ToRoleSpec

func (role Role) ToRoleSpec() *RoleSpec

type RoleListParamParser

type RoleListParamParser struct{}

func (RoleListParamParser) GetDefaultSortBy

func (parser RoleListParamParser) GetDefaultSortBy() string

func (RoleListParamParser) GetSupportedSortBys

func (parser RoleListParamParser) GetSupportedSortBys() []string

func (RoleListParamParser) ParseValue

func (parser RoleListParamParser) ParseValue(val string, sortBy string) (interface{}, error)

type RoleRepository

type RoleRepository interface {
	Create(ctx context.Context, role Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByRoleId(ctx context.Context, roleId string) (Model, error)
	List(ctx context.Context, listParams service.ListParams) ([]Model, error)
	UpdateByRoleId(ctx context.Context, roleId string, role Model) error
	DeleteByRoleId(ctx context.Context, roleId string) error
}

func NewRepository

func NewRepository(db database.Database) (RoleRepository, error)

type RoleService

type RoleService struct {
	service.BaseService
	Repository RoleRepository
	EventSvc   event.EventService
	ObjectSvc  object.ObjectService
}

func NewService

func NewService(env service.Env, repository RoleRepository, eventSvc event.EventService, objectSvc object.ObjectService) RoleService

func (RoleService) Create

func (svc RoleService) Create(ctx context.Context, roleSpec RoleSpec) (*RoleSpec, error)

func (RoleService) DeleteByRoleId

func (svc RoleService) DeleteByRoleId(ctx context.Context, roleId string) error

func (RoleService) GetByRoleId

func (svc RoleService) GetByRoleId(ctx context.Context, roleId string) (*RoleSpec, error)

func (RoleService) List

func (svc RoleService) List(ctx context.Context, listParams service.ListParams) ([]RoleSpec, error)

func (RoleService) Routes added in v0.8.0

func (svc RoleService) Routes() ([]service.Route, error)

GetRoutes registers all route handlers for this module

func (RoleService) UpdateByRoleId

func (svc RoleService) UpdateByRoleId(ctx context.Context, roleId string, roleSpec UpdateRoleSpec) (*RoleSpec, error)

type RoleSpec

type RoleSpec struct {
	RoleId      string    `json:"roleId" validate:"required,valid_object_id"`
	Name        *string   `json:"name"`
	Description *string   `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
}

func (RoleSpec) ToObjectSpec

func (spec RoleSpec) ToObjectSpec() *object.ObjectSpec

func (RoleSpec) ToRole

func (spec RoleSpec) ToRole(objectId int64) *Role

type SQLiteRepository added in v0.11.0

type SQLiteRepository struct {
	database.SQLRepository
}

func NewSQLiteRepository added in v0.11.0

func NewSQLiteRepository(db *database.SQLite) SQLiteRepository

func (SQLiteRepository) Create added in v0.11.0

func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)

func (SQLiteRepository) DeleteByRoleId added in v0.11.0

func (repo SQLiteRepository) DeleteByRoleId(ctx context.Context, roleId string) error

func (SQLiteRepository) GetById added in v0.11.0

func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)

func (SQLiteRepository) GetByRoleId added in v0.11.0

func (repo SQLiteRepository) GetByRoleId(ctx context.Context, roleId string) (Model, error)

func (SQLiteRepository) List added in v0.11.0

func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)

func (SQLiteRepository) UpdateByRoleId added in v0.11.0

func (repo SQLiteRepository) UpdateByRoleId(ctx context.Context, roleId string, model Model) error

type UpdateRoleSpec

type UpdateRoleSpec struct {
	Name        *string `json:"name"`
	Description *string `json:"description"`
}

Jump to

Keyboard shortcuts

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