rules

package
v0.0.0-...-f2fa0db Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCreateRequest

func ValidateCreateRequest(c *auth.CreateRuleRequest) error

ValidateCreateRequest validates the CreateRuleRequest fields.

func ValidateUpdateRequest

func ValidateUpdateRequest(u *auth.UpdateRuleRequest) error

Validate validates the UpdateRuleRequest fields.

Types

type API

type API interface {
	grpcgw.Controller
}

func New

func New(srv Service) API

type MockRepository

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

MockRepository rules mock repository

func NewMockRepository

func NewMockRepository() *MockRepository

NewMockRepository create a mock repository for rules

func (*MockRepository) All

func (m *MockRepository) All(ctx context.Context) ([]entity.Rule, error)

func (MockRepository) Count

func (m MockRepository) Count(ctx context.Context) (int64, error)

func (*MockRepository) Create

func (m *MockRepository) Create(ctx context.Context, rule entity.Rule) (string, error)

func (*MockRepository) Delete

func (m *MockRepository) Delete(ctx context.Context, rule entity.Rule) error

func (MockRepository) Get

func (m MockRepository) Get(ctx context.Context, id string) (entity.Rule, error)

func (MockRepository) Query

func (m MockRepository) Query(ctx context.Context, query string, offset, limit int64) ([]entity.Rule, int, error)

func (*MockRepository) Update

func (m *MockRepository) Update(ctx context.Context, rule entity.Rule) error

type Repository

type Repository interface {
	// Get returns the rule with the specified rule UUID.
	Get(ctx context.Context, uuid string) (entity.Rule, error)
	// Count returns the number of rules.
	Count(ctx context.Context) (int64, error)
	// Query returns the list of rules with the given offset and limit.
	Query(ctx context.Context, query string, offset, limit int64) ([]entity.Rule, int, error)
	// Create saves a new rule in the storage.
	Create(ctx context.Context, rule entity.Rule) (string, error)
	// Update updates the rule with given UUID in the storage.
	Update(ctx context.Context, rule entity.Rule) error
	// Delete removes the rule with given UUID from the storage.
	Delete(ctx context.Context, rule entity.Rule) error
	// All retrieves all rules records from the database.
	All(ctx context.Context) ([]entity.Rule, error)
}

Repository encapsulates the logic to access rules from the data source.

func NewRepository

func NewRepository(db *db.DB) Repository

NewRepository creates a new rule repository

type Service

type Service interface {
	Get(ctx context.Context, uuid string) (*auth.Rule, error)
	Query(ctx context.Context, query string, offset, limit int64) (*auth.ListRulesResponse, error)
	Count(ctx context.Context) (int64, error)
	Create(ctx context.Context, input *auth.CreateRuleRequest) (*auth.Rule, error)
	Update(ctx context.Context, input *auth.UpdateRuleRequest) (*auth.Rule, error)
	Delete(ctx context.Context, uuid string) (*auth.Rule, error)
	All(ctx context.Context) ([]entity.Rule, error)
}

Service encapsulates use case logic for rules.

func NewService

func NewService(repo Repository, domainsRepo domains.Repository, rolesRepo roles.Repository) Service

NewService creates a new rule service.

Jump to

Keyboard shortcuts

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