backup

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package backup enables management and retrieval of back up resources.

Example to List Backup

listbackup := backup.ListOpts{ID: "7b99acfd-18c3-4f26-9d39-b4ebd2ea3e12"}
allbackups, err := backup.List(client,listbackup)
if err != nil {
	panic(err)
}
fmt.Println(allbackups)

Example to Create a Backup

createBackup:=backup.CreateOpts{BackupName: "c2c-backup", Description: "mybackup"}
out,err:=backup.Create(client,"fc4d5750-22e7-4798-8a46-f48f62c4c1da", "f8ddc472-cf00-4384-851e-5f2a68c33762",
						createBackup).Extract()
fmt.Println(out)
fmt.Println(err)

Example to Query if resources can be backed up

createQuery:=backup.ResourceBackupCapOpts{CheckProtectable:[]backup.ResourceCapQueryParams{{ResourceId: "069e678a-f1d1-4a38-880b-459bde82fcc6",
										ResourceType: "OS::Nova::Server"}}}
out,err:=backup.QueryResourceBackupCapability(client,"fc4d5750-22e7-4798-8a46-f48f62c4c1da",
	createQuery).ExtractQueryResponse()
fmt.Println(out)
fmt.Println(err)

Example to Delete a Backup

out:=backup.Delete(client,"fc4d5750-22e7-4798-8a46-f48f62c4c1da")
fmt.Println(out)
if err != nil {
	panic(err)
}

Example to Get Backup

result:=backup.Get(client,"7b99acfd-18c3-4f26-9d39-b4ebd2ea3e12")
out,err:=result.ExtractBackup()
fmt.Println(out)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	CheckpointId string             `json:"checkpoint_id"`
	CreatedAt    string             `json:"created_at"`
	ExtendInfo   ExtendInfo         `json:"extend_info"`
	Id           string             `json:"id"`
	Name         string             `json:"name"`
	ResourceId   string             `json:"resource_id"`
	Status       string             `json:"status"`
	UpdatedAt    string             `json:"updated_at"`
	VMMetadata   VMMetadata         `json:"backup_data"`
	Description  string             `json:"description"`
	Tags         []tags.ResourceTag `json:"tags"`
	ResourceType string             `json:"resource_type"`
}

func ExtractBackups

func ExtractBackups(r pagination.Page) ([]Backup, error)

ExtractBackups accepts a Page struct, specifically a СsbsBackupPage struct, and extracts the elements into a slice of Backup structs. In other words, a generic collection is mapped into a relevant slice.

func FilterBackupsById

func FilterBackupsById(backups []Backup, filterId string) ([]Backup, error)

func List

func List(c *golangsdk.ServiceClient, opts ListOpts) ([]Backup, error)

List returns collection of backups. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

type Checkpoint

type Checkpoint struct {
	Status         string         `json:"status"`
	CreatedAt      string         `json:"created_at"`
	Id             string         `json:"id"`
	ResourceGraph  string         `json:"resource_graph"`
	ProjectId      string         `json:"project_id"`
	ProtectionPlan ProtectionPlan `json:"protection_plan"`
	ExtraInfo      interface{}    `json:"extra_info"`
}

type CreateOpts

type CreateOpts struct {
	BackupName   string             `json:"backup_name,omitempty"`
	Description  string             `json:"description,omitempty"`
	ResourceType string             `json:"resource_type,omitempty"`
	Incremental  *bool              `json:"incremental,omitempty"`
	Tags         []tags.ResourceTag `json:"tags,omitempty"`
	ExtraInfo    interface{}        `json:"extra_info,omitempty"`
}

CreateOpts contains the options for create a Backup. This object is passed to backup.Create().

func (CreateOpts) ToBackupCreateMap

func (opts CreateOpts) ToBackupCreateMap() (map[string]interface{}, error)

ToBackupCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToBackupCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	golangsdk.Result
}

func Create

func Create(client *golangsdk.ServiceClient, resourceID string, opts CreateOptsBuilder) (r CreateResult)

Create will create a new backup based on the values in CreateOpts. To extract the checkpoint object from the response, call the Extract method on the CreateResult.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Checkpoint, error)

Extract will get the checkpoint object from the golangsdk.Result

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

func Delete

func Delete(client *golangsdk.ServiceClient, checkpointID string) (r DeleteResult)

Delete will delete an existing backup.

type ExtendInfo

type ExtendInfo struct {
	AutoTrigger          bool           `json:"auto_trigger"`
	AverageSpeed         float32        `json:"average_speed"`
	CopyFrom             string         `json:"copy_from"`
	CopyStatus           string         `json:"copy_status"`
	FailCode             FailCode       `json:"fail_code"`
	FailOp               string         `json:"fail_op"`
	FailReason           string         `json:"fail_reason"`
	ImageType            string         `json:"image_type"`
	Incremental          bool           `json:"incremental"`
	Progress             int            `json:"progress"`
	ResourceAz           string         `json:"resource_az"`
	ResourceName         string         `json:"resource_name"`
	ResourceType         string         `json:"resource_type"`
	Size                 int            `json:"size"`
	SpaceSavingRatio     int            `json:"space_saving_ratio"`
	VolumeBackups        []VolumeBackup `json:"volume_backups"`
	FinishedAt           string         `json:"finished_at"`
	TaskId               string         `json:"taskid"`
	HypervisorType       string         `json:"hypervisor_type"`
	SupportedRestoreMode string         `json:"supported_restore_mode"`
	Supportlld           bool           `json:"support_lld"`
}

type FailCode

type FailCode struct {
	Code        string `json:"Code"`
	Description string `json:"Description"`
}

type GetResult

type GetResult struct {
	golangsdk.Result
}

func Get

func Get(client *golangsdk.ServiceClient, backupID string) (r GetResult)

Get will get a single backup with specific ID. To extract the Backup object from the response, call the ExtractBackup method on the GetResult.

func (GetResult) Extract

func (r GetResult) Extract() (*Backup, error)

Extract will get the backup object from the golangsdk.Result

type ListOpts

type ListOpts struct {
	Status       string `q:"status"`
	Limit        string `q:"limit"`
	Marker       string `q:"marker"`
	Sort         string `q:"sort"`
	AllTenants   string `q:"all_tenants"`
	Name         string `q:"name"`
	ResourceId   string `q:"resource_id"`
	ResourceName string `q:"resource_name"`
	PolicyId     string `q:"policy_id"`
	VmIp         string `q:"ip"`
	CheckpointId string `q:"checkpoint_id"`
	ID           string
	ResourceType string `q:"resource_type"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the attributes you want to see returned. Marker and Limit are used for pagination.

type ProtectionPlan

type ProtectionPlan struct {
	Id              string               `json:"id"`
	Name            string               `json:"name"`
	BackupResources []СsbsBackupResource `json:"resources"`
}

type QueryResult

type QueryResult struct {
	golangsdk.Result
}

func QueryResourceBackupCapability

func QueryResourceBackupCapability(client *golangsdk.ServiceClient, opts ResourceBackupCapabilityOptsBuilder) (r QueryResult)

QueryResourceBackupCapability will query whether resources can be backed up based on the values in ResourceBackupCapOpts. To extract the ResourceCap object from the response, call the ExtractQueryResponse method on the QueryResult.

func (QueryResult) ExtractQueryResponse

func (r QueryResult) ExtractQueryResponse() ([]ResourceCapability, error)

type ResourceBackupCapOpts

type ResourceBackupCapOpts struct {
	CheckProtectable []ResourceCapQueryParams `json:"check_protectable" required:"true"`
}

ResourceBackupCapOpts contains the options for querying whether resources can be backed up. This object is passed to backup.QueryResourceBackupCapability().

func (ResourceBackupCapOpts) ToQueryResourceCreateMap

func (opts ResourceBackupCapOpts) ToQueryResourceCreateMap() (map[string]interface{}, error)

ToQueryResourceCreateMap assembles a request body based on the contents of a ResourceBackupCapOpts.

type ResourceBackupCapabilityOptsBuilder

type ResourceBackupCapabilityOptsBuilder interface {
	ToQueryResourceCreateMap() (map[string]interface{}, error)
}

ResourceBackupCapabilityOptsBuilder allows extensions to add additional parameters to the QueryResourceBackupCapability request.

type ResourceCapQueryParams

type ResourceCapQueryParams struct {
	ResourceId   string `json:"resource_id" required:"true"`
	ResourceType string `json:"resource_type" required:"true"`
}

type ResourceCapability

type ResourceCapability struct {
	Result       bool   `json:"result"`
	ResourceType string `json:"resource_type"`
	ErrorCode    string `json:"error_code"`
	ErrorMsg     string `json:"error_msg"`
	ResourceId   string `json:"resource_id"`
}

type VMMetadata

type VMMetadata struct {
	RegionName       string `json:"__openstack_region_name"`
	CloudServiceType string `json:"cloudservicetype"`
	Disk             int    `json:"disk"`
	ImageType        string `json:"imagetype"`
	Ram              int    `json:"ram"`
	Vcpus            int    `json:"vcpus"`
	Eip              string `json:"eip"`
	PrivateIp        string `json:"private_ip"`
}

type VolumeBackup

type VolumeBackup struct {
	AverageSpeed     int    `json:"average_speed"`
	Bootable         bool   `json:"bootable"`
	Id               string `json:"id"`
	ImageType        string `json:"image_type"`
	Incremental      bool   `json:"incremental"`
	SnapshotID       string `json:"snapshot_id"`
	Name             string `json:"name"`
	Size             int    `json:"size"`
	SourceVolumeId   string `json:"source_volume_id"`
	SourceVolumeSize int    `json:"source_volume_size"`
	SpaceSavingRatio int    `json:"space_saving_ratio"`
	Status           string `json:"status"`
	SourceVolumeName string `json:"source_volume_name"`
}

type СsbsBackupPage added in v0.5.2

type СsbsBackupPage struct {
	pagination.LinkedPageBase
}

СsbsBackupPage is the page returned by a pager when traversing over a collection of backups.

func (СsbsBackupPage) IsEmpty added in v0.5.2

func (r СsbsBackupPage) IsEmpty() (bool, error)

IsEmpty checks whether a СsbsBackupPage struct is empty.

func (СsbsBackupPage) NextPageURL added in v0.5.2

func (r СsbsBackupPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of backups has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type СsbsBackupResource added in v0.5.2

type СsbsBackupResource struct {
	ID        string      `json:"id"`
	Type      string      `json:"type"`
	Name      string      `json:"name"`
	ExtraInfo interface{} `json:"extra_info"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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