snapshots

package
v0.3.29 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

Create accepts a CreateOpts struct and creates a new snapshot using the values provided.

func Delete

func Delete(c *gcorecloud.ServiceClient, snapshotID string) (r tasks.Result)

Delete accepts a unique ID and deletes the snapshot associated with it.

func ExtractSnapshotIDFromTask

func ExtractSnapshotIDFromTask(task *tasks.Task) (string, error)

func ExtractSnapshotsInto

func ExtractSnapshotsInto(r pagination.Page, v interface{}) error

func IDFromName

func IDFromName(client *gcorecloud.ServiceClient, name string, opts ListOptsBuilder) (string, error)

IDFromName is a convenience function that returns a snapshot ID, given its name.

Types

type CreateOpts

type CreateOpts struct {
	VolumeID    string `json:"volume_id" required:"true" validate:"required"`
	Name        string `json:"name" required:"true" validate:"required"`
	Description string `json:"description,omitempty"`
}

CreateOpts represents options used to create a snapshot.

func (CreateOpts) ToSnapshotCreateMap

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

ToSnapshotCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

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

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

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Snapshot.

func Get

func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific snapshot based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a snapshot resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type ListOpts

type ListOpts struct {
	VolumeID   string `q:"volume_id"`
	InstanceID string `q:"instance_id"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToSnapshotListQuery

func (opts ListOpts) ToSnapshotListQuery() (string, error)

ToListenerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToSnapshotListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Snapshot

type Snapshot struct {
	ID            string                   `json:"id"`
	Name          string                   `json:"name"`
	Description   string                   `json:"description"`
	Status        string                   `json:"status"`
	Size          int                      `json:"size"`
	VolumeID      string                   `json:"volume_id"`
	CreatedAt     gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt     *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	Metadata      map[string]interface{}   `json:"metadata"`
	CreatorTaskID *string                  `json:"creator_task_id"`
	TaskID        *string                  `json:"task_id"`
	ProjectID     int                      `json:"project_id"`
	RegionID      int                      `json:"region_id"`
	Region        string                   `json:"region"`
}

Snapshot represents a snapshot.

func ExtractSnapshots

func ExtractSnapshots(r pagination.Page) ([]Snapshot, error)

ExtractSnapshot accepts a Page struct, specifically a SnapshotPage struct, and extracts the elements into a slice of Snapshot structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(client *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Snapshot, error)

ListAll is a convenience function that returns all snapshots.

type SnapshotPage

type SnapshotPage struct {
	pagination.LinkedPageBase
}

SnapshotPage is the page returned by a pager when traversing over a collection of snapshots.

func (SnapshotPage) IsEmpty

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

IsEmpty checks whether a SnapshotPage struct is empty.

func (SnapshotPage) NextPageURL

func (r SnapshotPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of snapshots 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 SnapshotTaskResult

type SnapshotTaskResult struct {
	Snapshots []string `json:"snapshots"`
}

type UpdateOpts

type UpdateOpts struct {
	Name string `json:"name,omitempty"`
}

UpdateOpts represents options used to update a snapshot.

func (UpdateOpts) ToSnapshotUpdateMap

func (opts UpdateOpts) ToSnapshotUpdateMap() (map[string]interface{}, error)

ToSnapshotUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToSnapshotUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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