Documentation
¶
Index ¶
- Constants
- func BuildQuestionMarkString(numReplacements int) string
- type CreateWarrantSpec
- type DeleteWarrantSpec
- type FilterParams
- type ListWarrantsSpecV1
- type ListWarrantsSpecV2
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) Delete(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (repo MySQLRepository) Get(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) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- type Policy
- type PolicyContext
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) Delete(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (repo PostgresRepository) Get(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) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) Delete(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (repo SQLiteRepository) Get(ctx context.Context, objectType string, objectId string, relation string, ...) (Model, error)
- func (repo SQLiteRepository) GetByID(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- type Service
- type SubjectSpec
- type Warrant
- func (warrant Warrant) GetCreatedAt() time.Time
- func (warrant Warrant) GetDeletedAt() *time.Time
- func (warrant Warrant) GetID() int64
- func (warrant Warrant) GetObjectId() string
- func (warrant Warrant) GetObjectType() string
- func (warrant Warrant) GetPolicy() Policy
- func (warrant Warrant) GetPolicyHash() string
- func (warrant Warrant) GetRelation() string
- func (warrant Warrant) GetSubjectId() string
- func (warrant Warrant) GetSubjectRelation() string
- 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, spec CreateWarrantSpec) (*WarrantSpec, *wookie.Token, error)
- func (svc WarrantService) Delete(ctx context.Context, spec DeleteWarrantSpec) (*wookie.Token, error)
- func (svc WarrantService) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]WarrantSpec, *service.Cursor, *service.Cursor, error)
- func (svc WarrantService) Routes() ([]service.Route, error)
- type WarrantSpec
Constants ¶
View Source
const PrimarySortKey = "id"
View Source
const Wildcard = "*"
Variables ¶
This section is empty.
Functions ¶
func BuildQuestionMarkString ¶ added in v0.40.0
Types ¶
type CreateWarrantSpec ¶ added in v0.57.0
type CreateWarrantSpec 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 map[string]string `json:"context,omitempty" validate:"excluded_with=Policy"`
Policy Policy `json:"policy,omitempty" validate:"excluded_with=Context"`
}
func (CreateWarrantSpec) String ¶ added in v0.57.0
func (spec CreateWarrantSpec) String() string
func (CreateWarrantSpec) ToWarrant ¶ added in v0.57.0
func (spec CreateWarrantSpec) ToWarrant() (*Warrant, error)
type DeleteWarrantSpec ¶ added in v0.57.0
type DeleteWarrantSpec 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 map[string]string `json:"context,omitempty" validate:"excluded_with=Policy"`
Policy Policy `json:"policy,omitempty" validate:"excluded_with=Context"`
}
func (DeleteWarrantSpec) String ¶ added in v0.57.0
func (spec DeleteWarrantSpec) String() string
func (DeleteWarrantSpec) ToWarrant ¶ added in v0.57.0
func (spec DeleteWarrantSpec) ToWarrant() (*Warrant, error)
type FilterParams ¶ added in v0.40.0
type FilterParams struct {
ObjectType string `json:"objectType,omitempty"`
ObjectId string `json:"objectId,omitempty"`
Relation string `json:"relation,omitempty"`
SubjectType string `json:"subjectType,omitempty"`
SubjectId string `json:"subjectId,omitempty"`
SubjectRelation string `json:"subjectRelation,omitempty"`
Policy Policy `json:"policy,omitempty"`
}
func (FilterParams) String ¶ added in v0.40.0
func (fp FilterParams) String() string
type ListWarrantsSpecV1 ¶ added in v0.57.0
type ListWarrantsSpecV1 []WarrantSpec
type ListWarrantsSpecV2 ¶ added in v0.57.0
type ListWarrantsSpecV2 struct {
Results []WarrantSpec `json:"results"`
NextCursor *service.Cursor `json:"nextCursor,omitempty"`
PrevCursor *service.Cursor `json:"prevCursor,omitempty"`
}
type Model ¶ added in v0.8.0
type Model interface {
GetID() int64
GetObjectType() string
GetObjectId() string
GetRelation() string
GetSubjectType() string
GetSubjectId() string
GetSubjectRelation() string
GetPolicy() Policy
GetPolicyHash() string
GetCreatedAt() time.Time
GetUpdatedAt() time.Time
GetDeletedAt() *time.Time
ToWarrantSpec() *WarrantSpec
String() string
}
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) *MySQLRepository
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
type PolicyContext ¶ added in v0.19.0
type PolicyContext map[string]interface{}
func (PolicyContext) String ¶ added in v0.19.0
func (pc PolicyContext) String() string
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) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, 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) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
type Service ¶ added in v0.41.0
type Service interface {
Create(ctx context.Context, spec CreateWarrantSpec) (*WarrantSpec, *wookie.Token, error)
List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]WarrantSpec, *service.Cursor, *service.Cursor, error)
Delete(ctx context.Context, spec DeleteWarrantSpec) (*wookie.Token, error)
}
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:"omitempty,valid_relation"`
}
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" sqlite:"id"`
ObjectType string `mysql:"objectType" postgres:"object_type" sqlite:"objectType"`
ObjectId string `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
Relation string `mysql:"relation" postgres:"relation" sqlite:"relation"`
SubjectType string `mysql:"subjectType" postgres:"subject_type" sqlite:"subjectType"`
SubjectId string `mysql:"subjectId" postgres:"subject_id" sqlite:"subjectId"`
SubjectRelation string `mysql:"subjectRelation" postgres:"subject_relation" sqlite:"subjectRelation"`
Policy Policy `mysql:"policy" postgres:"policy" sqlite:"policy"`
PolicyHash string `mysql:"policyHash" postgres:"policy_hash" sqlite:"policyHash"`
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 (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) GetPolicyHash ¶ added in v0.18.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) 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, policyHash string) (Model, error)
GetByID(ctx context.Context, id int64) (Model, error)
List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
Delete(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, policyHash 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, repository WarrantRepository, objectTypeSvc objecttype.Service, objectSvc object.Service) *WarrantService
func (WarrantService) Create ¶
func (svc WarrantService) Create(ctx context.Context, spec CreateWarrantSpec) (*WarrantSpec, *wookie.Token, error)
func (WarrantService) Delete ¶
func (svc WarrantService) Delete(ctx context.Context, spec DeleteWarrantSpec) (*wookie.Token, error)
func (WarrantService) List ¶
func (svc WarrantService) List(ctx context.Context, filterParams FilterParams, listParams service.ListParams) ([]WarrantSpec, *service.Cursor, *service.Cursor, error)
type WarrantSpec ¶
type WarrantSpec struct {
ObjectType string `json:"objectType"`
ObjectId string `json:"objectId"`
Relation string `json:"relation"`
Subject *SubjectSpec `json:"subject"`
Context map[string]string `json:"context,omitempty"`
Policy Policy `json:"policy,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
}
func StringToWarrantSpec ¶
func StringToWarrantSpec(str string) (*WarrantSpec, error)
func (WarrantSpec) String ¶
func (spec WarrantSpec) String() string
Click to show internal directories.
Click to hide internal directories.