Documentation
¶
Overview ¶
Package flavors provides information and interaction with Flavors for the OpenStack Load-balancing service.
Example to List Flavors
listOpts := flavors.ListOpts{}
allPages, err := flavors.List(octaviaClient, listOpts).AllPages(context.TODO())
if err != nil {
panic(err)
}
allFlavors, err := flavors.ExtractFlavors(allPages)
if err != nil {
panic(err)
}
for _, flavor := range allFlavors {
fmt.Printf("%+v\n", flavor)
}
Example to Create a Flavor
createOpts := flavors.CreateOpts{
Name: "Flavor name",
Description: "My flavor description",
Enable: true,
FlavorProfileId: "9daa2768-74e7-4d13-bf5d-1b8e0dc239e1",
}
flavor, err := flavors.Create(context.TODO(), octaviaClient, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Update a Flavor
flavorID := "d67d56a6-4a86-4688-a282-f46444705c64"
updateOpts := flavors.UpdateOpts{
Name: "New name",
}
flavor, err := flavors.Update(context.TODO(), octaviaClient, flavorID, updateOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete a Flavor
flavorID := "d67d56a6-4a86-4688-a282-f46444705c64"
err := flavors.Delete(context.TODO(), octaviaClient, flavorID).ExtractErr()
if err != nil {
panic(err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of Flavor. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type CreateOpts ¶
type CreateOpts struct {
// Human-readable name for the Loadbalancer. Does not have to be unique.
Name string `json:"name" required:"true"`
// Human-readable description for the Flavor.
Description string `json:"description,omitempty"`
// The ID of the FlavorProfile which give the metadata for the creation of
// a LoadBalancer.
FlavorProfileId string `json:"flavor_profile_id" required:"true"`
// If the resource is available for use. The default is True.
Enabled bool `json:"enabled,omitempty"`
}
CreateOpts is the common options struct used in this package's Create operation.
func (CreateOpts) ToFlavorCreateMap ¶
func (opts CreateOpts) ToFlavorCreateMap() (map[string]any, error)
ToFlavorCreateMap builds a request body from 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 represents the result of a create operation. Call its Extract method to interpret it as a Flavor.
func Create ¶
func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create is and operation which add a new Flavor into the database. CreateResult will be returned.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
type Flavor ¶
type Flavor struct {
// The unique ID for the Flavor
ID string `json:"id"`
// Human-readable name for the Flavor. Does not have to be unique.
Name string `json:"name"`
// Human-readable description for the Flavor.
Description string `json:"description"`
// Status of the Flavor.
Enabled bool `json:"enabled"`
// Flavor Profile apply to this Flavor.
FlavorProfileId string `json:"flavor_profile_id"`
}
Flavor provide specs for the creation of a load balancer.
func ExtractFlavors ¶
func ExtractFlavors(r pagination.Page) ([]Flavor, error)
ExtractFlavors 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.
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.
type ListOpts ¶
type ListOpts struct {
// The fields that you want the server to return
Fields []string `q:"fields"`
}
ListOpts allows to manage the output of the request.
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 UpdateOpts ¶
type UpdateOpts struct {
// Human-readable name for the Loadbalancer. Does not have to be unique.
Name string `json:"name,omitempty"`
// Human-readable description for the Flavor.
Description string `json:"description,omitempty"`
// If the resource is available for use.
Enabled bool `json:"enabled,omitempty"`
}
UpdateOpts is the common options struct used in this package's Update operation.
func (UpdateOpts) ToFlavorUpdateMap ¶
func (opts UpdateOpts) ToFlavorUpdateMap() (map[string]any, error)
ToFlavorUpdateMap builds a request body from 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 represents the result of an update operation. Call its Extract method to interpret it as a Flavor.
func Update ¶
func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult)
Update is an operation which modifies the attributes of the specified Flavor.