Documentation ¶
Overview ¶
Package volume contains functionality for working GCLoud volumes API resources
Example to List Volume
listOpts := volumes.ListOpts{ } allPages, err := volumes.List(volumeClient).AllPages() if err != nil { panic(err) } allVolumes, err := volumes.ExtractVolumes(allPages) if err != nil { panic(err) } for _, volume := range allVolumes { fmt.Printf("%+v", volume) }
Example to Create a Volume
createOpts := volumes.CreateOpts{ } volumes, err := volumes.Create(volumeClient, createOpts).Extract() if err != nil { panic(err) }
Example to Delete a Volume
volumeID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" err := volumes.Delete(volumeClient, volumeID).ExtractErr() if err != nil { panic(err) }
Index ¶
- Constants
- func Create(c *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r tasks.Result)
- func Delete(c *gcorecloud.ServiceClient, volumeID string, opts DeleteOptsBuilder) (r tasks.Result)
- func Extend(c *gcorecloud.ServiceClient, volumeID string, ...) (r tasks.Result)
- func ExtractVolumeIDFromTask(task *tasks.Task) (string, error)
- func ExtractVolumesInto(r pagination.Page, v interface{}) error
- func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)
- func List(c *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type Attachment
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteOpts
- type DeleteOptsBuilder
- type DeleteResult
- type GetResult
- type InstanceOperationOpts
- type InstanceOperationOptsBuilder
- type ListOpts
- type ListOptsBuilder
- type Metadata
- type PropertiesOperationOptsBuilder
- type SizePropertyOperationOpts
- type UpdateResult
- type Volume
- type VolumeImageMetadata
- type VolumePage
- type VolumeSource
- func (vs VolumeSource) IsValid() error
- func (vs VolumeSource) List() []VolumeSource
- func (vs *VolumeSource) MarshalJSON() ([]byte, error)
- func (vs VolumeSource) String() string
- func (vs VolumeSource) StringList() []string
- func (vs *VolumeSource) UnmarshalJSON(data []byte) error
- func (vs VolumeSource) ValidOrNil() (*VolumeSource, error)
- type VolumeStatus
- func (vs VolumeStatus) IsValid() error
- func (vs VolumeStatus) List() []VolumeStatus
- func (vs *VolumeStatus) MarshalJSON() ([]byte, error)
- func (vs VolumeStatus) String() string
- func (vs VolumeStatus) StringList() []string
- func (vs *VolumeStatus) UnmarshalJSON(data []byte) error
- func (vs VolumeStatus) ValidOrNil() (*VolumeStatus, error)
- type VolumeTaskResult
- type VolumeType
- func (vt VolumeType) IsValid() error
- func (vt VolumeType) List() []VolumeType
- func (vt *VolumeType) MarshalJSON() ([]byte, error)
- func (vt VolumeType) String() string
- func (vt VolumeType) StringList() []string
- func (vt *VolumeType) UnmarshalJSON(data []byte) error
- func (vt VolumeType) ValidOrNil() (*VolumeType, error)
- type VolumeTypePropertyOperationOpts
Constants ¶
const ( NewVolume VolumeSource = "new-volume" Image VolumeSource = "image" Snapshot VolumeSource = "snapshot" Standard VolumeType = "standard" SsdHiIops VolumeType = "ssd_hiiops" Cold VolumeType = "cold" Ultra VolumeType = "ultra" Creating VolumeStatus = "creating" Available VolumeStatus = "available" Reserved VolumeStatus = "reserved" Attaching VolumeStatus = "attaching" Detaching VolumeStatus = "detaching" InUse VolumeStatus = "in-use" Maintenance VolumeStatus = "maintenance" Deleting VolumeStatus = "deleting" AwaitingTransfer VolumeStatus = "awaiting-transfer" Error VolumeStatus = "error" ErrorDeleting VolumeStatus = "error_deleting" RestoringBackup VolumeStatus = "restoring-backup" ErrorBackingUp VolumeStatus = "error_backing-up" ErrorRestoring VolumeStatus = "error_restoring" ErrorExtending VolumeStatus = "error_extending" Downloading VolumeStatus = "downloading" Uploading VolumeStatus = "uploading" Retyping VolumeStatus = "retyping" Extending VolumeStatus = "extending" )
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(c *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r tasks.Result)
Create accepts a CreateOpts struct and creates a new volume using the values provided.
func Delete ¶
func Delete(c *gcorecloud.ServiceClient, volumeID string, opts DeleteOptsBuilder) (r tasks.Result)
Delete accepts a unique ID and deletes the volume associated with it.
func Extend ¶
func Extend(c *gcorecloud.ServiceClient, volumeID string, opts PropertiesOperationOptsBuilder) (r tasks.Result)
Extend accepts a VolumeTypePropertyOperationOpts struct and extend volume.
func ExtractVolumesInto ¶
func ExtractVolumesInto(r pagination.Page, v interface{}) error
func IDFromName ¶
func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)
IDFromName is a convenience function that returns a volume ID, given its name.
func List ¶
func List(c *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List retrieves list of volumes
Types ¶
type Attachment ¶
type Attachment struct { ServerID string `json:"server_id"` AttachmentID string `json:"attachment_id"` InstanceName string `json:"instance_name"` AttachedAt gcorecloud.JSONRFC3339Z `json:"attached_at"` VolumeID string `json:"volume_id"` Device string `json:"device"` }
Attachment represents a attachment structure.
type CreateOpts ¶
type CreateOpts struct { Source VolumeSource `json:"source" required:"true" validate:"required,enum"` Name string `json:"name" required:"true" validate:"required"` Size int `json:"size,omitempty"` TypeName VolumeType `json:"type_name" required:"true" validate:"required,enum"` ImageID string `json:"image_id,omitempty" validate:"rfe=Source:image,allowed_without=SnapshotID,omitempty,uuid4"` SnapshotID string `json:"snapshot_id,omitempty" validate:"rfe=Source:snapshot,allowed_without=ImageID,omitempty,uuid4"` InstanceIDToAttachTo string `json:"instance_id_to_attach_to,omitempty" validate:"omitempty,uuid4"` Metadata map[string]string `json:"metadata,omitempty"` }
CreateOpts represents options used to create a volume.
func (CreateOpts) ToVolumeCreateMap ¶
func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error)
ToVolumeCreateMap builds a request body.
func (*CreateOpts) Validate ¶
func (opts *CreateOpts) Validate() error
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Volume.
func (CreateResult) Extract ¶
Extract is a function that accepts a result and extracts a volume resource.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
type DeleteOpts ¶
type DeleteOpts struct {
Snapshots []string `q:"snapshots" delimiter:"comma"`
}
DeleteOpts allows set additional parameters during volume deletion.
func (DeleteOpts) ToVolumeDeleteQuery ¶
func (opts DeleteOpts) ToVolumeDeleteQuery() (string, error)
ToVolumeDeleteQuery formats a DeleteOpts into a query string.
type DeleteOptsBuilder ¶
DeleteOptsBuilder allows extensions to add additional parameters to the Delete request
type DeleteResult ¶
type DeleteResult struct {
// contains filtered or unexported fields
}
DeleteResult represents the result of a delete operation
func (DeleteResult) Extract ¶
Extract is a function that accepts a result and extracts a volume resource.
func (DeleteResult) ExtractInto ¶
func (r DeleteResult) ExtractInto(v interface{}) error
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 Volume.
func Get ¶
func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific volume based on its unique ID.
func (GetResult) Extract ¶
Extract is a function that accepts a result and extracts a volume resource.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
type InstanceOperationOpts ¶
type InstanceOperationOpts struct {
InstanceID string `json:"instance_id" required:"true" validate:"required,uuid4"`
}
InstanceOperationOpts allows prepare data for Attach and Detach requests
func (InstanceOperationOpts) ToVolumeInstanceOperationMap ¶
func (opts InstanceOperationOpts) ToVolumeInstanceOperationMap() (map[string]interface{}, error)
ToVolumeInstanceOperationMap builds a request body.
type InstanceOperationOptsBuilder ¶
type InstanceOperationOptsBuilder interface {
ToVolumeInstanceOperationMap() (map[string]interface{}, error)
}
InstanceOperationOptsBuilder prepare data to proceed with Attach and Detach requests
type ListOpts ¶
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 cluster templates attributes you want to see returned. SortKey allows you to sort by a particular cluster templates attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToVolumeListQuery ¶
ToVolumeListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Metadata ¶
type Metadata struct { TaskID string `json:"task_id"` ClusterID string `json:"cluster_id"` AttachedMode string `json:"attached_mode"` }
Metadata represents a metadata of volume.
type PropertiesOperationOptsBuilder ¶
type PropertiesOperationOptsBuilder interface {
ToVolumePropertiesOperationMap() (map[string]interface{}, error)
}
PropertiesOperationOptsBuilder prepare data to proceed with Retype and Extend requests
type SizePropertyOperationOpts ¶
type SizePropertyOperationOpts struct {
Size int `json:"size" required:"true" validate:"required,gt=0"`
}
func (SizePropertyOperationOpts) ToVolumePropertiesOperationMap ¶
func (opts SizePropertyOperationOpts) ToVolumePropertiesOperationMap() (map[string]interface{}, error)
ToVolumePropertiesOperationMap builds a request body.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Volume.
func Attach ¶
func Attach(c *gcorecloud.ServiceClient, volumeID string, opts InstanceOperationOptsBuilder) (r UpdateResult)
Attach accepts a InstanceOperationOpts struct and attach volume to an instance.
func Detach ¶
func Detach(c *gcorecloud.ServiceClient, volumeID string, opts InstanceOperationOptsBuilder) (r UpdateResult)
Detach accepts a InstanceOperationOpts struct and detach volume to an instance.
func Retype ¶
func Retype(c *gcorecloud.ServiceClient, volumeID string, opts PropertiesOperationOptsBuilder) (r UpdateResult)
Retype accepts a VolumeTypePropertyOperationOpts struct and retype volume.
func (UpdateResult) Extract ¶
Extract is a function that accepts a result and extracts a volume resource.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(v interface{}) error
type Volume ¶
type Volume struct { AvailabilityZone string `json:"availability_zone"` CreatedAt gcorecloud.JSONRFC3339Z `json:"created_at"` UpdatedAt gcorecloud.JSONRFC3339Z `json:"updated_at"` VolumeType VolumeType `json:"volume_type"` ID string `json:"id"` Name string `json:"name"` RegionName string `json:"region"` Status VolumeStatus `json:"status"` Size int `json:"size"` Bootable bool `json:"bootable"` SnapshotID string `json:"snapshot_id"` SourceVolID string `json:"source_volid"` ProjectID int `json:"project_id"` RegionID int `json:"region_id"` Attachments []Attachment `json:"attachments"` Metadata Metadata `json:"metadata"` CreatorTaskID string `json:"creator_task_id"` VolumeImageMetadata VolumeImageMetadata `json:"volume_image_metadata"` }
Volume represents a volume structure.
func ExtractVolumes ¶
func ExtractVolumes(r pagination.Page) ([]Volume, error)
ExtractVolume accepts a Page struct, specifically a VolumePage struct, and extracts the elements into a slice of Volume structs. In other words, a generic collection is mapped into a relevant slice.
func ListAll ¶
func ListAll(client *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Volume, error)
ListAll is a convenience function that returns all volumes.
type VolumeImageMetadata ¶
type VolumeImageMetadata struct { ContainerFormat string `json:"container_format"` MinRAM string `json:"min_ram"` OwnerSpecifiedOpenstackSHA256 string `json:"owner_specified.openstack.sha256"` DiskFormat string `json:"disk_format"` ImageName string `json:"image_name"` ImageID string `json:"image_id"` OwnerSpecifiedOpenstackObject string `json:"owner_specified.openstack.object"` OwnerSpecifiedOpenstackMD5 string `json:"owner_specified.openstack.md5"` MinDisk string `json:"min_disk"` Checksum string `json:"checksum"` Size string `json:"size"` }
VolumeImageMetadata represents a metadata of volume image.
type VolumePage ¶
type VolumePage struct {
pagination.LinkedPageBase
}
VolumePage is the page returned by a pager when traversing over a collection of volumes.
func (VolumePage) IsEmpty ¶
func (r VolumePage) IsEmpty() (bool, error)
IsEmpty checks whether a VolumePage struct is empty.
func (VolumePage) NextPageURL ¶
func (r VolumePage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of volumes 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 VolumeSource ¶
type VolumeSource string
func (VolumeSource) IsValid ¶
func (vs VolumeSource) IsValid() error
func (VolumeSource) List ¶
func (vs VolumeSource) List() []VolumeSource
func (*VolumeSource) MarshalJSON ¶
func (vs *VolumeSource) MarshalJSON() ([]byte, error)
MarshalJSON - implements Marshaler interface for VolumeSource
func (VolumeSource) String ¶
func (vs VolumeSource) String() string
func (VolumeSource) StringList ¶
func (vs VolumeSource) StringList() []string
func (*VolumeSource) UnmarshalJSON ¶
func (vs *VolumeSource) UnmarshalJSON(data []byte) error
UnmarshalJSON - implements Unmarshaler interface for VolumeSource
func (VolumeSource) ValidOrNil ¶
func (vs VolumeSource) ValidOrNil() (*VolumeSource, error)
type VolumeStatus ¶
type VolumeStatus string
func (VolumeStatus) IsValid ¶
func (vs VolumeStatus) IsValid() error
func (VolumeStatus) List ¶
func (vs VolumeStatus) List() []VolumeStatus
func (*VolumeStatus) MarshalJSON ¶
func (vs *VolumeStatus) MarshalJSON() ([]byte, error)
MarshalJSON - implements Marshaler interface for VolumeStatus
func (VolumeStatus) String ¶
func (vs VolumeStatus) String() string
func (VolumeStatus) StringList ¶
func (vs VolumeStatus) StringList() []string
func (*VolumeStatus) UnmarshalJSON ¶
func (vs *VolumeStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON - implements Unmarshaler interface for VolumeStatus
func (VolumeStatus) ValidOrNil ¶
func (vs VolumeStatus) ValidOrNil() (*VolumeStatus, error)
type VolumeTaskResult ¶
type VolumeTaskResult struct {
Volumes []string `json:"volumes"`
}
type VolumeType ¶
type VolumeType string
func (VolumeType) IsValid ¶
func (vt VolumeType) IsValid() error
func (VolumeType) List ¶
func (vt VolumeType) List() []VolumeType
func (*VolumeType) MarshalJSON ¶
func (vt *VolumeType) MarshalJSON() ([]byte, error)
MarshalJSON - implements Marshaler interface for VolumeType
func (VolumeType) String ¶
func (vt VolumeType) String() string
func (VolumeType) StringList ¶
func (vt VolumeType) StringList() []string
func (*VolumeType) UnmarshalJSON ¶
func (vt *VolumeType) UnmarshalJSON(data []byte) error
UnmarshalJSON - implements Unmarshaler interface for VolumeType
func (VolumeType) ValidOrNil ¶
func (vt VolumeType) ValidOrNil() (*VolumeType, error)
type VolumeTypePropertyOperationOpts ¶
type VolumeTypePropertyOperationOpts struct {
VolumeType VolumeType `json:"volume_type" required:"true" validate:"required,enum"`
}
func (VolumeTypePropertyOperationOpts) ToVolumePropertiesOperationMap ¶
func (opts VolumeTypePropertyOperationOpts) ToVolumePropertiesOperationMap() (map[string]interface{}, error)
ToVolumePropertiesOperationMap builds a request body.