Documentation
¶
Index ¶
- Variables
- func EncodeURLParams(url string, params url.Values) string
- func MakeURL(defaultScheme string, defaultPath string, rawURL string, defaultPort int) (string, error)
- func ParseURL(raw string, hints ...ParseHint) (*url.URL, error)
- type AgentCommon
- type AgentExisting
- type AgentPolicy
- type AgentPolicyReassignRequest
- type AgentPolicyUpdateRequest
- type AgentPrivilegeLevelChangeRequest
- type AgentUpgradeDetails
- type Client
- func NewClientWithConfig(config *ClientConfig, binaryName, version, commit, buildtime string) (*Client, error)
- func NewClientWithConfigDefault(config *ClientConfig, defaultPort int, ...) (*Client, error)
- func NewKibanaClient(cfg *config.C, binaryName, version, commit, buildtime string) (*Client, error)
- func (client *Client) AgentPrivilegeLevelChange(ctx context.Context, agentID string, request AgentPrivilegeLevelChangeRequest) error
- func (client *Client) Close() error
- func (client *Client) CreateDownloadSource(ctx context.Context, source DownloadSource) (DownloadSourceResponse, error)
- func (client *Client) CreateEnrollmentAPIKey(ctx context.Context, request CreateEnrollmentAPIKeyRequest) (r CreateEnrollmentAPIKeyResponse, err error)
- func (client *Client) CreateFleetProxy(ctx context.Context, req ProxiesRequest) (ProxiesResponse, error)
- func (client *Client) CreateFleetServerHosts(ctx context.Context, req ListFleetServerHostsRequest) (FleetServerHostsResponse, error)
- func (client *Client) CreatePolicy(ctx context.Context, request AgentPolicy) (r PolicyResponse, err error)
- func (client *Client) DeleteFleetPackage(ctx context.Context, packagePolicyID string) (r DeletePackagePolicyResponse, err error)
- func (client *Client) DeletePolicy(ctx context.Context, id string) error
- func (client *Client) GetAgent(ctx context.Context, request GetAgentRequest) (r GetAgentResponse, err error)
- func (client *Client) GetFleetServerHost(ctx context.Context, request GetFleetServerHostRequest) (r GetFleetServerHostResponse, err error)
- func (client *Client) GetPolicy(ctx context.Context, id string) (r PolicyResponse, err error)
- func (client *Client) GetPolicyUninstallTokens(ctx context.Context, policyID string) (r UninstallTokenResponse, err error)
- func (client *Client) GetUninstallToken(ctx context.Context, tokenID string) (r UninstallTokenItem, err error)
- func (client *Client) GetVersion() version.V
- func (client *Client) ImportMultiPartFormFile(url string, params url.Values, filename string, contents string) error
- func (client *Client) InstallFleetPackage(ctx context.Context, req PackagePolicyRequest) (r PackagePolicyResponse, err error)
- func (client *Client) KibanaIsServerless() (bool, error)
- func (client *Client) ListAgents(ctx context.Context, _ ListAgentsRequest) (r ListAgentsResponse, err error)
- func (client *Client) ListFleetServerHosts(ctx context.Context, _ ListFleetServerHostsRequest) (r ListFleetServerHostsResponse, err error)
- func (client *Client) ReassignAgentToPolicy(ctx context.Context, agentID string, request AgentPolicyReassignRequest) error
- func (client *Client) RollbackAgent(ctx context.Context, request RollbackAgentRequest) (r RollbackAgentResponse, err error)
- func (client *Client) UnEnrollAgent(ctx context.Context, request UnEnrollAgentRequest) (r UnEnrollAgentResponse, err error)
- func (client *Client) UpdateDownloadSource(ctx context.Context, id string, source DownloadSource) (DownloadSourceResponse, error)
- func (client *Client) UpdatePolicy(ctx context.Context, id string, request AgentPolicyUpdateRequest) (r PolicyResponse, err error)
- func (client *Client) UpgradeAgent(ctx context.Context, request UpgradeAgentRequest) (r UpgradeAgentResponse, err error)
- type ClientConfig
- type Connection
- func (conn *Connection) Request(method, extraPath string, params url.Values, headers http.Header, ...) (int, []byte, error)
- func (conn *Connection) RoundTrip(r *http.Request) (*http.Response, error)
- func (conn *Connection) Send(method, extraPath string, params url.Values, headers http.Header, ...) (*http.Response, error)
- func (conn *Connection) SendWithContext(ctx context.Context, method, extraPath string, params url.Values, ...) (*http.Response, error)
- type CreateEnrollmentAPIKeyRequest
- type CreateEnrollmentAPIKeyResponse
- type DeletePackagePolicyResponse
- type DownloadSource
- type DownloadSourceAuth
- type DownloadSourceResponse
- type FleetServerHost
- type FleetServerHostsResponse
- type GetAgentRequest
- type GetAgentResponse
- type GetFleetServerHostRequest
- type GetFleetServerHostResponse
- type ListAgentsRequest
- type ListAgentsResponse
- type ListFleetServerHostsRequest
- type ListFleetServerHostsResponse
- type MonitoringEnabledOption
- type PackagePolicy
- type PackagePolicyRequest
- type PackagePolicyRequestPackage
- type PackagePolicyResponse
- type ParseHint
- type PolicyResponse
- type ProxiesRequest
- type ProxiesResponse
- type RetryConfig
- type RollbackAgentRequest
- type RollbackAgentResponse
- type UnEnrollAgentRequest
- type UnEnrollAgentResponse
- type UninstallTokenItem
- type UninstallTokenResponse
- type UpgradeAgentRequest
- type UpgradeAgentResponse
Constants ¶
This section is empty.
Variables ¶
var ( TRUE *bool = &bt FALSE *bool = &bf )
Constant booleans for convenience for dealing with *bool
Functions ¶
Types ¶
type AgentCommon ¶ added in v0.3.9
type AgentCommon struct {
Active bool `json:"active"`
Status string `json:"status"`
Agent struct {
ID string `json:"id"`
Version string `json:"version"`
} `json:"agent"`
LocalMetadata struct {
Host struct {
Hostname string `json:"hostname"`
} `json:"host"`
Elastic struct {
Agent struct {
FIPS bool `json:"fips"`
} `json:"agent"`
} `json:"elastic"`
} `json:"local_metadata"`
PolicyID string `json:"policy_id"`
PolicyRevision int `json:"policy_revision"`
UpgradeDetails *AgentUpgradeDetails `json:"upgrade_details"`
}
AgentCommon represents common agent data used across Agent APIs
type AgentExisting ¶ added in v0.3.9
type AgentExisting struct {
ID string `json:"id"`
AgentCommon `json:",inline"`
}
type AgentPolicy ¶ added in v0.3.9
type AgentPolicy struct {
ID string `json:"id,omitempty"`
// Name of the policy. Required to create a policy.
Name string `json:"name"`
// Namespace of the policy. Required to create a policy.
Namespace string `json:"namespace"`
AdvancedSettings map[string]interface{} `json:"advanced_settings,omitempty"`
Description string `json:"description,omitempty"`
MonitoringEnabled []MonitoringEnabledOption `json:"monitoring_enabled,omitempty"`
DataOutputID string `json:"data_output_id,omitempty"`
MonitoringOutputID string `json:"monitoring_output_id,omitempty"`
FleetServerHostID string `json:"fleet_server_host_id,omitempty"`
DownloadSourceID string `json:"download_source_id,omitempty"`
UnenrollTimeout int `json:"unenroll_timeout,omitempty"`
InactivityTImeout int `json:"inactivity_timeout,omitempty"`
AgentFeatures []map[string]interface{} `json:"agent_features,omitempty"`
Overrides map[string]interface{} `json:"overrides,omitempty"`
IsProtected bool `json:"is_protected"`
}
type AgentPolicyReassignRequest ¶ added in v0.30.0
type AgentPolicyReassignRequest struct {
PolicyID string `json:"policy_id"`
}
type AgentPolicyUpdateRequest ¶ added in v0.3.9
type AgentPolicyUpdateRequest struct {
// Name of the policy. Required in an update request.
Name string `json:"name"`
// Namespace of the policy. Required in an update request.
Namespace string `json:"namespace"`
AdvancedSettings map[string]interface{} `json:"advanced_settings,omitempty"`
Description string `json:"description,omitempty"`
MonitoringEnabled []MonitoringEnabledOption `json:"monitoring_enabled,omitempty"`
DataOutputID string `json:"data_output_id,omitempty"`
MonitoringOutputID string `json:"monitoring_output_id,omitempty"`
FleetServerHostID string `json:"fleet_server_host_id,omitempty"`
DownloadSourceID string `json:"download_source_id,omitempty"`
UnenrollTimeout int `json:"unenroll_timeout,omitempty"`
InactivityTImeout int `json:"inactivity_timeout,omitempty"`
AgentFeatures []map[string]interface{} `json:"agent_features,omitempty"`
Overrides map[string]interface{} `json:"overrides,omitempty"`
IsProtected *bool `json:"is_protected,omitempty"` // Optional bool for compatibility with the older pre 8.9.0 stack
}
AgentPolicyUpdateRequest is the JSON object for requesting an updated policy Unlike the Agent create and response structures, the update request does not contain an ID field.
type AgentPrivilegeLevelChangeRequest ¶ added in v0.32.0
type AgentPrivilegeLevelChangeRequest struct {
UserInfo *struct {
Groupname string `json:"groupname"`
Password string `json:"password"`
Username string `json:"username"`
} `json:"user_info"`
}
AgentPrivilegeLevelChangeRequest is the JSON object for requesting an agent privilege level change
type AgentUpgradeDetails ¶ added in v0.6.3
type AgentUpgradeDetails struct {
TargetVersion string `json:"target_version"`
State string `json:"state"`
ActionID string `json:"action_id"`
Metadata struct {
ScheduledAt *time.Time `json:"scheduled_at"`
DownloadPercent float64 `json:"download_percent"`
DownloadRate details.DownloadRate `json:"download_rate"`
FailedState string `json:"failed_state"`
ErrorMsg string `json:"error_msg"`
Reason string `json:"reason"`
} `json:"metadata"`
}
type Client ¶
type Client struct {
Connection
// contains filtered or unexported fields
}
func NewClientWithConfig ¶
func NewClientWithConfig(config *ClientConfig, binaryName, version, commit, buildtime string) (*Client, error)
NewClientWithConfig creates and returns a kibana client using the given config
func NewClientWithConfigDefault ¶
func NewClientWithConfigDefault(config *ClientConfig, defaultPort int, binaryName, version, commit, buildtime string) (*Client, error)
NewClientWithConfigDefault creates and returns a kibana client using the given config
func NewKibanaClient ¶
NewKibanaClient builds and returns a new Kibana client
func (*Client) AgentPrivilegeLevelChange ¶ added in v0.32.0
func (client *Client) AgentPrivilegeLevelChange(ctx context.Context, agentID string, request AgentPrivilegeLevelChangeRequest) error
AgentPrivilegeLevelChange changes the privilege level of the given agent
func (*Client) CreateDownloadSource ¶ added in v0.6.3
func (client *Client) CreateDownloadSource(ctx context.Context, source DownloadSource) (DownloadSourceResponse, error)
func (*Client) CreateEnrollmentAPIKey ¶ added in v0.3.8
func (client *Client) CreateEnrollmentAPIKey(ctx context.Context, request CreateEnrollmentAPIKeyRequest) (r CreateEnrollmentAPIKeyResponse, err error)
CreateEnrollmentAPIKey creates an enrollment API key
func (*Client) CreateFleetProxy ¶ added in v0.17.0
func (client *Client) CreateFleetProxy(ctx context.Context, req ProxiesRequest) (ProxiesResponse, error)
CreateFleetProxy creates a new proxy
func (*Client) CreateFleetServerHosts ¶ added in v0.17.0
func (client *Client) CreateFleetServerHosts(ctx context.Context, req ListFleetServerHostsRequest) (FleetServerHostsResponse, error)
CreateFleetServerHosts creates a new Fleet Server host
func (*Client) CreatePolicy ¶ added in v0.3.8
func (client *Client) CreatePolicy(ctx context.Context, request AgentPolicy) (r PolicyResponse, err error)
CreatePolicy creates a new agent policy with the given config
func (*Client) DeleteFleetPackage ¶ added in v0.3.10
func (client *Client) DeleteFleetPackage(ctx context.Context, packagePolicyID string) (r DeletePackagePolicyResponse, err error)
DeleteFleetPackage deletes integration with packagePolicyID from the policy ID
func (*Client) DeletePolicy ¶ added in v0.3.9
DeletePolicy deletes the policy with the given ID
func (*Client) GetAgent ¶ added in v0.3.9
func (client *Client) GetAgent(ctx context.Context, request GetAgentRequest) (r GetAgentResponse, err error)
GetAgent fetches data for an agent
func (*Client) GetFleetServerHost ¶ added in v0.3.9
func (client *Client) GetFleetServerHost(ctx context.Context, request GetFleetServerHostRequest) (r GetFleetServerHostResponse, err error)
func (*Client) GetPolicyUninstallTokens ¶ added in v0.3.10
func (client *Client) GetPolicyUninstallTokens(ctx context.Context, policyID string) (r UninstallTokenResponse, err error)
GetPolicyUninstallTokens Retrieves the policy uninstall tokens
func (*Client) GetUninstallToken ¶ added in v0.3.10
func (client *Client) GetUninstallToken(ctx context.Context, tokenID string) (r UninstallTokenItem, err error)
GetUninstallToken return uninstall token value for the given token ID
func (*Client) GetVersion ¶
GetVersion returns the version read from kibana. The version is not set if IgnoreVersion was set when creating the client.
func (*Client) ImportMultiPartFormFile ¶
func (*Client) InstallFleetPackage ¶ added in v0.3.10
func (client *Client) InstallFleetPackage(ctx context.Context, req PackagePolicyRequest) (r PackagePolicyResponse, err error)
InstallFleetPackage uses the Fleet package policies API install an integration package as specified in the request. Note that the package policy ID and Name must be globally unique across all installed packages.
func (*Client) KibanaIsServerless ¶ added in v0.4.0
KibanaIsServerless returns true if we're talking to a serverless instance.
func (*Client) ListAgents ¶ added in v0.3.8
func (client *Client) ListAgents(ctx context.Context, _ ListAgentsRequest) (r ListAgentsResponse, err error)
ListAgents returns a list of agents known to Kibana
func (*Client) ListFleetServerHosts ¶ added in v0.3.9
func (client *Client) ListFleetServerHosts(ctx context.Context, _ ListFleetServerHostsRequest) (r ListFleetServerHostsResponse, err error)
ListFleetServerHosts returns a list of fleet server hosts
func (*Client) ReassignAgentToPolicy ¶ added in v0.30.0
func (client *Client) ReassignAgentToPolicy(ctx context.Context, agentID string, request AgentPolicyReassignRequest) error
ReassignAgentToPolicy reassigns the given agent to the policy ID specified in the request
func (*Client) RollbackAgent ¶ added in v0.35.0
func (client *Client) RollbackAgent(ctx context.Context, request RollbackAgentRequest) (r RollbackAgentResponse, err error)
RollbackAgent rolls back the requested agent
func (*Client) UnEnrollAgent ¶ added in v0.3.8
func (client *Client) UnEnrollAgent(ctx context.Context, request UnEnrollAgentRequest) (r UnEnrollAgentResponse, err error)
UnEnrollAgent removes the agent from fleet
func (*Client) UpdateDownloadSource ¶ added in v0.27.0
func (client *Client) UpdateDownloadSource(ctx context.Context, id string, source DownloadSource) (DownloadSourceResponse, error)
func (*Client) UpdatePolicy ¶ added in v0.3.9
func (client *Client) UpdatePolicy(ctx context.Context, id string, request AgentPolicyUpdateRequest) (r PolicyResponse, err error)
UpdatePolicy updates an existing agent policy.
func (*Client) UpgradeAgent ¶ added in v0.3.8
func (client *Client) UpgradeAgent(ctx context.Context, request UpgradeAgentRequest) (r UpgradeAgentResponse, err error)
UpgradeAgent upgrades the requested agent
type ClientConfig ¶
type ClientConfig struct {
Protocol string `config:"protocol" yaml:"protocol,omitempty"`
Host string `config:"host" yaml:"host,omitempty"`
Path string `config:"path" yaml:"path,omitempty"`
SpaceID string `config:"space.id" yaml:"space.id,omitempty"`
Username string `config:"username" yaml:"username,omitempty"`
Password string `config:"password" yaml:"password,omitempty"`
APIKey string `config:"api_key" yaml:"api_key,omitempty"`
ServiceToken string `config:"service_token" yaml:"service_token,omitempty"`
// Headers holds headers to include in every request sent to Kibana.
Headers map[string]string `config:"headers" yaml:"headers,omitempty"`
IgnoreVersion bool
Retry RetryConfig `config:"retry" yaml:"retry,omitempty"`
Transport httpcommon.HTTPTransportSettings `config:",inline" yaml:",inline"`
}
ClientConfig to connect to Kibana
func DefaultClientConfig ¶
func DefaultClientConfig() ClientConfig
DefaultClientConfig connects to a locally running kibana over HTTP
func (*ClientConfig) Validate ¶
func (c *ClientConfig) Validate() error
type Connection ¶
type Connection struct {
URL string
Username string
Password string
APIKey string
ServiceToken string
Headers http.Header
HTTP *http.Client
Version version.V
Retry RetryConfig
}
func (*Connection) Send ¶
func (conn *Connection) Send(method, extraPath string, params url.Values, headers http.Header, body io.Reader) (*http.Response, error)
Send an application/json request to Kibana with appropriate kbn headers
func (*Connection) SendWithContext ¶
func (conn *Connection) SendWithContext(ctx context.Context, method, extraPath string, params url.Values, headers http.Header, body io.Reader) (*http.Response, error)
SendWithContext sends an application/json request to Kibana with appropriate kbn headers and the given context.
type CreateEnrollmentAPIKeyRequest ¶ added in v0.3.8
type CreateEnrollmentAPIKeyResponse ¶ added in v0.3.8
type DeletePackagePolicyResponse ¶ added in v0.3.10
type DeletePackagePolicyResponse struct {
ID string `json:"id"`
}
type DownloadSource ¶ added in v0.6.3
type DownloadSource struct {
Name string `json:"name"`
Host string `json:"host"`
IsDefault bool `json:"is_default"`
ProxyID interface{} `json:"proxy_id"`
Auth *DownloadSourceAuth `json:"auth,omitempty"`
}
type DownloadSourceAuth ¶ added in v0.33.2
type DownloadSourceResponse ¶ added in v0.7.1
type FleetServerHost ¶ added in v0.3.9
type FleetServerHostsResponse ¶ added in v0.17.0
type FleetServerHostsResponse struct {
Item struct {
ID string `json:"id"`
HostUrls []string `json:"host_urls"`
IsDefault bool `json:"is_default"`
IsInternal bool `json:"is_internal"`
IsPreconfigured bool `json:"is_preconfigured"`
Name string `json:"name"`
ProxyID string `json:"proxy_id"`
} `json:"item"`
}
type GetAgentRequest ¶ added in v0.3.9
type GetAgentRequest struct {
ID string
}
type GetAgentResponse ¶ added in v0.3.9
type GetAgentResponse AgentExisting
type GetFleetServerHostRequest ¶ added in v0.3.9
type GetFleetServerHostRequest struct {
ID string
}
type GetFleetServerHostResponse ¶ added in v0.3.9
type GetFleetServerHostResponse FleetServerHost
type ListAgentsRequest ¶ added in v0.3.8
type ListAgentsRequest struct {
}
type ListAgentsResponse ¶ added in v0.3.8
type ListAgentsResponse struct {
Items []AgentExisting `json:"items"`
}
type ListFleetServerHostsRequest ¶ added in v0.3.9
type ListFleetServerHostsResponse ¶ added in v0.3.9
type ListFleetServerHostsResponse struct {
Items []FleetServerHost `json:"items"`
}
type MonitoringEnabledOption ¶ added in v0.3.8
type MonitoringEnabledOption string
MonitoringEnabledOption is a Kibana JSON value that specifies the various monitoring option types
const ( // MonitoringEnabledLogs specifies log monitoring MonitoringEnabledLogs MonitoringEnabledOption = "logs" // MonitoringEnabledMetrics specifies metrics monitoring MonitoringEnabledMetrics MonitoringEnabledOption = "metrics" )
type PackagePolicy ¶ added in v0.3.10
type PackagePolicy struct {
ID string `json:"id,omitempty"`
Revision int `json:"revision"`
Enabled bool `json:"enabled"`
Inputs []map[string]interface{} `json:"inputs"`
Package PackagePolicyRequestPackage `json:"package"`
Namespace string `json:"namespace"`
OutputID string `json:"output_id"`
PolicyID string `json:"policy_id"`
Name string `json:"name"`
Description string `json:"description"`
}
type PackagePolicyRequest ¶ added in v0.3.10
type PackagePolicyRequest struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Namespace string `json:"namespace"`
PolicyID string `json:"policy_id"`
Package PackagePolicyRequestPackage `json:"package"`
Vars map[string]interface{} `json:"vars"`
Inputs []map[string]interface{} `json:"inputs"`
Force bool `json:"force"`
}
type PackagePolicyRequestPackage ¶ added in v0.3.10
type PackagePolicyResponse ¶ added in v0.3.10
type PackagePolicyResponse struct {
Item PackagePolicy `json:"item"`
}
type ParseHint ¶
func WithDefaultScheme ¶
type PolicyResponse ¶ added in v0.3.9
type ProxiesRequest ¶ added in v0.17.0
type ProxiesRequest struct {
Certificate string `json:"certificate"`
CertificateAuthorities string `json:"certificate_authorities"`
CertificateKey string `json:"certificate_key"`
ID string `json:"id"`
Name string `json:"name"`
ProxyHeaders map[string]string `json:"proxy_headers"`
URL string `json:"url"`
}
type ProxiesResponse ¶ added in v0.17.0
type ProxiesResponse struct {
Item struct {
Certificate string `json:"certificate"`
CertificateAuthorities string `json:"certificate_authorities"`
CertificateKey string `json:"certificate_key"`
ID string `json:"id"`
IsPreconfigured bool `json:"is_preconfigured"`
Name string `json:"name"`
ProxyHeaders map[string]string `json:"proxy_headers"`
URL string `json:"url"`
} `json:"item"`
}
type RetryConfig ¶ added in v0.39.0
type RetryConfig struct {
// MaxRetries is the maximum number of retry attempts per request. Defaults to 3.
MaxRetries int `config:"max_retries" yaml:"max_retries,omitempty"`
// RetryOnStatus is the list of HTTP status codes that trigger a retry.
// Defaults to [502, 503, 504].
RetryOnStatus []int `config:"retry_on_status" yaml:"retry_on_status,omitempty"`
// RetryOnError is called for transport errors to decide whether to retry.
// When nil, all transport errors are retried. Return true to retry.
RetryOnError func(*http.Request, error) bool `config:"-" yaml:"-"`
// RetryBackoff returns the duration to wait before the given retry attempt (1-based).
// When nil, requests are retried immediately with no delay.
RetryBackoff func(attempt int) time.Duration `config:"-" yaml:"-"`
}
RetryConfig configures retry behaviour for requests made by the Kibana client. The API mirrors the Elasticsearch Go client retry configuration.
type RollbackAgentRequest ¶ added in v0.35.0
type RollbackAgentRequest struct {
ID string `json:"-"` // ID is not part of the request body sent to the Fleet API
}
type RollbackAgentResponse ¶ added in v0.35.0
type UnEnrollAgentRequest ¶ added in v0.3.8
type UnEnrollAgentResponse ¶ added in v0.3.8
type UnEnrollAgentResponse struct {
}
type UninstallTokenItem ¶ added in v0.3.10
type UninstallTokenResponse ¶ added in v0.3.10
type UninstallTokenResponse struct {
Items []UninstallTokenItem `json:"items"`
Total int `json:"total"`
Page int `json:"page"`
PerPage int `json:"perPage"`
}
type UpgradeAgentRequest ¶ added in v0.3.8
type UpgradeAgentResponse ¶ added in v0.3.8
type UpgradeAgentResponse struct {
}