authz

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateObjectSpec

type CreateObjectSpec struct {
	ObjectType string `json:"objectType" validate:"required"`
	ObjectId   string `json:"objectId" validate:"required"`
}

type FilterOptions

type FilterOptions struct {
	ObjectType string
}

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, object Object) (int64, error)

func (MySQLRepository) DeleteByObjectTypeAndId

func (repo MySQLRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error

func (MySQLRepository) GetById

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

func (MySQLRepository) GetByObjectTypeAndId

func (repo MySQLRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*Object, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Object, error)

type Object

type Object struct {
	ID         int64             `mysql:"id" postgres:"id"`
	ObjectType string            `mysql:"objectType" postgres:"object_type"`
	ObjectId   string            `mysql:"objectId" postgres:"object_id"`
	CreatedAt  time.Time         `mysql:"createdAt" postgres:"created_at"`
	UpdatedAt  time.Time         `mysql:"updatedAt" postgres:"updated_at"`
	DeletedAt  database.NullTime `mysql:"deletedAt" postgres:"deleted_at"`
}

func (Object) ToObjectSpec

func (object Object) ToObjectSpec() *ObjectSpec

type ObjectListParamParser

type ObjectListParamParser struct{}

func (ObjectListParamParser) GetDefaultSortBy

func (parser ObjectListParamParser) GetDefaultSortBy() string

func (ObjectListParamParser) GetSupportedSortBys

func (parser ObjectListParamParser) GetSupportedSortBys() []string

func (ObjectListParamParser) ParseValue

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

type ObjectRepository

type ObjectRepository interface {
	Create(ctx context.Context, object Object) (int64, error)
	GetById(ctx context.Context, id int64) (*Object, error)
	GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*Object, error)
	List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Object, error)
	DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error
}

func NewRepository

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

type ObjectService

type ObjectService struct {
	service.BaseService
}

func NewService

func NewService(env service.Env) ObjectService

func (ObjectService) Create

func (svc ObjectService) Create(ctx context.Context, objectSpec ObjectSpec) (*ObjectSpec, error)

func (ObjectService) DeleteByObjectTypeAndId

func (svc ObjectService) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error

func (ObjectService) GetByObjectId

func (svc ObjectService) GetByObjectId(ctx context.Context, objectType string, objectId string) (*ObjectSpec, error)

func (ObjectService) GetRoutes

func (svc ObjectService) GetRoutes() []service.Route

func (ObjectService) List

func (svc ObjectService) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]ObjectSpec, error)

type ObjectSpec

type ObjectSpec struct {
	// NOTE: ID is required here for internal use.
	// However, we don't return it to the client.
	ID         int64     `json:"-"`
	ObjectType string    `json:"objectType" validate:"required,valid_object_type"`
	ObjectId   string    `json:"objectId" validate:"required,valid_object_id"`
	CreatedAt  time.Time `json:"createdAt"`
}

func (ObjectSpec) ToObject

func (spec ObjectSpec) ToObject() *Object

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, object Object) (int64, error)

func (PostgresRepository) DeleteByObjectTypeAndId added in v0.4.0

func (repo PostgresRepository) DeleteByObjectTypeAndId(ctx context.Context, objectType string, objectId string) error

func (PostgresRepository) GetById added in v0.4.0

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

func (PostgresRepository) GetByObjectTypeAndId added in v0.4.0

func (repo PostgresRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (*Object, error)

func (PostgresRepository) List added in v0.4.0

func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Object, error)

Jump to

Keyboard shortcuts

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