client

package
v2.17.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 23 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)
View Source
var DefaultRetryOptions = corerest.RetryOptions{MaxRetries: 10, ShouldRetryFunc: corerest.RetryIfNotSuccess}
View Source
var DummyClientSet = ClientSet{
	ConfigClient:       &dtclient.DummyConfigClient{},
	SettingsClient:     &dtclient.DummySettingsClient{},
	AutClient:          &DummyAutomationClient{},
	BucketClient:       &DummyBucketClient{},
	DocumentClient:     &DummyDocumentClient{},
	OpenPipelineClient: &DummyOpenPipelineClient{},
}

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 {
	// ConfigClient is the client capable of updating or creating classic configs
	ConfigClient ConfigClient

	// SettingsClient is the client capable of updating or creating settings
	SettingsClient SettingsClient

	// 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

	// OpenPipelineClient is a client capable of manipulating openPipeline configs
	OpenPipelineClient OpenPipelineClient
}

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 CreateClientSet added in v2.17.0

func CreateClientSet(ctx context.Context, url string, auth manifest.Auth, 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) Config added in v2.17.0

func (s ClientSet) Config() ConfigClient

func (ClientSet) Document added in v2.14.0

func (s ClientSet) Document() DocumentClient

func (ClientSet) OpenPipeline added in v2.14.3

func (s ClientSet) OpenPipeline() OpenPipelineClient

func (ClientSet) Settings

func (s ClientSet) Settings() SettingsClient

type ConfigClient added in v2.14.0

type ConfigClient interface {
	// Cache caches all config values for a given API.
	Cache(ctx context.Context, a api.API) error

	// List 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).
	List(ctx context.Context, a api.API) (values []dtclient.Value, err error)

	// Get 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
	Get(ctx context.Context, a api.API, id string) (json []byte, err error)

	// UpsertByName 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
	UpsertByName(ctx context.Context, a api.API, name string, payload []byte) (entity dtclient.DynatraceEntity, err error)

	// UpsertByNonUniqueNameAndId 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
	UpsertByNonUniqueNameAndId(ctx context.Context, a api.API, entityID string, name string, payload []byte, duplicate bool) (entity dtclient.DynatraceEntity, err error)

	// Delete 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
	Delete(ctx context.Context, a api.API, id string) error

	// ExistsWithName 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
	ExistsWithName(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, isPrivate bool, externalId string, data []byte, documentType documents.DocumentType) (coreapi.Response, error)
	Update(ctx context.Context, id string, name string, isPrivate bool, data []byte, documentType documents.DocumentType) (coreapi.Response, error)
	Delete(ctx context.Context, id string) (coreapi.Response, error)
}

type DummyAutomationClient added in v2.17.0

type DummyAutomationClient struct {
}

func (*DummyAutomationClient) Create added in v2.17.0

func (d *DummyAutomationClient) Create(ctx context.Context, resourceType automationApi.ResourceType, data []byte) (result coreapi.Response, err error)

Create implements AutomationClient.

func (*DummyAutomationClient) Delete added in v2.17.0

Delete implements AutomationClient.

func (*DummyAutomationClient) Get added in v2.17.0

Get implements AutomationClient.

func (*DummyAutomationClient) List added in v2.17.0

List implements AutomationClient.

func (*DummyAutomationClient) Update added in v2.17.0

func (d *DummyAutomationClient) Update(ctx context.Context, resourceType automationApi.ResourceType, id string, data []byte) (coreapi.Response, error)

Update implements AutomationClient.

func (*DummyAutomationClient) Upsert added in v2.17.0

func (d *DummyAutomationClient) Upsert(ctx context.Context, resourceType automationApi.ResourceType, id string, data []byte) (result coreapi.Response, err error)

Upsert implements AutomationClient.

type DummyBucketClient added in v2.17.0

type DummyBucketClient struct{}

func (*DummyBucketClient) Create added in v2.17.0

func (d *DummyBucketClient) Create(ctx context.Context, bucketName string, data []byte) (coreapi.Response, error)

Create implements BucketClient.

func (*DummyBucketClient) Delete added in v2.17.0

func (d *DummyBucketClient) Delete(ctx context.Context, bucketName string) (coreapi.Response, error)

Delete implements BucketClient.

func (*DummyBucketClient) Get added in v2.17.0

func (d *DummyBucketClient) Get(ctx context.Context, bucketName string) (coreapi.Response, error)

Get implements BucketClient.

func (*DummyBucketClient) List added in v2.17.0

List implements BucketClient.

func (*DummyBucketClient) Update added in v2.17.0

func (d *DummyBucketClient) Update(ctx context.Context, bucketName string, data []byte) (coreapi.Response, error)

Update implements BucketClient.

func (*DummyBucketClient) Upsert added in v2.17.0

func (d *DummyBucketClient) Upsert(ctx context.Context, bucketName string, data []byte) (coreapi.Response, error)

Upsert implements BucketClient.

type DummyDocumentClient added in v2.17.0

type DummyDocumentClient struct{}

func (*DummyDocumentClient) Create added in v2.17.0

func (c *DummyDocumentClient) Create(ctx context.Context, name string, isPrivate bool, externalId string, data []byte, documentType documents.DocumentType) (coreapi.Response, error)

Create implements Client.

func (*DummyDocumentClient) Delete added in v2.17.0

Delete implements DocumentClient.

func (*DummyDocumentClient) Get added in v2.17.0

Get implements Client.

func (*DummyDocumentClient) List added in v2.17.0

List implements Client.

func (*DummyDocumentClient) Update added in v2.17.0

func (c *DummyDocumentClient) Update(ctx context.Context, id string, name string, isPrivate bool, data []byte, documentType documents.DocumentType) (coreapi.Response, error)

Update implements Client.

type DummyOpenPipelineClient added in v2.17.0

type DummyOpenPipelineClient struct{}

func (*DummyOpenPipelineClient) GetAll added in v2.17.0

GetAll implements OpenPipelineClient.

func (*DummyOpenPipelineClient) Update added in v2.17.0

type OpenPipelineClient added in v2.14.3

type OpenPipelineClient interface {
	GetAll(ctx context.Context) ([]openpipeline.Response, error)
	Update(ctx context.Context, id string, data []byte) (openpipeline.Response, error)
}

type PlatformAuth

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

type SettingsClient added in v2.14.0

type SettingsClient interface {
	// Cache caches all settings objects for a given schema.
	Cache(context.Context, string) error

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

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

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

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

	// Get returns the setting with the given object ID
	Get(context.Context, string) (*dtclient.DownloadSettingsObject, error)

	// Delete deletes a settings object giving its object ID
	Delete(context.Context, 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