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 AgentPolicyUpdateRequest
- 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) Close() error
- func (client *Client) CreateEnrollmentAPIKey(ctx context.Context, request CreateEnrollmentAPIKeyRequest) (r CreateEnrollmentAPIKeyResponse, err 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) UnEnrollAgent(ctx context.Context, request UnEnrollAgentRequest) (r UnEnrollAgentResponse, err 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 FleetServerHost
- 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 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"` } `json:"local_metadata"` PolicyID string `json:"policy_id"` PolicyRevision int `json:"policy_revision"` }
AgentCommon represents common agent data used across APIs
type AgentExisting ¶ added in v0.3.9
type AgentExisting struct { ID string `json:"id"` AgentCommon `json:",inline"` }
AgentExisting is the data structure for an existing agent
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"` 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"` IsProtected bool `json:"is_protected"` }
AgentPolicy is the JSON that represents a agent policy. These fields are used by both the create policy request, and the GET request for an agent policy. see: https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml and https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml
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"` 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"` 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. See https://github.com/elastic/kibana/blob/v8.9.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml
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) 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) 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)
GetFleetServerHost returns data on a fleet server
func (*Client) GetPolicyUninstallTokens ¶ added in v0.3.10
func (client *Client) GetPolicyUninstallTokens(ctx context.Context, policyID string) (r UninstallTokenResponse, err error)
GetPolicyUninstallTokens Retrieves the 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. Right now we don't have an API to tell us if we're running against serverless or not, so this actual implementation is something of a hack. see https://github.com/elastic/kibana/pull/164850
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) 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) 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 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 }
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 CreateEnrollmentAPIKeyRequest struct { Name string `json:"name"` PolicyID string `json:"policy_id"` }
CreateEnrollmentAPIKeyRequest is the JSON object for requesting an enrollment API key
type CreateEnrollmentAPIKeyResponse ¶ added in v0.3.8
type CreateEnrollmentAPIKeyResponse struct { Active bool `json:"active"` APIKey string `json:"api_key"` APIKeyID string `json:"api_key_id"` ID string `json:"id"` Name string `json:"name"` PolicyID string `json:"policy_id"` }
CreateEnrollmentAPIKeyResponse is the JSON response the an enrollment key request
type DeletePackagePolicyResponse ¶ added in v0.3.10
type DeletePackagePolicyResponse struct {
ID string `json:"id"`
}
https://www.elastic.co/guide/en/fleet/8.8/fleet-apis.html#delete_package_policy_200_response
type FleetServerHost ¶ added in v0.3.9
type FleetServerHost struct { ID string `json:"id"` Name string `json:"name"` IsDefault bool `json:"is_default"` HostURLs []string `json:"host_urls"` IsPreconfigured bool `json:"is_preconfigured"` }
FleetServerHost handles JSON data for fleet server info
type GetAgentRequest ¶ added in v0.3.9
type GetAgentRequest struct {
ID string
}
GetAgentRequest contains the ID used for fetching agent data
type GetAgentResponse ¶ added in v0.3.9
type GetAgentResponse AgentExisting
GetAgentResponse is the JSON response for GetAgent
type GetFleetServerHostRequest ¶ added in v0.3.9
type GetFleetServerHostRequest struct {
ID string
}
GetFleetServerHostRequest is the ID for a request via GetFleetServerHost
type GetFleetServerHostResponse ¶ added in v0.3.9
type GetFleetServerHostResponse FleetServerHost
GetFleetServerHostResponse is the JSON respose from GetFleetServerHost
type ListAgentsRequest ¶ added in v0.3.8
type ListAgentsRequest struct { }
ListAgentsRequest is currently unused
type ListAgentsResponse ¶ added in v0.3.8
type ListAgentsResponse struct {
Items []AgentExisting `json:"items"`
}
ListAgentsResponse is a list of agents returned by the API
type ListFleetServerHostsRequest ¶ added in v0.3.9
type ListFleetServerHostsRequest struct { }
ListFleetServerHostsRequest is currently unused
type ListFleetServerHostsResponse ¶ added in v0.3.9
type ListFleetServerHostsResponse struct {
Items []FleetServerHost `json:"items"`
}
ListFleetServerHostsResponse is the JSON response for ListFleetServerHosts
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"` }
https://www.elastic.co/guide/en/fleet/8.8/fleet-apis.html#package_policy
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"` }
https://www.elastic.co/guide/en/fleet/8.8/fleet-apis.html#createPackagePolicy request https://www.elastic.co/guide/en/fleet/8.8/fleet-apis.html#package_policy_request
type PackagePolicyRequestPackage ¶ added in v0.3.10
type PackagePolicyResponse ¶ added in v0.3.10
type PackagePolicyResponse struct {
Item PackagePolicy `json:"item"`
}
https://www.elastic.co/guide/en/fleet/8.8/fleet-apis.html#create_package_policy_200_response
type ParseHint ¶
func WithDefaultScheme ¶
type PolicyResponse ¶ added in v0.3.9
type PolicyResponse struct { AgentPolicy `json:",inline"` UpdatedOn time.Time `json:"updated_on"` UpdatedBy string `json:"updated_by"` Revision int `json:"revision"` IsProtected bool `json:"is_protected"` PackagePolicies []map[string]interface{} `json:"package_policies"` }
PolicyResponse is the response JSON from a policy request This is returned on a GET request for a policy, and on a policy create request See https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml
type UnEnrollAgentRequest ¶ added in v0.3.8
type UnEnrollAgentRequest struct { ID string `json:"-"` // ID is not part of the request body send to the Fleet API Revoke bool `json:"revoke"` }
UnEnrollAgentRequest is the JSON request for unenrolling an agent
type UnEnrollAgentResponse ¶ added in v0.3.8
type UnEnrollAgentResponse struct { }
UnEnrollAgentResponse is currently unused
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"` }
UninstallTokenResponse uninstall tokens response with resolved token values
type UpgradeAgentRequest ¶ added in v0.3.8
type UpgradeAgentRequest struct { ID string `json:"-"` // ID is not part of the request body send to the Fleet API Version string `json:"version"` }
UpgradeAgentRequest is the JSON request for an agent upgrade
type UpgradeAgentResponse ¶ added in v0.3.8
type UpgradeAgentResponse struct { }
UpgradeAgentResponse is currently unused