client

package
v2.14.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMonacoUserAgent = "Dynatrace Monitoring as Code/" + version.MonitoringAsCode + " " + (runtime.GOOS + " " + runtime.GOARCH)

Functions

This section is empty.

Types

type AutomationClient added in v2.14.0

type AutomationClient interface {
	Get(ctx context.Context, resourceType automationApi.ResourceType, id string) (automation.Response, error)
	Create(ctx context.Context, resourceType automationApi.ResourceType, data []byte) (result automation.Response, err error)
	Update(ctx context.Context, resourceType automationApi.ResourceType, id string, data []byte) (automation.Response, error)
	List(ctx context.Context, resourceType automationApi.ResourceType) (automation.ListResponse, error)
	Upsert(ctx context.Context, resourceType automationApi.ResourceType, id string, data []byte) (result automation.Response, err error)
	Delete(ctx context.Context, resourceType automationApi.ResourceType, id string) (automation.Response, error)
}

type BucketClient added in v2.14.0

type BucketClient interface {
	Get(ctx context.Context, bucketName string) (buckets.Response, error)
	List(ctx context.Context) (buckets.ListResponse, error)
	Create(ctx context.Context, bucketName string, data []byte) (buckets.Response, error)
	Update(ctx context.Context, bucketName string, data []byte) (buckets.Response, error)
	Upsert(ctx context.Context, bucketName string, data []byte) (buckets.Response, error)
	Delete(ctx context.Context, bucketName string) (buckets.Response, error)
}

type ClientOptions

type ClientOptions struct {
	CustomUserAgent string
	SupportArchive  bool
	CachingDisabled bool
}

type ClientSet

type ClientSet struct {
	// dtClient is the client capable of updating or creating settings and classic configs
	DTClient DynatraceClient
	// autClient is the client capable of updating or creating automation API configs
	AutClient AutomationClient
	// bucketClient is the client capable of updating or creating Grail Bucket configs
	BucketClient BucketClient
	// DocumentClient is a client capable of manipulating documents
	DocumentClient DocumentClient
}

ClientSet composes a "full" set of sub-clients to access Dynatrace APIs Each field may be nil, if the ClientSet is partially initialized - e.g. no autClient will be part of a ClientSet created for a 'classic' Dynatrace environment, as Automations are a Platform feature

func CreateClassicClientSet

func CreateClassicClientSet(url string, token string, opts ClientOptions) (*ClientSet, error)

func CreatePlatformClientSet

func CreatePlatformClientSet(url string, auth PlatformAuth, opts ClientOptions) (*ClientSet, error)

func (ClientSet) Automation

func (s ClientSet) Automation() AutomationClient

func (ClientSet) Bucket added in v2.7.0

func (s ClientSet) Bucket() BucketClient

func (ClientSet) Classic

func (s ClientSet) Classic() ConfigClient

func (ClientSet) Document added in v2.14.0

func (s ClientSet) Document() DocumentClient

func (ClientSet) Settings

func (s ClientSet) Settings() SettingsClient

type ConfigClient added in v2.14.0

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(ctx context.Context, a api.API) (values []dtclient.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.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(ctx context.Context, a api.API, name string, payload []byte) (entity dtclient.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(ctx context.Context, a api.API, entityID string, name string, payload []byte, duplicate bool) (entity dtclient.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.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(ctx context.Context, a api.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 DocumentClient added in v2.14.0

type DocumentClient interface {
	Get(ctx context.Context, id string) (documents.Response, error)
	List(ctx context.Context, filter string) (documents.ListResponse, error)
	Create(ctx context.Context, name string, externalId string, data []byte, documentType documents.DocumentType) (documents.Response, error)
	Update(ctx context.Context, id string, name string, data []byte, documentType documents.DocumentType) (documents.Response, error)
	Delete(ctx context.Context, id string) (documents.Response, error)
}

type DynatraceClient added in v2.14.0

type DynatraceClient interface {
	ConfigClient
	SettingsClient
}

DynatraceClient 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.

type PlatformAuth

type PlatformAuth struct {
	OauthClientID, OauthClientSecret, OauthTokenURL string
	Token                                           string
}

type SettingsClient added in v2.14.0

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(context.Context, dtclient.SettingsObject, dtclient.UpsertSettingsOptions) (dtclient.DynatraceEntity, error)

	// ListSchemas returns all schemas that the Dynatrace environment reports
	ListSchemas() (dtclient.SchemaList, error)

	// GetSchemaById returns the settings schema with the given schema ID
	GetSchemaById(string) (dtclient.Schema, error)

	// ListSettings returns all settings objects for a given schema.
	ListSettings(context.Context, string, dtclient.ListSettingsOptions) ([]dtclient.DownloadSettingsObject, error)

	// GetSettingById returns the setting with the given object ID
	GetSettingById(string) (*dtclient.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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