flavors

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package flavors contains functionality for working with ECL Baremetal Server's flavor resources.

Example to list flavors

listOpts := flavors.ListOpts{
	TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66",
}

allPages, err := flavors.List(client, listOpts).AllPages()
if err != nil {
	panic(err)
}

allFlavors, err := flavors.ExtractFlavors(allPages)
if err != nil {
	panic(err)
}

for _, flavor := range allFlavors {
	fmt.Printf("%+v", flavor)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDFromName

func IDFromName(client *eclcloud.ServiceClient, name string) (string, error)

IDFromName is a convenience function that returns a flavor's ID given its name.

func List

func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns Flavor optionally limited by the conditions provided in ListOpts.

Types

type Flavor

type Flavor struct {
	// ID is the flavor's unique ID.
	ID string `json:"id"`

	// Name is the name of the flavor.
	Name string `json:"name"`

	// Disk is the amount of root disk, measured in GB.
	Disk int `json:"disk"`

	// RAM is the amount of memory, measured in MB.
	RAM int `json:"ram"`

	// VCPUs indicates how many (virtual) CPUs are available for this flavor.
	VCPUs int `json:"vcpus"`
}

Flavor represent (virtual) hardware configurations for server resources in a region.

func ExtractFlavors

func ExtractFlavors(r pagination.Page) ([]Flavor, error)

ExtractFlavors provides access to the list of flavors in a page acquired from the ListDetail operation.

type FlavorPage

type FlavorPage struct {
	pagination.LinkedPageBase
}

FlavorPage contains a single page of all flavors from a ListDetails call.

func (FlavorPage) IsEmpty

func (page FlavorPage) IsEmpty() (bool, error)

IsEmpty determines if a FlavorPage contains any results.

func (FlavorPage) NextPageURL

func (page FlavorPage) NextPageURL() (string, error)

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult is the result of Get operations. Call its Extract method to interpret it as a Flavor.

func Get

func Get(client *eclcloud.ServiceClient, id string) (r GetResult)

Get retrieves the flavor with the provided ID. To extract the Flavor object from the response, call the Extract method on the GetResult.

func (GetResult) Extract

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

Extract provides access to the individual Flavor returned by the Get and functions.

type ListOpts

type ListOpts struct {
}

ListOpts holds options for listing flavors. It is passed to the flavors.List function.

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.

Directories

Path Synopsis
Package testing contains baremetal flavor unit tests
Package testing contains baremetal flavor unit tests

Jump to

Keyboard shortcuts

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