logtypesapi

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Code generated by apigen; DO NOT EDIT.

Index

Constants

View Source
const (
	// ErrRevisionConflict is the error code to use when there is a revision conflict
	ErrRevisionConflict = "RevisionConflict"
	ErrAlreadyExists    = "AlreadyExists"
	ErrNotFound         = "NotFound"
	ErrInUse            = "InUse"
	ErrInvalidUpdate    = "InvalidUpdate"
	ErrInvalidMetadata  = "InvalidMetadata"
	ErrInvalidSyntax    = "InvalidSyntax"
	ErrInvalidLogSchema = "InvalidLogSchema"
	ErrServerError      = "ServerError"
)
View Source
const LambdaName = "panther-logtypes-api"

Variables

Functions

This section is empty.

Types

type APIError added in v1.15.0

type APIError struct {
	Code    string `json:"code" validate:"required"`
	Message string `json:"message" validate:"required"`
	// contains filtered or unexported fields
}

APIError is an error that has a code and a message and is returned as part of the API response

func AsAPIError added in v1.15.0

func AsAPIError(err error) *APIError

func NewAPIError added in v1.15.0

func NewAPIError(code, message string) *APIError

NewAPIError creates a new API error

func WrapAPIError added in v1.15.0

func WrapAPIError(err error) *APIError

func (*APIError) Error added in v1.15.0

func (e *APIError) Error() string

Error implements error interface

func (*APIError) Unwrap added in v1.15.0

func (e *APIError) Unwrap() error

type AvailableLogTypes

type AvailableLogTypes struct {
	LogTypes []string `json:"logTypes"`
}

type CustomLog added in v1.15.0

type CustomLog struct {
	Description  string `json:"description" description:"Log type description"`
	ReferenceURL string `json:"referenceURL" description:"A URL with reference docs for the log type"`
	LogSpec      string `json:"logSpec" validate:"required" description:"The log spec in YAML or JSON format"`
}

type CustomLogRecord added in v1.15.0

type CustomLogRecord struct {
	LogType   string    `json:"logType" validate:"required,startswith=Custom." description:"The log type id"`
	Revision  int64     `json:"revision" validate:"required,min=1" description:"Log record revision"`
	UpdatedAt time.Time `json:"updatedAt" description:"Last update timestamp of the record"`
	CustomLog
}

CustomLogRecord is a stored record for a custom log type

type DelCustomLogInput added in v1.15.0

type DelCustomLogInput struct {
	LogType  string `json:"logType" validate:"required,startswith=Custom." description:"The log type id"`
	Revision int64  `json:"revision" validate:"min=1" description:"Log record revision"`
}

type DelCustomLogOutput added in v1.15.0

type DelCustomLogOutput struct {
	Error *APIError `json:"error,omitempty" description:"The delete record"`
}

type DeletedCustomLogs added in v1.15.0

type DeletedCustomLogs struct {
	LogTypes []string  `json:"logTypes,omitempty" description:"A list of ids of deleted log types (omitted if an error occurred)"`
	Error    *APIError `json:"error,omitempty" description:"An error that occurred while fetching the list"`
}

type DynamoDBLogTypes

type DynamoDBLogTypes struct {
	DB        dynamodbiface.DynamoDBAPI
	TableName string
}

DynamoDBLogTypes provides logtypes api actions for DDB

func (*DynamoDBLogTypes) BatchGetCustomLogs added in v1.15.0

func (d *DynamoDBLogTypes) BatchGetCustomLogs(ctx context.Context, ids ...string) ([]*CustomLogRecord, error)

func (*DynamoDBLogTypes) CreateCustomLog added in v1.15.0

func (d *DynamoDBLogTypes) CreateCustomLog(ctx context.Context, id string, params *CustomLog) (*CustomLogRecord, error)

func (*DynamoDBLogTypes) DeleteCustomLog added in v1.15.0

func (d *DynamoDBLogTypes) DeleteCustomLog(ctx context.Context, id string, revision int64) error

func (*DynamoDBLogTypes) GetCustomLog added in v1.15.0

func (d *DynamoDBLogTypes) GetCustomLog(ctx context.Context, id string, revision int64) (*CustomLogRecord, error)

func (*DynamoDBLogTypes) IndexLogTypes

func (d *DynamoDBLogTypes) IndexLogTypes(ctx context.Context) ([]string, error)

func (*DynamoDBLogTypes) ListDeletedLogTypes added in v1.15.0

func (d *DynamoDBLogTypes) ListDeletedLogTypes(ctx context.Context) ([]string, error)

func (*DynamoDBLogTypes) UpdateCustomLog added in v1.15.0

func (d *DynamoDBLogTypes) UpdateCustomLog(ctx context.Context, id string, revision int64, params *CustomLog) (*CustomLogRecord, error)

type ErrorReply added in v1.15.0

type ErrorReply struct {
	Error *APIError `json:"error"`
}

type GetCustomLogInput added in v1.15.0

type GetCustomLogInput struct {
	LogType  string `json:"logType" validate:"required,startswith=Custom." description:"The log type id"`
	Revision int64  `json:"revision,omitempty" validate:"omitempty,min=1" description:"Log record revision (0 means latest)"`
}

GetCustomLogInput specifies the log type id and revision to retrieve. Zero Revision will get the latest revision of the log type record

type GetCustomLogOutput added in v1.15.0

type GetCustomLogOutput struct {
	Result *CustomLogRecord `json:"record,omitempty" description:"The custom log record (field omitted if an error occurred)"`
	Error  *APIError        `json:"error,omitempty" description:"An error that occurred while fetching the record"`
}

type InMemDB added in v1.15.0

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

InMemDB is an in-memory implementation of the LogTypesDatabase. It is useful for tests and for caching results of another implementation.

func NewInMemory added in v1.15.0

func NewInMemory() *InMemDB

func (*InMemDB) BatchGetCustomLogs added in v1.15.0

func (db *InMemDB) BatchGetCustomLogs(ctx context.Context, ids ...string) ([]*CustomLogRecord, error)

func (*InMemDB) CreateCustomLog added in v1.15.0

func (db *InMemDB) CreateCustomLog(_ context.Context, id string, params *CustomLog) (*CustomLogRecord, error)

func (*InMemDB) DeleteCustomLog added in v1.15.0

func (db *InMemDB) DeleteCustomLog(_ context.Context, id string, revision int64) error

func (*InMemDB) GetCustomLog added in v1.15.0

func (db *InMemDB) GetCustomLog(_ context.Context, id string, revision int64) (*CustomLogRecord, error)

func (*InMemDB) IndexLogTypes added in v1.15.0

func (db *InMemDB) IndexLogTypes(_ context.Context) ([]string, error)

func (*InMemDB) ListDeletedLogTypes added in v1.15.0

func (db *InMemDB) ListDeletedLogTypes(ctx context.Context) ([]string, error)

func (*InMemDB) UpdateCustomLog added in v1.15.0

func (db *InMemDB) UpdateCustomLog(_ context.Context, id string, revision int64, params *CustomLog) (*CustomLogRecord, error)

type ListCustomLogsOutput added in v1.15.0

type ListCustomLogsOutput struct {
	CustomLogs []*CustomLogRecord `json:"customLogs" description:"Custom log records stored"`
	Error      *APIError          `json:"error,omitempty" description:"An error that occurred during the operation"`
}

type LogTypesAPI

type LogTypesAPI struct {
	NativeLogTypes    func() []string
	Database          LogTypesDatabase
	UpdateDataCatalog func(ctx context.Context, logType string, from, to []logschema.FieldSchema) error
	// FIXME: Rename to LogTypesInUse
	LogTypeInUse func(ctx context.Context) ([]string, error)
}

LogTypesAPI handles the business logic of log types LogTypesAPI

func (*LogTypesAPI) DelCustomLog added in v1.15.0

func (api *LogTypesAPI) DelCustomLog(ctx context.Context, input *DelCustomLogInput) (*DelCustomLogOutput, error)

func (*LogTypesAPI) GetCustomLog added in v1.15.0

func (api *LogTypesAPI) GetCustomLog(ctx context.Context, input *GetCustomLogInput) (*GetCustomLogOutput, error)

GetCustomLog gets a custom log record for the specified id and revision

func (*LogTypesAPI) ListAvailableLogTypes

func (api *LogTypesAPI) ListAvailableLogTypes(ctx context.Context) (*AvailableLogTypes, error)

ListAvailableLogTypes lists all available log type ids

func (*LogTypesAPI) ListCustomLogs added in v1.15.0

func (api *LogTypesAPI) ListCustomLogs(ctx context.Context) (*ListCustomLogsOutput, error)

func (*LogTypesAPI) ListDeletedCustomLogs added in v1.15.0

func (api *LogTypesAPI) ListDeletedCustomLogs(ctx context.Context) (*DeletedCustomLogs, error)

ListDeletedCustomLogs lists all deleted log type ids

func (*LogTypesAPI) PutCustomLog added in v1.15.0

func (api *LogTypesAPI) PutCustomLog(ctx context.Context, input *PutCustomLogInput) (*PutCustomLogOutput, error)

type LogTypesAPILambdaClient

type LogTypesAPILambdaClient struct {
	LambdaName string
	LambdaAPI  lambdaiface.LambdaAPI
	Validate   func(interface{}) error
	JSON       jsoniter.API
}

LogTypesAPILambdaClient implements LogTypesAPI by invoking a Lambda

func (*LogTypesAPILambdaClient) DelCustomLog added in v1.15.0

func (*LogTypesAPILambdaClient) GetCustomLog added in v1.15.0

func (*LogTypesAPILambdaClient) ListAvailableLogTypes

func (c *LogTypesAPILambdaClient) ListAvailableLogTypes(ctx context.Context) (*AvailableLogTypes, error)

func (*LogTypesAPILambdaClient) ListCustomLogs added in v1.15.0

func (*LogTypesAPILambdaClient) ListDeletedCustomLogs added in v1.15.0

func (c *LogTypesAPILambdaClient) ListDeletedCustomLogs(ctx context.Context) (*DeletedCustomLogs, error)

func (*LogTypesAPILambdaClient) PutCustomLog added in v1.15.0

type LogTypesAPIPayload

type LogTypesAPIPayload struct {
	ListAvailableLogTypes *struct{}          `json:"ListAvailableLogTypes,omitempty"`
	ListDeletedCustomLogs *struct{}          `json:"ListDeletedCustomLogs,omitempty"`
	GetCustomLog          *GetCustomLogInput `json:"GetCustomLog,omitempty"`
	PutCustomLog          *PutCustomLogInput `json:"PutCustomLog,omitempty"`
	DelCustomLog          *DelCustomLogInput `json:"DelCustomLog,omitempty"`
	ListCustomLogs        *struct{}          `json:"ListCustomLogs,omitempty"`
}

type LogTypesDatabase

type LogTypesDatabase interface {
	// Return an index of available log types
	IndexLogTypes(ctx context.Context) ([]string, error)
	// Create a new custom log record
	CreateCustomLog(ctx context.Context, id string, params *CustomLog) (*CustomLogRecord, error)
	// Get a single custom log record
	GetCustomLog(ctx context.Context, id string, revision int64) (*CustomLogRecord, error)
	// Update a custom log record
	UpdateCustomLog(ctx context.Context, id string, currentRevision int64, params *CustomLog) (*CustomLogRecord, error)
	// Delete a custom log record
	DeleteCustomLog(ctx context.Context, id string, currentRevision int64) error
	// Get multiple custom log records at their latest revision
	BatchGetCustomLogs(ctx context.Context, ids ...string) ([]*CustomLogRecord, error)
	// List deleted log types
	ListDeletedLogTypes(ctx context.Context) ([]string, error)
}

LogTypesDatabase handles the external actions required for LogTypesAPI to be implemented

type PutCustomLogInput added in v1.15.0

type PutCustomLogInput struct {
	LogType string `json:"logType" validate:"required,startswith=Custom." description:"The log type id"`
	// Revision is required when updating a custom log record.
	// If  is omitted a new custom log record will be created.
	Revision int64 `` /* 145-byte string literal not displayed */
	CustomLog
}

nolint:lll

type PutCustomLogOutput added in v1.15.0

type PutCustomLogOutput struct {
	Result *CustomLogRecord `json:"record,omitempty" description:"The modified record (field is omitted if an error occurred)"`
	Error  *APIError        `json:"error,omitempty" description:"An error that occurred during the operation"`
}

type Resolver added in v1.15.0

type Resolver struct {
	LogTypesAPI *LogTypesAPILambdaClient
}

Resolver resolves a custom log type using the API

func (*Resolver) Resolve added in v1.15.0

func (r *Resolver) Resolve(ctx context.Context, name string) (logtypes.Entry, error)

Resolve implements logtypes.Resolver

Directories

Path Synopsis
Package ddbextras provides a builder for DynamoDB transactions.
Package ddbextras provides a builder for DynamoDB transactions.

Jump to

Keyboard shortcuts

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