Documentation ¶
Overview ¶
Package flavors contains functionality for working GCLoud flavors API resources
Example to List Flavors
listOpts := flavors.ListOpts{ } allPages, err := flavors.List(flavorClient).AllPages() if err != nil { panic(err) } allFlavors, err := flavors.ExtractFlavors(allPages) if err != nil { panic(err) } for _, flavor := range allFlavors { fmt.Printf("%+v", flavor) }
Example to Create a Flavor
createOpts := flavors.CreateOpts{ } flavors, err := flavors.Create(flavorClient, createOpts).Extract() if err != nil { panic(err) }
Example to Delete a Flavor
flavorID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" err := flavors.Delete(flavorClient, flavorID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func ExtractFlavorsInto(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 Flavor
- type FlavorPage
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type ListResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFlavorsInto ¶
func ExtractFlavorsInto(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 flavor ID, given its name.
func List ¶
func List(c *gcorecloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List retrieves list of flavors
Types ¶
type Flavor ¶
type Flavor struct { FlavorID string `json:"flavor_id"` FlavorName string `json:"flavor_name"` PriceStatus *string `json:"price_status,omitempty"` CurrencyCode *gcorecloud.Currency `json:"currency_code,omitempty"` PricePerHour *decimal.Decimal `json:"price_per_hour,omitempty"` PricePerMonth *decimal.Decimal `json:"price_per_month,omitempty"` RAM int `json:"ram"` VCPUS int `json:"vcpus"` }
Flavor represents a flavor structure.
func ExtractFlavors ¶
func ExtractFlavors(r pagination.Page) ([]Flavor, error)
ExtractFlavor accepts a Page struct, specifically a FlavorPage struct, and extracts the elements into a slice of Flavor structs. In other words, a generic collection is mapped into a relevant slice.
func ListAll ¶ added in v0.4.29
func ListAll(c *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Flavor, error)
ListAll retrieves list of flavors
type FlavorPage ¶
type FlavorPage struct {
pagination.LinkedPageBase
}
FlavorPage is the page returned by a pager when traversing over a collection of flavors.
func (FlavorPage) IsEmpty ¶
func (r FlavorPage) IsEmpty() (bool, error)
IsEmpty checks whether a FlavorPage struct is empty.
func (FlavorPage) NextPageURL ¶
func (r FlavorPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of flavors 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 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 Flavor.
func (GetResult) Extract ¶
Extract is a function that accepts a result and extracts a flavor resource.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
type ListOpts ¶
type ListOpts struct {
IncludePrices *bool `q:"include_prices"`
}
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) ToFlavorListQuery ¶
ToFlavorListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type ListResult ¶ added in v0.4.24
type ListResult struct {
gcorecloud.Result
}
func (ListResult) Extract ¶ added in v0.4.24
func (r ListResult) Extract() ([]Flavor, error)
Extract is a function that accepts a result and extracts a flavor resource.
func (ListResult) ExtractInto ¶ added in v0.4.24
func (r ListResult) ExtractInto(v interface{}) error