dynatrace_client

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OsWindows = "windows"
	OsUnix    = "unix"
	OsAix     = "aix"
	OsSolaris = "solaris"
)

Known OS values.

View Source
const (
	InstallerTypeDefault    = "default"
	InstallerTypeUnattended = "default-unattended"
	InstallerTypePaasZip    = "paas"
	InstallerTypePaasSh     = "paas-sh"
)

Known installer types.

View Source
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)

	// GetVersionForIp 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.
	GetCommunicationHosts() ([]CommunicationHost, 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)
}

Client is the interface for the Dynatrace REST API client.

func NewClient

func NewClient(url, apiToken, paasToken string, opts ...Option) (Client, error)

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 CommunicationHost added in v0.4.0

type CommunicationHost struct {
	Protocol string
	Host     string
	Port     uint32
}

CommunicationHost => struct of connection endpoint

type EventData added in v0.5.0

type EventData struct {
	EventType     string               `json:"eventType"`
	StartInMillis uint64               `json:"start"`
	Description   string               `json:"description"`
	AttachRules   EventDataAttachRules `json:"attachRules"`
	Source        string               `json:"source"`
}

EventData struct which defines what event payload should contain

type EventDataAttachRules added in v0.5.0

type EventDataAttachRules struct {
	EntityIDs []string `json:"entityIds"`
}

type MockDynatraceClient added in v0.5.0

type MockDynatraceClient struct {
	mock.Mock
}

MockDynatraceClient implements a Dynatrace REST API Client mock

func (*MockDynatraceClient) GetAgentVersionForIP added in v0.5.0

func (o *MockDynatraceClient) GetAgentVersionForIP(ip string) (string, error)

func (*MockDynatraceClient) GetCommunicationHostForClient added in v0.5.0

func (o *MockDynatraceClient) GetCommunicationHostForClient() (CommunicationHost, error)

func (*MockDynatraceClient) GetCommunicationHosts added in v0.5.0

func (o *MockDynatraceClient) GetCommunicationHosts() ([]CommunicationHost, error)

func (*MockDynatraceClient) GetEntityIDForIP added in v0.5.0

func (o *MockDynatraceClient) GetEntityIDForIP(ip string) (string, error)

func (*MockDynatraceClient) GetLatestAgentVersion added in v0.5.0

func (o *MockDynatraceClient) GetLatestAgentVersion(os, installerType string) (string, error)

func (*MockDynatraceClient) SendEvent added in v0.5.0

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 SkipCertificateValidation

func SkipCertificateValidation(skip bool) Option

SkipCertificateValidation creates an Option that specifies whether validation of the server's TLS certificate should be skipped. The default is false.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL