Documentation ¶
Index ¶
- Constants
- func CheckResponse(r *http.Response) error
- type AbsoluteSearchOptions
- type Auth
- type Client
- type ErrorResponse
- type RelativeSearchOptions
- type RequestCompletionCallback
- type Response
- type SearchService
- type SearchServiceOp
- type Token
- type User
- type UserService
- type UserServiceOp
- type UserTokenService
- type UserTokenServiceOp
- func (s *UserTokenServiceOp) Create(ctx context.Context, user, tokenName string) (Token, *Response, error)
- func (s *UserTokenServiceOp) Delete(ctx context.Context, user string, token Token) (*Response, error)
- func (s *UserTokenServiceOp) List(ctx context.Context, user string) ([]Token, *Response, error)
Constants ¶
const TimeFormat = "2006-01-02T15:04:05.000Z"
TimeFormat is the recognised time format for the Graylog API
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type AbsoluteSearchOptions ¶
type AbsoluteSearchOptions struct { Query string `url:"query"` From string `url:"from"` To string `url:"to"` Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` Filter string `url:"filter,omitempty"` Fields string `url:"fields,omitempty"` Sort string `url:"sort,omitempty"` Decorate bool `url:"decorate"` FromTime time.Time `url:"-"` ToTime time.Time `url:"-"` }
AbsoluteSearchOptions is the options available for use when using an absolute search.
func (*AbsoluteSearchOptions) ParseTime ¶
func (a *AbsoluteSearchOptions) ParseTime()
ParseTime formats the From and To times into the fromTime and toTime strings for the query
type Client ¶
type Client struct { // Base URL for requests BaseURL *url.URL // User agent for client UserAgent string // Services used for communicating with the API User UserService UserToken UserTokenService Search SearchService // contains filtered or unexported fields }
Client manages communication with Graylog API.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.
func (*Client) OnRequestCompleted ¶
func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
OnRequestCompleted sets the Graylog API request completion callback
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string `json:"message"` // RequestID returned from the API, useful to contact support. RequestID string `json:"request_id"` }
An ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type RelativeSearchOptions ¶
type RelativeSearchOptions struct { Query string `url:"query"` Range int `url:"range"` Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` Filter string `url:"filter,omitempty"` Fields string `url:"fields,omitempty"` Sort string `url:"sort,omitempty"` Decorate bool `url:"decorate"` }
RelativeSearchOptions is the options available when using a relative search.
type RequestCompletionCallback ¶
RequestCompletionCallback defines the type of the request callback function
type Response ¶
Response is a Graylog API response. This wraps the standard http.Response returned from Graylog.
type SearchService ¶
type SearchService interface { Absolute(context.Context, *AbsoluteSearchOptions) ([]map[string]interface{}, *Response, error) Relative(context.Context, *RelativeSearchOptions) ([]map[string]interface{}, *Response, error) }
SearchService is an interface for interfacing with the Absolute Search endpoints of the Graylog API
type SearchServiceOp ¶
type SearchServiceOp struct {
// contains filtered or unexported fields
}
SearchServiceOp handles communication with the Absolute Search related methods of the API.
func (*SearchServiceOp) Absolute ¶
func (s *SearchServiceOp) Absolute(ctx context.Context, opt *AbsoluteSearchOptions) ([]map[string]interface{}, *Response, error)
Absolute does an absolute search of messages.
func (*SearchServiceOp) Relative ¶
func (s *SearchServiceOp) Relative(ctx context.Context, opt *RelativeSearchOptions) ([]map[string]interface{}, *Response, error)
Relative does a relative search of messages.
type Token ¶
type Token struct { Name string `json:"name"` Token string `json:"token"` LastAccess time.Time `json:"last_access"` }
Token returned by API
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Email string `json:"email"` FullName string `json:"full_name"` Permissions []string `json:"permissions"` Preferences struct { UpdateUnfocussed bool `json:"updateUnfocussed"` EnableSmartSearch bool `json:"enableSmartSearch"` } `json:"preferences"` Timezone string `json:"timezone"` SessionTimeoutMs int `json:"session_timeout_ms"` External bool `json:"external"` Startpage interface{} `json:"startpage"` Roles []string `json:"roles"` ReadOnly bool `json:"read_only"` SessionActive bool `json:"session_active"` LastActivity string `json:"last_activity"` ClientAddress string `json:"client_address"` }
User object returned from API
type UserService ¶
type UserService interface { List(context.Context) ([]User, *Response, error) Get(context.Context, string) (User, *Response, error) }
UserService is an interface for interfacing with the Users endpoints of the Graylog API
type UserServiceOp ¶
type UserServiceOp struct {
// contains filtered or unexported fields
}
UserServiceOp handles communication with the User related methods of the API.
type UserTokenService ¶
type UserTokenService interface { List(context.Context, string) ([]Token, *Response, error) Create(context.Context, string, string) (Token, *Response, error) Delete(context.Context, string, Token) (*Response, error) }
UserTokenService is an interface for interfacing with the User Tokens endpoints of the Graylog API
type UserTokenServiceOp ¶
type UserTokenServiceOp struct {
// contains filtered or unexported fields
}
UserTokenServiceOp handles communication with the User Token related methods of the API.
func (*UserTokenServiceOp) Create ¶
func (s *UserTokenServiceOp) Create(ctx context.Context, user, tokenName string) (Token, *Response, error)
Create a new user token.