Documentation
¶
Index ¶
- func UserIdToSubjectString(userId string) string
- type FilterOptions
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, warrant Warrant) (int64, error)
- func (repo MySQLRepository) DeleteAllByObject(ctx context.Context, objectType string, objectId string) error
- func (repo MySQLRepository) DeleteAllBySubject(ctx context.Context, subjectType string, subjectId string) error
- func (repo MySQLRepository) DeleteById(ctx context.Context, id int64) error
- func (repo MySQLRepository) Get(ctx context.Context, objectType string, objectId string, relation string, ...) (*Warrant, error)
- func (repo MySQLRepository) GetAllMatchingObjectAndRelation(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Warrant, error)
- func (repo MySQLRepository) GetAllMatchingObjectAndSubject(ctx context.Context, objectType string, objectId string, subjectType string, ...) ([]Warrant, error)
- func (repo MySQLRepository) GetAllMatchingSubjectAndRelation(ctx context.Context, objectType string, relation string, subjectType string, ...) ([]Warrant, error)
- func (repo MySQLRepository) GetAllMatchingWildcard(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Warrant, error)
- func (repo MySQLRepository) GetByID(ctx context.Context, id int64) (*Warrant, error)
- func (repo MySQLRepository) GetWithContextMatch(ctx context.Context, objectType string, objectId string, relation string, ...) (*Warrant, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Warrant, error)
- type ObjectSpec
- type SortOptions
- type SubjectSpec
- type Warrant
- type WarrantListParamParser
- type WarrantRepository
- type WarrantService
- func (svc WarrantService) Create(ctx context.Context, warrantSpec WarrantSpec) (*WarrantSpec, error)
- func (svc WarrantService) Delete(ctx context.Context, warrantSpec WarrantSpec) error
- func (svc WarrantService) DeleteRelatedWarrants(ctx context.Context, objectType string, objectId string) error
- func (svc WarrantService) Get(ctx context.Context, objectType string, objectId string, relation string, ...) (*WarrantSpec, error)
- func (svc WarrantService) GetRoutes() []service.Route
- func (svc WarrantService) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]*WarrantSpec, error)
- type WarrantSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserIdToSubjectString ¶
Types ¶
type FilterOptions ¶
type FilterOptions struct {
ObjectType string
ObjectId string
Relation string
Subject *SubjectSpec
Context *context.ContextSetSpec
ObjectIds []string
SubjectIds []string
}
FilterOptions type for the filter options available on the warrant table
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteAllByObject ¶
func (MySQLRepository) DeleteAllBySubject ¶
func (MySQLRepository) DeleteById ¶
func (repo MySQLRepository) DeleteById(ctx context.Context, id int64) error
func (MySQLRepository) GetAllMatchingObjectAndRelation ¶
func (MySQLRepository) GetAllMatchingObjectAndSubject ¶
func (MySQLRepository) GetAllMatchingSubjectAndRelation ¶
func (MySQLRepository) GetAllMatchingWildcard ¶
func (MySQLRepository) GetWithContextMatch ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Warrant, error)
type ObjectSpec ¶
type ObjectSpec struct {
ObjectType string `json:"objectType" validate:"required,valid_object_type"`
ObjectId string `json:"objectId" validate:"required,valid_object_id"`
}
ObjectSpec type
func StringToObjectSpec ¶
func StringToObjectSpec(str string) (*ObjectSpec, error)
type SortOptions ¶
SortOptions type for sorting filtered results from the warrant table
type SubjectSpec ¶
type SubjectSpec struct {
UserId string `json:"userId,omitempty" validate:"required_without_all=ObjectType ObjectId Relation"`
ObjectType string `json:"objectType,omitempty" validate:"required_with=ObjectId,valid_object_type"`
ObjectId string `json:"objectId,omitempty" validate:"required_with=ObjectType,valid_object_id"`
Relation string `json:"relation,omitempty" validate:"valid_relation"`
}
SubjectSpec type
func StringToSubjectSpec ¶
func StringToSubjectSpec(str string) (*SubjectSpec, error)
func UserIdToSubjectSpec ¶
func UserIdToSubjectSpec(userId string) *SubjectSpec
func (*SubjectSpec) String ¶
func (spec *SubjectSpec) String() string
type Warrant ¶
type Warrant struct {
ID int64 `db:"id"`
ObjectType string `db:"objectType"`
ObjectId string `db:"objectId"`
Relation string `db:"relation"`
Subject string `db:"subject"`
SubjectType string `db:"subjectType"`
SubjectId string `db:"subjectId"`
SubjectRelation database.NullString `db:"subjectRelation"`
ContextHash string `db:"contextHash"`
Context []context.Context `db:"context"`
CreatedAt time.Time `db:"createdAt"`
UpdatedAt time.Time `db:"updatedAt"`
DeletedAt database.NullTime `db:"deletedAt"`
}
Warrant model
func StringToWarrant ¶
func (*Warrant) ToWarrantSpec ¶
func (warrant *Warrant) ToWarrantSpec() *WarrantSpec
type WarrantListParamParser ¶
type WarrantListParamParser struct{}
func (WarrantListParamParser) GetDefaultSortBy ¶
func (parser WarrantListParamParser) GetDefaultSortBy() string
func (WarrantListParamParser) GetSupportedSortBys ¶
func (parser WarrantListParamParser) GetSupportedSortBys() []string
func (WarrantListParamParser) ParseValue ¶
func (parser WarrantListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type WarrantRepository ¶
type WarrantRepository interface {
Create(ctx context.Context, warrant Warrant) (int64, error)
Get(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, contextHash string) (*Warrant, error)
GetByID(ctx context.Context, id int64) (*Warrant, error)
GetWithContextMatch(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, contextHash string) (*Warrant, error)
GetAllMatchingWildcard(ctx context.Context, objectType string, objectId string, relation string, contextHash string) ([]Warrant, error)
GetAllMatchingObjectAndRelation(ctx context.Context, objectType string, objectId string, relation string, subjectType string, contextHash string) ([]Warrant, error)
GetAllMatchingObjectAndSubject(ctx context.Context, objectType string, objectId string, subjectType string, subjectId string, subjectRelation string) ([]Warrant, error)
GetAllMatchingSubjectAndRelation(ctx context.Context, objectType string, relation string, subjectType string, subjectId string, subjectRelation string) ([]Warrant, error)
List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Warrant, error)
DeleteById(ctx context.Context, id int64) error
DeleteAllByObject(ctx context.Context, objectType string, objectId string) error
DeleteAllBySubject(ctx context.Context, subjectType string, subjectId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (WarrantRepository, error)
type WarrantService ¶
type WarrantService struct {
service.BaseService
// contains filtered or unexported fields
}
func NewService ¶
func NewService(env service.Env) WarrantService
func (WarrantService) Create ¶
func (svc WarrantService) Create(ctx context.Context, warrantSpec WarrantSpec) (*WarrantSpec, error)
func (WarrantService) Delete ¶
func (svc WarrantService) Delete(ctx context.Context, warrantSpec WarrantSpec) error
func (WarrantService) DeleteRelatedWarrants ¶
func (WarrantService) Get ¶
func (svc WarrantService) Get(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec) (*WarrantSpec, error)
func (WarrantService) GetRoutes ¶
func (svc WarrantService) GetRoutes() []service.Route
GetRoutes registers all route handlers for this module
func (WarrantService) List ¶
func (svc WarrantService) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]*WarrantSpec, error)
type WarrantSpec ¶
type WarrantSpec struct {
ObjectType string `json:"objectType" validate:"required,valid_object_type"`
ObjectId string `json:"objectId" validate:"required,valid_object_id"`
Relation string `json:"relation" validate:"required,valid_relation"`
Subject *SubjectSpec `json:"subject" validate:"required_without=User"`
User *SubjectSpec `json:"user,omitempty" validate:"required_without=Subject"`
Context context.ContextSetSpec `json:"context,omitempty"`
IsImplicit *bool `json:"isImplicit,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
WarrantSpec type
func StringToWarrantSpec ¶
func StringToWarrantSpec(warrantString string) (*WarrantSpec, error)
func (WarrantSpec) String ¶
func (spec WarrantSpec) String() string
func (*WarrantSpec) ToMap ¶
func (spec *WarrantSpec) ToMap() map[string]interface{}
func (*WarrantSpec) ToWarrant ¶
func (spec *WarrantSpec) ToWarrant() *Warrant
Click to show internal directories.
Click to hide internal directories.