Documentation
¶
Index ¶
- Constants
- Variables
- func WithHTTPClient(client *http.Client) func(*Client) error
- type BackupDirectory
- type BackupDirectoryConfig
- type BackupDirectoryConfigPolicy
- type Client
- func (c *Client) CompleteMultipart(ctx context.Context, recoveryPointID, uploadID string) error
- func (c *Client) CreateRecoveryPoint(ctx context.Context, backupDirectoryID string, ...) (*CreateRecoveryPointResponse, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) DownloadFileContent(ctx context.Context, createdAt string, restoreSessionKey string, ...) error
- func (c *Client) GetBackupDirectory(id string) (*BackupDirectory, error)
- func (c *Client) GetConfig(ctx context.Context) (*Config, error)
- func (c *Client) InitMultipart(ctx context.Context, recoveryPointID string) (*Multipart, error)
- func (c *Client) ListRecoveryPoints(ctx context.Context, backupDirectoryID string) ([]RecoveryPoint, error)
- func (c *Client) NewRequest(method, relPath string, body interface{}) (*http.Request, error)
- func (c *Client) RequestBackupDirectory(id string, cmbr *CreateManualBackupRequest) error
- func (c *Client) RequestRestore(recoveryPointID string, crr *CreateRestoreRequest) error
- func (c *Client) UpdateMachine() (*UpdateMachineResponse, error)
- func (c *Client) UpdateRecoveryPoint(ctx context.Context, backupDirectoryID string, recoveryPointID string, ...) error
- func (c *Client) UploadFile(fn string, r io.Reader, pw io.Writer, batch bool) error
- type ClientOption
- type Config
- type CreateManualBackupRequest
- type CreateRecoveryPointRequest
- type CreateRecoveryPointResponse
- type CreateRestoreRequest
- type File
- type Machine
- type Multipart
- type Part
- type Policy
- type PolicyDirectories
- type ProgressWriter
- type RecoveryPoint
- type UpdateMachineResponse
- type UpdateRecoveryPointRequest
Constants ¶
const ( RecoveryPointTypePoint = "RECOVERY_POINT" RecoveryPointTypeInitialReplica = "INITIAL_REPLICA" RecoveryPointStatusCreated = "CREATED" RecoveryPointStatusCompleted = "COMPLETED" RecoveryPointStatusFAILED = "FAILED" )
const MultipartUploadLowerBound = 15 * 1000 * 1000
Variables ¶
var ErrUpdateRecoveryPoint = errors.New("failed to update recovery point")
ErrUpdateRecoveryPoint indicates that there is error from server when updating recovery point.
Functions ¶
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 ¶
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 (*Client) CreateRecoveryPoint ¶
func (c *Client) CreateRecoveryPoint(ctx context.Context, backupDirectoryID string, crpr *CreateRecoveryPointRequest) (*CreateRecoveryPointResponse, error)
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) InitMultipart ¶
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 ¶
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 ¶
type ClientOption ¶
ClientOption provides mechanism to configure Client.
func WithAccessKey ¶
func WithAccessKey(accessKey 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 ¶
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 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.
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.