Documentation ¶
Overview ¶
Copyright 2022 Red Hat Inc. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- type APIExport
- type DBInterface
- type ExportDB
- func (edb *ExportDB) APIList(user User, params *QueryParams, offset, limit int, sort, dir string) (result []*APIExport, count int64, err error)
- func (edb *ExportDB) Create(payload *ExportPayload) (*ExportPayload, error)
- func (edb *ExportDB) Delete(exportUUID uuid.UUID, user User) error
- func (edb *ExportDB) DeleteExpiredExports() error
- func (edb *ExportDB) Get(exportUUID uuid.UUID) (result *ExportPayload, err error)
- func (edb *ExportDB) GetWithUser(exportUUID uuid.UUID, user User) (result *ExportPayload, err error)
- func (edb *ExportDB) List(user User) (result []*ExportPayload, err error)
- func (edb *ExportDB) Raw(sql string, values ...interface{}) *gorm.DB
- func (edb *ExportDB) Updates(m *ExportPayload, values interface{}) error
- type ExportPayload
- func (ep *ExportPayload) BeforeCreate(tx *gorm.DB) (err error)
- func (ep *ExportPayload) GetAllSourcesStatus() (int, error)
- func (ep *ExportPayload) GetSource(uid uuid.UUID) (int, *Source, error)
- func (ep *ExportPayload) GetSources() ([]Source, error)
- func (ep *ExportPayload) SetSourceStatus(db DBInterface, uid uuid.UUID, status ResourceStatus, sourceError *SourceError) error
- func (ep *ExportPayload) SetStatusComplete(db DBInterface, t *time.Time, s3key string) error
- func (ep *ExportPayload) SetStatusFailed(db DBInterface) error
- func (ep *ExportPayload) SetStatusPartial(db DBInterface, t *time.Time, s3key string) error
- func (ep *ExportPayload) SetStatusRunning(db DBInterface) error
- type PayloadFormat
- type PayloadStatus
- type QueryParams
- type ResourceStatus
- type Source
- type SourceError
- type User
Constants ¶
View Source
const ( StatusError = iota - 1 StatusFailed StatusPending StatusPartial StatusComplete )
Variables ¶
View Source
var ErrRecordNotFound = errors.New("record not found")
Functions ¶
This section is empty.
Types ¶
type APIExport ¶
type APIExport struct { ID uuid.UUID `json:"id"` Name string `json:"name"` CreatedAt time.Time `json:"created_at"` CompletedAt *time.Time `json:"completed_at,omitempty"` Expires *time.Time `json:"expires_at,omitempty"` Format string `json:"format"` Status string `json:"status"` }
APIExport represents select fields of the ExportPayload which are returned to the user
type DBInterface ¶
type DBInterface interface { APIList(user User, params *QueryParams, offset, limit int, sort, dir string) (result []*APIExport, count int64, err error) Create(payload *ExportPayload) (result *ExportPayload, err error) Delete(exportUUID uuid.UUID, user User) error Get(exportUUID uuid.UUID) (result *ExportPayload, err error) GetWithUser(exportUUID uuid.UUID, user User) (result *ExportPayload, err error) List(user User) (result []*ExportPayload, err error) Raw(sql string, values ...interface{}) *gorm.DB Updates(m *ExportPayload, values interface{}) error DeleteExpiredExports() error }
type ExportDB ¶
type ExportDB struct { DB *gorm.DB Cfg *config.ExportConfig }
func (*ExportDB) Create ¶
func (edb *ExportDB) Create(payload *ExportPayload) (*ExportPayload, error)
func (*ExportDB) DeleteExpiredExports ¶
func (*ExportDB) Get ¶
func (edb *ExportDB) Get(exportUUID uuid.UUID) (result *ExportPayload, err error)
func (*ExportDB) GetWithUser ¶
func (*ExportDB) Updates ¶
func (edb *ExportDB) Updates(m *ExportPayload, values interface{}) error
type ExportPayload ¶
type ExportPayload struct { ID uuid.UUID `gorm:"type:uuid;primarykey"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"` CompletedAt *time.Time Expires *time.Time RequestID string Name string Format PayloadFormat `gorm:"type:string"` Status PayloadStatus `gorm:"type:string"` Sources []Source `gorm:"foreignKey:ExportPayloadID"` S3Key string User }
func (*ExportPayload) BeforeCreate ¶
func (ep *ExportPayload) BeforeCreate(tx *gorm.DB) (err error)
func (*ExportPayload) GetAllSourcesStatus ¶
func (ep *ExportPayload) GetAllSourcesStatus() (int, error)
GetAllSourcesStatus gets the status for all of the sources. This function can return these different states:
- StatusError - failed to retrieve sources
- StatusComplete - sources are all complete as success
- StatusPending - sources are still pending
- StatusPartial - sources are all complete, some sources are a failure
- StatusFailed - all sources have failed
func (*ExportPayload) GetSources ¶
func (ep *ExportPayload) GetSources() ([]Source, error)
func (*ExportPayload) SetSourceStatus ¶
func (ep *ExportPayload) SetSourceStatus(db DBInterface, uid uuid.UUID, status ResourceStatus, sourceError *SourceError) error
func (*ExportPayload) SetStatusComplete ¶
func (ep *ExportPayload) SetStatusComplete(db DBInterface, t *time.Time, s3key string) error
func (*ExportPayload) SetStatusFailed ¶
func (ep *ExportPayload) SetStatusFailed(db DBInterface) error
func (*ExportPayload) SetStatusPartial ¶
func (ep *ExportPayload) SetStatusPartial(db DBInterface, t *time.Time, s3key string) error
func (*ExportPayload) SetStatusRunning ¶
func (ep *ExportPayload) SetStatusRunning(db DBInterface) error
type PayloadFormat ¶
type PayloadFormat string
const ( CSV PayloadFormat = "csv" JSON PayloadFormat = "json" )
type PayloadStatus ¶
type PayloadStatus string
const ( Partial PayloadStatus = "partial" Pending PayloadStatus = "pending" Running PayloadStatus = "running" Complete PayloadStatus = "complete" Failed PayloadStatus = "failed" )
type QueryParams ¶
type QueryParams struct { Name string Created time.Time Expires time.Time Status string Application string Resource string }
QueryParams for the /export/v1/exports endpoint
type ResourceStatus ¶
type ResourceStatus string
const ( RPending ResourceStatus = "pending" RSuccess ResourceStatus = "success" RFailed ResourceStatus = "failed" )
type Source ¶
type Source struct { ID uuid.UUID `gorm:"type:uuid;primarykey"` ExportPayloadID uuid.UUID `gorm:"type:uuid"` Application string Status ResourceStatus Resource string Filters datatypes.JSON `gorm:"type:json"` *SourceError }
type SourceError ¶
Click to show internal directories.
Click to hide internal directories.