backup

package
v0.0.0-...-63319d1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 5 Imported by: 0

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

View Source
const ProviderID = "fc4d5750-22e7-4798-8a46-f48f62c4c1da"

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	CheckpointId string        `json:"checkpoint_id"`
	CreatedAt    time.Time     `json:"-"`
	ExtendInfo   ExtendInfo    `json:"extend_info"`
	Id           string        `json:"id"`
	Name         string        `json:"name"`
	ResourceId   string        `json:"resource_id"`
	Status       string        `json:"status"`
	UpdatedAt    time.Time     `json:"-"`
	VMMetadata   VMMetadata    `json:"backup_data"`
	Description  string        `json:"description"`
	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 BackupPage 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.

func (*Backup) UnmarshalJSON

func (r *Backup) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal Backup fields into needed values.

type BackupPage

type BackupPage struct {
	pagination.LinkedPageBase
}

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

func (BackupPage) IsEmpty

func (r BackupPage) IsEmpty() (bool, error)

IsEmpty checks whether a BackupPage struct is empty.

func (BackupPage) NextPageURL

func (r BackupPage) 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 BackupResource

type BackupResource struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Name      string `json:"name"`
	ExtraInfo string `json:"-"`
}

func (*BackupResource) UnmarshalJSON

func (r *BackupResource) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal BackupResource fields into needed values.

type Checkpoint

type Checkpoint struct {
	Status         string         `json:"status"`
	CreatedAt      time.Time      `json:"-"`
	Id             string         `json:"id"`
	ResourceGraph  string         `json:"resource_graph"`
	ProjectId      string         `json:"project_id"`
	ProtectionPlan ProtectionPlan `json:"protection_plan"`
}

func (*Checkpoint) UnmarshalJSON

func (r *Checkpoint) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal Checkpoint fields into needed values.

type CreateOpts

type CreateOpts struct {
	BackupName   string        `json:"backup_name,omitempty"`
	Description  string        `json:"description,omitempty"`
	ResourceType string        `json:"resource_type,omitempty"`
	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 {
	// contains filtered or unexported fields
}

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 commonResult

func (CreateResult) ExtractBackup

func (r CreateResult) ExtractBackup() (*Backup, error)

ExtractBackup will get the backup object from the commonResult

func (CreateResult) ExtractQueryResponse

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

type DeleteResult

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

func Delete

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

Delete will delete an existing backup.

func (DeleteResult) Extract

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

Extract will get the checkpoint object from the commonResult

func (DeleteResult) ExtractBackup

func (r DeleteResult) ExtractBackup() (*Backup, error)

ExtractBackup will get the backup object from the commonResult

func (DeleteResult) ExtractQueryResponse

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

type ExtendInfo

type ExtendInfo struct {
	AutoTrigger          bool           `json:"auto_trigger"`
	AverageSpeed         int            `json:"-"`
	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           time.Time      `json:"-"`
	TaskId               string         `json:"taskid"`
	HypervisorType       string         `json:"hypervisor_type"`
	SupportedRestoreMode string         `json:"supported_restore_mode"`
	Supportlld           bool           `json:"support_lld"`
}

func (*ExtendInfo) UnmarshalJSON

func (r *ExtendInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal ExtendInfo fields into needed values.

type FailCode

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

type GetResult

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

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() (*Checkpoint, error)

Extract will get the checkpoint object from the commonResult

func (GetResult) ExtractBackup

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

ExtractBackup will get the backup object from the commonResult

func (GetResult) ExtractQueryResponse

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

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 []BackupResource `json:"resources"`
}

type QueryResult

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

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) Extract

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

Extract will get the checkpoint object from the commonResult

func (QueryResult) ExtractBackup

func (r QueryResult) ExtractBackup() (*Backup, error)

ExtractBackup will get the backup object from the commonResult

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 ResourceTag

type ResourceTag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

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:"-"`
	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"`
}

Jump to

Keyboard shortcuts

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