client

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthTypeDescription added in v0.11.0

func GetAuthTypeDescription(authType AuthType) string

GetAuthTypeDescription returns a human-readable description of the auth type

func RequiresAPIKeyFallback added in v0.11.0

func RequiresAPIKeyFallback(method, path string) bool

RequiresAPIKeyFallback returns true if the endpoint doesn't support OAuth and we need to fallback to API keys even if OAuth is available

func ValidateEndpointAuth added in v0.11.0

func ValidateEndpointAuth(ctx context.Context, cfg *config.Config, method, path string) error

ValidateEndpointAuth checks if the endpoint can be accessed with the current authentication Returns an error if: 1. The endpoint doesn't support OAuth but only OAuth is available 2. The endpoint requires API keys but they're not configured

Types

type AuthType added in v0.11.0

type AuthType int

AuthType represents the type of authentication being used

const (
	AuthTypeNone AuthType = iota
	AuthTypeOAuth
	AuthTypeAPIKeys
)

func GetAuthType added in v0.11.0

func GetAuthType(ctx context.Context) AuthType

GetAuthType returns the authentication type from the context

type Client

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

Client wraps the Datadog API client

func New

func New(cfg *config.Config) (*Client, error)

New creates a new Datadog API client Authentication priority:

  1. OAuth2 tokens (if available and valid)
  2. API keys (DD_API_KEY and DD_APP_KEY)

func NewWithAPIKeys added in v0.11.0

func NewWithAPIKeys(cfg *config.Config) (*Client, error)

NewWithAPIKeys creates a new Datadog API client forcing API key authentication This is used for endpoints that don't support OAuth2

func NewWithOptions added in v0.11.0

func NewWithOptions(cfg *config.Config, forceAPIKeys bool) (*Client, error)

NewWithOptions creates a new Datadog API client with authentication options

func (*Client) API

func (c *Client) API() *datadog.APIClient

API returns the API client

func (*Client) Config

func (c *Client) Config() *config.Config

Config returns the client configuration

func (*Client) Context

func (c *Client) Context() context.Context

Context returns the client context

func (*Client) GetAuthType added in v0.11.0

func (c *Client) GetAuthType() AuthType

GetAuthType returns the type of authentication being used by this client

func (*Client) RawRequest

func (c *Client) RawRequest(method, path string, body io.Reader) (*http.Response, error)

RawRequest makes an HTTP request with proper authentication headers. This is used for APIs not covered by the typed datadog-api-client-go library.

func (*Client) V1

func (c *Client) V1() *datadog.APIClient

V1 returns the v1 API client

func (*Client) V2

func (c *Client) V2() *datadog.APIClient

V2 returns the v2 API client

func (*Client) ValidateEndpointAuth added in v0.11.0

func (c *Client) ValidateEndpointAuth(method, path string) error

ValidateEndpointAuth checks if the current authentication is compatible with the endpoint

type EndpointAuthRequirement added in v0.11.0

type EndpointAuthRequirement struct {
	Path            string
	Method          string
	SupportsOAuth   bool
	RequiresAPIKeys bool
	Reason          string
}

EndpointAuthRequirement defines authentication requirements for API endpoints

Jump to

Keyboard shortcuts

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