Documentation ¶
Overview ¶
Package volumetransfers provides an interaction with volume transfers in the OpenStack Block Storage service. A volume transfer allows to transfer volumes between projects withing the same OpenStack region.
Example to List all Volume Transfer requests being an OpenStack admin
listOpts := &volumetransfers.ListOpts{ // this option is available only for OpenStack cloud admin AllTenants: true, } allPages, err := volumetransfers.List(client, listOpts).AllPages() if err != nil { panic(err) } allTransfers, err := volumetransfers.ExtractTransfers(allPages) if err != nil { panic(err) } for _, transfer := range allTransfers { fmt.Println(transfer) }
Example to Create a Volume Transfer request
createOpts := volumetransfers.CreateOpts{ VolumeID: "uuid", Name: "my-volume-transfer", } transfer, err := volumetransfers.Create(client, createOpts).Extract() if err != nil { panic(err) } fmt.Println(transfer) // secret auth key is returned only once as a create response fmt.Printf("AuthKey: %s\n", transfer.AuthKey)
Example to Accept a Volume Transfer request from the target project
acceptOpts := volumetransfers.AcceptOpts{ // see the create response above AuthKey: "volume-transfer-secret-auth-key", } // see the transfer ID from the create response above transfer, err := volumetransfers.Accept(client, "transfer-uuid", acceptOpts).Extract() if err != nil { panic(err) } fmt.Println(transfer)
Example to Delete a Volume Transfer request from the source project
err := volumetransfers.Delete(client, "transfer-uuid").ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTransfersInto ¶
func ExtractTransfersInto(r pagination.Page, v interface{}) error
ExtractTransfersInto similar to ExtractInto but operates on a `list` of transfers
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns Transfers optionally limited by the conditions provided in ListOpts.
Types ¶
type AcceptOpts ¶
type AcceptOpts struct { // The auth key of the volume transfer to accept. AuthKey string `json:"auth_key" required:"true"` }
AcceptOpts contains options for a Volume transfer accept reqeust.
func (AcceptOpts) ToAcceptMap ¶
func (opts AcceptOpts) ToAcceptMap() (map[string]interface{}, error)
ToAcceptMap assembles a request body based on the contents of a AcceptOpts.
type CreateOpts ¶
type CreateOpts struct { // The ID of the volume to transfer. VolumeID string `json:"volume_id" required:"true"` // The name of the volume transfer Name string `json:"name,omitempty"` }
CreateOpts contains options for a Volume transfer.
func (CreateOpts) ToCreateMap ¶
func (opts CreateOpts) ToCreateMap() (map[string]interface{}, error)
ToCreateMap assembles a request body based on the contents of a TransferOpts.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult contains the response body and error from a Create request.
func Accept ¶
func Accept(client *gophercloud.ServiceClient, id string, opts AcceptOpts) (r CreateResult)
Accept will accept a volume tranfer request based on the values in AcceptOpts.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOpts) (r CreateResult)
Create will create a volume tranfer request based on the values in CreateOpts.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
ExtractInto converts our response data into a transfer struct
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 deletes a volume transfer.
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 Transfer with the provided ID. To extract the Transfer object from the response, call the Extract method on the GetResult.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
ExtractInto converts our response data into a transfer struct
type ListOpts ¶
type ListOpts struct { // AllTenants will retrieve transfers of all tenants/projects. AllTenants bool `q:"all_tenants"` // 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"` }
ListOpts holds options for listing Transfers. It is passed to the transfers.List function.
func (ListOpts) ToTransferListQuery ¶
ToTransferListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Transfer ¶
type Transfer struct { ID string `json:"id"` AuthKey string `json:"auth_key"` Name string `json:"name"` VolumeID string `json:"volume_id"` CreatedAt time.Time `json:"-"` Links []map[string]string `json:"links"` }
Transfer represents a Volume Transfer record
func ExtractTransfers ¶
func ExtractTransfers(r pagination.Page) ([]Transfer, error)
ExtractTransfers extracts and returns Transfers. It is used while iterating over a transfers.List call.
func (*Transfer) UnmarshalJSON ¶
UnmarshalJSON is our unmarshalling helper
type TransferPage ¶
type TransferPage struct {
pagination.LinkedPageBase
}
TransferPage is a pagination.pager that is returned from a call to the List function.
func (TransferPage) IsEmpty ¶
func (r TransferPage) IsEmpty() (bool, error)
IsEmpty returns true if a ListResult contains no Transfers.
func (TransferPage) NextPageURL ¶
func (page TransferPage) NextPageURL() (string, error)