Documentation ¶
Overview ¶
Package client provides Graylog API client.
Index ¶
- type Client
- func (client *Client) AddUserToRole(userName, roleName string) (*ErrorInfo, error)
- func (client *Client) AddUserToRoleContext(ctx context.Context, userName, roleName string) (*ErrorInfo, error)
- func (client *Client) CreateIndexSet(indexSet *graylog.IndexSet) (*ErrorInfo, error)
- func (client *Client) CreateIndexSetContext(ctx context.Context, is *graylog.IndexSet) (*ErrorInfo, error)
- func (client *Client) CreateInput(input *graylog.Input) (ei *ErrorInfo, err error)
- func (client *Client) CreateInputContext(ctx context.Context, input *graylog.Input) (ei *ErrorInfo, err error)
- func (client *Client) CreateRole(role *graylog.Role) (*ErrorInfo, error)
- func (client *Client) CreateRoleContext(ctx context.Context, role *graylog.Role) (*ErrorInfo, error)
- func (client *Client) CreateStream(stream *graylog.Stream) (*ErrorInfo, error)
- func (client *Client) CreateStreamContext(ctx context.Context, stream *graylog.Stream) (*ErrorInfo, error)
- func (client *Client) CreateStreamRule(rule *graylog.StreamRule) (*ErrorInfo, error)
- func (client *Client) CreateStreamRuleContext(ctx context.Context, rule *graylog.StreamRule) (*ErrorInfo, error)
- func (client *Client) CreateUser(user *graylog.User) (*ErrorInfo, error)
- func (client *Client) CreateUserContext(ctx context.Context, user *graylog.User) (*ErrorInfo, error)
- func (client *Client) DeleteIndexSet(id string) (*ErrorInfo, error)
- func (client *Client) DeleteIndexSetContext(ctx context.Context, id string) (*ErrorInfo, error)
- func (client *Client) DeleteInput(id string) (*ErrorInfo, error)
- func (client *Client) DeleteInputContext(ctx context.Context, id string) (*ErrorInfo, error)
- func (client *Client) DeleteRole(name string) (*ErrorInfo, error)
- func (client *Client) DeleteRoleContext(ctx context.Context, name string) (*ErrorInfo, error)
- func (client *Client) DeleteStream(id string) (*ErrorInfo, error)
- func (client *Client) DeleteStreamContext(ctx context.Context, id string) (*ErrorInfo, error)
- func (client *Client) DeleteStreamRule(streamID, ruleID string) (*ErrorInfo, error)
- func (client *Client) DeleteStreamRuleContext(ctx context.Context, streamID, ruleID string) (*ErrorInfo, error)
- func (client *Client) DeleteUser(name string) (*ErrorInfo, error)
- func (client *Client) DeleteUserContext(ctx context.Context, name string) (*ErrorInfo, error)
- func (client *Client) Endpoints() *endpoint.Endpoints
- func (client *Client) GetEnabledStreams() (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
- func (client *Client) GetEnabledStreamsContext(ctx context.Context) (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
- func (client *Client) GetIndexSet(id string) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) GetIndexSetContext(ctx context.Context, id string) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) GetIndexSetStats(id string) (*graylog.IndexSetStats, *ErrorInfo, error)
- func (client *Client) GetIndexSetStatsContext(ctx context.Context, id string) (*graylog.IndexSetStats, *ErrorInfo, error)
- func (client *Client) GetIndexSets(skip, limit int, stats bool) ([]graylog.IndexSet, map[string]graylog.IndexSetStats, int, *ErrorInfo, error)
- func (client *Client) GetIndexSetsContext(ctx context.Context, skip, limit int, stats bool) ([]graylog.IndexSet, map[string]graylog.IndexSetStats, int, *ErrorInfo, error)
- func (client *Client) GetInput(id string) (*graylog.Input, *ErrorInfo, error)
- func (client *Client) GetInputContext(ctx context.Context, id string) (*graylog.Input, *ErrorInfo, error)
- func (client *Client) GetInputs() ([]graylog.Input, int, *ErrorInfo, error)
- func (client *Client) GetInputsContext(ctx context.Context) ([]graylog.Input, int, *ErrorInfo, error)
- func (client *Client) GetRole(name string) (*graylog.Role, *ErrorInfo, error)
- func (client *Client) GetRoleContext(ctx context.Context, name string) (*graylog.Role, *ErrorInfo, error)
- func (client *Client) GetRoleMembers(name string) ([]graylog.User, *ErrorInfo, error)
- func (client *Client) GetRoleMembersContext(ctx context.Context, name string) ([]graylog.User, *ErrorInfo, error)
- func (client *Client) GetRoles() ([]graylog.Role, int, *ErrorInfo, error)
- func (client *Client) GetRolesContext(ctx context.Context) ([]graylog.Role, int, *ErrorInfo, error)
- func (client *Client) GetStream(id string) (*graylog.Stream, *ErrorInfo, error)
- func (client *Client) GetStreamContext(ctx context.Context, id string) (*graylog.Stream, *ErrorInfo, error)
- func (client *Client) GetStreamRule(streamID, ruleID string) (*graylog.StreamRule, *ErrorInfo, error)
- func (client *Client) GetStreamRuleContext(ctx context.Context, streamID, ruleID string) (*graylog.StreamRule, *ErrorInfo, error)
- func (client *Client) GetStreamRules(streamID string) (streamRules []graylog.StreamRule, total int, ei *ErrorInfo, err error)
- func (client *Client) GetStreamRulesContext(ctx context.Context, streamID string) (streamRules []graylog.StreamRule, total int, ei *ErrorInfo, err error)
- func (client *Client) GetStreams() (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
- func (client *Client) GetStreamsContext(ctx context.Context) (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
- func (client *Client) GetTotalIndexSetsStats() (*graylog.IndexSetStats, *ErrorInfo, error)
- func (client *Client) GetTotalIndexSetsStatsContext(ctx context.Context) (*graylog.IndexSetStats, *ErrorInfo, error)
- func (client *Client) GetUser(name string) (*graylog.User, *ErrorInfo, error)
- func (client *Client) GetUserContext(ctx context.Context, name string) (*graylog.User, *ErrorInfo, error)
- func (client *Client) GetUsers() ([]graylog.User, *ErrorInfo, error)
- func (client *Client) GetUsersContext(ctx context.Context) ([]graylog.User, *ErrorInfo, error)
- func (client *Client) Name() string
- func (client *Client) Password() string
- func (client *Client) PauseStream(id string) (*ErrorInfo, error)
- func (client *Client) PauseStreamContext(ctx context.Context, id string) (*ErrorInfo, error)
- func (client *Client) RemoveUserFromRole(userName, roleName string) (*ErrorInfo, error)
- func (client *Client) RemoveUserFromRoleContext(ctx context.Context, userName, roleName string) (*ErrorInfo, error)
- func (client *Client) ResumeStream(id string) (*ErrorInfo, error)
- func (client *Client) ResumeStreamContext(ctx context.Context, id string) (*ErrorInfo, error)
- func (client *Client) SetDefaultIndexSet(id string) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) SetDefaultIndexSetContext(ctx context.Context, id string) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) UpdateIndexSet(is *graylog.IndexSetUpdateParams) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) UpdateIndexSetContext(ctx context.Context, prms *graylog.IndexSetUpdateParams) (*graylog.IndexSet, *ErrorInfo, error)
- func (client *Client) UpdateInput(input *graylog.InputUpdateParams) (*graylog.Input, *ErrorInfo, error)
- func (client *Client) UpdateInputContext(ctx context.Context, prms *graylog.InputUpdateParams) (*graylog.Input, *ErrorInfo, error)
- func (client *Client) UpdateRole(name string, role *graylog.RoleUpdateParams) (*graylog.Role, *ErrorInfo, error)
- func (client *Client) UpdateRoleContext(ctx context.Context, name string, prms *graylog.RoleUpdateParams) (*graylog.Role, *ErrorInfo, error)
- func (client *Client) UpdateStream(stream *graylog.Stream) (*ErrorInfo, error)
- func (client *Client) UpdateStreamContext(ctx context.Context, stream *graylog.Stream) (*ErrorInfo, error)
- func (client *Client) UpdateStreamRule(rule *graylog.StreamRule) (*ErrorInfo, error)
- func (client *Client) UpdateStreamRuleContext(ctx context.Context, rule *graylog.StreamRule) (*ErrorInfo, error)
- func (client *Client) UpdateUser(prms *graylog.UserUpdateParams) (*ErrorInfo, error)
- func (client *Client) UpdateUserContext(ctx context.Context, prms *graylog.UserUpdateParams) (*ErrorInfo, error)
- type ErrorInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Graylog API client.
Example ¶
package main import ( "fmt" "log" "github.com/suzuki-shunsuke/go-graylog/client" "github.com/suzuki-shunsuke/go-graylog/mockserver" ) func main() { // Create a mock server server, err := mockserver.NewServer("", nil) if err != nil { log.Fatal(err) } // Start a server server.Start() defer server.Close() // Create a client cl, err := client.NewClient(server.Endpoint(), "admin", "admin") if err != nil { log.Fatal(err) } // get a role "Admin" // ei.Response.Body is closed role, ei, err := cl.GetRole("Admin") if err != nil { log.Fatal(err) } fmt.Println(ei.Response.StatusCode) fmt.Println(role.Name) }
Output: 200 Admin
func NewClient ¶
NewClient returns a new Graylog API Client. ep is API endpoint url (ex. http://localhost:9000/api). name and password are authentication name and password. If you use an access token instead of password, name is access token and password is literal password "token". If you use a session token instead of password, name is session token and password is literal password "session".
func (*Client) AddUserToRole ¶
AddUserToRole adds a user to a role.
func (*Client) AddUserToRoleContext ¶
func (client *Client) AddUserToRoleContext( ctx context.Context, userName, roleName string, ) (*ErrorInfo, error)
AddUserToRoleContext adds a user to a role with a context.
func (*Client) CreateIndexSet ¶
CreateIndexSet creates a Index Set.
func (*Client) CreateIndexSetContext ¶
func (client *Client) CreateIndexSetContext( ctx context.Context, is *graylog.IndexSet, ) (*ErrorInfo, error)
CreateIndexSetContext creates a Index Set with a context.
func (*Client) CreateInput ¶
CreateInput creates an input.
func (*Client) CreateInputContext ¶
func (client *Client) CreateInputContext( ctx context.Context, input *graylog.Input, ) (ei *ErrorInfo, err error)
CreateInputContext creates an input with a context.
func (*Client) CreateRole ¶
CreateRole creates a new role.
func (*Client) CreateRoleContext ¶
func (client *Client) CreateRoleContext( ctx context.Context, role *graylog.Role, ) (*ErrorInfo, error)
CreateRoleContext creates a new role with a context.
func (*Client) CreateStream ¶
CreateStream creates a stream.
func (*Client) CreateStreamContext ¶
func (client *Client) CreateStreamContext( ctx context.Context, stream *graylog.Stream, ) (*ErrorInfo, error)
CreateStreamContext creates a stream with a context.
func (*Client) CreateStreamRule ¶
CreateStreamRule creates a stream
func (*Client) CreateStreamRuleContext ¶
func (client *Client) CreateStreamRuleContext( ctx context.Context, rule *graylog.StreamRule, ) (*ErrorInfo, error)
CreateStreamRuleContext creates a stream with a context
func (*Client) CreateUser ¶
CreateUser creates a new user account.
func (*Client) CreateUserContext ¶
func (client *Client) CreateUserContext( ctx context.Context, user *graylog.User, ) (*ErrorInfo, error)
CreateUserContext creates a new user account with a context.
func (*Client) DeleteIndexSet ¶
DeleteIndexSet deletes a given Index Set.
func (*Client) DeleteIndexSetContext ¶
DeleteIndexSetContext deletes a given Index Set with a context.
func (*Client) DeleteInput ¶
DeleteInput deletes an given input.
func (*Client) DeleteInputContext ¶
DeleteInputContext deletes an given input with a context.
func (*Client) DeleteRole ¶
DeleteRole deletes a given role.
func (*Client) DeleteRoleContext ¶
DeleteRoleContext deletes a given role with a context.
func (*Client) DeleteStream ¶
DeleteStream deletes a stream.
func (*Client) DeleteStreamContext ¶
DeleteStreamContext deletes a stream with a context.
func (*Client) DeleteStreamRule ¶
DeleteStreamRule deletes a stream rule
func (*Client) DeleteStreamRuleContext ¶
func (client *Client) DeleteStreamRuleContext( ctx context.Context, streamID, ruleID string, ) (*ErrorInfo, error)
DeleteStreamRuleContext deletes a stream rule with a context
func (*Client) DeleteUser ¶
DeleteUser deletes a given user.
func (*Client) DeleteUserContext ¶
DeleteUserContext deletes a given user with a context.
func (*Client) GetEnabledStreams ¶
func (client *Client) GetEnabledStreams() ( streams []graylog.Stream, total int, ei *ErrorInfo, err error, )
GetEnabledStreams returns all enabled streams.
func (*Client) GetEnabledStreamsContext ¶
func (client *Client) GetEnabledStreamsContext( ctx context.Context, ) (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
GetEnabledStreamsContext returns all enabled streams with a context.
func (*Client) GetIndexSet ¶
GetIndexSet returns a given index set.
func (*Client) GetIndexSetContext ¶
func (client *Client) GetIndexSetContext( ctx context.Context, id string, ) (*graylog.IndexSet, *ErrorInfo, error)
GetIndexSetContext returns a given index set with a context.
func (*Client) GetIndexSetStats ¶
GetIndexSetStats returns a given Index Set statistics.
func (*Client) GetIndexSetStatsContext ¶
func (client *Client) GetIndexSetStatsContext( ctx context.Context, id string, ) (*graylog.IndexSetStats, *ErrorInfo, error)
GetIndexSetStatsContext returns a given Index Set statistics with a context.
func (*Client) GetIndexSets ¶
func (client *Client) GetIndexSets( skip, limit int, stats bool, ) ([]graylog.IndexSet, map[string]graylog.IndexSetStats, int, *ErrorInfo, error)
GetIndexSets returns a list of all index sets.
func (*Client) GetIndexSetsContext ¶
func (client *Client) GetIndexSetsContext( ctx context.Context, skip, limit int, stats bool, ) ([]graylog.IndexSet, map[string]graylog.IndexSetStats, int, *ErrorInfo, error)
GetIndexSetsContext returns a list of all index sets with a context.
func (*Client) GetInputContext ¶
func (client *Client) GetInputContext( ctx context.Context, id string, ) (*graylog.Input, *ErrorInfo, error)
GetInputContext returns a given input with a context.
func (*Client) GetInputsContext ¶
func (client *Client) GetInputsContext(ctx context.Context) ( []graylog.Input, int, *ErrorInfo, error, )
GetInputsContext returns all inputs with a context.
func (*Client) GetRoleContext ¶
func (client *Client) GetRoleContext( ctx context.Context, name string, ) (*graylog.Role, *ErrorInfo, error)
GetRoleContext returns a given role with a context.
func (*Client) GetRoleMembers ¶
GetRoleMembers returns a given role's members.
func (*Client) GetRoleMembersContext ¶
func (client *Client) GetRoleMembersContext( ctx context.Context, name string, ) ([]graylog.User, *ErrorInfo, error)
GetRoleMembersContext returns a given role's members with a context.
func (*Client) GetRolesContext ¶
func (client *Client) GetRolesContext(ctx context.Context) ( []graylog.Role, int, *ErrorInfo, error, )
GetRolesContext returns all roles with a context.
func (*Client) GetStreamContext ¶
func (client *Client) GetStreamContext( ctx context.Context, id string, ) (*graylog.Stream, *ErrorInfo, error)
GetStreamContext returns a given stream with a context.
func (*Client) GetStreamRule ¶
func (client *Client) GetStreamRule(streamID, ruleID string) (*graylog.StreamRule, *ErrorInfo, error)
GetStreamRule returns a stream rule
func (*Client) GetStreamRuleContext ¶
func (client *Client) GetStreamRuleContext( ctx context.Context, streamID, ruleID string, ) (*graylog.StreamRule, *ErrorInfo, error)
GetStreamRuleContext returns a stream rule with a context
func (*Client) GetStreamRules ¶
func (client *Client) GetStreamRules(streamID string) ( streamRules []graylog.StreamRule, total int, ei *ErrorInfo, err error, )
GetStreamRules returns a list of all stream rules
func (*Client) GetStreamRulesContext ¶
func (client *Client) GetStreamRulesContext( ctx context.Context, streamID string, ) (streamRules []graylog.StreamRule, total int, ei *ErrorInfo, err error)
GetStreamRulesContext returns a list of all stream rules with a context.
func (*Client) GetStreams ¶
func (client *Client) GetStreams() ( streams []graylog.Stream, total int, ei *ErrorInfo, err error, )
GetStreams returns all streams.
func (*Client) GetStreamsContext ¶
func (client *Client) GetStreamsContext( ctx context.Context, ) (streams []graylog.Stream, total int, ei *ErrorInfo, err error)
GetStreamsContext returns all streams with a context.
func (*Client) GetTotalIndexSetsStats ¶
GetTotalIndexSetsStats returns stats of all Index Sets.
func (*Client) GetTotalIndexSetsStatsContext ¶
func (client *Client) GetTotalIndexSetsStatsContext( ctx context.Context, ) (*graylog.IndexSetStats, *ErrorInfo, error)
GetTotalIndexSetsStatsContext returns stats of all Index Sets with a context.
func (*Client) GetUserContext ¶
func (client *Client) GetUserContext( ctx context.Context, name string, ) (*graylog.User, *ErrorInfo, error)
GetUserContext returns a given user with a context.
func (*Client) GetUsersContext ¶
GetUsersContext returns all users with a context.
func (*Client) PauseStream ¶
PauseStream pauses a stream.
func (*Client) PauseStreamContext ¶
PauseStreamContext pauses a stream with a context.
func (*Client) RemoveUserFromRole ¶
RemoveUserFromRole removes a user from a role.
func (*Client) RemoveUserFromRoleContext ¶
func (client *Client) RemoveUserFromRoleContext( ctx context.Context, userName, roleName string, ) (*ErrorInfo, error)
RemoveUserFromRoleContext removes a user from a role with a context.
func (*Client) ResumeStream ¶
ResumeStream resumes a stream.
func (*Client) ResumeStreamContext ¶
ResumeStreamContext resumes a stream with a context.
func (*Client) SetDefaultIndexSet ¶
SetDefaultIndexSet sets default Index Set.
func (*Client) SetDefaultIndexSetContext ¶
func (client *Client) SetDefaultIndexSetContext( ctx context.Context, id string, ) (*graylog.IndexSet, *ErrorInfo, error)
SetDefaultIndexSetContext sets default Index Set with a context.
func (*Client) UpdateIndexSet ¶
func (client *Client) UpdateIndexSet(is *graylog.IndexSetUpdateParams) (*graylog.IndexSet, *ErrorInfo, error)
UpdateIndexSet updates a given Index Set.
func (*Client) UpdateIndexSetContext ¶
func (client *Client) UpdateIndexSetContext( ctx context.Context, prms *graylog.IndexSetUpdateParams, ) (*graylog.IndexSet, *ErrorInfo, error)
UpdateIndexSetContext updates a given Index Set with a context.
func (*Client) UpdateInput ¶
func (client *Client) UpdateInput(input *graylog.InputUpdateParams) (*graylog.Input, *ErrorInfo, error)
UpdateInput updates an given input.
func (*Client) UpdateInputContext ¶
func (client *Client) UpdateInputContext( ctx context.Context, prms *graylog.InputUpdateParams, ) (*graylog.Input, *ErrorInfo, error)
UpdateInputContext updates an given input with a context.
func (*Client) UpdateRole ¶
func (client *Client) UpdateRole(name string, role *graylog.RoleUpdateParams) ( *graylog.Role, *ErrorInfo, error, )
UpdateRole updates a given role.
func (*Client) UpdateRoleContext ¶
func (client *Client) UpdateRoleContext( ctx context.Context, name string, prms *graylog.RoleUpdateParams, ) (*graylog.Role, *ErrorInfo, error)
UpdateRoleContext updates a given role with a context.
func (*Client) UpdateStream ¶
UpdateStream updates a stream.
func (*Client) UpdateStreamContext ¶
func (client *Client) UpdateStreamContext( ctx context.Context, stream *graylog.Stream, ) (*ErrorInfo, error)
UpdateStreamContext updates a stream with a context.
func (*Client) UpdateStreamRule ¶
UpdateStreamRule updates a stream rule
func (*Client) UpdateStreamRuleContext ¶
func (client *Client) UpdateStreamRuleContext( ctx context.Context, rule *graylog.StreamRule, ) (*ErrorInfo, error)
UpdateStreamRuleContext updates a stream rule
func (*Client) UpdateUser ¶
UpdateUser updates a given user.
type ErrorInfo ¶
type ErrorInfo struct { Type string `json:"type"` Message string `json:"message"` Request *http.Request `json:"request"` Response *http.Response `json:"response"` }
ErrorInfo represents Graylog API's error information. Basically Client methods (ex. CreateRole) returns this, but note that Response is closed.