Documentation ¶
Index ¶
- Constants
- type Client
- type ClusterInfo
- type CommunicationHost
- type ConnectionInfo
- type EventData
- type EventDataAttachRules
- type MockDynatraceClient
- func (o *MockDynatraceClient) GetAgentVersionForIP(ip string) (string, error)
- func (o *MockDynatraceClient) GetClusterInfo() (*ClusterInfo, error)
- func (o *MockDynatraceClient) GetCommunicationHostForClient() (CommunicationHost, error)
- func (o *MockDynatraceClient) GetConnectionInfo() (ConnectionInfo, error)
- func (o *MockDynatraceClient) GetEntityIDForIP(ip string) (string, error)
- func (o *MockDynatraceClient) GetLatestAgentVersion(os, installerType string) (string, error)
- func (o *MockDynatraceClient) GetTokenScopes(token string) (TokenScopes, error)
- func (o *MockDynatraceClient) SendEvent(event *EventData) error
- type Option
- type ServerError
- type TokenScopes
Constants ¶
const ( OsWindows = "windows" OsUnix = "unix" OsAix = "aix" OsSolaris = "solaris" )
Known OS values.
const ( InstallerTypeDefault = "default" InstallerTypeUnattended = "default-unattended" InstallerTypePaasZip = "paas" InstallerTypePaasSh = "paas-sh" )
Known installer types.
const ( TokenScopeInstallerDownload = "InstallerDownload" TokenScopeDataExport = "DataExport" )
Known token scopes
const (
MarkedForTerminationEvent = "MARKED_FOR_TERMINATION"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetLatestAgentVersion gets the latest agent version for the given OS and installer type. // Returns the version as received from the server on success. // // Returns an error for the following conditions: // - os or installerType is empty // - IO error or unexpected response // - error response from the server (e.g. authentication failure) // - the agent version is not set or empty GetLatestAgentVersion(os, installerType string) (string, error) // GetAgentVersionForIP returns the agent version running on the host with the given IP address. // Returns the version string formatted as "Major.Minor.Revision.Timestamp" on success. // // Returns an error for the following conditions: // - the IP is empty // - IO error or unexpected response // - error response from the server (e.g. authentication failure) // - a host with the given IP cannot be found // - the agent version for the host is not set // // The list of all hosts with their IP addresses is cached the first time this method is called. Use a new // client instance to fetch a new list from the server. GetAgentVersionForIP(ip string) (string, error) // GetCommunicationHosts returns, on success, the list of communication hosts used for available // communication endpoints that the Dynatrace OneAgent can use to connect to. // // Returns an error if there was also an error response from the server. GetConnectionInfo() (ConnectionInfo, error) // GetCommunicationHostForClient returns a CommunicationHost for the client's API URL. Or error, if failed to be parsed. GetCommunicationHostForClient() (CommunicationHost, error) // SendEvent posts events to dynatrace API SendEvent(eventData *EventData) error // GetEntityIDForIP returns the entity id for a given IP address. // // Returns an error in case the lookup failed. GetEntityIDForIP(ip string) (string, error) // GetTokenScopes returns the list of scopes assigned to a token if successful. GetTokenScopes(token string) (TokenScopes, error) // GetClusterInfo returns the following information about the cluster: // * Version GetClusterInfo() (*ClusterInfo, error) }
Client is the interface for the Dynatrace REST API client.
func NewClient ¶
NewClient creates a REST client for the given API base URL and authentication tokens. Returns an error if a token or the URL is empty.
The API base URL is different for managed and SaaS environments:
- SaaS: https://{environment-id}.live.dynatrace.com/api
- Managed: https://{domain}/e/{environment-id}/api
opts can be used to customize the created client, entries must not be nil.
type ClusterInfo ¶
type ClusterInfo struct {
Version string `json:"version"`
}
type CommunicationHost ¶
CommunicationHost => struct of connection endpoint
type ConnectionInfo ¶
type ConnectionInfo struct { CommunicationHosts []CommunicationHost TenantUUID string }
ConnectionInfo => struct of TenantUUID and CommunicationHosts
type EventData ¶
type EventData struct { EventType string `json:"eventType"` StartInMillis uint64 `json:"start"` EndInMillis uint64 `json:"end"` Description string `json:"description"` AttachRules EventDataAttachRules `json:"attachRules"` Source string `json:"source"` }
EventData struct which defines what event payload should contain
type EventDataAttachRules ¶
type EventDataAttachRules struct {
EntityIDs []string `json:"entityIds"`
}
type MockDynatraceClient ¶
MockDynatraceClient implements a Dynatrace REST API Client mock
func (*MockDynatraceClient) GetAgentVersionForIP ¶
func (o *MockDynatraceClient) GetAgentVersionForIP(ip string) (string, error)
func (*MockDynatraceClient) GetClusterInfo ¶
func (o *MockDynatraceClient) GetClusterInfo() (*ClusterInfo, error)
func (*MockDynatraceClient) GetCommunicationHostForClient ¶
func (o *MockDynatraceClient) GetCommunicationHostForClient() (CommunicationHost, error)
func (*MockDynatraceClient) GetConnectionInfo ¶
func (o *MockDynatraceClient) GetConnectionInfo() (ConnectionInfo, error)
func (*MockDynatraceClient) GetEntityIDForIP ¶
func (o *MockDynatraceClient) GetEntityIDForIP(ip string) (string, error)
func (*MockDynatraceClient) GetLatestAgentVersion ¶
func (o *MockDynatraceClient) GetLatestAgentVersion(os, installerType string) (string, error)
func (*MockDynatraceClient) GetTokenScopes ¶
func (o *MockDynatraceClient) GetTokenScopes(token string) (TokenScopes, error)
func (*MockDynatraceClient) SendEvent ¶
func (o *MockDynatraceClient) SendEvent(event *EventData) error
type Option ¶
type Option func(*dynatraceClient)
Option can be passed to NewClient and customizes the created client instance.
func NetworkZone ¶
func SkipCertificateValidation ¶
SkipCertificateValidation creates an Option that specifies whether validation of the server's TLS certificate should be skipped. The default is false.
type ServerError ¶
ServerError represents an error returned from the server (e.g. authentication failure).
func (ServerError) Error ¶
func (e ServerError) Error() string
Error formats the server error code and message.
type TokenScopes ¶
type TokenScopes []string
TokenScopes is a list of scopes assigned to a token
func (TokenScopes) Contains ¶
func (s TokenScopes) Contains(scope string) bool
Contains returns true if scope is included on the scopes, or false otherwise.