authz

package
v0.22.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ResourceTypeFeature = "feature"

Variables

This section is empty.

Functions

func CreateHandler added in v0.11.0

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

func DeleteHandler added in v0.11.0

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

func GetHandler added in v0.11.0

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

func ListHandler added in v0.11.0

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

func UpdateHandler added in v0.11.0

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

Types

type Feature

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

func (feature Feature) GetCreatedAt() time.Time

func (Feature) GetDeletedAt added in v0.8.0

func (feature Feature) GetDeletedAt() *time.Time

func (Feature) GetDescription added in v0.8.0

func (feature Feature) GetDescription() *string

func (Feature) GetFeatureId added in v0.8.0

func (feature Feature) GetFeatureId() string

func (Feature) GetID added in v0.8.0

func (feature Feature) GetID() int64

func (Feature) GetName added in v0.8.0

func (feature Feature) GetName() *string

func (Feature) GetObjectId added in v0.8.0

func (feature Feature) GetObjectId() int64

func (Feature) GetUpdatedAt added in v0.8.0

func (feature Feature) GetUpdatedAt() time.Time

func (*Feature) SetDescription added in v0.8.0

func (feature *Feature) SetDescription(newDescription *string)

func (*Feature) SetName added in v0.8.0

func (feature *Feature) SetName(newName *string)

func (Feature) ToFeatureSpec

func (feature Feature) ToFeatureSpec() *FeatureSpec

type FeatureListParamParser

type FeatureListParamParser struct{}

func (FeatureListParamParser) GetDefaultSortBy

func (parser FeatureListParamParser) GetDefaultSortBy() string

func (FeatureListParamParser) GetSupportedSortBys

func (parser FeatureListParamParser) GetSupportedSortBys() []string

func (FeatureListParamParser) ParseValue

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

type FeatureRepository

type FeatureRepository interface {
	Create(ctx context.Context, feature Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByFeatureId(ctx context.Context, pricingTierId string) (Model, error)
	List(ctx context.Context, listParams service.ListParams) ([]Model, error)
	UpdateByFeatureId(ctx context.Context, pricingTierId string, feature Model) error
	DeleteByFeatureId(ctx context.Context, pricingTierId string) error
}

func NewRepository

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

type FeatureService

type FeatureService struct {
	service.BaseService
	Repository FeatureRepository
	EventSvc   event.EventService
	ObjectSvc  object.ObjectService
}

func NewService

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

func (FeatureService) Create

func (svc FeatureService) Create(ctx context.Context, featureSpec FeatureSpec) (*FeatureSpec, error)

func (FeatureService) DeleteByFeatureId

func (svc FeatureService) DeleteByFeatureId(ctx context.Context, featureId string) error

func (FeatureService) GetByFeatureId

func (svc FeatureService) GetByFeatureId(ctx context.Context, featureId string) (*FeatureSpec, error)

func (FeatureService) List

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

func (FeatureService) Routes added in v0.8.0

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

GetRoutes registers all route handlers for this module

func (FeatureService) UpdateByFeatureId

func (svc FeatureService) UpdateByFeatureId(ctx context.Context, featureId string, featureSpec UpdateFeatureSpec) (*FeatureSpec, error)

type FeatureSpec

type FeatureSpec struct {
	FeatureId   string    `json:"featureId" validate:"required,valid_object_id"`
	Name        *string   `json:"name"`
	Description *string   `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
}

func (FeatureSpec) ToFeature

func (spec FeatureSpec) ToFeature(objectId int64) *Feature

func (FeatureSpec) ToObjectSpec

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

type Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectId() int64
	GetFeatureId() string
	GetName() *string
	SetName(*string)
	GetDescription() *string
	SetDescription(*string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	ToFeatureSpec() *FeatureSpec
}

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) DeleteByFeatureId

func (repo MySQLRepository) DeleteByFeatureId(ctx context.Context, featureId string) error

func (MySQLRepository) GetByFeatureId

func (repo MySQLRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)

func (MySQLRepository) GetById

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

func (MySQLRepository) List

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

func (MySQLRepository) UpdateByFeatureId

func (repo MySQLRepository) UpdateByFeatureId(ctx context.Context, featureId 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) DeleteByFeatureId added in v0.4.0

func (repo PostgresRepository) DeleteByFeatureId(ctx context.Context, featureId string) error

func (PostgresRepository) GetByFeatureId added in v0.4.0

func (repo PostgresRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)

func (PostgresRepository) GetById added in v0.4.0

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

func (PostgresRepository) List added in v0.4.0

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

func (PostgresRepository) UpdateByFeatureId added in v0.4.0

func (repo PostgresRepository) UpdateByFeatureId(ctx context.Context, featureId string, model 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) DeleteByFeatureId added in v0.11.0

func (repo SQLiteRepository) DeleteByFeatureId(ctx context.Context, featureId string) error

func (SQLiteRepository) GetByFeatureId added in v0.11.0

func (repo SQLiteRepository) GetByFeatureId(ctx context.Context, featureId string) (Model, error)

func (SQLiteRepository) GetById added in v0.11.0

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

func (SQLiteRepository) List added in v0.11.0

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

func (SQLiteRepository) UpdateByFeatureId added in v0.11.0

func (repo SQLiteRepository) UpdateByFeatureId(ctx context.Context, featureId string, model Model) error

type UpdateFeatureSpec

type UpdateFeatureSpec 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