service

package module
v0.0.0-...-1673907 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(builder component.Builder)

Setup configure package services

Types

type AccessKeyRepository

type AccessKeyRepository interface {
	// List project's access keys
	List(projectID string) ([]*model.AccessKey, error)

	// Get an access key by its value
	Get(key string) (*model.AccessKey, error)

	// Get an access key by project ID and access key ID
	GetByID(projectID string, accessKeyID int) (*model.AccessKey, error)

	// Create new access key
	Create(projectID string, args *model.AccessKeyCreateParams) (*model.AccessKey, error)

	// Delete an access key
	Delete(projectID string, accessKeyID int) error
}

AccessKeyRepository contains methods to manage project access keys

func GetAccessKeyRepository

func GetAccessKeyRepository(c di.Container) AccessKeyRepository

GetAccessKeyRepository returns an implementation AccessKeyRepository from DI container

type BackupFile

type BackupFile struct {
	Backup *model.Backup
	File   io.ReadCloser
}

BackupFile is a readable backup file

type BackupRepository

type BackupRepository interface {
	// Create new backup
	Upload(projectID, filename string, source io.Reader) (*model.Backup, error)

	// List project's backups
	List(projectID string) ([]*model.Backup, error)

	// Download project's backup content
	Download(id string) (*BackupFile, error)

	// Delete a backup
	Delete(id, reason string) error
}

BackupRepository contains methods to manage project backups

func GetBackupRepository

func GetBackupRepository(c di.Container) BackupRepository

GetBackupRepository returns an implementation BackupRepository from DI container

type Jwt

type Jwt interface {
	// Validate a JWT token
	ValidateToken(token string) (*model.User, *JwtError)

	// Generate new JWT token
	GenerateToken(user *model.User) (string, error)
}

Jwt provides methods to create and to parse JWT tokens

func GetJwt

func GetJwt(c di.Container) Jwt

GetJwt returns an implementation of Jwt from DI container

type JwtError

type JwtError struct {
	// HTTP status code (usually 401 or 403)
	StatusCode int
	// Error message
	Message string
}

JwtError contains error information for JWT token validation

func NewJwtError

func NewJwtError(statusCode int, message string) *JwtError

NewJwtError creates new instance of JwtError

type ProjectRepository

type ProjectRepository interface {
	// List all registered projects
	List() ([]*model.Project, error)

	// Get a project by its ID
	Get(id string) (*model.Project, error)

	// Create new project
	Create(args *model.ProjectCreateParams) (*model.Project, error)

	// Update an existing project
	Update(id string, args *model.ProjectUpdateParams) (*model.Project, error)

	// Delete an existing project
	Delete(id string) error

	// Update status of project's backups
	UpdateBackupStatus(tx *gorm.DB, projectID string) error
}

ProjectRepository contains methods to manage projects registry

func GetProjectRepository

func GetProjectRepository(c di.Container) ProjectRepository

GetProjectRepository returns an implementation of ProjectRepository from DI container

type UserRepository

type UserRepository interface {
	// Get a user by its username
	Get(username string) (*model.User, error)

	// Set user's password
	SetPassword(id int, password string) error
}

UserRepository contains methods to manage user accounts

func GetUserRepository

func GetUserRepository(c di.Container) UserRepository

GetUserRepository returns an implementation of UserRepository from DI container

Jump to

Keyboard shortcuts

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