datadog

package
v2.25.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 27 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKeys takes a string apikey as authentication for the request
	ContextAPIKeys = contextKey("apiKeys")

	// ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
	ContextHttpSignatureAuth = contextKey("httpsignature")

	// ContextServerIndex uses a server configuration from the index.
	ContextServerIndex = contextKey("serverIndex")

	// ContextOperationServerIndices uses a server configuration from the index mapping.
	ContextOperationServerIndices = contextKey("serverOperationIndices")

	// ContextServerVariables overrides a server configuration variables.
	ContextServerVariables = contextKey("serverVariables")

	// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
	ContextOperationServerVariables = contextKey("serverOperationVariables")
)

Functions

func ContainsUnparsedObject

func ContainsUnparsedObject(i interface{}) (bool, interface{})

ContainsUnparsedObject returns true if the given data contains an unparsed object from the API.

func DeleteKeys added in v2.13.0

func DeleteKeys[V any](obj map[string]V, keysToDelete *[]string)

DeleteKeys helper method to delete keys from a map

func Marshal added in v2.19.0

func Marshal(v interface{}) ([]byte, error)

func NewDecoder added in v2.19.0

func NewDecoder(r io.Reader) *json.Decoder

func NewDefaultContext

func NewDefaultContext(ctx context.Context) context.Context

NewDefaultContext returns a new context setup with environment variables.

func NewEncoder added in v2.19.0

func NewEncoder(w io.Writer) *json.Encoder

func ParameterToString

func ParameterToString(obj interface{}, collectionFormat string) string

ParameterToString convert interface{} parameters to string, using a delimiter if format is provided.

func PtrBool

func PtrBool(v bool) *bool

PtrBool is a helper routine that returns a pointer to given boolean value.

func PtrFloat32

func PtrFloat32(v float32) *float32

PtrFloat32 is a helper routine that returns a pointer to given float value.

func PtrFloat64

func PtrFloat64(v float64) *float64

PtrFloat64 is a helper routine that returns a pointer to given float value.

func PtrInt

func PtrInt(v int) *int

PtrInt is a helper routine that returns a pointer to given integer value.

func PtrInt32

func PtrInt32(v int32) *int32

PtrInt32 is a helper routine that returns a pointer to given integer value.

func PtrInt64

func PtrInt64(v int64) *int64

PtrInt64 is a helper routine that returns a pointer to given integer value.

func PtrString

func PtrString(v string) *string

PtrString is a helper routine that returns a pointer to given string value.

func PtrTime

func PtrTime(v time.Time) *time.Time

PtrTime is helper routine that returns a pointer to given Time value.

func ReadBody added in v2.8.0

func ReadBody(response *http.Response) ([]byte, error)

ReadBody returns the byte content of the response and make it available again on the response object.

func ReportError

func ReportError(format string, a ...interface{}) error

ReportError Prevent trying to import "fmt".

func SetAuthKeys added in v2.6.0

func SetAuthKeys(ctx context.Context, headerParams *map[string]string, keys ...[2]string)

SetAuthKeys sets the appropriate values in the headers parameter.

func Strlen added in v2.8.0

func Strlen(s string) int

Strlen returns number of runes in string

func Unmarshal added in v2.19.0

func Unmarshal(data []byte, v interface{}) error

Types

type APIClient

type APIClient struct {
	Cfg *Configuration
}

APIClient manages communication with the Datadog API V2 Collection API v1.0. In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) CallAPI

func (c *APIClient) CallAPI(request *http.Request) (*http.Response, error)

CallAPI do the request.

func (*APIClient) Decode

func (c *APIClient) Decode(v interface{}, b []byte, contentType string) (err error)

Decode unmarshal bytes into an interface

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

GetConfig allows modification of underlying config for alternate implementations and testing. Caution: modifying the configuration while live can cause data races and potentially unwanted behavior.

func (*APIClient) PrepareRequest

func (c *APIClient) PrepareRequest(
	ctx context.Context,
	path string, method string,
	postBody interface{},
	headerParams map[string]string,
	queryParams url.Values,
	formParams url.Values,
	formFile *FormFile) (localVarRequest *http.Request, err error)

PrepareRequest build the request.

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey.

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.

type Configuration

type Configuration struct {
	Host             string            `json:"host,omitempty"`
	Scheme           string            `json:"scheme,omitempty"`
	DefaultHeader    map[string]string `json:"defaultHeader,omitempty"`
	UserAgent        string            `json:"userAgent,omitempty"`
	Debug            bool              `json:"debug,omitempty"`
	Compress         bool              `json:"compress,omitempty"`
	Servers          ServerConfigurations
	OperationServers map[string]ServerConfigurations
	HTTPClient       *http.Client

	RetryConfiguration RetryConfiguration
	// contains filtered or unexported fields
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object.

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request.

func (*Configuration) GetUnstableOperations

func (c *Configuration) GetUnstableOperations() []string

GetUnstableOperations returns a slice with all unstable operation Ids.

func (*Configuration) IsUnstableOperation

func (c *Configuration) IsUnstableOperation(operation string) bool

IsUnstableOperation determines whether an operation is an unstable operation. This function accepts operation ID as an argument - this is the name of the method on the API class, e.g. "CreateFoo".

func (*Configuration) IsUnstableOperationEnabled

func (c *Configuration) IsUnstableOperationEnabled(operation string) bool

IsUnstableOperationEnabled determines whether an unstable operation is enabled. This function accepts operation ID as an argument - this is the name of the method on the API class, e.g. "CreateFoo" Returns true if the operation is unstable and it is enabled, false otherwise.

func (*Configuration) ServerURL

func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error)

ServerURL returns URL based on server settings.

func (*Configuration) ServerURLWithContext

func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error)

ServerURLWithContext returns a new server URL given an endpoint.

func (*Configuration) SetUnstableOperationEnabled

func (c *Configuration) SetUnstableOperationEnabled(operation string, enabled bool) bool

SetUnstableOperationEnabled sets an unstable operation as enabled (true) or disabled (false). This function accepts operation ID as an argument - this is the name of the method on the API class, e.g. "CreateFoo" Returns true if the operation is marked as unstable and thus was enabled/disabled, false otherwise.

type FormFile

type FormFile struct {
	FormFileName string
	FileName     string
	FileBytes    []byte
}

FormFile holds parameters for a file in multipart/form-data request.

type GenericOpenAPIError

type GenericOpenAPIError struct {
	ErrorBody    []byte
	ErrorMessage string
	ErrorModel   interface{}
}

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response.

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error.

type NullableBool

type NullableBool struct {
	// contains filtered or unexported fields
}

NullableBool is a struct to hold a nullable boolean value.

func NewNullableBool

func NewNullableBool(val *bool) *NullableBool

NewNullableBool instantiates a new nullable bool.

func (NullableBool) Get

func (v NullableBool) Get() *bool

Get returns the value associated with the nullable bool.

func (NullableBool) IsSet

func (v NullableBool) IsSet() bool

IsSet returns true if the value has been set.

func (NullableBool) MarshalJSON

func (v NullableBool) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableBool) Set

func (v *NullableBool) Set(val *bool)

Set sets the value associated with the nullable bool.

func (*NullableBool) UnmarshalJSON

func (v *NullableBool) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableBool) Unset

func (v *NullableBool) Unset()

Unset resets fields of the nullable bool.

type NullableFloat32

type NullableFloat32 struct {
	// contains filtered or unexported fields
}

NullableFloat32 is a struct to hold a nullable float32 value.

func NewNullableFloat32

func NewNullableFloat32(val *float32) *NullableFloat32

NewNullableFloat32 instantiates a new nullable float32.

func (NullableFloat32) Get

func (v NullableFloat32) Get() *float32

Get returns the value associated with the nullable float32.

func (NullableFloat32) IsSet

func (v NullableFloat32) IsSet() bool

IsSet returns true if the value has been set.

func (NullableFloat32) MarshalJSON

func (v NullableFloat32) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableFloat32) Set

func (v *NullableFloat32) Set(val *float32)

Set sets the value associated with the nullable float32.

func (*NullableFloat32) UnmarshalJSON

func (v *NullableFloat32) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableFloat32) Unset

func (v *NullableFloat32) Unset()

Unset resets fields of the nullable float32.

type NullableFloat64

type NullableFloat64 struct {
	// contains filtered or unexported fields
}

NullableFloat64 is a struct to hold a nullable float64 value.

func NewNullableFloat64

func NewNullableFloat64(val *float64) *NullableFloat64

NewNullableFloat64 instantiates a new nullable float64.

func (NullableFloat64) Get

func (v NullableFloat64) Get() *float64

Get returns the value associated with the nullable float64.

func (NullableFloat64) IsSet

func (v NullableFloat64) IsSet() bool

IsSet returns true if the value has been set.

func (NullableFloat64) MarshalJSON

func (v NullableFloat64) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableFloat64) Set

func (v *NullableFloat64) Set(val *float64)

Set sets the value associated with the nullable float64.

func (*NullableFloat64) UnmarshalJSON

func (v *NullableFloat64) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableFloat64) Unset

func (v *NullableFloat64) Unset()

Unset resets fields of the nullable float64.

type NullableInt

type NullableInt struct {
	// contains filtered or unexported fields
}

NullableInt is a struct to hold a nullable int value.

func NewNullableInt

func NewNullableInt(val *int) *NullableInt

NewNullableInt instantiates a new nullable int.

func (NullableInt) Get

func (v NullableInt) Get() *int

Get returns the value associated with the nullable int.

func (NullableInt) IsSet

func (v NullableInt) IsSet() bool

IsSet returns true if the value has been set.

func (NullableInt) MarshalJSON

func (v NullableInt) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableInt) Set

func (v *NullableInt) Set(val *int)

Set sets the value associated with the nullable int.

func (*NullableInt) UnmarshalJSON

func (v *NullableInt) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableInt) Unset

func (v *NullableInt) Unset()

Unset resets fields of the nullable int.

type NullableInt32

type NullableInt32 struct {
	// contains filtered or unexported fields
}

NullableInt32 is a struct to hold a nullable int32 value.

func NewNullableInt32

func NewNullableInt32(val *int32) *NullableInt32

NewNullableInt32 instantiates a new nullable int32.

func (NullableInt32) Get

func (v NullableInt32) Get() *int32

Get returns the value associated with the nullable int32.

func (NullableInt32) IsSet

func (v NullableInt32) IsSet() bool

IsSet returns true if the value has been set.

func (NullableInt32) MarshalJSON

func (v NullableInt32) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableInt32) Set

func (v *NullableInt32) Set(val *int32)

Set sets the value associated with the nullable int32.

func (*NullableInt32) UnmarshalJSON

func (v *NullableInt32) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableInt32) Unset

func (v *NullableInt32) Unset()

Unset resets fields of the nullable int32.

type NullableInt64

type NullableInt64 struct {
	// contains filtered or unexported fields
}

NullableInt64 is a struct to hold a nullable int64 value.

func NewNullableInt64

func NewNullableInt64(val *int64) *NullableInt64

NewNullableInt64 instantiates a new nullable int64.

func (NullableInt64) Get

func (v NullableInt64) Get() *int64

Get returns the value associated with the nullable int64.

func (NullableInt64) IsSet

func (v NullableInt64) IsSet() bool

IsSet returns true if the value has been set.

func (NullableInt64) MarshalJSON

func (v NullableInt64) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableInt64) Set

func (v *NullableInt64) Set(val *int64)

Set sets the value associated with the nullable int64.

func (*NullableInt64) UnmarshalJSON

func (v *NullableInt64) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableInt64) Unset

func (v *NullableInt64) Unset()

Unset resets fields of the nullable int64.

type NullableList added in v2.14.0

type NullableList[T any] struct {
	// contains filtered or unexported fields
}

NullableList struct to hold nullable list value.

func NewNullableList added in v2.14.0

func NewNullableList[T any](val *[]T) *NullableList[T]

NewNullableList instantiates a new nullable list.

func (NullableList[T]) Get added in v2.14.0

func (v NullableList[T]) Get() *[]T

Get returns the value associated with the nullable list.

func (NullableList[T]) IsSet added in v2.14.0

func (v NullableList[T]) IsSet() bool

IsSet returns true if the value has been set.

func (NullableList[T]) MarshalJSON added in v2.14.0

func (v NullableList[T]) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableList[T]) Set added in v2.14.0

func (v *NullableList[T]) Set(val *[]T)

Set sets the value associated with the nullable list.

func (*NullableList[T]) UnmarshalJSON added in v2.14.0

func (v *NullableList[T]) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableList[T]) Unset added in v2.14.0

func (v *NullableList[T]) Unset()

Unset resets fields of the nullable list.

type NullableString

type NullableString struct {
	// contains filtered or unexported fields
}

NullableString is a struct to hold a nullable string value.

func NewNullableString

func NewNullableString(val *string) *NullableString

NewNullableString instantiates a new nullable string.

func (NullableString) Get

func (v NullableString) Get() *string

Get returns the value associated with the nullable string.

func (NullableString) IsSet

func (v NullableString) IsSet() bool

IsSet returns true if the value has been set.

func (NullableString) MarshalJSON

func (v NullableString) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableString) Set

func (v *NullableString) Set(val *string)

Set sets the value associated with the nullable string.

func (*NullableString) UnmarshalJSON

func (v *NullableString) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableString) Unset

func (v *NullableString) Unset()

Unset resets fields of the nullable string.

type NullableTime

type NullableTime struct {
	// contains filtered or unexported fields
}

NullableTime is a struct to hold a nullable Time value.

func NewNullableTime

func NewNullableTime(val *time.Time) *NullableTime

NewNullableTime instantiates a new nullable Time.

func (NullableTime) Get

func (v NullableTime) Get() *time.Time

Get returns the value associated with the nullable Time.

func (NullableTime) IsSet

func (v NullableTime) IsSet() bool

IsSet returns true if the value has been set.

func (NullableTime) MarshalJSON

func (v NullableTime) MarshalJSON() ([]byte, error)

MarshalJSON serializes the associated value.

func (*NullableTime) Set

func (v *NullableTime) Set(val *time.Time)

Set sets the value associated with the nullable Time.

func (*NullableTime) UnmarshalJSON

func (v *NullableTime) UnmarshalJSON(src []byte) error

UnmarshalJSON deserializes to the associated value.

func (*NullableTime) Unset

func (v *NullableTime) Unset()

Unset resets fields of the nullable Time.

type PaginationResult added in v2.6.0

type PaginationResult[T any] struct {
	Item  T
	Error error
}

PaginationResult pagination item helper struct

type RetryConfiguration added in v2.11.0

type RetryConfiguration struct {
	EnableRetry       bool
	BackOffMultiplier float64
	BackOffBase       float64
	HTTPRetryTimeout  time.Duration
	MaxRetries        int
}

RetryConfiguration stores the configuration of the retry behavior of the api client

type ServerConfiguration

type ServerConfiguration struct {
	URL         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server.

type ServerConfigurations

type ServerConfigurations []ServerConfiguration

ServerConfigurations stores multiple ServerConfiguration items.

func (ServerConfigurations) URL

func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error)

URL formats template on a index using given variables.

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable.

type Service

type Service struct {
	Client *APIClient
}

Service holds APIClient

Jump to

Keyboard shortcuts

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