helpermodels

package
v0.0.0-...-10bc8b7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StatusDone the thing is done
	StatusDone = StatusType("done")

	// StatusNew the thing is just created
	StatusNew = StatusType("new")

	// StatusScheduled the thing is scheduled (has a date when it will start)
	StatusScheduled = StatusType("scheduled")

	// StatusActive means the thing is active (has been consume)
	StatusActive = StatusType("active")

	// StatusFailed the thing failed and has an error
	StatusFailed = StatusType("failed")

	// StatusCanceled the thing has been canceled for some reason
	StatusCanceled = StatusType("canceled")

	// StatusPaused the thing has been paused for some reason
	StatusPaused = StatusType("paused")

	// StatusSkipped the thing has been skipped for some reason
	StatusSkipped = StatusType("skipped")

	// StatusDeleted the thing has been deleted for some reason
	StatusDeleted = StatusType("deleted")

	// StatusDeleting something that as been marked to be deleted
	StatusDeleting = StatusType("deleting")
)

Variables

ValidStatusTypes valid types of permissions

Functions

This section is empty.

Types

type Datable

type Datable interface {
	Identificable
	Timeable
	Ownable

	GetServicePrn() string
}

Datable Db data

type Identificable

type Identificable interface {
	GetID() string
	GetPrn() string
	SetPrn(service string) Identificable
}

Identificable interface of something with ID

type Identification

type Identification struct {
	ID  string `json:"id" bson:"_id"`
	PRN string `json:"prn" bson:"prn"`
}

Identification identification fields for a model

func NewIdentification

func NewIdentification(service string) Identification

NewIdentification Create new indentification

func (*Identification) GetID

func (identification *Identification) GetID() string

GetID get the id of a Identification

func (*Identification) GetPrn

func (identification *Identification) GetPrn() string

GetPrn get the id of a Identification

func (*Identification) SetPrn

func (identification *Identification) SetPrn(service string) Identificable

GetID get the id of a Identification

type Ownable

type Ownable interface {
	GetOwnerID() string
	GetOwnerPrn() string
	SetOwnerPrn(service string) Ownable
}

Ownable interface of something with ID

type Ownership

type Ownership struct {
	OwnerID  string `json:"owner_id" bson:"owner_id"`
	OwnerPrn string `json:"owner" bson:"owner"`
}

Ownership define owner of a resource

func (*Ownership) GetOwnerID

func (owner *Ownership) GetOwnerID() string

GetOwnerID get the id of a owner

func (*Ownership) GetOwnerPrn

func (owner *Ownership) GetOwnerPrn() string

GetOwnerPrn get the prn of a owner

func (*Ownership) SetOwnerPrn

func (owner *Ownership) SetOwnerPrn(service string) Ownable

SetOwnerPrn set the prn of a owner

type Pagination

type Pagination struct {
	PageSizes   []int  `json:"-"`
	ServiceURL  string `json:"resource"`
	PageSize    int    `json:"page_size"`
	PageOffset  int    `json:"page_offset"`
	CurrentPage int    `json:"current_page"`
	Total       int    `json:"total"`
	Next        string `json:"next"`
	Prev        string `json:"prev"`
}

Pagination paginable response

type Status

type Status struct {
	State   StatusType `json:"state" bson:"state"`
	Message string     `json:"message" bson:"message"`
}

Status status for a collection

func NewStatus

func NewStatus(status string) *Status

NewStatus create new status

func (*Status) GetMessage

func (s *Status) GetMessage() string

GetMessage Get the message

func (*Status) GetStatus

func (s *Status) GetStatus() StatusType

GetStatus Get the status

func (*Status) IsFinal

func (s *Status) IsFinal() bool

IsFinal Status is final

func (*Status) IsValid

func (s *Status) IsValid() bool

IsValid permission is valid

func (*Status) SetActive

func (s *Status) SetActive()

SetActive set status as active

func (*Status) SetCanceled

func (s *Status) SetCanceled()

SetCanceled set the status as Canceled

func (*Status) SetDeleted

func (s *Status) SetDeleted()

SetDeleted set the status as Canceled

func (*Status) SetDeleting

func (s *Status) SetDeleting()

SetDeleting set element as deleting

func (*Status) SetDone

func (s *Status) SetDone()

SetDone set the status as done

func (*Status) SetFailed

func (s *Status) SetFailed()

SetFailed set the status as Failed

func (*Status) SetNew

func (s *Status) SetNew()

SetNew set the status as New

func (*Status) SetPaused

func (s *Status) SetPaused()

SetPaused set the status as paused

func (*Status) SetScheduled

func (s *Status) SetScheduled()

SetScheduled set the status as Scheduled

type StatusType

type StatusType string

StatusType type of status

type Statusable

type Statusable interface {
	SetDone()
	SetNew()
	SetScheduled()
	SetFailed()
	SetCanceled()
	SetDeleted()
	SetPaused()
	SetDeleting()
	SetActive()
	GetStatus() StatusType
	GetMessage() string
	IsFinal() bool
	IsValid() bool
}

Statusable make something Status able

type Timeable

type Timeable interface {
	SetCreatedAt()
	SetUpdatedAt()
	SetDeletedAt()
	GetCreatedAt() *time.Time
	GetUpdatedAt() *time.Time
	GetDeletedAt() *time.Time
}

Timeable interface of something with TimeStamp

type Timestamp

type Timestamp struct {
	DeletedAt *time.Time `json:"deleted_at,omitempty" bson:"deleted_at"`
	CreatedAt *time.Time `json:"created_at,omitempty" bson:"created_at"`
	UpdatedAt *time.Time `json:"updated_at,omitempty" bson:"updated_at"`
}

Timestamp timestamp extension for all models

func NewTimeStamp

func NewTimeStamp() Timestamp

NewTimeStamp create new timestamp

func (*Timestamp) GetCreatedAt

func (t *Timestamp) GetCreatedAt() *time.Time

GetCreatedAt get method for created at

func (*Timestamp) GetDeletedAt

func (t *Timestamp) GetDeletedAt() *time.Time

GetDeletedAt get method for deleted at

func (*Timestamp) GetUpdatedAt

func (t *Timestamp) GetUpdatedAt() *time.Time

GetUpdatedAt get method for updated at

func (*Timestamp) SetCreatedAt

func (t *Timestamp) SetCreatedAt()

SetCreatedAt to a timestamp

func (*Timestamp) SetDeletedAt

func (t *Timestamp) SetDeletedAt()

SetDeletedAt set delete to a timestamp

func (*Timestamp) SetUpdatedAt

func (t *Timestamp) SetUpdatedAt()

SetUpdatedAt set update to a timestamp

Jump to

Keyboard shortcuts

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