Documentation
¶
Index ¶
- type FilterOptions
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (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, ...) (Model, error)
- func (repo MySQLRepository) GetAllMatchingObjectAndRelation(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Model, error)
- func (repo MySQLRepository) GetAllMatchingObjectAndSubject(ctx context.Context, objectType string, objectId string, subjectType string, ...) ([]Model, error)
- func (repo MySQLRepository) GetAllMatchingSubjectAndRelation(ctx context.Context, objectType string, relation string, subjectType string, ...) ([]Model, error)
- func (repo MySQLRepository) GetAllMatchingWildcard(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Model, error)
- func (repo MySQLRepository) GetByID(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetWithContextMatch(ctx context.Context, objectType string, objectId string, relation string, ...) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
- type ObjectSpec
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteAllByObject(ctx context.Context, objectType string, objectId string) error
- func (repo PostgresRepository) DeleteAllBySubject(ctx context.Context, subjectType string, subjectId string) error
- func (repo PostgresRepository) DeleteById(ctx context.Context, id int64) error
- func (repo PostgresRepository) Get(ctx context.Context, objectType string, objectId string, relation string, ...) (Model, error)
- func (repo PostgresRepository) GetAllMatchingObjectAndRelation(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Model, error)
- func (repo PostgresRepository) GetAllMatchingObjectAndSubject(ctx context.Context, objectType string, objectId string, subjectType string, ...) ([]Model, error)
- func (repo PostgresRepository) GetAllMatchingSubjectAndRelation(ctx context.Context, objectType string, relation string, subjectType string, ...) ([]Model, error)
- func (repo PostgresRepository) GetAllMatchingWildcard(ctx context.Context, objectType string, objectId string, relation string, ...) ([]Model, error)
- func (repo PostgresRepository) GetByID(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetWithContextMatch(ctx context.Context, objectType string, objectId string, relation string, ...) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]Model, error)
- type SessionWarrantSpec
- type SortOptions
- type SubjectSpec
- type Warrant
- func (warrant Warrant) GetContextHash() string
- func (warrant Warrant) GetCreatedAt() time.Time
- func (warrant Warrant) GetDeletedAt() database.NullTime
- func (warrant Warrant) GetID() int64
- func (warrant Warrant) GetObjectId() string
- func (warrant Warrant) GetObjectType() string
- func (warrant Warrant) GetRelation() string
- func (warrant Warrant) GetSubjectId() string
- func (warrant Warrant) GetSubjectRelation() database.NullString
- func (warrant Warrant) GetSubjectType() string
- func (warrant Warrant) GetUpdatedAt() time.Time
- func (warrant Warrant) String() string
- func (warrant Warrant) ToWarrantSpec() *WarrantSpec
- 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) List(ctx context.Context, filterOptions *FilterOptions, ...) ([]*WarrantSpec, error)
- func (svc WarrantService) Routes() []service.Route
- type WarrantSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 Model ¶ added in v0.8.0
type Model interface {
GetID() int64
GetObjectType() string
GetObjectId() string
GetRelation() string
GetSubjectType() string
GetSubjectId() string
GetSubjectRelation() database.NullString
GetContextHash() string
GetCreatedAt() time.Time
GetUpdatedAt() time.Time
GetDeletedAt() database.NullTime
ToWarrantSpec() *WarrantSpec
String() string
}
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) ([]Model, 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 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) DeleteAllByObject ¶ added in v0.4.0
func (PostgresRepository) DeleteAllBySubject ¶ added in v0.4.0
func (PostgresRepository) DeleteById ¶ added in v0.4.0
func (repo PostgresRepository) DeleteById(ctx context.Context, id int64) error
func (PostgresRepository) GetAllMatchingObjectAndRelation ¶ added in v0.4.0
func (PostgresRepository) GetAllMatchingObjectAndSubject ¶ added in v0.4.0
func (PostgresRepository) GetAllMatchingSubjectAndRelation ¶ added in v0.4.0
func (PostgresRepository) GetAllMatchingWildcard ¶ added in v0.4.0
func (PostgresRepository) GetWithContextMatch ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Model, error)
type SessionWarrantSpec ¶ added in v0.7.0
type SessionWarrantSpec 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"`
Context context.ContextSetSpec `json:"context,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
SessionWarrantSpec type
type SortOptions ¶
SortOptions type for sorting filtered results from the warrant table
type SubjectSpec ¶
type SubjectSpec struct {
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 (*SubjectSpec) String ¶
func (spec *SubjectSpec) String() string
type Warrant ¶
type Warrant struct {
ID int64 `mysql:"id" postgres:"id"`
ObjectType string `mysql:"objectType" postgres:"object_type"`
ObjectId string `mysql:"objectId" postgres:"object_id"`
Relation string `mysql:"relation" postgres:"relation"`
SubjectType string `mysql:"subjectType" postgres:"subject_type"`
SubjectId string `mysql:"subjectId" postgres:"subject_id"`
SubjectRelation database.NullString `mysql:"subjectRelation" postgres:"subject_relation"`
ContextHash string `mysql:"contextHash" postgres:"context_hash"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at"`
DeletedAt database.NullTime `mysql:"deletedAt" postgres:"deleted_at"`
}
Warrant model
func StringToWarrant ¶
func (Warrant) GetContextHash ¶ added in v0.8.0
func (Warrant) GetCreatedAt ¶ added in v0.8.0
func (Warrant) GetDeletedAt ¶ added in v0.8.0
func (Warrant) GetObjectId ¶ added in v0.8.0
func (Warrant) GetObjectType ¶ added in v0.8.0
func (Warrant) GetRelation ¶ added in v0.8.0
func (Warrant) GetSubjectId ¶ added in v0.8.0
func (Warrant) GetSubjectRelation ¶ added in v0.8.0
func (warrant Warrant) GetSubjectRelation() database.NullString
func (Warrant) GetSubjectType ¶ added in v0.8.0
func (Warrant) GetUpdatedAt ¶ added in v0.8.0
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 Model) (int64, error)
Get(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, contextHash string) (Model, error)
GetByID(ctx context.Context, id int64) (Model, error)
GetWithContextMatch(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, contextHash string) (Model, error)
GetAllMatchingWildcard(ctx context.Context, objectType string, objectId string, relation string, contextHash string) ([]Model, error)
GetAllMatchingObjectAndRelation(ctx context.Context, objectType string, objectId string, relation string, subjectType string, contextHash string) ([]Model, error)
GetAllMatchingObjectAndSubject(ctx context.Context, objectType string, objectId string, subjectType string, subjectId string, subjectRelation string) ([]Model, error)
GetAllMatchingSubjectAndRelation(ctx context.Context, objectType string, relation string, subjectType string, subjectId string, subjectRelation string) ([]Model, error)
List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]Model, 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, repo WarrantRepository, eventSvc event.EventService, objectTypeSvc objecttype.ObjectTypeService, ctxSvc wntContext.ContextService) 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) List ¶
func (svc WarrantService) List(ctx context.Context, filterOptions *FilterOptions, listParams middleware.ListParams) ([]*WarrantSpec, error)
func (WarrantService) Routes ¶ added in v0.8.0
func (svc WarrantService) Routes() []service.Route
GetRoutes registers all route handlers for this module
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"`
Context context.ContextSetSpec `json:"context,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.