Documentation
¶
Overview ¶
Package transfers 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 := &transfers.ListOpts{
// this option is available only for OpenStack cloud admin
AllTenants: true,
}
allPages, err := transfers.List(client, listOpts).AllPages(context.TODO())
if err != nil {
panic(err)
}
allTransfers, err := transfers.ExtractTransfers(allPages)
if err != nil {
panic(err)
}
for _, transfer := range allTransfers {
fmt.Println(transfer)
}
Example to Create a Volume Transfer request
createOpts := transfers.CreateOpts{
VolumeID: "uuid",
Name: "my-volume-transfer",
}
transfer, err := transfers.Create(context.TODO(), 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 := transfers.AcceptOpts{
// see the create response above
AuthKey: "volume-transfer-secret-auth-key",
}
// see the transfer ID from the create response above
transfer, err := transfers.Accept(context.TODO(), 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 := transfers.Delete(context.TODO(), 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 any) 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]any, 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]any, 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(ctx context.Context, 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(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOpts) (r CreateResult)
Create will create a volume tranfer request based on the values in CreateOpts.
func (CreateResult) ExtractInto ¶
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.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult contains the response body and error from a Get request.
func Get ¶
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 ¶
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)