Documentation ¶
Overview ¶
Package backups provides information and interaction with backups in the OpenStack Block Storage service. A backup is a point in time copy of the data contained in an external storage volume, and can be controlled programmatically.
Example to List Backups
listOpts := backups.ListOpts{ VolumeID: "uuid", } allPages, err := backups.List(client, listOpts).AllPages() if err != nil { panic(err) } allBackups, err := backups.ExtractBackups(allPages) if err != nil { panic(err) } for _, backup := range allBackups { fmt.Println(backup) }
Example to Create a Backup
createOpts := backups.CreateOpts{ VolumeID: "uuid", Name: "my-backup", } backup, err := backups.Create(client, createOpts).Extract() if err != nil { panic(err) } fmt.Println(backup)
Example to Update a Backup
updateOpts := backups.UpdateOpts{ Name: "new-name", } backup, err := backups.Update(client, "uuid", updateOpts).Extract() if err != nil { panic(err) } fmt.Println(backup)
Example to Delete a Backup
err := backups.Delete(client, "uuid").ExtractErr() if err != nil { panic(err) }
Index ¶
- func ExtractBackupsInto(r pagination.Page, v interface{}) error
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type Backup
- type BackupPage
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractBackupsInto ¶
func ExtractBackupsInto(r pagination.Page, v interface{}) error
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns Backups optionally limited by the conditions provided in ListOpts.
Types ¶
type Backup ¶
type Backup struct { // ID is the Unique identifier of the backup. ID string `json:"id"` // CreatedAt is the date the backup was created. CreatedAt time.Time `json:"-"` // UpdatedAt is the date the backup was updated. UpdatedAt time.Time `json:"-"` // Name is the display name of the backup. Name string `json:"name"` // Description is the description of the backup. Description string `json:"description"` // VolumeID is the ID of the Volume from which this backup was created. VolumeID string `json:"volume_id"` // SnapshotID is the ID of the snapshot from which this backup was created. SnapshotID string `json:"snapshot_id"` // Status is the status of the backup. Status string `json:"status"` // Size is the size of the backup, in GB. Size int `json:"size"` // Object Count is the number of objects in the backup. ObjectCount int `json:"object_count"` // Container is the container where the backup is stored. Container string `json:"container"` // AvailabilityZone is the availability zone of the backup. AvailabilityZone string `json:"availability_zone"` // HasDependentBackups is whether there are other backups // depending on this backup. HasDependentBackups bool `json:"has_dependent_backups"` // FailReason has the reason for the backup failure. FailReason string `json:"fail_reason"` // IsIncremental is whether this is an incremental backup. IsIncremental bool `json:"is_incremental"` // DataTimestamp is the time when the data on the volume was first saved. DataTimestamp time.Time `json:"-"` // ProjectID is the ID of the project that owns the backup. This is // an admin-only field. ProjectID string `json:"os-backup-project-attr:project_id"` }
Backup contains all the information associated with a Cinder Backup.
func ExtractBackups ¶
func ExtractBackups(r pagination.Page) ([]Backup, error)
ExtractBackups extracts and returns Backups. It is used while iterating over a backups.List call.
func (*Backup) UnmarshalJSON ¶
UnmarshalJSON converts our JSON API response into our backup struct
type BackupPage ¶
type BackupPage struct {
pagination.LinkedPageBase
}
BackupPage is a pagination.Pager that is returned from a call to the List function.
func (BackupPage) IsEmpty ¶
func (r BackupPage) IsEmpty() (bool, error)
IsEmpty returns true if a BackupPage contains no Backups.
func (BackupPage) NextPageURL ¶
func (page BackupPage) NextPageURL() (string, error)
type CreateOpts ¶
type CreateOpts struct { // VolumeID is the ID of the volume to create the backup from. VolumeID string `json:"volume_id" required:"true"` // Force will force the creation of a backup regardless of the //volume's status. Force bool `json:"force,omitempty"` // Name is the name of the backup. Name string `json:"name,omitempty"` // Description is the description of the backup. Description string `json:"description,omitempty"` // Metadata is metadata for the backup. // Requires microversion 3.43 or later. Metadata map[string]string `json:"metadata,omitempty"` // Container is a container to store the backup. Container string `json:"container,omitempty"` // Incremental is whether the backup should be incremental or not. Incremental bool `json:"incremental,omitempty"` // SnapshotID is the ID of a snapshot to backup. SnapshotID string `json:"snapshot_id,omitempty"` // AvailabilityZone is an availability zone to locate the volume or snapshot. // Requires microversion 3.51 or later. AvailabilityZone string `json:"availability_zone,omitempty"` }
CreateOpts contains options for creating a Backup. This object is passed to the backups.Create function. For more information about these parameters, see the Backup object.
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 ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult contains the response body and error from a Create request.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new Backup based on the values in CreateOpts. To extract the Backup object from the response, call the Extract method on the CreateResult.
func (CreateResult) ExtractAvailabilityZone ¶
ExtractAvailaiblityZone will extract the availability zone of a backup. This requires the client to be set to microversion 3.51 or later.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
func (CreateResult) ExtractMetadata ¶
ExtractMetadata will extract the metadata of a backup. This requires the client to be set to microversion 3.43 or later.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult contains the response body and error from a Delete request.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete will delete the existing Backup with the provided ID.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult contains the response body and error from a Get request.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves the Backup with the provided ID. To extract the Backup object from the response, call the Extract method on the GetResult.
func (GetResult) ExtractAvailabilityZone ¶
ExtractAvailaiblityZone will extract the availability zone of a backup. This requires the client to be set to microversion 3.51 or later.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
func (GetResult) ExtractMetadata ¶
ExtractMetadata will extract the metadata of a backup. This requires the client to be set to microversion 3.43 or later.
type ListOpts ¶
type ListOpts struct { // AllTenants will retrieve backups of all tenants/projects. AllTenants bool `q:"all_tenants"` // Name will filter by the specified backup name. // This does not work in later microversions. Name string `q:"name"` // Status will filter by the specified status. // This does not work in later microversions. Status string `q:"status"` // TenantID will filter by a specific tenant/project ID. // Setting AllTenants is required to use this. TenantID string `q:"project_id"` // VolumeID will filter by a specified volume ID. // This does not work in later microversions. VolumeID string `q:"volume_id"` // Comma-separated list of sort keys and optional sort directions in the // form of <key>[:<direction>]. Sort string `q:"sort"` // Requests a page size of items. Limit int `q:"limit"` // Used in conjunction with limit to return a slice of items. Offset int `q:"offset"` // The ID of the last-seen item. Marker string `q:"marker"` }
func (ListOpts) ToBackupListQuery ¶
ToBackupListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type UpdateOpts ¶
type UpdateOpts struct { // Name is the name of the backup. Name *string `json:"name,omitempty"` // Description is the description of the backup. Description *string `json:"description,omitempty"` // Metadata is metadata for the backup. // Requires microversion 3.43 or later. Metadata map[string]string `json:"metadata,omitempty"` }
UpdateOpts contain options for updating an existing Backup.
func (UpdateOpts) ToBackupUpdateMap ¶
func (opts UpdateOpts) ToBackupUpdateMap() (map[string]interface{}, error)
ToBackupUpdateMap assembles a request body based on the contents of an UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult contains the response body and error from an Update request.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update will update the Backup with provided information. To extract the updated Backup from the response, call the Extract method on the UpdateResult. Requires microversion 3.9 or later.
func (UpdateResult) ExtractAvailabilityZone ¶
ExtractAvailaiblityZone will extract the availability zone of a backup. This requires the client to be set to microversion 3.51 or later.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(v interface{}) error
func (UpdateResult) ExtractMetadata ¶
ExtractMetadata will extract the metadata of a backup. This requires the client to be set to microversion 3.43 or later.