storage

package
v0.0.0-...-72a65b5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateUserInput

type CreateUserInput struct {
	Username       string
	HashedPassword string
	Role           string
	MFASecret      string
	MFAImage       []byte
}

type EventStore

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

func MustNewEventStore

func MustNewEventStore(config NewEventStoreInput) *EventStore

MustNewEventStore expects a configured and live ent database client this function will panic if passed a nil database connection

func (*EventStore) Create

func (s *EventStore) Create(ctx context.Context, events []models.Event) error

Create will insert new events into the database, if the database is not available the events will be saved to disk and a retry will be attempted later. An error is only returned if the insert failed as well as writing the file to disk. This could happen because the disk is full or other IO errors

func (EventStore) GetByID

func (s EventStore) GetByID(ctx context.Context, id string) (models.Event, error)

func (*EventStore) ListUniqueEventNames

func (s *EventStore) ListUniqueEventNames(ctx context.Context) ([]models.EventNameAutoFillValue, error)

func (*EventStore) ListUniqueEventUsernames

func (s *EventStore) ListUniqueEventUsernames(ctx context.Context) ([]models.UsernameAutoFillValue, error)

listUniqueEventUsernames gets all the unique usernames from the database, this can probably grow out of control someday and we should deal with that

func (*EventStore) Query

type EventStoreQueryBuilder

type EventStoreQueryBuilder struct {
	Username    *string
	Resource    *string
	StartTime   time.Time
	EndTime     time.Time
	EventName   *string
	RequestID   *string
	EventSource *string
	EventIP     *string
	ReadOnly    *bool
	Limit       int
	Page        int
}

EventStoreQueryBuilder is used to construct an event query, the only required fields are EndTime, StartTime, Limit and Page

type NewEventStoreInput

type NewEventStoreInput struct {
	EntClient       *ent.Client
	BufferDirectory string // Any trailing / added to the buffer directory is removed
}

type NewUserStoreInput

type NewUserStoreInput struct {
	EntClient *ent.Client
}

type UserStore

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

func MustNewUserStore

func MustNewUserStore(config NewUserStoreInput) *UserStore

func (*UserStore) All

func (s *UserStore) All(ctx context.Context) ([]models.User, error)

func (*UserStore) Create

func (s *UserStore) Create(ctx context.Context, input CreateUserInput) (*models.User, error)

func (*UserStore) GetByUsername

func (s *UserStore) GetByUsername(ctx context.Context, username string) (models.User, error)

func (*UserStore) Update

func (s *UserStore) Update(ctx context.Context, u models.User) (models.User, error)

Jump to

Keyboard shortcuts

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