snapshots

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MPL-2.0 Imports: 5 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"`
	Metadata    map[string]string `json:"metadata,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 MetadataReplace

func MetadataReplace(client *gcorecloud.ServiceClient, id string, opts MetadataSetOpts) (r GetResult)

MetadataReplace replace a metadata for an snapshot.

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 MetadataActionResult

type MetadataActionResult struct {
	gcorecloud.ErrResult
}

MetadataActionResult represents the result of a create, delete or update operation(no content)

type MetadataOpts

type MetadataOpts struct {
	Key   string `json:"key" validate:"required,max=255"`
	Value string `json:"value" validate:"required,max=255"`
}

MetadataOpts. Set parameters for Create or Update operation

func (MetadataOpts) Validate

func (opts MetadataOpts) Validate() error

Validate

type MetadataOptsBuilder

type MetadataOptsBuilder interface {
	ToMetadataMap() (string, error)
}

MetadataOptsBuilder allows extensions to add additional parameters to the metadata Create and Update request.

type MetadataSetOpts

type MetadataSetOpts struct {
	Metadata []MetadataOpts `json:"metadata"`
}

MetadataSetOpts. Set parameters for Create or Update operation

func (MetadataSetOpts) ToMetadataMap

func (opts MetadataSetOpts) ToMetadataMap() (map[string]interface{}, error)

ToMetadataMap builds a request body from MetadataSetOpts.

func (MetadataSetOpts) Validate

func (opts MetadataSetOpts) Validate() error

Validate

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]string        `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