Documentation ¶
Overview ¶
Package shares enables management and retrieval of Shares VBS service.
Example to List Shares
listOpts := shares.ListOpts{} allShares, err := shares.List(vbsClient, listOpts) if err != nil { panic(err) } for _, share := range allShares { fmt.Printf("%+v\n", share) }
Example to Get a Share
getshare,err:=shares.Get(vbsClient, "6149e448-dcac-4691-96d9-041e09ef617f").ExtractShare() if err != nil { panic(err) } fmt.Println(getshare)
Example to Create a Share
createOpts := shares.CreateOpts{BackupID:"87566ed6-72cb-4053-aa6e-6f6216b3d507", ToProjectIDs:[]string{"91d687759aed45d28b5f6084bc2fa8ad"}} share, err := shares.Create(vbsClient, createOpts).Extract() if err != nil { panic(err) }
Example to Delete a Share
shareID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" deleteopts := shares.DeleteOpts{IsBackupID:false} err := shares.Delete(vbsclient,shareID,deleteopts).ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backup ¶
type Backup struct { // Backup ID ID string `json:"id"` // Backup name Name string `json:"name"` // Backup status Status string `json:"status"` // Backup description Description string `json:"description"` // AZ where the backup resides AvailabilityZone string `json:"availability_zone"` // Source volume ID of the backup VolumeID string `json:"volume_id"` // Cause of the backup failure FailReason string `json:"fail_reason"` // Backup size Size int `json:"size"` // Number of objects on OBS for the disk data ObjectCount int `json:"object_count"` // Container of the backup Container string `json:"container"` // Backup creation time CreatedAt time.Time `json:"-"` // Backup metadata ServiceMetadata string `json:"service_metadata"` // Time when the backup was updated UpdatedAt time.Time `json:"-"` // Current time DataTimeStamp time.Time `json:"-"` // Whether a dependent backup exists DependentBackups bool `json:"has_dependent_backups"` // ID of the snapshot associated with the backup SnapshotID string `json:"snapshot_id"` // Whether the backup is an incremental backup IsIncremental bool `json:"is_incremental"` }
func (*Backup) UnmarshalJSON ¶
UnmarshalJSON overrides the default, to convert the JSON API response into our Backup struct
type CreateOpts ¶
type CreateOpts struct { // ID of the backup to be shared BackupID string `json:"backup_id" required:"true"` // IDs of projects with which the backup is shared ToProjectIDs []string `json:"to_project_ids" required:"true"` }
CreateOpts contains all the values needed to create a new share.
func (CreateOpts) ToShareCreateMap ¶
func (opts CreateOpts) ToShareCreateMap() (map[string]interface{}, error)
ToShareCreateMap builds a create request body from CreateOpts.
type CreateOptsBuilder ¶
type CreateOptsBuilder interface {
}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 Share.
func Create ¶
func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new Share based on the values in CreateOpts. To extract the Share object from the response, call the Extract method on the CreateResult.
func (CreateResult) ExtractShare ¶
ExtractShare is a function that accepts a result and extracts a share.
type DeleteOpts ¶
type DeleteOpts struct { // Whether the ID in the URL is a backup share ID or a backup ID IsBackupID bool `q:"is_backup_id"` }
func (DeleteOpts) ToShareDeleteQuery ¶
func (opts DeleteOpts) ToShareDeleteQuery() (string, error)
type DeleteOptsBuilder ¶
type DeleteOptsBuilder interface {
}DeleteOptsBuilder is an interface which can be able to build the query string of share deletion.
type DeleteResult ¶
type DeleteResult struct {
golangsdk.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(client *golangsdk.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)
Delete is a method by which can be able to delete one or all shares of a backup.
type FilterStruct ¶
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation. Call its ExtractShare method to interpret it as a Share.
func (GetResult) ExtractShare ¶
ExtractShare is a function that accepts a result and extracts a share.
type ListOpts ¶
type ListOpts struct { ID string SnapshotID string Name string `q:"name"` Status string `q:"status"` BackupID string `q:"backup_id"` FromProjectID string `q:"from_project_id"` ToProjectID string `q:"to_project_id"` AvailabilityZone string `q:"availability_zone"` SortDir SortDir `q:"sort_dir"` Limit int `q:"limit"` Offset int `q:"offset"` VolumeID string `q:"volume_id"` }
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 share attributes you want to see returned.
type Share ¶
type Share struct { Backup `json:"backup"` BackupID string `json:"backup_id"` ID string `json:"id"` ToProjectID string `json:"to_project_id"` FromProjectID string `json:"from_project_id"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` Deleted string `json:"deleted"` DeletedAt time.Time `json:"-"` }Backup
func ExtractShareList ¶
func ExtractShareList(r pagination.Page) ([]Share, error)
ExtractShareList accepts a Page struct, specifically a SharePage struct, and extracts the elements into a slice of Shares struct. In other words, a generic collection is mapped into a relevant slice.
func List ¶
List returns collection of share. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency. Default policy settings return only those share that are owned by the tenant who submits the request, unless an admin user submits the request.
func (*Share) UnmarshalJSON ¶
UnmarshalJSON overrides the default, to convert the JSON API response into our Share struct
type SharePage ¶
type SharePage struct {
}SharePage is the page returned by a pager when traversing over a collection of Shares.
func (SharePage) NextPageURL ¶
NextPageURL is invoked when a paginated collection of Shares 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.