api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(rootRouter *mux.Router, context *Context)

Register sets up the routing of HTTP endpoints to their respective handler functions. It associates each route with a specific handler and HTTP method in the provided router.

Types

type AWS

type AWS interface {
	GetBucketName() string
	CheckBucketFileExists(file string) (bool, error)
	UploadArchiveToS3(uploadFileName, destKeyName string) error
	DownloadArchiveFromS3(filename string) (string, func(), error)
}

AWS provides an interface to interact with AWS services.

type AWSContext

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

AWSContext implements the AWS interface and provides methods to interact with AWS S3.

func NewAWSContext added in v0.3.0

func NewAWSContext(bucket string) (*AWSContext, error)

NewAWSContext creates a new AWSContext with the specified bucket name.

func (*AWSContext) CheckBucketFileExists

func (a *AWSContext) CheckBucketFileExists(file string) (bool, error)

CheckBucketFileExists checks if a file exists in the S3 bucket.

func (*AWSContext) DownloadArchiveFromS3 added in v0.3.0

func (a *AWSContext) DownloadArchiveFromS3(archiveName string) (path string, cleanup func(), err error)

DownloadArchiveFromS3 downloads a file from an S3 bucket.

func (*AWSContext) GetBucketName

func (a *AWSContext) GetBucketName() string

GetBucketName returns the name of the S3 bucket used in AWSContext.

func (*AWSContext) UploadArchiveToS3

func (a *AWSContext) UploadArchiveToS3(uploadFileName, destKeyName string) error

UploadArchiveToS3 uploads a file to an S3 bucket.

type Context

type Context struct {
	Store     Store
	Logger    logrus.FieldLogger
	AWS       AWS
	Workdir   string
	RequestID string
}

Context provides the API with all necessary data and interfaces for responding to requests.

It is cloned before each request, allowing per-request changes such as logger annotations.

func (*Context) Clone

func (c *Context) Clone() *Context

Clone creates a shallow copy of context, allowing clones to apply per-request changes.

type Store

type Store interface {
	GetTranslation(id string) (*model.Translation, error)
	GetTranslationsByInstallation(id string) ([]*model.Translation, error)
	GetAllTranslations() ([]*model.Translation, error)
	CreateTranslation(t *model.Translation) error
	UpdateTranslation(t *model.Translation) error

	GetAndClaimNextReadyImport(provisionerID string) (*model.Import, error)
	GetAllImports() ([]*model.Import, error)
	GetImport(id string) (*model.Import, error)
	GetImportsInProgress() ([]*model.Import, error)
	GetImportsByInstallation(id string) ([]*model.Import, error)
	GetImportsByTranslation(id string) ([]*model.Import, error)
	UpdateImport(imp *model.Import) error

	GetUpload(id string) (*model.Upload, error)
	CreateUpload(id string, archiveType model.BackupType) error
	CompleteUpload(uploadID, errorMessage string) error
}

Store defines the interface for data storage and retrieval operations. It provides methods for managing translations, imports, and uploads within the system.

Jump to

Keyboard shortcuts

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