logtypesapi

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: 27 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"
	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 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 DynamoDBSchemas added in v1.16.0

type DynamoDBSchemas struct {
	DB        dynamodbiface.DynamoDBAPI
	TableName string
}

DynamoDBSchemas provides logtypes api actions for DDB

func (*DynamoDBSchemas) GetSchema added in v1.16.0

func (d *DynamoDBSchemas) GetSchema(ctx context.Context, id string) (*SchemaRecord, error)

func (*DynamoDBSchemas) PutSchema added in v1.16.0

func (d *DynamoDBSchemas) PutSchema(ctx context.Context, id string, record *SchemaRecord) (*SchemaRecord, error)

nolint:lll

func (*DynamoDBSchemas) ScanSchemas added in v1.16.0

func (d *DynamoDBSchemas) ScanSchemas(ctx context.Context, scan ScanSchemaFunc) 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"`
}

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 *SchemaRecord `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 GetSchemaInput added in v1.16.0

type GetSchemaInput struct {
	Name string `json:"name" validate:"required" description:"The schema id"`
}

GetSchemaInput specifies the schema id and revision to retrieve. Zero Revision will get the latest revision of the schema record

type GetSchemaOutput added in v1.16.0

type GetSchemaOutput struct {
	Record *SchemaRecord `json:"record,omitempty" description:"The schema 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 SchemaDatabase. It is useful for tests and for caching results of another implementation.

func NewInMemory added in v1.15.0

func NewInMemory() *InMemDB

func (*InMemDB) GetSchema added in v1.16.0

func (db *InMemDB) GetSchema(_ context.Context, id string) (*SchemaRecord, error)

func (*InMemDB) PutSchema added in v1.16.0

func (db *InMemDB) PutSchema(_ context.Context, name string, r *SchemaRecord) (*SchemaRecord, error)

func (*InMemDB) ScanSchemas added in v1.16.0

func (db *InMemDB) ScanSchemas(_ context.Context, scan ScanSchemaFunc) error

type ListCustomLogsOutput added in v1.15.0

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

type ListManagedSchemaUpdatesInput added in v1.16.0

type ListManagedSchemaUpdatesInput struct{}

type ListManagedSchemaUpdatesOutput added in v1.16.0

type ListManagedSchemaUpdatesOutput struct {
	Releases *[]managedschemas.Release `json:"releases,omitempty" description:"Available release updates"`
	Error    *APIError                 `json:"error,omitempty" description:"An error that occurred while fetching the record"`
}

type LogTypesAPI

type LogTypesAPI struct {
	Database          SchemaDatabase
	UpdateDataCatalog func(ctx context.Context, logType string, from, to []logschema.FieldSchema) error
	LogTypesInUse     func(ctx context.Context) ([]string, error)
	ManagedSchemas    managedschemas.ReleaseFeeder
}

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) GetSchema added in v1.16.0

func (api *LogTypesAPI) GetSchema(ctx context.Context, input *GetSchemaInput) (*GetSchemaOutput, error)

GetSchema gets a schema record

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) ListManagedSchemaUpdates added in v1.16.0

nolint:lll

func (*LogTypesAPI) PutCustomLog added in v1.15.0

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

func (*LogTypesAPI) UpdateManagedSchemas added in v1.16.0

func (api *LogTypesAPI) UpdateManagedSchemas(ctx context.Context, input *UpdateManagedSchemasInput) (*UpdateManagedSchemasOutput, 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) GetSchema added in v1.16.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) ListManagedSchemaUpdates added in v1.16.0

func (*LogTypesAPILambdaClient) PutCustomLog added in v1.15.0

func (*LogTypesAPILambdaClient) UpdateManagedSchemas added in v1.16.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"`
	ListManagedSchemaUpdates *ListManagedSchemaUpdatesInput `json:"ListManagedSchemaUpdates,omitempty"`
	UpdateManagedSchemas     *UpdateManagedSchemasInput     `json:"UpdateManagedSchemas,omitempty"`
	GetSchema                *GetSchemaInput                `json:"GetSchema,omitempty"`
}

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 */
	Description  string `json:"description" description:"Log type description"`
	ReferenceURL string `json:"referenceURL" description:"A URL with reference docs for the schema"`
	// For compatibility we use 'logSpec' as the JSON and DDB field names
	Spec string `json:"logSpec" dynamodbav:"logSpec" validate:"required" description:"The schema spec in YAML or JSON format"`
}

nolint:lll

type PutCustomLogOutput added in v1.15.0

type PutCustomLogOutput struct {
	Result *SchemaRecord `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
	NativeLogTypes logtypes.Finder
}

Resolver resolves a log type entry 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

type ScanSchemaFunc added in v1.16.0

type ScanSchemaFunc func(r *SchemaRecord) bool

type SchemaDatabase added in v1.16.0

type SchemaDatabase interface {
	// GetSchema gets a single schema record
	GetSchema(ctx context.Context, id string) (*SchemaRecord, error)
	// PutSchema puts a single schema record
	PutSchema(ctx context.Context, id string, record *SchemaRecord) (*SchemaRecord, error)
	// ScanSchemas iterates through all schema records as long as scan returns true
	ScanSchemas(ctx context.Context, scan ScanSchemaFunc) error
}

SchemaDatabase handles the external actions required for LogTypesAPI to be implemented

type SchemaRecord added in v1.16.0

type SchemaRecord struct {
	// For compatibility we use 'logType' as the DDB field name
	Name      string    `json:"logType" dynamodbav:"logType" validate:"required" description:"The schema id"`
	Revision  int64     `json:"revision" validate:"required,min=1" description:"Schema record revision"`
	Release   string    `json:"release,omitempty" description:"Managed schema release version"`
	UpdatedAt time.Time `json:"updatedAt" description:"Last update timestamp of the record"`
	CreatedAt time.Time `json:"createdAt" description:"Creation timestamp of the record"`
	Managed   bool      `json:"managed,omitempty" description:"Schema is managed by Panther"`
	// For compatibility we use 'IsDeleted' as the DDB field name
	Disabled     bool   `json:"disabled,omitempty" dynamodbav:"IsDeleted"  description:"Log record is deleted"`
	Description  string `json:"description" description:"Log type description"`
	ReferenceURL string `json:"referenceURL" description:"A URL with reference docs for the schema"`
	// For compatibility we use 'logSpec' as the JSON and DDB field names
	Spec string `json:"logSpec" dynamodbav:"logSpec" validate:"required" description:"The schema spec in YAML or JSON format"`
}

SchemaRecord describes a stored schema.

A SchemaRecord can either be managed or user-defined. Managed schema records have their Managed field set to `true` and include a version tag in Release field. User-defined schema records have Managed and Release fields missing.

func (*SchemaRecord) IsCustom added in v1.16.0

func (r *SchemaRecord) IsCustom() bool

IsCustom checks the schema record name to determine if it is for a user-defined schema

func (*SchemaRecord) IsManaged added in v1.16.0

func (r *SchemaRecord) IsManaged() bool

IsManaged checks if a schema record is managed by Panther

type UpdateManagedSchemasInput added in v1.16.0

type UpdateManagedSchemasInput struct {
	Release     string `json:"release" validate:"required" description:"The release of the schema"`
	ManifestURL string `json:"manifestURL,omitempty" validate:"omitempty,url" description:"The URL to download the manifest archive from"`
}

type UpdateManagedSchemasOutput added in v1.16.0

type UpdateManagedSchemasOutput struct {
	Records []*SchemaRecord `json:"records"`
	Error   *APIError       `json:"error,omitempty" description:"An error that occurred while fetching the record"`
}

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