action

package
v0.0.2-rc-ci Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryStore

func NewMemoryStore() *crud.MemoryStore[Action, Action, Filters]

NewMemoryStore returns a new in memory store.

func Router

func Router(service *Service, authService auth.Service) func(chi.Router)

Router returns a new http router that handles crud action requests for a given action service.

Types

type Action

type Action struct {
	Name         string    `json:"name"`
	Calls        int       `json:"calls"`
	LastCall     time.Time `json:"lastCall" db:"last_call"`
	LastCalledBy string    `json:"lastCalledBy" db:"last_called_by"`
	Error        string    `json:"error"`
}

func (Action) Identifier

func (a Action) Identifier() string

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(store Storer) *Authorizer

NewAuthorizer wraps the given store with authorization methods.

func (*Authorizer) Create

func (a *Authorizer) Create(ctx context.Context, action *Action) (*Action, error)

Create is allowed by

  • internally

func (*Authorizer) Delete

func (a *Authorizer) Delete(ctx context.Context, id string) error

Delete is allowed by

  • the user owning the action
  • an admin
  • internally

func (*Authorizer) Find

func (a *Authorizer) Find(ctx context.Context, params *crud.FindParams[Filters]) ([]*Action, int, error)

Find is allowed by

  • an admin
  • internally

func (*Authorizer) FindByID

func (a *Authorizer) FindByID(ctx context.Context, id string) (*Action, error)

FindByID is allowed by

  • an admin
  • internally

func (*Authorizer) Update

func (a *Authorizer) Update(ctx context.Context, action *Action) (*Action, error)

Update is allowed by

  • an admin
  • internally

type CreateRequest

type CreateRequest struct {
	// in:body
	Action *Action
}

swagger:parameters createAction

type CreateResponse

type CreateResponse struct {
	// in:body
	Action *Action
}

swagger:response createActionResponse

type DeleteRequest

type DeleteRequest struct {
	// in:query
	ID string `json:"id"`
}

swagger:parameters deleteAction

type DeleteResponse

type DeleteResponse struct{}

swagger:response deleteActionResponse

type Filters

type Filters struct{}

type FindByIDRequest

type FindByIDRequest struct {
	// in:query
	ID string `json:"id"`
}

swagger:parameters findAction

type FindByIDResponse

type FindByIDResponse struct {
	// in:body
	Action *Action
}

swagger:response findActionResponse

type FindResponse

type FindResponse struct {
	// in:body
	Actions []*Action

	// in:header
	TotalActions int `json:"x-total-count"`
}

swagger:response findActionsResponse

type Function

type Function func(ctx context.Context) error

type RunRequest

type RunRequest struct {
	// in:body
	Name string `json:"name"`
}

swagger:parameters deleteAction

type RunResponse

type RunResponse struct{}

swagger:response runActionResponse

type Service

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

func NewService

func NewService(store Storer, sheduler gocron.Scheduler) *Service

func (*Service) Call

func (s *Service) Call(ctx context.Context, name string) error

func (*Service) Register

func (s *Service) Register(name string, fn Function, cronExpression string) error

func (*Service) Store

func (s *Service) Store() Storer

type SqlStore

type SqlStore struct {
	*crud.SqlStore[Action, Action, Filters]
	// contains filtered or unexported fields
}

func NewSqlStore

func NewSqlStore(db *sqlx.DB, migrationService dbmigration.Service) (*SqlStore, error)

NewSqlStore returns a new sql store for notifications.

type Storer

type Storer crud.Storer[Action, Action, Filters]

type UpdateRequest

type UpdateRequest struct {
	// in:body
	Action *Action
}

swagger:parameters updateAction

type UpdateResponse

type UpdateResponse struct {
	// in:body
	Action *Action
}

swagger:response updateActionResponse

Jump to

Keyboard shortcuts

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