Documentation ¶
Overview ¶
Package volumetypes provides information and interaction with volume types in the OpenStack Block Storage service. A volume type is a collection of specs used to define the volume capabilities.
Example to list Volume Types
allPages, err := volumetypes.List(client, volumetypes.ListOpts{}).AllPages() if err != nil{ panic(err) } volumeTypes, err := volumetypes.ExtractVolumeTypes(allPages) if err != nil{ panic(err) } for _,vt := range volumeTypes{ fmt.Println(vt) }
Example to show a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" volumeType, err := volumetypes.Get(client, typeID).Extract() if err != nil{ panic(err) } fmt.Println(volumeType)
Example to create a Volume Type
volumeType, err := volumetypes.Create(client, volumetypes.CreateOpts{ Name:"volume_type_001", IsPublic:true, Description:"description_001", }).Extract() if err != nil{ panic(err) } fmt.Println(volumeType)
Example to delete a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" err := volumetypes.Delete(client, typeID).ExtractErr() if err != nil{ panic(err) }
Example to update a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" volumetype, err = volumetypes.Update(client, typeID, volumetypes.UpdateOpts{ Name: "volume_type_002", Description:"description_002", IsPublic:false, }).Extract() if err != nil{ panic(err) } fmt.Println(volumetype)
Example to Create Extra Specs for a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" createOpts := volumetypes.ExtraSpecsOpts{ "capabilities": "gpu", } createdExtraSpecs, err := volumetypes.CreateExtraSpecs(client, typeID, createOpts).Extract() if err != nil { panic(err) } fmt.Printf("%+v", createdExtraSpecs)
Example to Get Extra Specs for a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" extraSpecs, err := volumetypes.ListExtraSpecs(client, typeID).Extract() if err != nil { panic(err) } fmt.Printf("%+v", extraSpecs)
Example to Get specific Extra Spec for a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" extraSpec, err := volumetypes.GetExtraSpec(client, typeID, "capabilities").Extract() if err != nil { panic(err) } fmt.Printf("%+v", extraSpec)
Example to Update Extra Specs for a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" updateOpts := volumetypes.ExtraSpecsOpts{ "capabilities": "capabilities-updated", } updatedExtraSpec, err := volumetypes.UpdateExtraSpec(client, typeID, updateOpts).Extract() if err != nil { panic(err) } fmt.Printf("%+v", updatedExtraSpec)
Example to Delete an Extra Spec for a Volume Type
typeID := "7ffaca22-f646-41d4-b79d-d7e4452ef8cc" err := volumetypes.DeleteExtraSpec(client, typeID, "capabilities").ExtractErr() if err != nil { panic(err) }
Example to List Volume Type Access
typeID := "e91758d6-a54a-4778-ad72-0c73a1cb695b" allPages, err := volumetypes.ListAccesses(client, typeID).AllPages() if err != nil { panic(err) } allAccesses, err := volumetypes.ExtractAccesses(allPages) if err != nil { panic(err) } for _, access := range allAccesses { fmt.Printf("%+v", access) }
Example to Grant Access to a Volume Type
typeID := "e91758d6-a54a-4778-ad72-0c73a1cb695b" accessOpts := volumetypes.AddAccessOpts{ Project: "15153a0979884b59b0592248ef947921", } err := volumetypes.AddAccess(client, typeID, accessOpts).ExtractErr() if err != nil { panic(err) }
Example to Remove/Revoke Access to a Volume Type
typeID := "e91758d6-a54a-4778-ad72-0c73a1cb695b" accessOpts := volumetypes.RemoveAccessOpts{ Project: "15153a0979884b59b0592248ef947921", } err := volumetypes.RemoveAccess(client, typeID, accessOpts).ExtractErr() if err != nil { panic(err) }
Index ¶
- func ExtractVolumeTypesInto(r pagination.Page, v interface{}) error
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListAccesses(client *gophercloud.ServiceClient, id string) pagination.Pager
- type AccessPage
- type AddAccessOpts
- type AddAccessOptsBuilder
- type AddAccessResult
- type CreateExtraSpecsOptsBuilder
- type CreateExtraSpecsResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteExtraSpecResult
- type DeleteResult
- type ExtraSpecsOpts
- type GetExtraSpecResult
- type GetResult
- type ListExtraSpecsResult
- type ListOpts
- type ListOptsBuilder
- type RemoveAccessOpts
- type RemoveAccessOptsBuilder
- type RemoveAccessResult
- type UpdateExtraSpecOptsBuilder
- type UpdateExtraSpecResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type VolumeType
- type VolumeTypeAccess
- type VolumeTypePage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractVolumeTypesInto ¶
func ExtractVolumeTypesInto(r pagination.Page, v interface{}) error
ExtractVolumeTypesInto similar to ExtractInto but operates on a `list` of volume types
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns Volume types.
func ListAccesses ¶
func ListAccesses(client *gophercloud.ServiceClient, id string) pagination.Pager
ListAccesses retrieves the tenants which have access to a volume type.
Types ¶
type AccessPage ¶
type AccessPage struct {
pagination.SinglePageBase
}
AccessPage contains a single page of all VolumeTypeAccess entries for a volume type.
func (AccessPage) IsEmpty ¶
func (page AccessPage) IsEmpty() (bool, error)
IsEmpty indicates whether an AccessPage is empty.
type AddAccessOpts ¶
type AddAccessOpts struct { // Project is the project/tenant ID to grant access. Project string `json:"project"` }
AddAccessOpts represents options for adding access to a volume type.
func (AddAccessOpts) ToVolumeTypeAddAccessMap ¶
func (opts AddAccessOpts) ToVolumeTypeAddAccessMap() (map[string]interface{}, error)
ToVolumeTypeAddAccessMap constructs a request body from AddAccessOpts.
type AddAccessOptsBuilder ¶
AddAccessOptsBuilder allows extensions to add additional parameters to the AddAccess requests.
type AddAccessResult ¶
type AddAccessResult struct {
gophercloud.ErrResult
}
AddAccessResult is the response from a AddAccess request. Call its ExtractErr method to determine if the request succeeded or failed.
func AddAccess ¶
func AddAccess(client *gophercloud.ServiceClient, id string, opts AddAccessOptsBuilder) (r AddAccessResult)
AddAccess grants a tenant/project access to a volume type.
type CreateExtraSpecsOptsBuilder ¶
type CreateExtraSpecsOptsBuilder interface {
ToVolumeTypeExtraSpecsCreateMap() (map[string]interface{}, error)
}
CreateExtraSpecsOptsBuilder allows extensions to add additional parameters to the CreateExtraSpecs requests.
type CreateExtraSpecsResult ¶
type CreateExtraSpecsResult struct {
// contains filtered or unexported fields
}
CreateExtraSpecsResult contains the result of a Create operation. Call its Extract method to interpret it as a map[string]interface.
func CreateExtraSpecs ¶
func CreateExtraSpecs(client *gophercloud.ServiceClient, volumeTypeID string, opts CreateExtraSpecsOptsBuilder) (r CreateExtraSpecsResult)
CreateExtraSpecs will create or update the extra-specs key-value pairs for the specified volume type.
type CreateOpts ¶
type CreateOpts struct { // The name of the volume type Name string `json:"name" required:"true"` // The volume type description Description string `json:"description,omitempty"` // the ID of the existing volume snapshot IsPublic *bool `json:"os-volume-type-access:is_public,omitempty"` // Extra spec key-value pairs defined by the user. ExtraSpecs map[string]string `json:"extra_specs,omitempty"` }
CreateOpts contains options for creating a Volume Type. This object is passed to the volumetypes.Create function. For more information about these parameters, see the Volume Type object.
func (CreateOpts) ToVolumeTypeCreateMap ¶
func (opts CreateOpts) ToVolumeTypeCreateMap() (map[string]interface{}, error)
ToVolumeTypeCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult contains the response body and error from a Create request.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create will create a new Volume Type based on the values in CreateOpts. To extract the Volume Type object from the response, call the Extract method on the CreateResult.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*VolumeType, error)
Extract will get the Volume Type object out of the commonResult object.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
ExtractInto converts our response data into a volume type struct
type DeleteExtraSpecResult ¶
type DeleteExtraSpecResult struct {
gophercloud.ErrResult
}
DeleteExtraSpecResult contains the result of a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.
func DeleteExtraSpec ¶
func DeleteExtraSpec(client *gophercloud.ServiceClient, volumeTypeID, key string) (r DeleteExtraSpecResult)
DeleteExtraSpec will delete the key-value pair with the given key for the given volume type ID.
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 will delete the existing Volume Type with the provided ID.
type ExtraSpecsOpts ¶
ExtraSpecsOpts is a map that contains key-value pairs.
func (ExtraSpecsOpts) ToVolumeTypeExtraSpecUpdateMap ¶
func (opts ExtraSpecsOpts) ToVolumeTypeExtraSpecUpdateMap() (map[string]string, string, error)
ToVolumeTypeExtraSpecUpdateMap assembles a body for an Update request based on the contents of a ExtraSpecOpts.
func (ExtraSpecsOpts) ToVolumeTypeExtraSpecsCreateMap ¶
func (opts ExtraSpecsOpts) ToVolumeTypeExtraSpecsCreateMap() (map[string]interface{}, error)
ToVolumeTypeExtraSpecsCreateMap assembles a body for a Create request based on the contents of ExtraSpecsOpts.
type GetExtraSpecResult ¶
type GetExtraSpecResult struct {
// contains filtered or unexported fields
}
GetExtraSpecResult contains the result of a Get operation. Call its Extract method to interpret it as a map[string]interface.
func GetExtraSpec ¶
func GetExtraSpec(client *gophercloud.ServiceClient, volumeTypeID string, key string) (r GetExtraSpecResult)
GetExtraSpec requests an extra-spec specified by key for the given volume type ID
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 Volume Type with the provided ID. To extract the Volume Type object from the response, call the Extract method on the GetResult.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*VolumeType, error)
Extract will get the Volume Type object out of the commonResult object.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
ExtractInto converts our response data into a volume type struct
type ListExtraSpecsResult ¶
type ListExtraSpecsResult struct {
// contains filtered or unexported fields
}
ListExtraSpecsResult contains the result of a Get operation. Call its Extract method to interpret it as a map[string]interface.
func ListExtraSpecs ¶
func ListExtraSpecs(client *gophercloud.ServiceClient, volumeTypeID string) (r ListExtraSpecsResult)
ListExtraSpecs requests all the extra-specs for the given volume type ID.
type ListOpts ¶
type ListOpts struct { // 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 Volume Types. It is passed to the volumetypes.List function.
func (ListOpts) ToVolumeTypeListQuery ¶
ToVolumeTypeListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type RemoveAccessOpts ¶
type RemoveAccessOpts struct { // Project is the project/tenant ID to remove access. Project string `json:"project"` }
RemoveAccessOpts represents options for removing access to a volume type.
func (RemoveAccessOpts) ToVolumeTypeRemoveAccessMap ¶
func (opts RemoveAccessOpts) ToVolumeTypeRemoveAccessMap() (map[string]interface{}, error)
ToVolumeTypeRemoveAccessMap constructs a request body from RemoveAccessOpts.
type RemoveAccessOptsBuilder ¶
type RemoveAccessOptsBuilder interface {
ToVolumeTypeRemoveAccessMap() (map[string]interface{}, error)
}
RemoveAccessOptsBuilder allows extensions to add additional parameters to the RemoveAccess requests.
type RemoveAccessResult ¶
type RemoveAccessResult struct {
gophercloud.ErrResult
}
RemoveAccessResult is the response from a RemoveAccess request. Call its ExtractErr method to determine if the request succeeded or failed.
func RemoveAccess ¶
func RemoveAccess(client *gophercloud.ServiceClient, id string, opts RemoveAccessOptsBuilder) (r RemoveAccessResult)
RemoveAccess removes/revokes a tenant/project access to a volume type.
type UpdateExtraSpecOptsBuilder ¶
type UpdateExtraSpecOptsBuilder interface {
ToVolumeTypeExtraSpecUpdateMap() (map[string]string, string, error)
}
UpdateExtraSpecOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateExtraSpecResult ¶
type UpdateExtraSpecResult struct {
// contains filtered or unexported fields
}
UpdateExtraSpecResult contains the result of an Update operation. Call its Extract method to interpret it as a map[string]interface.
func UpdateExtraSpec ¶
func UpdateExtraSpec(client *gophercloud.ServiceClient, volumeTypeID string, opts UpdateExtraSpecOptsBuilder) (r UpdateExtraSpecResult)
UpdateExtraSpec will updates the value of the specified volume type's extra spec for the key in opts.
type UpdateOpts ¶
type UpdateOpts struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` IsPublic *bool `json:"is_public,omitempty"` }
UpdateOpts contain options for updating an existing Volume Type. This object is passed to the volumetypes.Update function. For more information about the parameters, see the Volume Type object.
func (UpdateOpts) ToVolumeTypeUpdateMap ¶
func (opts UpdateOpts) ToVolumeTypeUpdateMap() (map[string]interface{}, error)
ToVolumeTypeUpdateMap assembles a request body based on the contents of an UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult contains the response body and error from an Update request.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update will update the Volume Type with provided information. To extract the updated Volume Type from the response, call the Extract method on the UpdateResult.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*VolumeType, error)
Extract will get the Volume Type object out of the commonResult object.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(v interface{}) error
ExtractInto converts our response data into a volume type struct
type VolumeType ¶
type VolumeType struct { // Unique identifier for the volume type. ID string `json:"id"` // Human-readable display name for the volume type. Name string `json:"name"` // Human-readable description for the volume type. Description string `json:"description"` // Arbitrary key-value pairs defined by the user. ExtraSpecs map[string]string `json:"extra_specs"` // Whether the volume type is publicly visible. IsPublic bool `json:"is_public"` // Qos Spec ID QosSpecID string `json:"qos_specs_id"` // Volume Type access public attribute PublicAccess bool `json:"os-volume-type-access:is_public"` }
VolumeType contains all the information associated with an OpenStack Volume Type.
func ExtractVolumeTypes ¶
func ExtractVolumeTypes(r pagination.Page) ([]VolumeType, error)
ExtractVolumeTypes extracts and returns Volumes. It is used while iterating over a volumetypes.List call.
type VolumeTypeAccess ¶
type VolumeTypeAccess struct { // VolumeTypeID is the unique ID of the volume type. VolumeTypeID string `json:"volume_type_id"` // ProjectID is the unique ID of the project. ProjectID string `json:"project_id"` }
VolumeTypeAccess represents an ACL of project access to a specific Volume Type.
func ExtractAccesses ¶
func ExtractAccesses(r pagination.Page) ([]VolumeTypeAccess, error)
ExtractAccesses interprets a page of results as a slice of VolumeTypeAccess.
type VolumeTypePage ¶
type VolumeTypePage struct {
pagination.LinkedPageBase
}
VolumeTypePage is a pagination.pager that is returned from a call to the List function.
func (VolumeTypePage) IsEmpty ¶
func (r VolumeTypePage) IsEmpty() (bool, error)
IsEmpty returns true if a ListResult contains no Volume Types.
func (VolumeTypePage) NextPageURL ¶
func (page VolumeTypePage) NextPageURL() (string, error)