model

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: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ImportStateRequested                  = "import-requested"
	ImportStateInstallationPreAdjustment  = "installation-pre-adjustment"
	ImportStateInProgress                 = "import-in-progress"
	ImportStateComplete                   = "import-complete"
	ImportStateInstallationPostAdjustment = "installation-post-adjustment"
	ImportStateSucceeded                  = "import-succeeded"
	ImportStateFailed                     = "import-failed"

	SizeCloud10Users  = "cloud10users"
	Size1000String    = "1000users"
	S3ExtendedTimeout = 48 * 60 * 60 * 1000
	S3DefaultTimeout  = 10 * 60 * 1000
	S3EnvKey          = "MM_FILESETTINGS_AMAZONS3REQUESTTIMEOUTMILLISECONDS"
)

Constants defining various states of import.

View Source
const (
	TranslationStateRequested  = "translation-requested"
	TranslationStateInProgress = "translation-in-progress"
	TranslationStateComplete   = "translation-complete"
)

Constants defining various states of translation.

View Source
const (
	// TeamNameMaxLength is the maximum length allowed for team names.
	TeamNameMaxLength = 64
	// TeamNameMinLength is the minimum length required for team names.
	TeamNameMinLength = 2
)

Variables

AllImportStatesPendingWork contains all import states that indicate pending work.

View Source
var BuildHash string

BuildHash holds the git commit hash when we build the server

Functions

func GetMillis added in v0.2.0

func GetMillis() int64

GetMillis is a convenience method to get milliseconds since epoch.

func IsValidArchiveName added in v0.3.0

func IsValidArchiveName(filename string) bool

IsValidArchiveName checks if the provided filename is a valid for an awat supported archive

func NewID

func NewID() string

NewID produces IDs for unique objects

func TrimExtensionFromArchiveFilename added in v0.3.0

func TrimExtensionFromArchiveFilename(filename string) string

TrimExtensionFromArchiveFilename returns the archive filename without the extension, mostly to retrieve the ID from an upload/archive to use on database entries.

Types

type ArchiveUploadRequest added in v0.3.0

type ArchiveUploadRequest struct {
	Type BackupType
}

ArchiveUploadRequest represents a request to upload an archive.

func NewArchiveUploadFromURLQuery added in v0.3.0

func NewArchiveUploadFromURLQuery(values url.Values) (*ArchiveUploadRequest, error)

NewArchiveUploadFromURLQuery creates an ArchiveUploadRequest from URL query values.

func (ArchiveUploadRequest) Validate added in v0.3.0

func (r ArchiveUploadRequest) Validate() error

Validate checks if the ArchiveUploadRequest fields are valid.

type BackupType

type BackupType string

BackupType defines the type of backup (e.g., Slack, Mattermost).

const (
	SlackWorkspaceBackupType      BackupType = "slack"
	MattermostWorkspaceBackupType BackupType = "mattermost"
)

Backup type constants.

type Client

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

Client is the programmatic interface to the AWAT API.

func NewClient

func NewClient(address string) *Client

NewClient creates a new instance of Client.

func (*Client) CompleteImport

func (c *Client) CompleteImport(completed *ImportCompletedWorkRequest) error

CompleteImport marks an Import as finished, with or without an error

func (*Client) CreateTranslation

func (c *Client) CreateTranslation(translationRequest *TranslationRequest) (*TranslationStatus, error)

CreateTranslation creates a new Translation which will start shortly after being created

func (*Client) GetAllImports

func (c *Client) GetAllImports() ([]*ImportStatus, error)

GetAllImports gets all Imports from the API and returns them as a JSON list

func (*Client) GetAllTranslations

func (c *Client) GetAllTranslations() ([]*TranslationStatus, error)

GetAllTranslations gets all Translations from the API and returns them as a JSON list

func (*Client) GetImportStatus

func (c *Client) GetImportStatus(importID string) (*ImportStatus, error)

GetImportStatus returns the status of a single import specified by ID

func (*Client) GetImportStatusesByInstallation

func (c *Client) GetImportStatusesByInstallation(installationID string) ([]*ImportStatus, error)

GetImportStatusesByInstallation returns all Imports that pertain to an Installation

func (*Client) GetImportStatusesByTranslation

func (c *Client) GetImportStatusesByTranslation(translationID string) ([]*ImportStatus, error)

GetImportStatusesByTranslation retrieves all import statuses related to a translation.

func (*Client) GetTranslationReadyToImport

func (c *Client) GetTranslationReadyToImport(request *ImportWorkRequest) (*ImportStatus, error)

GetTranslationReadyToImport gets and claims the next Import waiting to be imported. The Import will be claimed for the caller specified in the ProvisionerID filed of the request argument

func (*Client) GetTranslationStatus

func (c *Client) GetTranslationStatus(translationID string) (*TranslationStatus, error)

GetTranslationStatus returns the TranslationStatus struct returned from the API for the given Translation ID

func (*Client) GetTranslationStatusesByInstallation

func (c *Client) GetTranslationStatusesByInstallation(installationID string) ([]*TranslationStatus, error)

GetTranslationStatusesByInstallation returns all Translations that pertain to an Installation

func (*Client) ReleaseLockOnImport

func (c *Client) ReleaseLockOnImport(importID string) error

ReleaseLockOnImport marks an Import as finished, with or without an error

func (*Client) UploadArchiveForTranslation

func (c *Client) UploadArchiveForTranslation(filename string, archiveType BackupType) (string, error)

UploadArchiveForTranslation uploads the file specified as an argument to S3 via the AWAT

func (*Client) WaitForUploadToComplete

func (c *Client) WaitForUploadToComplete(uploadID string) error

WaitForUploadToComplete waits for an upload to complete on the AWAT server.

type Import

type Import struct {
	ID            string
	TranslationID string
	Resource      string
	CreateAt      int64
	StartAt       int64
	CompleteAt    int64
	State         string
	LockedBy      string
	ImportBy      string
	Error         string
}

Import represents a completed Translation that is being imported into an Installation in order to track that process

func NewImport

func NewImport(translationID, importResource string) *Import

NewImport returns a new import resource.

type ImportCompletedWorkRequest

type ImportCompletedWorkRequest struct {
	ID         string
	CompleteAt int64
	Error      string
}

ImportCompletedWorkRequest contains the metadata needed from the Provisioner for the AWAT to mark that an import has finished with or without an error

func NewImportCompletedWorkRequestFromReader

func NewImportCompletedWorkRequestFromReader(reader io.Reader) (*ImportCompletedWorkRequest, error)

NewImportCompletedWorkRequestFromReader creates an ImportCompletedWorkRequest from an io.Reader.

func (*ImportCompletedWorkRequest) Matches

func (a *ImportCompletedWorkRequest) Matches(input interface{}) bool

Matches determines whether two *ImportCompletedWorkRequests point to the same logical request, in testing. Since this is for testing, timestamps are ignored

func (*ImportCompletedWorkRequest) String

func (a *ImportCompletedWorkRequest) String() string

String outputs a string representation of ImportCompletedWorkRequest. It is needed to satisfy the Matcher interface

type ImportStatus

type ImportStatus struct {
	Import

	InstallationID string
	Users          int
	Team           string
	State          string
	Type           BackupType
}

ImportStatus provides a container for returning the State with the Import to the client without explicitly needing to store a state attribute in the database

func NewImportStatusFromReader

func NewImportStatusFromReader(reader io.Reader) (*ImportStatus, error)

NewImportStatusFromReader creates a ImportStatus from a Reader

func NewImportStatusListFromReader

func NewImportStatusListFromReader(reader io.Reader) ([]*ImportStatus, error)

NewImportStatusListFromReader creates a list of ImportStatuses from a Reader

type ImportWorkRequest

type ImportWorkRequest struct {
	ProvisionerID string
}

ImportWorkRequest contains an identifier from the caller in order to claim an import for the caller at request time

func NewImportWorkRequestFromReader

func NewImportWorkRequestFromReader(reader io.Reader) (*ImportWorkRequest, error)

NewImportWorkRequestFromReader creates a ImportWorkRequest from a Reader

type Translation

type Translation struct {
	ID             string
	InstallationID string
	Resource       string
	Type           BackupType
	Team           string
	Users          int
	CreateAt       int64
	StartAt        int64
	CompleteAt     int64
	LockedBy       string
	UploadID       *string
}

Translation represents a single process of converting a foreign workspace archive into a native Mattermost workspace import archive

func NewTranslationFromRequest

func NewTranslationFromRequest(translationRequest *TranslationRequest) *Translation

NewTranslationFromRequest returns a new Translation from a TranslationRequest.

func (*Translation) State

func (t *Translation) State() string

State provides a container for returning the state with the Translation to the client without explicitly needing to store a state attribute in the database

type TranslationMetadata

type TranslationMetadata struct {
	Options interface{}
}

TranslationMetadata holds metadata related to a translation.

type TranslationRequest

type TranslationRequest struct {
	Type           BackupType
	InstallationID string
	Archive        string
	Team           string
	UploadID       *string
}

TranslationRequest represents a request for translating a workspace archive.

func NewTranslationRequestFromReader

func NewTranslationRequestFromReader(reader io.Reader) (*TranslationRequest, error)

NewTranslationRequestFromReader creates a TranslationRequest from an io.Reader.

func (*TranslationRequest) Validate added in v0.2.0

func (request *TranslationRequest) Validate() error

Validate validates the values of a translation create request.

type TranslationStatus

type TranslationStatus struct {
	Translation

	State string
}

TranslationStatus represents the status of a translation.

func NewTranslationStatusFromBytes added in v0.3.0

func NewTranslationStatusFromBytes(data []byte) (*TranslationStatus, error)

NewTranslationStatusFromBytes creates a TranslationStatus from a byte slice.

func NewTranslationStatusFromReader

func NewTranslationStatusFromReader(reader io.Reader) (*TranslationStatus, error)

NewTranslationStatusFromReader creates a TranslationStatus from an io.Reader.

func NewTranslationStatusListFromReader

func NewTranslationStatusListFromReader(reader io.Reader) ([]*TranslationStatus, error)

NewTranslationStatusListFromReader creates a list of TranslationStatus from an io.Reader.

type Upload

type Upload struct {
	ID         string
	CompleteAt int64
	CreateAt   int64
	Error      string
	Type       BackupType
}

Upload represents the details of an upload process in the system. It includes metadata like the ID, creation and completion timestamps, any errors encountered, and the type of backup being uploaded.

Jump to

Keyboard shortcuts

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