aud

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package audit is the domain package for auditum.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProjectNotFound = errors.New("project not found")
	ErrRecordNotFound  = errors.New("record not found")

	ErrDisabled = errors.New("disabled")
)
View Source
var DefaultSettings = Settings{
	Records: RecordsSettings{
		UpdateEnabled: false,
		DeleteEnabled: false,
		Restrictions: RecordsRestrictions{
			Labels: RestrictionsKeyValue{
				KeyMaxSizeBytes:   64,
				ValueMaxSizeBytes: 256,
				TotalMaxSizeBytes: 2048,
			},
			Resource: RecordsRestrictionsResource{
				Type: RestrictionsString{
					MaxSizeBytes: 256,
				},
				ID: RestrictionsString{
					MaxSizeBytes: 256,
				},
				Metadata: RestrictionsKeyValue{
					KeyMaxSizeBytes:   64,
					ValueMaxSizeBytes: 256,
					TotalMaxSizeBytes: 2048,
				},
				Changes: RecordsRestrictionsResourceChanges{
					TotalMaxCount: 20,
					Name: RestrictionsString{
						MaxSizeBytes: 256,
					},
					Description: RestrictionsString{
						MaxSizeBytes: 1024,
					},
					OldValue: RestrictionsBytes{
						MaxSizeBytes: 4096,
					},
					NewValue: RestrictionsBytes{
						MaxSizeBytes: 4096,
					},
				},
			},
			Operation: RecordsRestrictionsOperation{
				Type: RestrictionsString{
					MaxSizeBytes: 256,
				},
				ID: RestrictionsString{
					MaxSizeBytes: 512,
				},
				Metadata: RestrictionsKeyValue{
					KeyMaxSizeBytes:   64,
					ValueMaxSizeBytes: 256,
					TotalMaxSizeBytes: 2048,
				},
			},
			Actor: RecordsRestrictionsActor{
				Type: RestrictionsString{
					MaxSizeBytes: 256,
				},
				ID: RestrictionsString{
					MaxSizeBytes: 256,
				},
				Metadata: RestrictionsKeyValue{
					KeyMaxSizeBytes:   64,
					ValueMaxSizeBytes: 256,
					TotalMaxSizeBytes: 2048,
				},
			},
		},
	},
}

Functions

func DecodePageToken

func DecodePageToken(token string, cursor any) error

func EncodePageToken

func EncodePageToken(cursor Cursor) (string, error)

Types

type Actor

type Actor struct {
	Type     string
	ID       string
	Metadata map[string]string
}

type Cursor

type Cursor interface {
	Empty() bool
}

type ID

type ID uuid.UUID

ID is a unique identifier.

func MustNewID

func MustNewID() ID

MustNewID returns a new identifier, panicking on error.

func MustParseID

func MustParseID(s string) ID

func NewID

func NewID() (ID, error)

NewID returns a new identifier.

func ParseID

func ParseID(s string) (ID, error)

func (ID) IsEmpty

func (id ID) IsEmpty() bool

func (*ID) Scan

func (id *ID) Scan(src interface{}) error

func (ID) String

func (id ID) String() string

func (ID) Value

func (id ID) Value() (driver.Value, error)

type Operation

type Operation struct {
	Type         string
	ID           string
	Time         time.Time
	Metadata     map[string]string
	TraceContext TraceContext
	Status       OperationStatus
}

type OperationStatus

type OperationStatus int
const (
	OperationStatusUnspecified OperationStatus = iota
	OperationStatusSucceeded
	OperationStatusFailed
)

func (OperationStatus) Int

func (s OperationStatus) Int() int

type Project

type Project struct {
	ID                  ID
	CreateTime          time.Time
	DisplayName         string
	UpdateRecordEnabled types.BoolValue
	DeleteRecordEnabled types.BoolValue
}

type ProjectCursor

type ProjectCursor struct {
	LastID *ID `json:"lid,omitempty"`
}

func NewProjectCursor

func NewProjectCursor(projects []Project, pageSize int32) ProjectCursor

func (ProjectCursor) Empty

func (p ProjectCursor) Empty() bool

type ProjectUpdate

type ProjectUpdate struct {
	DisplayName       string
	UpdateDisplayName bool

	UpdateRecordEnabled       types.BoolValue
	UpdateUpdateRecordEnabled bool

	DeleteRecordEnabled       types.BoolValue
	UpdateDeleteRecordEnabled bool
}

type Record

type Record struct {
	ID         ID
	ProjectID  ID
	CreateTime time.Time
	Labels     map[string]string
	Resource   Resource
	Operation  Operation
	Actor      Actor
}

type RecordCursor

type RecordCursor struct {
	LastOperationTime *time.Time `json:"lot,omitempty"`
	LastID            *ID        `json:"lid,omitempty"`
}

func NewRecordCursor

func NewRecordCursor(records []Record, pageSize int32) RecordCursor

func (RecordCursor) Empty

func (p RecordCursor) Empty() bool

type RecordFilter

type RecordFilter struct {
	Labels map[string]string

	ResourceType string
	ResourceID   string

	OperationType string
	OperationID   string

	OperationTimeFrom time.Time
	OperationTimeTo   time.Time

	ActorType string
	ActorID   string
}

type RecordUpdate

type RecordUpdate struct {
	Labels       map[string]string
	UpdateLabels bool

	Resource       Resource
	UpdateResource bool

	Operation       Operation
	UpdateOperation bool

	Actor       Actor
	UpdateActor bool
}

type RecordsRestrictions

type RecordsRestrictions struct {
	Labels    RestrictionsKeyValue         `yaml:"labels" json:"labels"`
	Resource  RecordsRestrictionsResource  `yaml:"resource" json:"resource"`
	Operation RecordsRestrictionsOperation `yaml:"operation" json:"operation"`
	Actor     RecordsRestrictionsActor     `yaml:"actor" json:"actor"`
}

func (RecordsRestrictions) Validate

func (r RecordsRestrictions) Validate() error

type RecordsRestrictionsActor

type RecordsRestrictionsActor struct {
	Type     RestrictionsString   `yaml:"type" json:"type"`
	ID       RestrictionsString   `yaml:"id" json:"id"`
	Metadata RestrictionsKeyValue `yaml:"metadata" json:"metadata"`
}

func (RecordsRestrictionsActor) Validate

func (r RecordsRestrictionsActor) Validate() error

type RecordsRestrictionsOperation

type RecordsRestrictionsOperation struct {
	Type     RestrictionsString   `yaml:"type" json:"type"`
	ID       RestrictionsString   `yaml:"id" json:"id"`
	Metadata RestrictionsKeyValue `yaml:"metadata" json:"metadata"`
}

func (RecordsRestrictionsOperation) Validate

func (r RecordsRestrictionsOperation) Validate() error

type RecordsRestrictionsResource

type RecordsRestrictionsResource struct {
	Type     RestrictionsString                 `yaml:"type" json:"type"`
	ID       RestrictionsString                 `yaml:"id" json:"id"`
	Metadata RestrictionsKeyValue               `yaml:"metadata" json:"metadata"`
	Changes  RecordsRestrictionsResourceChanges `yaml:"changes" json:"changes"`
}

func (RecordsRestrictionsResource) Validate

func (r RecordsRestrictionsResource) Validate() error

type RecordsRestrictionsResourceChanges

type RecordsRestrictionsResourceChanges struct {
	TotalMaxCount int                `yaml:"totalMaxCount" json:"totalMaxCount"`
	Name          RestrictionsString `yaml:"name" json:"name"`
	Description   RestrictionsString `yaml:"description" json:"description"`
	OldValue      RestrictionsBytes  `yaml:"oldValue" json:"oldValue"`
	NewValue      RestrictionsBytes  `yaml:"newValue" json:"newValue"`
}

func (RecordsRestrictionsResourceChanges) Validate

type RecordsSettings

type RecordsSettings struct {
	UpdateEnabled bool                `yaml:"updateEnabled" json:"updateEnabled"`
	DeleteEnabled bool                `yaml:"deleteEnabled" json:"deleteEnabled"`
	Restrictions  RecordsRestrictions `yaml:"restrictions" json:"restrictions"`
}

func (RecordsSettings) Validate

func (r RecordsSettings) Validate() error

type Resource

type Resource struct {
	Type     string
	ID       string
	Metadata map[string]string
	Changes  []ResourceChange
}

type ResourceChange

type ResourceChange struct {
	Name        string
	Description string
	OldValue    json.RawMessage
	NewValue    json.RawMessage
}

type RestrictionsBytes

type RestrictionsBytes struct {
	MaxSizeBytes int `yaml:"maxSizeBytes" json:"maxSizeBytes"`
}

func (RestrictionsBytes) Validate

func (r RestrictionsBytes) Validate() error

type RestrictionsKeyValue

type RestrictionsKeyValue struct {
	KeyMaxSizeBytes   int `yaml:"keyMaxSizeBytes" json:"keyMaxSizeBytes"`
	ValueMaxSizeBytes int `yaml:"valueMaxSizeBytes" json:"valueMaxSizeBytes"`
	TotalMaxSizeBytes int `yaml:"totalMaxSizeBytes" json:"totalMaxSizeBytes"`
}

func (RestrictionsKeyValue) Validate

func (r RestrictionsKeyValue) Validate() error

type RestrictionsString

type RestrictionsString struct {
	MaxSizeBytes int `yaml:"maxSizeBytes" json:"maxSizeBytes"`
}

func (RestrictionsString) Validate

func (r RestrictionsString) Validate() error

type Settings

type Settings struct {
	Records RecordsSettings `yaml:"records" json:"records"`
}

func (Settings) Validate

func (s Settings) Validate() error

type TraceContext

type TraceContext struct {
	Traceparent string
	Tracestate  string
}

func (TraceContext) IsZero

func (tc TraceContext) IsZero() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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