Documentation
¶
Index ¶
- Constants
- type AccessEvent
- type AccessEventSpec
- type CreateAccessEventSpec
- type CreateResourceEventSpec
- type EventRepository
- type EventService
- func (svc EventService) GetRoutes() []service.Route
- func (svc EventService) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEventSpec, string, error)
- func (svc EventService) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEventSpec, string, error)
- func (svc EventService) TrackAccessAllowedEvent(ctx context.Context, objectType string, objectId string, relation string, ...)
- func (svc EventService) TrackAccessAllowedEventSync(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (svc EventService) TrackAccessDeniedEvent(ctx context.Context, objectType string, objectId string, relation string, ...)
- func (svc EventService) TrackAccessDeniedEventSync(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (svc EventService) TrackAccessEvent(ctx context.Context, accessEventSpec CreateAccessEventSpec)
- func (svc EventService) TrackAccessEventSync(ctx context.Context, accessEventSpec CreateAccessEventSpec) error
- func (svc EventService) TrackAccessEvents(ctx context.Context, accessEventSpecs []CreateAccessEventSpec)
- func (svc EventService) TrackAccessEventsSync(ctx context.Context, accessEventSpecs []CreateAccessEventSpec) error
- func (svc EventService) TrackAccessGrantedEvent(ctx context.Context, objectType string, objectId string, relation string, ...)
- func (svc EventService) TrackAccessGrantedEventSync(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (svc EventService) TrackAccessRevokedEvent(ctx context.Context, objectType string, objectId string, relation string, ...)
- func (svc EventService) TrackAccessRevokedEventSync(ctx context.Context, objectType string, objectId string, relation string, ...) error
- func (svc EventService) TrackResourceCreated(ctx context.Context, resourceType string, resourceId string, meta interface{})
- func (svc EventService) TrackResourceCreatedSync(ctx context.Context, resourceType string, resourceId string, meta interface{}) error
- func (svc EventService) TrackResourceDeleted(ctx context.Context, resourceType string, resourceId string, meta interface{})
- func (svc EventService) TrackResourceDeletedSync(ctx context.Context, resourceType string, resourceId string, meta interface{}) error
- func (svc EventService) TrackResourceEvent(ctx context.Context, resourceEventSpec CreateResourceEventSpec)
- func (svc EventService) TrackResourceEventSync(ctx context.Context, resourceEventSpec CreateResourceEventSpec) error
- func (svc EventService) TrackResourceEvents(ctx context.Context, resourceEventSpecs []CreateResourceEventSpec)
- func (svc EventService) TrackResourceEventsSync(ctx context.Context, resourceEventSpecs []CreateResourceEventSpec) error
- func (svc EventService) TrackResourceUpdated(ctx context.Context, resourceType string, resourceId string, meta interface{})
- func (svc EventService) TrackResourceUpdatedSync(ctx context.Context, resourceType string, resourceId string, meta interface{}) error
- type LastIdSpec
- type ListAccessEventParams
- type ListEventsSpec
- type ListResourceEventParams
- type MySQLRepository
- func (repo MySQLRepository) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEvent, string, error)
- func (repo MySQLRepository) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEvent, string, error)
- func (repo MySQLRepository) TrackAccessEvent(ctx context.Context, accessEvent AccessEvent) error
- func (repo MySQLRepository) TrackAccessEvents(ctx context.Context, accessEvents []AccessEvent) error
- func (repo MySQLRepository) TrackResourceEvent(ctx context.Context, resourceEvent ResourceEvent) error
- func (repo MySQLRepository) TrackResourceEvents(ctx context.Context, resourceEvents []ResourceEvent) error
- type PostgresRepository
- func (repo PostgresRepository) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEvent, string, error)
- func (repo PostgresRepository) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEvent, string, error)
- func (repo PostgresRepository) TrackAccessEvent(ctx context.Context, accessEvent AccessEvent) error
- func (repo PostgresRepository) TrackAccessEvents(ctx context.Context, accessEvents []AccessEvent) error
- func (repo PostgresRepository) TrackResourceEvent(ctx context.Context, resourceEvent ResourceEvent) error
- func (repo PostgresRepository) TrackResourceEvents(ctx context.Context, resourceEvents []ResourceEvent) error
- type ResourceEvent
- type ResourceEventSpec
Constants ¶
View Source
const ( DateFormat = "2006-01-02" DefaultLimit = 100 QueryParamType = "type" QueryParamSource = "source" QueryParamResourceType = "resourceType" QueryParamResourceId = "resourceId" QueryParamLastId = "lastId" QueryParamSince = "since" QueryParamUntil = "until" QueryParamLimit = "limit" QueryParamObjectType = "objectType" QueryParamObjectId = "objectId" QueryParamRelation = "relation" QueryParamSubjectType = "subjectType" QueryParamSubjectId = "subjectId" QueryParamSubjectRelation = "subjectRelation" )
View Source
const ( EventSourceApi = "api" EventTypeAccessAllowed = "access_allowed" EventTypeAccessDenied = "access_denied" EventTypeAccessGranted = "access_granted" EventTypeAccessRevoked = "access_revoked" EventTypeCreated = "created" EventTypeDeleted = "deleted" EventTypeUpdated = "updated" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessEvent ¶
type AccessEvent struct {
ID string `mysql:"id" postgres:"id"`
Type string `mysql:"type" postgres:"type"`
Source string `mysql:"source" postgres:"source"`
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 string `mysql:"subjectRelation" postgres:"subject_relation"`
Context database.NullString `mysql:"context" postgres:"context"`
Meta database.NullString `mysql:"meta" postgres:"meta"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at"`
}
func (AccessEvent) ToAccessEventSpec ¶
func (accessEvent AccessEvent) ToAccessEventSpec() (*AccessEventSpec, error)
type AccessEventSpec ¶
type AccessEventSpec struct {
ID string `json:"id"`
Type string `json:"type"`
Source string `json:"source"`
ObjectType string `json:"objectType"`
ObjectId string `json:"objectId"`
Relation string `json:"relation"`
SubjectType string `json:"subjectType"`
SubjectId string `json:"subjectId"`
SubjectRelation string `json:"subjectRelation,omitempty"`
Context context.ContextSetSpec `json:"context,omitempty"`
Meta interface{} `json:"meta,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type CreateAccessEventSpec ¶
type CreateAccessEventSpec struct {
Type string `json:"type"`
Source string `json:"source"`
ObjectType string `json:"objectType"`
ObjectId string `json:"objectId"`
Relation string `json:"relation"`
SubjectType string `json:"subjectType"`
SubjectId string `json:"subjectId"`
SubjectRelation string `json:"subjectRelation"`
Context context.ContextSetSpec `json:"context"`
Meta interface{} `json:"meta"`
}
func (CreateAccessEventSpec) ToAccessEvent ¶
func (spec CreateAccessEventSpec) ToAccessEvent() (*AccessEvent, error)
type CreateResourceEventSpec ¶
type CreateResourceEventSpec struct {
Type string `json:"type"`
Source string `json:"source"`
ResourceType string `json:"resourceType"`
ResourceId string `json:"resourceId"`
Meta interface{} `json:"meta"`
}
func (CreateResourceEventSpec) ToResourceEvent ¶
func (spec CreateResourceEventSpec) ToResourceEvent() (*ResourceEvent, error)
type EventRepository ¶
type EventRepository interface {
TrackResourceEvent(context.Context, ResourceEvent) error
TrackResourceEvents(context.Context, []ResourceEvent) error
ListResourceEvents(context.Context, ListResourceEventParams) ([]ResourceEvent, string, error)
TrackAccessEvent(context.Context, AccessEvent) error
TrackAccessEvents(context.Context, []AccessEvent) error
ListAccessEvents(context.Context, ListAccessEventParams) ([]AccessEvent, string, error)
}
func NewRepository ¶
func NewRepository(db database.Database) (EventRepository, error)
type EventService ¶
type EventService struct {
service.BaseService
}
func NewService ¶
func NewService(env service.Env) EventService
func (EventService) GetRoutes ¶
func (svc EventService) GetRoutes() []service.Route
func (EventService) ListAccessEvents ¶
func (svc EventService) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEventSpec, string, error)
func (EventService) ListResourceEvents ¶
func (svc EventService) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEventSpec, string, error)
func (EventService) TrackAccessAllowedEvent ¶
func (svc EventService) TrackAccessAllowedEvent(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec)
func (EventService) TrackAccessAllowedEventSync ¶
func (svc EventService) TrackAccessAllowedEventSync(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec) error
func (EventService) TrackAccessDeniedEvent ¶
func (svc EventService) TrackAccessDeniedEvent(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec)
func (EventService) TrackAccessDeniedEventSync ¶
func (svc EventService) TrackAccessDeniedEventSync(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec) error
func (EventService) TrackAccessEvent ¶
func (svc EventService) TrackAccessEvent(ctx context.Context, accessEventSpec CreateAccessEventSpec)
func (EventService) TrackAccessEventSync ¶
func (svc EventService) TrackAccessEventSync(ctx context.Context, accessEventSpec CreateAccessEventSpec) error
func (EventService) TrackAccessEvents ¶
func (svc EventService) TrackAccessEvents(ctx context.Context, accessEventSpecs []CreateAccessEventSpec)
func (EventService) TrackAccessEventsSync ¶
func (svc EventService) TrackAccessEventsSync(ctx context.Context, accessEventSpecs []CreateAccessEventSpec) error
func (EventService) TrackAccessGrantedEvent ¶
func (svc EventService) TrackAccessGrantedEvent(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec)
func (EventService) TrackAccessGrantedEventSync ¶
func (svc EventService) TrackAccessGrantedEventSync(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec) error
func (EventService) TrackAccessRevokedEvent ¶
func (svc EventService) TrackAccessRevokedEvent(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec)
func (EventService) TrackAccessRevokedEventSync ¶
func (svc EventService) TrackAccessRevokedEventSync(ctx context.Context, objectType string, objectId string, relation string, subjectType string, subjectId string, subjectRelation string, wntCtx wntContext.ContextSetSpec) error
func (EventService) TrackResourceCreated ¶
func (svc EventService) TrackResourceCreated(ctx context.Context, resourceType string, resourceId string, meta interface{})
func (EventService) TrackResourceCreatedSync ¶
func (EventService) TrackResourceDeleted ¶
func (svc EventService) TrackResourceDeleted(ctx context.Context, resourceType string, resourceId string, meta interface{})
func (EventService) TrackResourceDeletedSync ¶
func (EventService) TrackResourceEvent ¶
func (svc EventService) TrackResourceEvent(ctx context.Context, resourceEventSpec CreateResourceEventSpec)
func (EventService) TrackResourceEventSync ¶
func (svc EventService) TrackResourceEventSync(ctx context.Context, resourceEventSpec CreateResourceEventSpec) error
func (EventService) TrackResourceEvents ¶
func (svc EventService) TrackResourceEvents(ctx context.Context, resourceEventSpecs []CreateResourceEventSpec)
func (EventService) TrackResourceEventsSync ¶
func (svc EventService) TrackResourceEventsSync(ctx context.Context, resourceEventSpecs []CreateResourceEventSpec) error
func (EventService) TrackResourceUpdated ¶
func (svc EventService) TrackResourceUpdated(ctx context.Context, resourceType string, resourceId string, meta interface{})
func (EventService) TrackResourceUpdatedSync ¶
type LastIdSpec ¶
type ListAccessEventParams ¶
type ListEventsSpec ¶
type ListEventsSpec[T ResourceEventSpec | AccessEventSpec] struct { Events []T `json:"events"` LastId string `json:"lastId,omitempty"` }
type ListResourceEventParams ¶
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) ListAccessEvents ¶
func (repo MySQLRepository) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEvent, string, error)
func (MySQLRepository) ListResourceEvents ¶
func (repo MySQLRepository) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEvent, string, error)
func (MySQLRepository) TrackAccessEvent ¶
func (repo MySQLRepository) TrackAccessEvent(ctx context.Context, accessEvent AccessEvent) error
func (MySQLRepository) TrackAccessEvents ¶
func (repo MySQLRepository) TrackAccessEvents(ctx context.Context, accessEvents []AccessEvent) error
func (MySQLRepository) TrackResourceEvent ¶
func (repo MySQLRepository) TrackResourceEvent(ctx context.Context, resourceEvent ResourceEvent) error
func (MySQLRepository) TrackResourceEvents ¶
func (repo MySQLRepository) TrackResourceEvents(ctx context.Context, resourceEvents []ResourceEvent) error
type PostgresRepository ¶
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *database.Postgres) PostgresRepository
func (PostgresRepository) ListAccessEvents ¶
func (repo PostgresRepository) ListAccessEvents(ctx context.Context, listParams ListAccessEventParams) ([]AccessEvent, string, error)
func (PostgresRepository) ListResourceEvents ¶
func (repo PostgresRepository) ListResourceEvents(ctx context.Context, listParams ListResourceEventParams) ([]ResourceEvent, string, error)
func (PostgresRepository) TrackAccessEvent ¶
func (repo PostgresRepository) TrackAccessEvent(ctx context.Context, accessEvent AccessEvent) error
func (PostgresRepository) TrackAccessEvents ¶
func (repo PostgresRepository) TrackAccessEvents(ctx context.Context, accessEvents []AccessEvent) error
func (PostgresRepository) TrackResourceEvent ¶
func (repo PostgresRepository) TrackResourceEvent(ctx context.Context, resourceEvent ResourceEvent) error
func (PostgresRepository) TrackResourceEvents ¶
func (repo PostgresRepository) TrackResourceEvents(ctx context.Context, resourceEvents []ResourceEvent) error
type ResourceEvent ¶
type ResourceEvent struct {
ID string `mysql:"id" postgres:"id"`
Type string `mysql:"type" postgres:"type"`
Source string `mysql:"source" postgres:"source"`
ResourceType string `mysql:"resourceType" postgres:"resource_type"`
ResourceId string `mysql:"resourceId" postgres:"resource_id"`
Meta database.NullString `mysql:"meta" postgres:"meta"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at"`
}
func (ResourceEvent) ToResourceEventSpec ¶
func (resourceEvent ResourceEvent) ToResourceEventSpec() (*ResourceEventSpec, error)
Click to show internal directories.
Click to hide internal directories.