adminaudit

package
v0.0.12-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adminaudit carries non-secret administrator provenance into business transactions, and owns the rules for recording it and the audit log's read models. persistence/postgres/auditpg stores it.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidQuery = errors.New("invalid administrator audit query")

ErrInvalidQuery reports an audit log query with an invalid filter, page size or cursor.

View Source
var ErrInvalidSource = errors.New("invalid administrator audit source")

ErrInvalidSource reports an administrator mutation record that cannot be recorded: missing or malformed provenance, or a malformed action or resource. The mutation it belongs to fails closed.

Functions

func WithSource

func WithSource(ctx context.Context, source Source) context.Context

Types

type Filter

type Filter struct {
	ProjectID, ResourceType, ResourceID, Action, After string
	CreatedAfter, CreatedBefore                        *time.Time
	Limit                                              int
}

Filter selects committed administrator mutations, newest first. A zero Limit is the default page size.

func (Filter) Validate

func (f Filter) Validate() (Filter, error)

Validate checks f and returns it with the default page size applied. The cursor is checked where it is resolved.

type Operation

type Operation struct {
	ID                string    `json:"id" binding:"required"`
	CreatedAt         time.Time `json:"created_at" binding:"required"`
	AdminCredentialID string    `json:"admin_credential_id" binding:"required"`
	ActorLabel        string    `json:"actor_label" binding:"required"`
	Action            string    `json:"action" binding:"required"`
	ProjectID         *string   `json:"project_id" extensions:"x-nullable" binding:"required"`
	ResourceType      string    `json:"resource_type" binding:"required"`
	ResourceID        string    `json:"resource_id" binding:"required"`
	RequestID         string    `json:"request_id" binding:"required"`
	TraceID           string    `json:"trace_id" binding:"required"`
}

Operation is one administrator write. ProjectID is null for deployment-wide writes, such as deployment default model providers.

type Page

type Page struct {
	Data       []Operation `json:"data" binding:"required"`
	HasMore    bool        `json:"has_more" binding:"required"`
	NextCursor string      `json:"next_cursor" binding:"required"`
}

type Reader

type Reader interface {
	ListAdminAudit(ctx context.Context, filter Filter) (Page, error)
}

Reader reads committed administrator mutations as safe metadata, never request bodies or secrets.

type Source

type Source struct {
	CredentialID string
	ActorLabel   string
	RequestID    string
	TraceID      string
	ProjectID    string
}

func FromContext

func FromContext(ctx context.Context) (Source, bool)

func (Source) ValidateDeploymentMutation

func (s Source) ValidateDeploymentMutation(action, resourceType, resourceID string) error

ValidateDeploymentMutation checks the record of a deployment-wide mutation, which has no Project, so s names none.

func (Source) ValidateProjectMutation

func (s Source) ValidateProjectMutation(action, resourceType, resourceID string) error

ValidateProjectMutation checks the record of a mutation in the Project that s names.

Jump to

Keyboard shortcuts

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