flavors

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

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()
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(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(octaviaClient, flavorID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Flavor

flavorID := "d67d56a6-4a86-4688-a282-f46444705c64"
err := flavors.Delete(octaviaClient, flavorID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

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]interface{}, error)

ToFlavorCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToFlavorCreateMap() (map[string]interface{}, error)
}

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

Create is and operation which add a new Flavor into the database. CreateResult will be returned.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Flavor, error)

Extract is a function that accepts a result and extracts a flavor.

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.

func Delete

func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete will permanently delete a particular Flavor based on its unique ID.

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.

func Get

func Get(c *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves a particular Flavor based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Flavor, error)

Extract is a function that accepts a result and extracts 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

func (opts ListOpts) ToFlavorListQuery() (string, error)

ToFlavorListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToFlavorListQuery() (string, error)
}

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]interface{}, error)

ToFlavorUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToFlavorUpdateMap() (map[string]interface{}, error)
}

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(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult)

Update is an operation which modifies the attributes of the specified Flavor.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Flavor, error)

Extract is a function that accepts a result and extracts a flavor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL