authz

package
v0.33.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultSortBy = "objectId"

Variables

This section is empty.

Functions

func CreateHandler added in v0.11.0

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

func DeleteHandler added in v0.11.0

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

func GetHandler added in v0.11.0

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

func ListHandler added in v0.11.0

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

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 Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectType() string
	GetObjectId() string
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	ToObjectSpec() *ObjectSpec
}

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, model Model) (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) (Model, error)

func (MySQLRepository) GetByObjectTypeAndId

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

func (MySQLRepository) List

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

type Object

type Object struct {
	ID         int64      `mysql:"id" postgres:"id" sqlite:"id"`
	ObjectType string     `mysql:"objectType" postgres:"object_type" sqlite:"objectType"`
	ObjectId   string     `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
	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 (Object) GetCreatedAt added in v0.8.0

func (object Object) GetCreatedAt() time.Time

func (Object) GetDeletedAt added in v0.8.0

func (object Object) GetDeletedAt() *time.Time

func (Object) GetID added in v0.8.0

func (object Object) GetID() int64

func (Object) GetObjectId added in v0.8.0

func (object Object) GetObjectId() string

func (Object) GetObjectType added in v0.8.0

func (object Object) GetObjectType() string

func (Object) GetUpdatedAt added in v0.8.0

func (object Object) GetUpdatedAt() time.Time

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 Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)
	List(ctx context.Context, filterOptions *FilterOptions, listParams service.ListParams) ([]Model, 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
	Repository ObjectRepository
	EventSvc   event.Service
	WarrantSvc *warrant.WarrantService
}

func NewService

func NewService(env service.Env, repository ObjectRepository, eventSvc event.Service, warrantSvc *warrant.WarrantService) *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) GetByObjectTypeAndId added in v0.12.0

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

func (ObjectService) List

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

func (ObjectService) Routes added in v0.8.0

func (svc ObjectService) Routes() ([]service.Route, 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, model Model) (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) (Model, error)

func (PostgresRepository) GetByObjectTypeAndId added in v0.4.0

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

func (PostgresRepository) List added in v0.4.0

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

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) DeleteByObjectTypeAndId added in v0.11.0

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

func (SQLiteRepository) GetById added in v0.11.0

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

func (SQLiteRepository) GetByObjectTypeAndId added in v0.11.0

func (repo SQLiteRepository) GetByObjectTypeAndId(ctx context.Context, objectType string, objectId string) (Model, error)

func (SQLiteRepository) List added in v0.11.0

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

Jump to

Keyboard shortcuts

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