package rulesengine import ( "context" ) type Dataset interface { // validation methods EARoles(ctx context.Context, bannerID string, command Command) ([]string, error) // admin methods AddCommands(ctx context.Context, names []string) (AddNameResult, error) AddPrivileges(ctx context.Context, names []string) (AddNameResult, error) AddDefaultRules(ctx context.Context, rules []RuleSegment) (AddRuleResult, error) DeleteCommand(ctx context.Context, name string) (DeleteResult, error) DeletePrivilege(ctx context.Context, name string) (DeleteResult, error) DeleteDefaultRule(ctx context.Context, commandName, privilegeName string) (DeleteResult, error) ReadAllCommands(ctx context.Context) ([]Command, error) ReadCommandsWithFilter(ctx context.Context, names []string) ([]Command, error) ReadCommand(ctx context.Context, name string) (Command, error) ReadAllPrivileges(ctx context.Context) ([]Privilege, error) ReadPrivilegesWithFilter(ctx context.Context, filter []string) ([]Privilege, error) ReadPrivilege(ctx context.Context, name string) (Privilege, error) ReadAllDefaultRules(ctx context.Context) ([]RuleSegment, error) ReadDefaultRulesForCommand(ctx context.Context, commandName string) ([]RuleSegment, error) // banner admin methods ReadRulesForAllBanners(ctx context.Context) ([]RuleSegment, error) AddBannerRules(ctx context.Context, rules []RuleSegment) (feedback AddRuleResult, err error) ReadRulesForBanner(ctx context.Context, bannerName string) ([]RuleSegment, error) ReadBannerRulesForCommandAndBanner(ctx context.Context, bannerName string, commandName string) ([]RuleSegment, error) ReadBannerRulesForCommand(ctx context.Context, commandName string) ([]RuleSegment, error) DeletePrivilegeFromBannerRule(ctx context.Context, bannerName, commandName, privilegeName string) (DeleteResult, error) } const ( // maxCommands is the maximum number of commands that can be inserted as a single request. maxCommands = 500 // maxPrivileges is the maximum number of privileges that can be inserted as a single request. maxPrivileges = 500 // maxRules is the maximum number of rules that can be inserted as a single request. maxRules = 500 ) type RulesEngine struct { ds Dataset } func New(ds Dataset) RulesEngine { return RulesEngine{ds: ds} }