backupapi

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RecoveryPointTypePoint          = "RECOVERY_POINT"
	RecoveryPointTypeInitialReplica = "INITIAL_REPLICA"

	RecoveryPointStatusCreated   = "CREATED"
	RecoveryPointStatusCompleted = "COMPLETED"
	RecoveryPointStatusFAILED    = "FAILED"
)
View Source
const MultipartUploadLowerBound = 15 * 1000 * 1000

Variables

View Source
var ErrUpdateRecoveryPoint = errors.New("failed to update recovery point")

ErrUpdateRecoveryPoint indicates that there is error from server when updating recovery point.

Functions

func WithHTTPClient

func WithHTTPClient(client *http.Client) func(*Client) error

WithHTTPClient sets the underlying HTTP client for Client.

Types

type BackupDirectory

type BackupDirectory struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Path        string `json:"path"`
	Quota       int    `json:"quota"`
	Size        int    `json:"size"`
	MachineID   string `json:"machine_id"`
	TenantID    string `json:"tenant_id"`
}

BackupDirectory ...

type BackupDirectoryConfig

type BackupDirectoryConfig struct {
	ID        string                        `json:"id" yaml:"id"`
	Name      string                        `json:"name" yaml:"name"`
	Path      string                        `json:"path" yaml:"path"`
	Policies  []BackupDirectoryConfigPolicy `json:"policies" yaml:"policies"`
	Activated bool                          `json:"activated" yaml:"activated"`
}

BackupDirectoryConfig is the cron policies for given directory.

type BackupDirectoryConfigPolicy

type BackupDirectoryConfigPolicy struct {
	ID              string `json:"id" yaml:"id"`
	Name            string `json:"name" yaml:"name"`
	SchedulePattern string `json:"schedule_pattern" yaml:"schedule_pattern"`
}

BackupDirectoryConfigPolicy is the cron policy.

type Client

type Client struct {
	ServerURL *url.URL
	Id        string
	// contains filtered or unexported fields
}

Client is the client for interacting with BackupService API server.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient creates a Client with given options.

func (*Client) CompleteMultipart

func (c *Client) CompleteMultipart(ctx context.Context, recoveryPointID, uploadID string) error

func (*Client) CreateRecoveryPoint

func (c *Client) CreateRecoveryPoint(ctx context.Context, backupDirectoryID string, crpr *CreateRecoveryPointRequest) (*CreateRecoveryPointResponse, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do makes an http request.

func (*Client) DownloadFileContent

func (c *Client) DownloadFileContent(ctx context.Context, createdAt string, restoreSessionKey string, recoveryPointID string, w io.Writer) error

DownloadFileContent downloads file content at given recovery point id, write the content to writer.

func (*Client) GetBackupDirectory

func (c *Client) GetBackupDirectory(id string) (*BackupDirectory, error)

GetBackupDirectory retrieves a backup directory by given id.

func (*Client) GetConfig

func (c *Client) GetConfig(ctx context.Context) (*Config, error)

func (*Client) InitMultipart

func (c *Client) InitMultipart(ctx context.Context, recoveryPointID string) (*Multipart, error)

func (*Client) ListRecoveryPoints

func (c *Client) ListRecoveryPoints(ctx context.Context, backupDirectoryID string) ([]RecoveryPoint, error)

ListRecoveryPoints list all recovery points of given backup directory.

func (*Client) NewRequest

func (c *Client) NewRequest(method, relPath string, body interface{}) (*http.Request, error)

NewRequest create new http request

func (*Client) RequestBackupDirectory

func (c *Client) RequestBackupDirectory(id string, cmbr *CreateManualBackupRequest) error

RequestBackupDirectory requests a manual backup.

func (*Client) RequestRestore

func (c *Client) RequestRestore(recoveryPointID string, crr *CreateRestoreRequest) error

RequestRestore requests restore

func (*Client) UpdateMachine

func (c *Client) UpdateMachine() (*UpdateMachineResponse, error)

UpdateMachine updates machine information.

func (*Client) UpdateRecoveryPoint

func (c *Client) UpdateRecoveryPoint(ctx context.Context, backupDirectoryID string, recoveryPointID string, urpr *UpdateRecoveryPointRequest) error

func (*Client) UploadFile

func (c *Client) UploadFile(fn string, r io.Reader, pw io.Writer, batch bool) error

UploadFile uploads given file to server.

type ClientOption

type ClientOption func(c *Client) error

ClientOption provides mechanism to configure Client.

func WithAccessKey

func WithAccessKey(accessKey string) ClientOption

WithAccessKey sets the access key for Client.

func WithID

func WithID(id string) ClientOption

WithAccessKey sets the access key for Client.

func WithSecretKey

func WithSecretKey(secretKey string) ClientOption

WithSecretKey sets the secret key for Client.

func WithServerURL

func WithServerURL(serverURL string) ClientOption

WithServerURL sets the server url for Client.

type Config

type Config struct {
	BackupDirectories []BackupDirectoryConfig `json:"backup_directories" yaml:"backup_directories"`
}

type CreateManualBackupRequest

type CreateManualBackupRequest struct {
	Action      string `json:"action"`
	StorageType string `json:"storage_type"`
	Name        string `json:"name"`
}

CreateManualBackupRequest represents a request manual backup.

type CreateRecoveryPointRequest

type CreateRecoveryPointRequest struct {
	PolicyID          string `json:"policy_id"`
	Name              string `json:"name"`
	RecoveryPointType string `json:"recovery_point_type"`
}

CreateRecoveryPointRequest represents a request to create a recovery point.

type CreateRecoveryPointResponse

type CreateRecoveryPointResponse struct {
	ID            string         `json:"id"`
	RecoveryPoint *RecoveryPoint `json:"recovery_point"`
	Action        string         `json:"action"`
	Status        string         `json:"status"`
}

CreateRecoveryPointResponse is the server response when creating recovery point

type CreateRestoreRequest

type CreateRestoreRequest struct {
	MachineID string `json:"machine_id"`
	Path      string `json:"path"`
}

CreateRestoreRequest represents a request manual backup.

type File

type File struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Size        int    `json:"size"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
	ContentType string `json:"content_type"`
	Etag        string `json:"eTag"`
}

File ...

type Machine

type Machine struct {
	ID           string `json:"id"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
	Name         string `json:"name"`
	HostName     string `json:"host_name"`
	IPAddress    string `json:"ip_address"`
	OSVersion    string `json:"os_version"`
	AgentVersion string `json:"agent_version"`
	TenantID     string `json:"tenant_id"`
	OSMachineID  string `json:"os_machine_id"`
}

Machine ...

type Multipart

type Multipart struct {
	UploadID string `json:"upload_id"`
	FileName string `json:"file_name"`
}

Multipart ...

type Part

type Part struct {
	PartNumber int    `json:"part_number"`
	Size       int    `json:"size"`
	Etag       string `json:"etag"`
}

Part ...

type Policy

type Policy struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	SchedulePattern string `json:"schedule_pattern"`
	RetentionHours  int    `json:"retention_hours"`
	RetentionDays   int    `json:"retention_days"`
	RetentionWeeks  int    `json:"retention_weeks"`
	RetentionMonths int    `json:"retention_months"`
	CreatedAt       string `json:"created_at"`
	UpdatedAt       string `json:"updated_at"`
	TenantID        string `json:"tenant_id"`
}

Policy ...

type PolicyDirectories

type PolicyDirectories struct {
	ID                string   `json:"id"`
	Name              string   `json:"name"`
	SchedulePattern   string   `json:"schedule_pattern"`
	RetentionHours    int      `json:"retention_hours"`
	RetentionDays     int      `json:"retention_days"`
	RetentionWeeks    int      `json:"retention_weeks"`
	RetentionMonths   int      `json:"retention_months"`
	CreatedAt         string   `json:"created_at"`
	UpdatedAt         string   `json:"updated_at"`
	TenantID          string   `json:"tenant_id"`
	BackupDirectories []string `json:"backup-directories"`
}

PolicyDirectories ...

type ProgressWriter

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

ProgressWriter wraps a writer, counts number of bytes written to it and write the report back to writer.

func NewProgressWriter

func NewProgressWriter(out io.Writer) *ProgressWriter

NewProgressWriter returns new progress writer.

func (*ProgressWriter) Write

func (pc *ProgressWriter) Write(buf []byte) (int, error)

Write implements io.Writer interface.

Report the progress to underlying writer before return.

type RecoveryPoint

type RecoveryPoint struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	RecoveryPointType string `json:"recovery_point_type"`
	Status            string `json:"status"`
	PolicyID          string `json:"policy_id"`
	BackupDirectoryID string `json:"backup_directory_id"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
}

RecoveryPoint ...

type UpdateMachineResponse added in v0.0.2

type UpdateMachineResponse struct {
	BrokerUrl string `json:"broker_url"`
}

UpdateMachineResponse is the server response when update machine info

type UpdateRecoveryPointRequest

type UpdateRecoveryPointRequest struct {
	Status string `json:"status"`
}

UpdateRecoveryPointRequest represents a request to update a recovery point.

Jump to

Keyboard shortcuts

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