Documentation ¶
Overview ¶
Package logic provides logic layers of Graylog API mock server. Basically enduser does not use the package directly, but the struct Logic is embed to mockserver.Server .
Index ¶
- func LogWE(sc int, entry *log.Entry, msg string)
- func ValidateObjectID(id string) error
- type Logic
- func (lgc *Logic) AddDashboard(dashboard *graylog.Dashboard) (int, error)
- func (lgc *Logic) AddIndexSet(is *graylog.IndexSet) (int, error)
- func (lgc *Logic) AddInput(input *graylog.Input) (int, error)
- func (lgc *Logic) AddRole(role *graylog.Role) (int, error)
- func (lgc *Logic) AddStream(stream *graylog.Stream) (int, error)
- func (lgc *Logic) AddStreamRule(rule *graylog.StreamRule) (int, error)
- func (lgc *Logic) AddUser(user *graylog.User) (int, error)
- func (lgc *Logic) AddUserToRole(userName, roleName string) (int, error)
- func (lgc *Logic) Auth() bool
- func (lgc *Logic) Authenticate(name, password string) (*graylog.User, int, error)
- func (lgc *Logic) Authorize(user *graylog.User, scope string, args ...string) (int, error)
- func (lgc *Logic) DeleteDashboard(id string) (int, error)
- func (lgc *Logic) DeleteIndexSet(id string) (int, error)
- func (lgc *Logic) DeleteInput(id string) (int, error)
- func (lgc *Logic) DeleteRole(name string) (int, error)
- func (lgc *Logic) DeleteStream(id string) (int, error)
- func (lgc *Logic) DeleteStreamRule(streamID, streamRuleID string) (int, error)
- func (lgc *Logic) DeleteUser(name string) (int, error)
- func (lgc *Logic) GetAlert(id string) (*graylog.Alert, int, error)
- func (lgc *Logic) GetAlertConditions() ([]graylog.AlertCondition, int, int, error)
- func (lgc *Logic) GetAlerts(since, limit int) ([]graylog.Alert, int, int, error)
- func (lgc *Logic) GetDashboard(id string) (*graylog.Dashboard, int, error)
- func (lgc *Logic) GetDashboards() ([]graylog.Dashboard, int, int, error)
- func (lgc *Logic) GetEnabledStreams() ([]graylog.Stream, int, int, error)
- func (lgc *Logic) GetIndexSet(id string) (*graylog.IndexSet, int, error)
- func (lgc *Logic) GetIndexSetStats(id string) (*graylog.IndexSetStats, int, error)
- func (lgc *Logic) GetIndexSetStatsMap() (map[string]graylog.IndexSetStats, int, error)
- func (lgc *Logic) GetIndexSets(skip, limit int) ([]graylog.IndexSet, int, int, error)
- func (lgc *Logic) GetInput(id string) (*graylog.Input, int, error)
- func (lgc *Logic) GetInputs() ([]graylog.Input, int, int, error)
- func (lgc *Logic) GetRole(name string) (*graylog.Role, int, error)
- func (lgc *Logic) GetRoles() ([]graylog.Role, int, int, error)
- func (lgc *Logic) GetStream(id string) (*graylog.Stream, int, error)
- func (lgc *Logic) GetStreamRule(streamID, streamRuleID string) (*graylog.StreamRule, int, error)
- func (lgc *Logic) GetStreamRules(streamID string) ([]graylog.StreamRule, int, int, error)
- func (lgc *Logic) GetStreams() ([]graylog.Stream, int, int, error)
- func (lgc *Logic) GetTotalIndexSetStats() (*graylog.IndexSetStats, int, error)
- func (lgc *Logic) GetUser(username string) (*graylog.User, int, error)
- func (lgc *Logic) GetUsers() ([]graylog.User, int, error)
- func (lgc *Logic) HasDashboard(id string) (bool, error)
- func (lgc *Logic) HasIndexSet(id string) (bool, error)
- func (lgc *Logic) HasInput(id string) (bool, error)
- func (lgc *Logic) HasRole(name string) (bool, error)
- func (lgc *Logic) HasStream(id string) (bool, error)
- func (lgc *Logic) HasStreamRule(streamID, streamRuleID string) (bool, error)
- func (lgc *Logic) HasUser(username string) (bool, error)
- func (lgc *Logic) InitData() error
- func (lgc *Logic) Load() error
- func (lgc *Logic) Logger() *log.Logger
- func (lgc *Logic) PauseStream(id string) (int, error)
- func (lgc *Logic) RemoveUserFromRole(userName, roleName string) (int, error)
- func (lgc *Logic) ResumeStream(id string) (int, error)
- func (lgc *Logic) RoleMembers(name string) ([]graylog.User, int, error)
- func (lgc *Logic) Save() error
- func (lgc *Logic) SetAuth(authEnabled bool)
- func (lgc *Logic) SetDefaultIndexSet(id string) (*graylog.IndexSet, int, error)
- func (lgc *Logic) SetStore(store store.Store)
- func (lgc *Logic) UpdateDashboard(dashboard *graylog.Dashboard) (int, error)
- func (lgc *Logic) UpdateIndexSet(prms *graylog.IndexSetUpdateParams) (*graylog.IndexSet, int, error)
- func (lgc *Logic) UpdateInput(prms *graylog.InputUpdateParams) (*graylog.Input, int, error)
- func (lgc *Logic) UpdateRole(name string, prms *graylog.RoleUpdateParams) (*graylog.Role, int, error)
- func (lgc *Logic) UpdateStream(prms *graylog.StreamUpdateParams) (*graylog.Stream, int, error)
- func (lgc *Logic) UpdateStreamRule(prms *graylog.StreamRuleUpdateParams) (int, error)
- func (lgc *Logic) UpdateUser(prms *graylog.UserUpdateParams) (int, error)
- func (lgc *Logic) UserList() ([]graylog.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logic ¶
type Logic struct {
// contains filtered or unexported fields
}
Logic represents a mock of the Graylog API. This is embedded to mockserver.Server.
func NewLogic ¶
NewLogic returns new Server. The argument `store` is the store which the server uses. If `store` is nil, the default plain store is used and data is not persisted.
func (*Logic) AddDashboard ¶ added in v0.4.0
AddDashboard adds an dashboard to the mock server.
func (*Logic) AddIndexSet ¶
AddIndexSet adds an index set to the Mock Server.
func (*Logic) AddStreamRule ¶
AddStreamRule adds a stream rule to the Server.
func (*Logic) AddUserToRole ¶
AddUserToRole adds a user to a role.
func (*Logic) Authenticate ¶
Authenticate authenticates a user.
func (*Logic) Authorize ¶
Authorize authorizes a user. If the user doesn't have the permission, an error is returned.
// whether the user has the permission to read all roles if sc, err := lgc.Authorize(user, "roles:read", ""); err != nil { fmt.Println(sc, err) // 403, "authorization failure" } // whether the user has the permission to read the role "foo" sc, err := lgc.Authorize(admin, "roles:read", "foo") fmt.Println(sc, err) // 200, nil
func (*Logic) DeleteDashboard ¶ added in v0.4.0
DeleteDashboard deletes a dashboard from the mock server.
func (*Logic) DeleteIndexSet ¶
DeleteIndexSet removes a index set from the Mock Server.
func (*Logic) DeleteInput ¶
DeleteInput deletes a input from the mock server.
func (*Logic) DeleteRole ¶
DeleteRole deletes a role.
func (*Logic) DeleteStream ¶
DeleteStream deletes a stream from the Server.
func (*Logic) DeleteStreamRule ¶
DeleteStreamRule deletes a stream rule from the Server.
func (*Logic) DeleteUser ¶
DeleteUser removes a user from the Server.
func (*Logic) GetAlert ¶ added in v0.3.0
GetAlert returns an alert. If an alert is not found, returns an error.
func (*Logic) GetAlertConditions ¶ added in v0.2.0
GetAlertConditions returns a list of alert conditions.
func (*Logic) GetDashboard ¶ added in v0.4.0
GetDashboard returns an dashboard. If an dashboard is not found, returns an error.
func (*Logic) GetDashboards ¶ added in v0.4.0
GetDashboards returns a list of dashboards.
func (*Logic) GetEnabledStreams ¶
GetEnabledStreams returns all enabled streams.
func (*Logic) GetIndexSet ¶
GetIndexSet returns an index set. If an index set is not found, returns an error.
func (*Logic) GetIndexSetStats ¶
GetIndexSetStats returns an index set stats.
func (*Logic) GetIndexSetStatsMap ¶
GetIndexSetStatsMap returns a each Index Set's statistics.
func (*Logic) GetIndexSets ¶
GetIndexSets returns a list of all index sets.
func (*Logic) GetStreamRule ¶
GetStreamRule returns a stream rule.
func (*Logic) GetStreamRules ¶
GetStreamRules returns a list of all stream rules of a given stream.
func (*Logic) GetStreams ¶
GetStreams returns a list of all streams.
func (*Logic) GetTotalIndexSetStats ¶
GetTotalIndexSetStats returns all index set's statistics.
func (*Logic) HasDashboard ¶ added in v0.4.0
HasDashboard returns whether the dashboard exists.
func (*Logic) HasIndexSet ¶
HasIndexSet returns whether the user exists.
func (*Logic) HasStreamRule ¶
HasStreamRule returns whether the stream sule exists.
func (*Logic) Logger ¶
Logger returns a logger. This logger is logrus.Logger . https://github.com/sirupsen/logrus You can change the Logic's logger configuration freely.
lgc := logic.NewLogic(nil) logger := lgc.Logger() logger.SetFormatter(&log.JSONFormatter{}) logger.SetLevel(log.WarnLevel)
func (*Logic) PauseStream ¶
PauseStream pauses a stream.
func (*Logic) RemoveUserFromRole ¶
RemoveUserFromRole removes a user from a role.
func (*Logic) ResumeStream ¶
ResumeStream resumes a stream.
func (*Logic) RoleMembers ¶
RoleMembers returns members of a given role.
func (*Logic) SetAuth ¶
SetAuth sets whether the authentication and authentication are enabled. Disable the authentication.
lgc.SetAuth(false)
Enable the authentication.
lgc.SetAuth(true)
func (*Logic) SetDefaultIndexSet ¶
SetDefaultIndexSet sets a default index set
func (*Logic) UpdateDashboard ¶ added in v0.4.0
UpdateDashboard updates an dashboard at the Server. Required: none Allowed: Title, Description
func (*Logic) UpdateIndexSet ¶
func (lgc *Logic) UpdateIndexSet(prms *graylog.IndexSetUpdateParams) (*graylog.IndexSet, int, error)
UpdateIndexSet updates an index set at the Mock Server.
func (*Logic) UpdateInput ¶
UpdateInput updates an input at the Server. Required: Title, Type, Attrs Allowed: Global, Node
func (*Logic) UpdateRole ¶
func (lgc *Logic) UpdateRole(name string, prms *graylog.RoleUpdateParams) (*graylog.Role, int, error)
UpdateRole updates a role.
func (*Logic) UpdateStream ¶
UpdateStream updates a stream at the Server.
func (*Logic) UpdateStreamRule ¶
UpdateStreamRule updates a stream rule of the Server.
func (*Logic) UpdateUser ¶
UpdateUser updates a user of the Server. "email", "permissions", "full_name", "password"