Documentation
¶
Index ¶
- Variables
- func GetDynatraceVersion(client *http.Client, environment Environment) (version.Version, error)
- func NewOAuthClient(oauthConfig OauthCredentials) *http.Client
- func NewTokenAuthClient(token string) *http.Client
- func WithAutoServerVersion() func(client *DynatraceClient)
- func WithRetrySettings(retrySettings rest.RetrySettings) func(*DynatraceClient)
- func WithServerVersion(serverVersion version.Version) func(client *DynatraceClient)
- type ApiVersionObject
- type Client
- type ConfigClient
- type ConstraintViolation
- type DataEntry
- type DownloadSettingsObject
- type DummyClient
- func (c *DummyClient) ConfigExistsByName(a api.API, name string) (exists bool, id string, err error)
- func (c *DummyClient) DeleteConfigById(a api.API, id string) error
- func (l *DummyClient) DeleteSettings(_ string) error
- func (c *DummyClient) GetSettingById(_ string) (*DownloadSettingsObject, error)
- func (c *DummyClient) ListConfigs(a api.API) (values []Value, err error)
- func (c *DummyClient) ListEntities(_ EntitiesType) ([]string, error)
- func (c *DummyClient) ListEntitiesTypes() ([]EntitiesType, error)
- func (c *DummyClient) ListSchemas() (SchemaList, error)
- func (c *DummyClient) ListSettings(_ string, _ ListSettingsOptions) ([]DownloadSettingsObject, error)
- func (c *DummyClient) ReadByName(a api.API, name string) ([]byte, error)
- func (c *DummyClient) ReadConfigById(a api.API, id string) ([]byte, error)
- func (c *DummyClient) UpsertConfigByName(a api.API, name string, data []byte) (entity DynatraceEntity, err error)
- func (c *DummyClient) UpsertConfigByNonUniqueNameAndId(a api.API, entityId string, name string, data []byte) (entity DynatraceEntity, err error)
- func (c *DummyClient) UpsertSettings(obj SettingsObject) (DynatraceEntity, error)
- type DynatraceClient
- func (d *DynatraceClient) ConfigExistsByName(api API, name string) (exists bool, id string, err error)
- func (d *DynatraceClient) DeleteConfigById(api API, id string) error
- func (d *DynatraceClient) DeleteSettings(objectID string) error
- func (d *DynatraceClient) GetSettingById(objectId string) (*DownloadSettingsObject, error)
- func (d *DynatraceClient) ListConfigs(api API) (values []Value, err error)
- func (d *DynatraceClient) ListEntities(entitiesType EntitiesType) ([]string, error)
- func (d *DynatraceClient) ListEntitiesTypes() ([]EntitiesType, error)
- func (d *DynatraceClient) ListSchemas() (SchemaList, error)
- func (d *DynatraceClient) ListSettings(schemaId string, opts ListSettingsOptions) ([]DownloadSettingsObject, error)
- func (d *DynatraceClient) ReadConfigById(api API, id string) (json []byte, err error)
- func (d *DynatraceClient) UpsertConfigByName(api API, name string, payload []byte) (entity DynatraceEntity, err error)
- func (d *DynatraceClient) UpsertConfigByNonUniqueNameAndId(api API, entityId string, name string, payload []byte) (entity DynatraceEntity, err error)
- func (d *DynatraceClient) UpsertSettings(obj SettingsObject) (DynatraceEntity, error)
- type DynatraceEntity
- type EntitiesClient
- type EntitiesType
- type EntitiesTypeListResponse
- type EntityListResponseRaw
- type Environment
- type EnvironmentType
- type ErrorResponse
- type ErrorResponseStruct
- type ListSettingsFilter
- type ListSettingsOptions
- type OauthCredentials
- type Properties
- type RespError
- type SchemaList
- type SchemaListResponse
- type SettingsClient
- type SettingsObject
- type SyntheticEntity
- type SyntheticLocationResponse
- type SyntheticMonitorsResponse
- type SyntheticValue
- type TokenAuthTransport
- type Value
- type ValuesResponse
Constants ¶
This section is empty.
Variables ¶
var ErrSettingNotFound = errors.New("settings object not found")
ErrSettingNotFound is returned when no settings 2.0 object could be found
Functions ¶
func GetDynatraceVersion ¶
GetDynatraceVersion returns the version of an environment
func NewOAuthClient ¶
func NewOAuthClient(oauthConfig OauthCredentials) *http.Client
NewOAuthClient creates a new HTTP client that supports OAuth2 client credentials based authorization
func NewTokenAuthClient ¶
NewTokenAuthClient creates a new HTTP client that supports token based authorization
func WithAutoServerVersion ¶
func WithAutoServerVersion() func(client *DynatraceClient)
WithAutoServerVersion can be used to let the client automatically determine the Dynatrace server version during creation using NewDynatraceClient. If the server version is already known WithServerVersion should be used
func WithRetrySettings ¶
func WithRetrySettings(retrySettings rest.RetrySettings) func(*DynatraceClient)
WithRetrySettings sets the retry settings to be used by the DynatraceClient
func WithServerVersion ¶
func WithServerVersion(serverVersion version.Version) func(client *DynatraceClient)
WithServerVersion sets the Dynatrace version of the Dynatrace server/tenant the client will be interacting with
Types ¶
type ApiVersionObject ¶
type ApiVersionObject struct {
Version string `json:"version"`
}
type Client ¶
type Client interface {
ConfigClient
SettingsClient
EntitiesClient
}
Client provides the functionality for performing basic CRUD operations on any Dynatrace API supported by monaco. It encapsulates the configuration-specific inconsistencies of certain APIs in one place to provide a common interface to work with. After all: A user of Client shouldn't care about the implementation details of each individual Dynatrace API. Its design is intentionally not dependent on the Config and Environment interfaces included in monaco. This makes sure, that Client can be used as a base for future tooling, which relies on a standardized way to access Dynatrace APIs.
func LimitClientParallelRequests ¶
LimitClientParallelRequests utilizes the decorator pattern to limit parallel requests to the dynatrace API
type ConfigClient ¶
type ConfigClient interface {
// ListConfigs lists the available configs for an API.
// It calls the underlying GET endpoint of the API. E.g. for alerting profiles this would be:
// GET <environment-url>/api/config/v1/alertingProfiles
// The result is expressed using a list of Value (id and name tuples).
ListConfigs(a API) (values []Value, err error)
// ReadConfigById reads a Dynatrace config identified by id from the given API.
// It calls the underlying GET endpoint for the API. E.g. for alerting profiles this would be:
// GET <environment-url>/api/config/v1/alertingProfiles/<id> ... to get the alerting profile
ReadConfigById(a API, id string) (json []byte, err error)
// UpsertConfigByName creates a given Dynatrace config if it doesn't exist and updates it otherwise using its name.
// It calls the underlying GET, POST, and PUT endpoints for the API. E.g. for alerting profiles this would be:
// GET <environment-url>/api/config/v1/alertingProfiles ... to check if the config is already available
// POST <environment-url>/api/config/v1/alertingProfiles ... afterwards, if the config is not yet available
// PUT <environment-url>/api/config/v1/alertingProfiles/<id> ... instead of POST, if the config is already available
UpsertConfigByName(a API, name string, payload []byte) (entity DynatraceEntity, err error)
// UpsertConfigByNonUniqueNameAndId creates a given Dynatrace config if it doesn't exist and updates it based on specific rules if it does not
// - if only one config with the name exist, behave like any other type and just update this entity
// - if an exact match is found (same name and same generated UUID) update that entity
// - if several configs exist, but non match the generated UUID create a new entity with generated UUID
// It calls the underlying GET and PUT endpoints for the API. E.g. for alerting profiles this would be:
// GET <environment-url>/api/config/v1/alertingProfiles ... to check if the config is already available
// PUT <environment-url>/api/config/v1/alertingProfiles/<id> ... with the given (or found by unique name) entity ID
UpsertConfigByNonUniqueNameAndId(a API, entityId string, name string, payload []byte) (entity DynatraceEntity, err error)
// DeleteConfigById removes a given config for a given API using its id.
// It calls the DELETE endpoint for the API. E.g. for alerting profiles this would be:
// DELETE <environment-url>/api/config/v1/alertingProfiles/<id> ... to delete the config
DeleteConfigById(a API, id string) error
// ConfigExistsByName checks if a config with the given name exists for the given API.
// It calls the underlying GET endpoint for the API. E.g. for alerting profiles this would be:
// GET <environment-url>/api/config/v1/alertingProfiles
ConfigExistsByName(a API, name string) (exists bool, id string, err error)
}
ConfigClient is responsible for the classic Dynatrace configs. For settings objects, the SettingsClient is responsible. Each config endpoint is described by an [API] object to describe endpoints, structure, and behavior.
type ConstraintViolation ¶
type DownloadSettingsObject ¶
type DownloadSettingsObject struct {
ExternalId string `json:"externalId"`
SchemaVersion string `json:"schemaVersion"`
SchemaId string `json:"schemaId"`
ObjectId string `json:"objectId"`
Scope string `json:"scope"`
Value json.RawMessage `json:"value"`
}
DownloadSettingsObject is the response type for the ListSettings operation
type DummyClient ¶
func (*DummyClient) ConfigExistsByName ¶
func (*DummyClient) DeleteConfigById ¶
func (c *DummyClient) DeleteConfigById(a api.API, id string) error
func (*DummyClient) DeleteSettings ¶
func (l *DummyClient) DeleteSettings(_ string) error
func (*DummyClient) GetSettingById ¶
func (c *DummyClient) GetSettingById(_ string) (*DownloadSettingsObject, error)
func (*DummyClient) ListConfigs ¶
func (c *DummyClient) ListConfigs(a api.API) (values []Value, err error)
func (*DummyClient) ListEntities ¶
func (c *DummyClient) ListEntities(_ EntitiesType) ([]string, error)
func (*DummyClient) ListEntitiesTypes ¶
func (c *DummyClient) ListEntitiesTypes() ([]EntitiesType, error)
func (*DummyClient) ListSchemas ¶
func (c *DummyClient) ListSchemas() (SchemaList, error)
func (*DummyClient) ListSettings ¶
func (c *DummyClient) ListSettings(_ string, _ ListSettingsOptions) ([]DownloadSettingsObject, error)
func (*DummyClient) ReadByName ¶
func (*DummyClient) ReadConfigById ¶
func (*DummyClient) UpsertConfigByName ¶
func (c *DummyClient) UpsertConfigByName(a api.API, name string, data []byte) (entity DynatraceEntity, err error)
func (*DummyClient) UpsertConfigByNonUniqueNameAndId ¶
func (c *DummyClient) UpsertConfigByNonUniqueNameAndId(a api.API, entityId string, name string, data []byte) (entity DynatraceEntity, err error)
func (*DummyClient) UpsertSettings ¶
func (c *DummyClient) UpsertSettings(obj SettingsObject) (DynatraceEntity, error)
type DynatraceClient ¶
type DynatraceClient struct {
// contains filtered or unexported fields
}
DynatraceClient is the default implementation of the HTTP client targeting the relevant Dynatrace APIs for Monaco
func NewDynatraceClient ¶
func NewDynatraceClient(httpClient *http.Client, environmentURL string, opts ...func(dynatraceClient *DynatraceClient)) (*DynatraceClient, error)
NewDynatraceClient creates a new DynatraceClient. It takes a http.Client to do its HTTP communication, a URL to the targeting Dynatrace environment and an optional list of options to further configure the behavior of the client It is also allowed to pass nil as httpClient
func (*DynatraceClient) ConfigExistsByName ¶
func (d *DynatraceClient) ConfigExistsByName(api API, name string) (exists bool, id string, err error)
func (*DynatraceClient) DeleteConfigById ¶
func (d *DynatraceClient) DeleteConfigById(api API, id string) error
func (*DynatraceClient) DeleteSettings ¶
func (d *DynatraceClient) DeleteSettings(objectID string) error
func (*DynatraceClient) GetSettingById ¶
func (d *DynatraceClient) GetSettingById(objectId string) (*DownloadSettingsObject, error)
func (*DynatraceClient) ListConfigs ¶
func (d *DynatraceClient) ListConfigs(api API) (values []Value, err error)
func (*DynatraceClient) ListEntities ¶
func (d *DynatraceClient) ListEntities(entitiesType EntitiesType) ([]string, error)
func (*DynatraceClient) ListEntitiesTypes ¶
func (d *DynatraceClient) ListEntitiesTypes() ([]EntitiesType, error)
func (*DynatraceClient) ListSchemas ¶
func (d *DynatraceClient) ListSchemas() (SchemaList, error)
func (*DynatraceClient) ListSettings ¶
func (d *DynatraceClient) ListSettings(schemaId string, opts ListSettingsOptions) ([]DownloadSettingsObject, error)
func (*DynatraceClient) ReadConfigById ¶
func (d *DynatraceClient) ReadConfigById(api API, id string) (json []byte, err error)
func (*DynatraceClient) UpsertConfigByName ¶
func (d *DynatraceClient) UpsertConfigByName(api API, name string, payload []byte) (entity DynatraceEntity, err error)
func (*DynatraceClient) UpsertConfigByNonUniqueNameAndId ¶
func (d *DynatraceClient) UpsertConfigByNonUniqueNameAndId(api API, entityId string, name string, payload []byte) (entity DynatraceEntity, err error)
func (*DynatraceClient) UpsertSettings ¶
func (d *DynatraceClient) UpsertSettings(obj SettingsObject) (DynatraceEntity, error)
type DynatraceEntity ¶
type EntitiesClient ¶
type EntitiesClient interface {
// ListEntitiesTypes returns all entities types
ListEntitiesTypes() ([]EntitiesType, error)
// ListEntities returns all entities objects for a given type.
ListEntities(EntitiesType) ([]string, error)
}
EntitiesClient is the abstraction layer for read-only operations on the Dynatrace Entities v2 API. Its design is intentionally not dependent on Monaco objects.
This interface exclusively accesses the entities api of Dynatrace.
More documentation is written in each method's documentation.
type EntitiesType ¶
type EntitiesTypeListResponse ¶
type EntitiesTypeListResponse struct {
Types []EntitiesType `json:"types"`
}
type EntityListResponseRaw ¶
type EntityListResponseRaw struct {
Entities []json.RawMessage `json:"entities"`
}
type Environment ¶
type Environment struct {
// URL is the base URL of the environment
URL string
// Type is the type / generation of environment
Type EnvironmentType
}
Environment represents a Dynatrace environment
type EnvironmentType ¶
type EnvironmentType int
EnvironmentType represents the type / generation of an environment
const ( // Classic identifies a Dynatrace Classic environment Classic EnvironmentType = iota // Platform identifies a Dynatrace Platform environment Platform )
type ErrorResponse ¶
type ErrorResponse struct {
ErrorCode int `json:"code"`
Message string `json:"message"`
ConstraintViolationList []ConstraintViolation `json:"constraintViolations"`
}
type ErrorResponseStruct ¶
type ErrorResponseStruct struct {
ErrorResponse ErrorResponse `json:"error"`
}
type ListSettingsFilter ¶
type ListSettingsFilter func(DownloadSettingsObject) bool
ListSettingsFilter can be used to filter fetched settings objects with custom criteria, e.g. o.ExternalId == ""
type ListSettingsOptions ¶
type ListSettingsOptions struct {
// DiscardValue specifies whether the value field of the returned
// settings object shall be included in the payload
DiscardValue bool
// ListSettingsFilter can be set to pre-filter the result given a special logic
Filter ListSettingsFilter
}
ListSettingsOptions are additional options for the ListSettings method of the Settings client
type OauthCredentials ¶
type OauthCredentials struct {
ClientID string
ClientSecret string
TokenURL string
Scopes []string
}
OauthCredentials holds information for authenticating to Dynatrace using Oauth2.0 client credential flow
type Properties ¶
type Properties struct {
Version *string `json:"version"`
}
type RespError ¶
func (RespError) ConcurrentError ¶
type SchemaList ¶
type SchemaList []struct {
SchemaId string `json:"schemaId"`
}
type SchemaListResponse ¶
type SchemaListResponse struct {
Items SchemaList `json:"items"`
TotalCount int `json:"totalCount"`
}
SchemaListResponse is the response type returned by the ListSchemas operation
type SettingsClient ¶
type SettingsClient interface {
// UpsertSettings either creates the supplied object, or updates an existing one.
// First, we try to find the external-id of the object. If we can't find it, we create the object, if we find it, we
// update the object.
UpsertSettings(SettingsObject) (DynatraceEntity, error)
// ListSchemas returns all schemas that the Dynatrace environment reports
ListSchemas() (SchemaList, error)
// ListSettings returns all settings objects for a given schema.
ListSettings(string, ListSettingsOptions) ([]DownloadSettingsObject, error)
// GetSettingById returns the setting with the given object ID
GetSettingById(string) (*DownloadSettingsObject, error)
// DeleteSettings deletes a settings object giving its object ID
DeleteSettings(string) error
}
SettingsClient is the abstraction layer for CRUD operations on the Dynatrace Settings API. Its design is intentionally not dependent on Monaco objects.
This interface exclusively accesses the settings api of Dynatrace.
The base mechanism for all methods is the same: We identify objects to be updated/deleted by their external-id. If an object can not be found using its external-id, we assume that it does not exist. More documentation is written in each method's documentation.
type SettingsObject ¶
type SettingsObject struct {
// Id is the monaco related Configuration ID
Id,
SchemaId,
SchemaVersion,
Scope string
// Content is the rendered config for the given settings object
Content []byte
// OriginObjectId is the object id of the Settings object when it was downloaded from an environment
OriginObjectId string
}
SettingsObject contains all the information necessary to create/update a settings object
type SyntheticEntity ¶
type SyntheticEntity struct {
EntityId string `json:"entityId"`
}
type SyntheticLocationResponse ¶
type SyntheticLocationResponse struct {
Locations []SyntheticValue `json:"locations"`
}
type SyntheticMonitorsResponse ¶
type SyntheticMonitorsResponse struct {
Monitors []SyntheticValue `json:"monitors"`
}
type SyntheticValue ¶
type TokenAuthTransport ¶
type TokenAuthTransport struct {
http.RoundTripper
// contains filtered or unexported fields
}
TokenAuthTransport should be used to enable a client to use dynatrace token authorization
func NewTokenAuthTransport ¶
func NewTokenAuthTransport(baseTransport http.RoundTripper, token string) *TokenAuthTransport
NewTokenAuthTransport creates a new http transport to be used for token authorization
type Value ¶
type Value struct {
Id string `json:"id"`
Name string `json:"name"`
// Owner is used by dashboards to indicate the creator of the dashboard. We use it to filter Dynatrace created dashboards.
Owner *string `json:"owner,omitempty"`
// Type is used by synthetic-locations to indicate whether it is a PRIVATE location or not.
Type *string `json:"type,omitempty"`
}
type ValuesResponse ¶
type ValuesResponse struct {
Values []Value `json:"values"`
}