table

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package table manages all of the Dynamo calls (query, scan, get, write, etc).

Index

Constants

View Source
const (
	RuleIDKey            = "ruleId"
	AlertIDKey           = "id"
	CreatedAtKey         = "creationTime"
	TimePartitionKey     = "timePartition"
	TimePartitionValue   = "defaultPartition"
	TitleKey             = "title"
	SeverityKey          = "severity"
	EventCountKey        = "eventCount"
	StatusKey            = "status"
	LogTypesKey          = "logTypes"
	ResourceTypesKey     = "resourceTypes"
	DeliveryResponsesKey = "deliveryResponses"
	LastUpdatedByKey     = "lastUpdatedBy"
	LastUpdatedByTimeKey = "lastUpdatedByTime"
	TypeKey              = "type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetAlert(string) (*AlertItem, error)
	ListAll(*models.ListAlertsInput) ([]*AlertItem, *string, error)
	UpdateAlertStatus(*models.UpdateAlertStatusInput) ([]*AlertItem, error)
	UpdateAlertDelivery(*models.UpdateAlertDeliveryInput) (*AlertItem, error)
}

API defines the interface for the alerts table which can be used for mocking.

type AlertItem added in v1.0.0

type AlertItem struct {
	AlertID             string                     `json:"id"`
	Type                string                     `json:"type"`
	RuleID              string                     `json:"ruleId"`
	RuleVersion         string                     `json:"ruleVersion"`
	RuleDisplayName     *string                    `json:"ruleDisplayName"`
	Title               string                     `json:"title"`
	Description         *string                    `json:"description"`
	Reference           *string                    `json:"reference"`
	Runbook             *string                    `json:"runbook"`
	Destinations        []string                   `json:"destinations,omitempty" validate:"dive,uuid4"`
	DedupString         string                     `json:"dedup"`
	FirstEventMatchTime time.Time                  `json:"firstEventMatchTime"`
	CreationTime        time.Time                  `json:"creationTime"`
	DeliveryResponses   []*models.DeliveryResponse `json:"deliveryResponses"`
	// UpdateTime - stores the timestamp from an update from a dedup event
	UpdateTime time.Time `json:"updateTime"`
	Severity   string    `json:"severity"`
	Status     string    `json:"status"`
	EventCount int       `json:"eventCount"`
	LogTypes   []string  `json:"logTypes"`
	// LastUpdatedBy - stores the UserID of the last person who modified the Alert
	LastUpdatedBy string `json:"lastUpdatedBy"`
	// LastUpdatedByTime - stores the timestamp of the last person who modified the Alert
	LastUpdatedByTime time.Time `json:"lastUpdatedByTime"`
	// Policy related fields
	PolicyID          string   `json:"policyId"`
	PolicyDisplayName string   `json:"policyDisplayName"`
	PolicySourceID    string   `json:"policySourceId"`
	PolicyVersion     string   `json:"policyVersion"`
	ResourceTypes     []string `json:"resourceTypes"`
	ResourceID        string   `json:"resourceId"`
}

AlertItem is a DDB representation of an Alert

type AlertsTable

type AlertsTable struct {
	AlertsTableName                    string
	RuleIDCreationTimeIndexName        string
	TimePartitionCreationTimeIndexName string
	Client                             dynamodbiface.DynamoDBAPI
}

AlertsTable encapsulates a connection to the Dynamo alerts table.

func (*AlertsTable) GetAlert

func (table *AlertsTable) GetAlert(alertID string) (*AlertItem, error)

GetAlert retrieve a AlertItem from DDB

func (*AlertsTable) ListAll added in v0.1.1

func (table *AlertsTable) ListAll(input *models.ListAlertsInput) (
	summaries []*AlertItem, lastEvaluatedKey *string, err error)

ListAll - lists all alerts and apply filtering, sorting logic

func (*AlertsTable) UpdateAlertDelivery added in v1.8.0

func (table *AlertsTable) UpdateAlertDelivery(input *models.UpdateAlertDeliveryInput) (*AlertItem, error)

UpdateAlertDelivery - updates the alert details and returns the updated item

func (*AlertsTable) UpdateAlertStatus added in v1.6.0

func (table *AlertsTable) UpdateAlertStatus(input *models.UpdateAlertStatusInput) ([]*AlertItem, error)

UpdateAlertStatus - updates a list of alerts to a specified status and returns the updated list

type AlertsTableEnvConfig added in v1.12.0

type AlertsTableEnvConfig struct {
	// env config for instantiating a table.AlertsTable
	AlertsTableName     string `required:"true" split_words:"true"`
	AlertsRuleIndexName string `required:"true" split_words:"true"`
	AlertsTimeIndexName string `required:"true" split_words:"true"`
}

func (*AlertsTableEnvConfig) NewAlertsTable added in v1.12.0

func (config *AlertsTableEnvConfig) NewAlertsTable(client dynamodbiface.DynamoDBAPI) *AlertsTable

type DynamoItem

type DynamoItem = map[string]*dynamodb.AttributeValue

DynamoItem is a type alias for the item format expected by the Dynamo SDK.

Jump to

Keyboard shortcuts

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