Documentation ¶
Index ¶
- func Bool(v bool) *bool
- func Float64(v float64) *float64
- func Int(v int) *int
- func Int64(v int64) *int64
- func String(v string) *string
- func TestDefaultContext() context.Context
- func WithTestMainSetup(runner TestMainRunner)
- type ACL
- type API
- type APIError
- type APIErrorMessage
- type APIParams
- type AccessControlService
- type AuthenticationService
- type Client
- type CreateUserOptions
- type DeploymentService
- type Entry
- type EntryMetadata
- type IntrospectionService
- type LoginResponse
- type PaginationFilter
- type Paging
- type PropertiesService
- type Response
- type ServerInfoEntry
- type TestMainRunner
- type Timestamp
- type UpdateUserOptions
- type UserEntry
- type UserService
- func (s *UserService) Create(opts *CreateUserOptions) (*UserEntry, *Response, error)
- func (s *UserService) Delete(user string) (*UserEntry, *Response, error)
- func (s *UserService) Update(user string, opts *UpdateUserOptions) (*UserEntry, *Response, error)
- func (s *UserService) Users() ([]UserEntry, *Response, error)
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func Float64 ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func Int64 ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.
func String ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
func TestDefaultContext ¶
TestDefaultContext returns a context set up for use in a Splunk client.
See also: APIParams.NewAPI
func WithTestMainSetup ¶
func WithTestMainSetup(runner TestMainRunner)
WithTestMainSetup provides global test setup for integration tests with Splunk.
During the life-time of a test run, a Splunk container is provided, and a client, which is configured to access the Splunk instance. Configuration details (e.g., admin user and password) can be obtained from the client.
See also: TestGlobalSplunkClient
Types ¶
type ACL ¶
type ACL struct { App string `json:"app"` CanChangePerms bool `json:"can_change_perms"` CanWrite bool `json:"can_write"` Modifiable bool `json:"modifiable"` // XXX doc mismatch Owner string `json:"owner"` Perms struct { Read []string `json:"read"` Write []string `json:"write"` } `json:"perms"` Removable bool `json:"removable"` Sharing string `json:"sharing"` }
ACL https://docs.splunk.com/Documentation/Splunk/7.2.4/RESTUM/RESTusing#Access_Control_List
type API ¶
type API struct { Introspection *IntrospectionService AccessControl *AccessControlService Properties *PropertiesService Deployment *DeploymentService // contains filtered or unexported fields }
API https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTprolog
func NewTestSplunkClient ¶
NewTestSplunkClient returns a new Splunk API client using the context provided by TestDefaultContext.
func NewTestSplunkService ¶
NewTestSplunkService spins up a new Splunk service, and returns a Splunk API configured to access it.
If the SPLUNK_ADDR environment variable is set, the tests will run against the specified Splunk. If also the SPLUNK_PASSWORD environment variable is set, this password will be used for admin access, instead of a default password ("test1234").
Example:
export SPLUNK_ADDR='https://localhost:8089' export SPLUNK_PASSWORD='SECRET'
func NewTestSplunkServiceWithTempAdmin ¶
NewTestSplunkServiceWithTempAdmin spins up a new Splunk instance, and also creates a new test admin user.
See also: NewTestSplunkService
func TestGlobalSplunkClient ¶
TestGlobalSplunkClient returns a Splunk API client that is configured to access a test Splunk instance.
If no Splunk instance has been set up via WithTestMainSetup, the calling test is skipped.
type APIError ¶
type APIError struct {
Messages []APIErrorMessage `json:"messages"`
}
The APIError type encapsulates API errors and status responses.
type APIErrorMessage ¶
type APIErrorMessage struct { Type string `json:"type"` Text string `json:"text"` Code string `json:"code"` }
The APIErrorMessage type encapsulates a single API error or status message.
type APIParams ¶
type APIParams struct { BaseURL string UserAgent string TokenTTL time.Duration // pass in an actual OAuth2 client, if supported by Splunk; if nil, use Splunk's basic auth/sessionkey token flow AuthClient *http.Client oauth2.Config }
APIParams provides the configuration for setting up a new API client with the NewClient() function.
func (*APIParams) NewAPI ¶
NewAPI creates a new instance to access the API of the configured Splunk instance.
func (*APIParams) TokenSource ¶
func (p *APIParams) TokenSource(ctx context.Context) oauth2.TokenSource
TokenSource returns a TokenSource using the configuration in params and the HTTP client from the provided context.
type AccessControlService ¶
type AccessControlService struct { Authentication *AuthenticationService // contains filtered or unexported fields }
AccessControlService encapsulates the Access Control portion of the Splunk API.
type AuthenticationService ¶
type AuthenticationService struct { Users *UserService // contains filtered or unexported fields }
AuthenticationService encapsulates the Authentication portion of the Splunk API.
func (*AuthenticationService) Login ¶
func (s *AuthenticationService) Login(username, password string) (*LoginResponse, error)
Login returns a valid session key, or an error.
type Client ¶
The Client type wraps the underlying API transport.
type CreateUserOptions ¶
type CreateUserOptions struct { CreateRole *bool `url:"createrole,omitempty"` DefaultApp string `url:"defaultApp,omitempty"` Email string `url:"email,omitempty"` ForceChangePass *bool `url:"force-change-pass,omitempty"` Name string `url:"name"` Password string `url:"password,omitempty"` Realname string `url:"realname,omitempty"` RestartBackgroundJobs *bool `url:"restart_background_jobs,omitempty"` Roles []string `url:"roles,omitempty"` TZ string `url:"tz,omitempty"` }
The CreateUserOptions type provides options for creating a new user.
type DeploymentService ¶ added in v0.2.0
type DeploymentService struct {
// contains filtered or unexported fields
}
DeploymentService encapsulates the Deployment portion of the Splunk API
func (*DeploymentService) SearchPeers ¶ added in v0.5.0
func (d *DeploymentService) SearchPeers(filter *PaginationFilter) ([]ServerInfoEntry, *Response, error)
SearchPeers returns information about all search peers
type EntryMetadata ¶
type EntryMetadata struct { ACL // XXX doc mismatch Messages []APIErrorMessage `json:"messages"` Title string `json:"title"` ID string `json:"id"` Updated time.Time `json:"updated"` Links map[string]string `json:"links"` // XXX doc mismatch Author string `json:"author"` }
EntryMetadata https://docs.splunk.com/Documentation/Splunk/latest/RESTUM/RESTusing#Response_elements
type IntrospectionService ¶
type IntrospectionService struct {
// contains filtered or unexported fields
}
IntrospectionService encapsulates the Introspection portion of the Splunk API.
func (*IntrospectionService) ServerInfo ¶
func (s *IntrospectionService) ServerInfo() ([]ServerInfoEntry, *Response, error)
ServerInfo returns information about the Splunk instance.
type LoginResponse ¶
LoginResponse is returned from Login() calls.
type PaginationFilter ¶ added in v0.5.0
type PaginationFilter struct { Count int `url:"count,omitempty"` // NOTE: we omit zero value, since this is already set in outputMode Filter []string `url:"f,omitempty"` Offset int `url:"offset,omitempty"` Search string `url:"search,omitempty"` SortDir string `url:"sort_dir,omitempty"` SortKey string `url:"sort_key,omitempty"` SortMode string `url:"sort_mode,omitempty"` Summarize bool `url:"summarize,omitempty"` }
API https://docs.splunk.com/Documentation/Splunk/8.0.2/RESTREF/RESTprolog#Request_and_response_details
var ( ServerInfoEntryFilterDefault *PaginationFilter ServerInfoEntryFilterMinimal *PaginationFilter = &PaginationFilter{ Filter: []string{"host", "host_fqdn", "server_roles"}, } )
type Paging ¶
type Paging struct { Offset int `json:"offset"` PerPage int `json:"perPage"` Total int `json:"total"` }
The Paging type encapsulates paging information provided by the API.
See also: https://docs.splunk.com/Documentation/Splunk/latest/RESTUM/RESTusing#Atom_Feed_response
type PropertiesService ¶ added in v0.1.3
type PropertiesService struct {
// contains filtered or unexported fields
}
type Response ¶
type Response struct { Title string `json:"title"` ID string `json:"id"` Updated time.Time `json:"updated"` Generator map[string]string `json:"generator"` Author string `json:"author"` Links map[string]string `json:"links"` // XXX doc mismatch Messages []APIErrorMessage `json:"messages"` Paging Paging `json:"paging"` // XXX doc mismatch Entry json.RawMessage `json:"entry"` HTTPResponse *http.Response }
Response https://docs.splunk.com/Documentation/Splunk/latest/RESTUM/RESTusing#Atom_Feed_response
type ServerInfoEntry ¶
type ServerInfoEntry struct { EntryMetadata Content struct { ActiveLicenseGroup string `json:"activeLicenseGroup"` // XXX ... Build string `json:"build"` CPUArch string `json:"cpu_arch"` GUID string `json:"guid"` Host string `json:"host"` HostFQDN string `json:"host_fqdn"` IsFree bool `json:"isFree"` IsTrial bool `json:"isTrial"` // XXX ... Roles []string `json:"server_roles"` ServerName string `json:"serverName"` StartupTime Timestamp `json:"startup_time"` Version string `json:"version"` } `json:"content"` }
ServerInfoEntry is returned from ServerInfo() calls.
BUG(mweber): this type is incomplete.
type TestMainRunner ¶
type TestMainRunner interface {
Run() (status int)
}
TestMainRunner is an interface for running Tests.
This interface is implemented by testing.M.
type Timestamp ¶
The Timestamp type is used for (un)marshalling Unix timestamps from JSON.
func (*Timestamp) MarshalJSON ¶
MarshalJSON marshals Timestamp structs to JSON.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON unmarshals Timestamp structs from JSON.
type UpdateUserOptions ¶
type UpdateUserOptions struct { DefaultApp string `url:"defaultApp,omitempty"` Email string `url:"email,omitempty"` ForceChangePass *bool `url:"force-change-pass,omitempty"` OldPassword string `url:"oldpassword,omitempty"` Password string `url:"password,omitempty"` Realname string `url:"realname,omitempty"` RestartBackgroundJobs *bool `url:"restart_background_jobs,omitempty"` Roles []string `url:"roles,omitempty"` TZ string `url:"tz,omitempty"` }
The UpdateUserOptions type provides options for updating a user.
type UserEntry ¶
type UserEntry struct { EntryMetadata Name string `json:"name"` Content struct { Capabilities []string `json:"capabilities"` DefaultApp string `json:"defaultApp"` DefaultAppIsUserOverride *bool `json:"DefaultAppIsUserOverride"` Email string `json:"email"` Password string `json:"password"` RealName string `json:"realname"` RestartBackgroundJobs *bool `json:"restart_background_jobs"` Roles []string `json:"roles"` Type string `json:"type"` TZ string `json:"tz"` } `json:"content"` }
UserEntry is returned from Users() calls.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService encapsulates the User portion of the Splunk API.
func (*UserService) Create ¶
func (s *UserService) Create(opts *CreateUserOptions) (*UserEntry, *Response, error)
Create creates a new user, and returns additional meta data.
func (*UserService) Delete ¶
func (s *UserService) Delete(user string) (*UserEntry, *Response, error)
Delete deletes a user, and returns additional meta data.
func (*UserService) Update ¶
func (s *UserService) Update(user string, opts *UpdateUserOptions) (*UserEntry, *Response, error)
Update updates a user, and returns additional meta data.
Notes ¶
Bugs ¶
this type is incomplete.