api

package
v0.56.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package api provides test helpers to interact with the Datadog API

Package api provides test helpers to interact with the Datadog API

Package api provides test helpers to interact with the Datadog API

Index

Constants

This section is empty.

Variables

View Source
var ErrNoLogFound = errors.New("no log found")

ErrNoLogFound is returned when no log is found

View Source
var ErrNoSignalFound = errors.New("no signal found")

ErrNoSignalFound is returned when no signal is found

Functions

func GetAppEvent added in v0.54.0

func GetAppEvent[T any, PT GetterFromPointer[T, *Event]](c *Client, query string) (*T, error)

GetAppEvent returns the last event matching the query

Types

type AgentContext added in v0.54.0

type AgentContext struct {
	RuleID string `json:"rule_id" mapstructure:"rule_id"`
	Origin string `json:"origin" mapstructure:"origin"`
}

AgentContext represents the context of an agent

type Attributes

type Attributes struct {
	Columns []Column `json:"columns"`
}

Attributes is a struct that represents the attributes of a data entry in a DDSQL table response

type Client

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

Client represents the datadog API context

func NewClient

func NewClient() *Client

NewClient initialise a client with the API and APP keys

func (*Client) CreateCWSAgentRule

func (c *Client) CreateCWSAgentRule(name string, msg string, secl string, filters []string) (*datadogV2.CloudWorkloadSecurityAgentRuleResponse, error)

CreateCWSAgentRule creates a cws agent rule

func (*Client) CreateCwsSignalRule

func (c *Client) CreateCwsSignalRule(name string, msg string, agentRuleID string, tags []string) (*datadogV2.SecurityMonitoringRuleResponse, error)

CreateCwsSignalRule creates a cws signal rule

func (*Client) DeleteAgentRule

func (c *Client) DeleteAgentRule(ruleID string) error

DeleteAgentRule deletes an agent rule

func (*Client) DeleteSignalRule

func (c *Client) DeleteSignalRule(ruleID string) error

DeleteSignalRule deletes a signal rule

func (*Client) GetSignal added in v0.54.0

GetSignal returns the last signal matching the query

func (*Client) QueryMetric added in v0.54.0

func (c *Client) QueryMetric(query string) (*datadogV1.MetricsQueryResponse, error)

QueryMetric queries the timeseries using the specified query

func (*Client) TableQuery added in v0.54.0

func (c *Client) TableQuery(query string) (*DDSQLTableResponse, error)

TableQuery executes a DDSQL query, returning a DDSQL table response

type Column

type Column struct {
	Name   string        `json:"name"`
	Type   string        `json:"type"`
	Values []interface{} `json:"values"`
}

Column is a struct that represents a column of a data entry in a DDSQL table response

type DDSQLTableQueryParams

type DDSQLTableQueryParams struct {
	DefaultStart    int    `json:"default_start"`
	DefaultEnd      int    `json:"default_end"`
	DefaultInterval int    `json:"default_interval"`
	Query           string `json:"query"`
}

DDSQLTableQueryParams is a struct that represents a DDSQL table query

type DDSQLTableResponse

type DDSQLTableResponse struct {
	Data []DataEntry `json:"data"`
}

DDSQLTableResponse is a struct that represents a DDSQL table response

type DataEntry

type DataEntry struct {
	Type       string     `json:"type"`
	Attributes Attributes `json:"attributes"`
}

DataEntry is a struct that represents a data entry in a DDSQL table response

type Event added in v0.54.0

type Event struct {
	Tags []string `json:"-" mapstructure:"-"`
	// log       *datadogV2.LogAttributes `json:"-" mapstructure:"-"`
	Agent AgentContext `json:"agent" mapstructure:"agent"`
	// contains filtered or unexported fields
}

Event represents a cws event

func (*Event) MarshalJSON added in v0.54.0

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON marshals the event to JSON

type Evt added in v0.54.0

type Evt struct {
	Name string `json:"name" mapstructure:"name"`
}

Evt contains information about a rule event

type File added in v0.54.0

type File struct {
	Path string `json:"path" mapstructure:"path"`
}

File represents a file

type GetterFromPointer added in v0.54.0

type GetterFromPointer[T any, E any] interface {
	*T
	Get() E
}

GetterFromPointer is a type constraint for log-based events

type JSONAPIPayload added in v0.52.1

type JSONAPIPayload[Attr any] struct {
	Data JSONAPIPayloadData[Attr] `json:"data"`
}

JSONAPIPayload is a struct that represents the body of a JSON API request

type JSONAPIPayloadData added in v0.52.1

type JSONAPIPayloadData[Attr any] struct {
	Type      string `json:"type"`
	Attribute Attr   `json:"attributes"`
}

JSONAPIPayloadData is a struct that represents the data field of a JSON API request

type Policy added in v0.54.0

type Policy struct {
	Name   string `json:"name" mapstructure:"name"`
	Source string `json:"source" mapstructure:"source"`
}

Policy represents a policy

type Process added in v0.54.0

type Process struct {
	Executable File `json:"executable" mapstructure:"executable"`
}

Process represents a process

type RuleEvent added in v0.54.0

type RuleEvent struct {
	Event   `mapstructure:",squash"`
	Evt     `json:"evt" mapstructure:"evt"`
	Process Process `json:"process" mapstructure:"process"`
	File    File    `json:"file" mapstructure:"file"`
}

RuleEvent represents a rule event

func (*RuleEvent) Get added in v0.54.0

func (e *RuleEvent) Get() *Event

Get implements the GetterFromPointer interface

type RulesetLoadedEvent added in v0.54.0

type RulesetLoadedEvent struct {
	Event    `mapstructure:",squash"`
	Policies []Policy `json:"policies" mapstructure:"policies"`
}

RulesetLoadedEvent represents a ruleset loaded event

func (*RulesetLoadedEvent) ContainsPolicy added in v0.54.0

func (e *RulesetLoadedEvent) ContainsPolicy(policySource string, policyName string) bool

ContainsPolicy checks if a policy, given its source and name, is contained in the ruleset loaded event

func (*RulesetLoadedEvent) Get added in v0.54.0

func (e *RulesetLoadedEvent) Get() *Event

Get implements the GetterFromPointer interface

type SelftestsEvent added in v0.54.0

type SelftestsEvent struct {
	Event          `mapstructure:",squash"`
	SucceededTests []string `json:"succeeded_tests" mapstructure:"succeeded_tests"`
	FailedTests    []string `json:"failed_tests" mapstructure:"failed_tests"`
}

SelftestsEvent represents a selftests event

func (*SelftestsEvent) Get added in v0.54.0

func (e *SelftestsEvent) Get() *Event

Get implements the GetterFromPointer interface

Jump to

Keyboard shortcuts

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