client

package
v0.0.0-...-61a96ab Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidDashboard is returned if the passed dashboard object is invalid.
	ErrInvalidDashboard = errors.New("invalid dashboard")

	// ErrInvalidMonitor is returned if the passed monitor object is invalid.
	ErrInvalidMonitor = errors.New("invalid monitor")

	// ErrInvalidDowntime is returned if the passed downtime object is invalid.
	ErrInvalidDowntime = errors.New("invalid downtime")

	// ErrInvalidScreenboard is returned if the passed screen board object is invalid.
	ErrInvalidScreenboard = errors.New("invalid screenboard")

	// ErrInvalidAlert s returned if the passed alert object in invalid.
	ErrInvalidAlert = errors.New("invalid alert")
)

Functions

This section is empty.

Types

type Client

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

Client represents a datadog API.

func New

func New(apiKey, appKey string, opts ...Option) (*Client, error)

New returns an datadog client.

func (Client) GetAlert

func (c Client) GetAlert(id int) (json.RawMessage, error)

GetAlert returns an alert with a given ID.

func (Client) GetAlerts

func (c Client) GetAlerts() (json.RawMessage, error)

GetAlerts returns a list of alerts.

func (Client) GetDashboard

func (c Client) GetDashboard(id int) (json.RawMessage, error)

GetDashboard returns a raw json of dashboard.

func (Client) GetDashboards

func (c Client) GetDashboards() (DashboardsResponse, error)

GetDashboards returns a list of dashboards.

func (Client) GetDowntime

func (c Client) GetDowntime(id int) (json.RawMessage, error)

GetDowntime returns a downtime

func (Client) GetDowntimes

func (c Client) GetDowntimes() (Downtimes, error)

GetDowntimes returns a downtimes

func (Client) GetMonitor

func (c Client) GetMonitor(id int) (json.RawMessage, error)

GetMonitor returns a monitor by ID

func (Client) GetMonitorWithDependencies

func (c Client) GetMonitorWithDependencies(id int, includeDowntime bool) (*MonitorWithDependencies, error)

GetMonitorWithDependencies returns a monitor with dependencies.

func (Client) GetMonitors

func (c Client) GetMonitors() (MonitorsResponse, error)

GetMonitors returns a list of all monitors.

func (Client) GetScreenboard

func (c Client) GetScreenboard(id int) (json.RawMessage, error)

GetScreenboard returns a raw json representation of a screen board.

func (Client) GetScreenboards

func (c Client) GetScreenboards() (ScreenBoardsResponse, error)

GetScreenboards returns a json raw message response from calling /api/v1/dash

func (Client) UpdateAlert

func (c Client) UpdateAlert(alert json.RawMessage) error

UpdateAlert updates an alert from raw message.

func (Client) UpdateDashboard

func (c Client) UpdateDashboard(dash json.RawMessage) error

UpdateDashboard updates the dashboard from json raw message.

func (Client) UpdateDowntime

func (c Client) UpdateDowntime(downtime json.RawMessage) error

UpdateDowntime updates a downtime.

func (Client) UpdateMonitor

func (c Client) UpdateMonitor(monitor json.RawMessage) error

UpdateMonitor updates a monitor from raw message.

func (Client) UpdateMonitorWithDependencies

func (c Client) UpdateMonitorWithDependencies(m *MonitorWithDependencies) error

UpdateMonitorWithDependencies will update the dashboard and dependencies.

func (Client) UpdateScreenboard

func (c Client) UpdateScreenboard(screen json.RawMessage) error

UpdateScreenboard updates the screen board from a given raw json message.

type Component

type Component string

Component stands for datadog component.

type DashboardsResponse

type DashboardsResponse json.RawMessage

DashboardsResponse represents a response by GetDashboards method.

func (DashboardsResponse) GetModifiedIDsWithin

func (dr DashboardsResponse) GetModifiedIDsWithin(interval time.Duration, fn func(time.Time) time.Duration) ([]int, error)

GetModifiedIDsWithin returns a list of IDs that were modified within the given interval.

type Downtime

type Downtime struct {
	MonitorID int    `json:"monitor_id"`
	OrgID     int    `json:"org_id"`
	Disabled  bool   `json:"disabled"`
	Start     uint64 `json:"start"`
	End       uint64 `json:"end"`
	CreatorID int    `json:"creator_id"`
	ID        int    `json:"id"`
	UpdaterID int    `json:"updater_id"`
	Message   string `json:"message"`
}

Downtime represents a downtime structure

type Downtimes

type Downtimes []*Downtime

Downtimes is a list of downtimes

func (Downtimes) GetByMonitorID

func (d Downtimes) GetByMonitorID(id int) *Downtime

GetByMonitorID returns a downtime by a monitor ID.

type MonitorWithDependencies

type MonitorWithDependencies struct {
	Monitor  json.RawMessage `json:"monitor"`
	Alert    json.RawMessage `json:"alert"`
	Downtime json.RawMessage `json:"downtime"`
}

MonitorWithDependencies represents a monitor with dependencies like Alert and Downtime.

type MonitorsResponse

type MonitorsResponse json.RawMessage

MonitorsResponse represents a response from calling /api/v1/monitor endpoint

func (MonitorsResponse) GetModifiedIDsWithin

func (mr MonitorsResponse) GetModifiedIDsWithin(interval time.Duration, fn func(time.Time) time.Duration) ([]int, error)

GetModifiedIDsWithin returns a list of monitor IDs if the modified field was changes within the given interval.

type Option

type Option func(c *Client) error

Option is a functional parameter for datadog client.

func WithRemoveDashboardFields

func WithRemoveDashboardFields(fields []string) Option

WithRemoveDashboardFields sets fields to be removed from a dashboard response. Nested fields are supported via comma for example (dash.modified) will remove the modified field from a nested dict under "dash" endpoint /api/v1/dash/<id>

func WithRemoveMonitorFields

func WithRemoveMonitorFields(monitorFields, alertFields []string) Option

WithRemoveMonitorFields sets fields to be removed from monitor response. endpoint /api/v1/monitor/<id>

func WithRemoveScreenBoardFields

func WithRemoveScreenBoardFields(fields []string) Option

WithRemoveScreenBoardFields sets fields to be removed from screen board response. endpoint /api/v1/screen/<id>

type ScreenBoardsResponse

type ScreenBoardsResponse json.RawMessage

ScreenBoardsResponse represents a response from calling /api/v1/dash endpoint

func (ScreenBoardsResponse) GetModifiedIDsWithin

func (sr ScreenBoardsResponse) GetModifiedIDsWithin(interval time.Duration, fn func(time.Time) time.Duration) ([]int, error)

GetModifiedIDsWithin returns a list of screen board IDs if the modified field was changes within the given interval.

Jump to

Keyboard shortcuts

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