dynatrace

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DynatracePaasToken       = "paasToken"
	DynatraceApiToken        = "apiToken"
	DynatraceDataIngestToken = "dataIngestToken"
)
View Source
const (
	InstallerTypeDefault = "default"
	// Commented for linter, left for further reference
	// InstallerTypeUnattended = "default-unattended"
	InstallerTypePaaS = "paas"
)

Known installer types.

View Source
const (
	TokenScopeInstallerDownload     = "InstallerDownload"
	TokenScopeDataExport            = "DataExport"
	TokenScopeMetricsIngest         = "metrics.ingest"
	TokenScopeEntitiesRead          = "entities.read"
	TokenScopeSettingsRead          = "settings.read"
	TokenScopeSettingsWrite         = "settings.write"
	TokenScopeActiveGateTokenCreate = "activeGateTokenManagement.create"
)

Known token scopes

View Source
const (
	SettingsSchemaId      = "builtin:cloud.kubernetes"
	AppTransitionSchemaId = "builtin:app-transition.kubernetes"
)
View Source
const (
	MarkedForTerminationEvent = "MARKED_FOR_TERMINATION"
)
View Source
const (
	OsUnix = "unix"
)

Known OS values.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveGateAuthTokenInfo

type ActiveGateAuthTokenInfo struct {
	TokenId string `json:"id"`
	Token   string `json:"token"`
}

type ActiveGateAuthTokenParams

type ActiveGateAuthTokenParams struct {
	Name           string `json:"name"`
	SeedToken      bool   `json:"seedToken"`
	ActiveGateType string `json:"activeGateType"`
	ExpirationDate string `json:"expirationDate"`
}

type ActiveGateConnectionInfo

type ActiveGateConnectionInfo struct {
	ConnectionInfo
}

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)

	// GetLatestAgent returns a reader with the contents of the download. Must be closed by caller.
	GetLatestAgent(os, installerType, flavor, arch string, technologies []string, skipMetadata bool, writer io.Writer) error

	// GetAgent downloads a specific agent version and writes it to the given io.Writer
	GetAgent(os, installerType, flavor, arch, version string, technologies []string, skipMetadata bool, writer io.Writer) error

	// GetAgentViaInstallerUrl downloads the agent from the user specified URL and writes it to the given io.Writer
	GetAgentViaInstallerUrl(url string, writer io.Writer) error

	// GetAgentVersions on success returns an array of versions that can be used with GetAgent to
	// download a specific agent version
	GetAgentVersions(os, installerType, flavor, arch string) ([]string, error)

	GetOneAgentConnectionInfo() (OneAgentConnectionInfo, error)

	GetProcessModuleConfig(prevRevision uint) (*ProcessModuleConfig, 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)

	// GetActiveGateConnectionInfo returns AgentTenantInfo for ActiveGate that holds UUID, Tenant Token and Endpoints
	GetActiveGateConnectionInfo() (ActiveGateConnectionInfo, error)

	// CreateOrUpdateKubernetesSetting returns the object id of the created k8s settings if successful, or an api error otherwise
	CreateOrUpdateKubernetesSetting(name, kubeSystemUUID, scope string) (string, error)

	// CreateOrUpdateKubernetesAppSetting returns the object id of the created k8s app settings if successful, or an api error otherwise
	CreateOrUpdateKubernetesAppSetting(scope string) (string, error)

	// GetMonitoredEntitiesForKubeSystemUUID returns a (possibly empty) list of k8s monitored entities for the given uuid,
	// or an api error otherwise
	GetMonitoredEntitiesForKubeSystemUUID(kubeSystemUUID string) ([]MonitoredEntity, error)

	// GetSettingsForMonitoredEntities returns the settings response with the number of settings objects,
	// or an api error otherwise
	GetSettingsForMonitoredEntities(monitoredEntities []MonitoredEntity, schemaId string) (GetSettingsResponse, error)

	// GetSettingsForMonitoredEntities returns the settings response with the number of settings objects,
	// or an api error otherwise
	GetActiveGateAuthToken(dynakubeName string) (*ActiveGateAuthTokenInfo, error)

	GetLatestOneAgentImage() (*LatestImageInfo, error)

	GetLatestCodeModulesImage() (*LatestImageInfo, error)

	GetLatestActiveGateImage() (*LatestImageInfo, error)

	// GetLatestActiveGateVersion gets the latest gateway version for the given OS and arch.
	// Returns the version as received from the server on success.
	GetLatestActiveGateVersion(os 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

type CommunicationHost struct {
	Protocol string // nolint:unused
	Host     string // nolint:unused
	Port     uint32 // nolint:unused
}

CommunicationHost => struct of connection endpoint

func ParseEndpoint

func ParseEndpoint(s string) (CommunicationHost, error)

type ConfMap

type ConfMap map[string]map[string]string

ConfMap is the representation of a config file with sections that are divided by headers (map[header] == section) each section consists of key value pairs.

type ConnectionInfo

type ConnectionInfo struct {
	TenantUUID  string
	TenantToken string
	Endpoints   string
}

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 GetSettingsResponse

type GetSettingsResponse struct {
	TotalCount int `json:"totalCount"`
}

type HostNotFoundErr

type HostNotFoundErr struct {
	IP string
}

func (HostNotFoundErr) Error

func (e HostNotFoundErr) Error() string

type LatestImageInfo

type LatestImageInfo struct {
	Source string `json:"source"`
	Tag    string `json:"tag"`
}

func (LatestImageInfo) String

func (image LatestImageInfo) String() string

type MonitoredEntity

type MonitoredEntity struct {
	EntityId    string `json:"entityId"`
	DisplayName string `json:"displayName"`
	LastSeenTms int64  `json:"lastSeenTms"`
}

type MonitoringSettings

type MonitoringSettings struct {
	CloudApplicationPipelineEnabled bool `json:"cloudApplicationPipelineEnabled"`
	OpenMetricsPipelineEnabled      bool `json:"openMetricsPipelineEnabled"`
	EventProcessingActive           bool `json:"eventProcessingActive"`
	EventProcessingV2Active         bool `json:"eventProcessingV2Active"`
	FilterEvents                    bool `json:"filterEvents"`
}

type OneAgentConnectionInfo

type OneAgentConnectionInfo struct {
	ConnectionInfo
	CommunicationHosts []CommunicationHost
}

type Option

type Option func(*dynatraceClient)

Option can be passed to NewClient and customizes the created client instance.

func Certs

func Certs(certs []byte) Option

func HostGroup added in v1.0.0

func HostGroup(hostGroup string) Option

func NetworkZone

func NetworkZone(networkZone string) Option

func Proxy

func Proxy(proxyURL string, noProxy string) Option

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.

type ProcessModuleConfig

type ProcessModuleConfig struct {
	Revision   uint                    `json:"revision"`
	Properties []ProcessModuleProperty `json:"properties"`
}

func (*ProcessModuleConfig) Add

func (*ProcessModuleConfig) AddConnectionInfo

func (pmc *ProcessModuleConfig) AddConnectionInfo(oneAgentConnectionInfo dynatracev1beta1.OneAgentConnectionInfoStatus, tenantToken string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddHostGroup

func (pmc *ProcessModuleConfig) AddHostGroup(hostGroup string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddNoProxy added in v1.0.0

func (pmc *ProcessModuleConfig) AddNoProxy(noProxy string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddProxy

func (pmc *ProcessModuleConfig) AddProxy(proxy string) *ProcessModuleConfig

func (ProcessModuleConfig) IsEmpty

func (pmc ProcessModuleConfig) IsEmpty() bool

func (ProcessModuleConfig) ToMap

func (pmc ProcessModuleConfig) ToMap() ConfMap

type ProcessModuleProperty

type ProcessModuleProperty struct {
	Section string `json:"section"`
	Key     string `json:"key"`
	Value   string `json:"value"`
}

type ServerError

type ServerError struct {
	Code    int
	Message string
}

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.

Jump to

Keyboard shortcuts

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