extensions

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 154

Documentation

Overview

Package extensions provides information and interaction with the different extensions available for an OpenStack service.

The purpose of OpenStack API extensions is to:

- Introduce new features in the API without requiring a version change. - Introduce vendor-specific niche functionality. - Act as a proving ground for experimental functionalities that might be included in a future version of the API.

Extensions usually have tags that prevent conflicts with other extensions that define attributes or resources with the same names, and with core resources and attributes. Because an extension might not be supported by all plug-ins, its availability varies with deployments and the specific plug-in.

The results of this package vary depending on the type of Service Client used. In the following examples, note how the only difference is the creation of the Service Client.

Example of Retrieving Compute Extensions

ao, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.AuthenticatedClient(ao)
computeClient, err := openstack.NewComputeV2(provider, gophercloud.EndpointOpts{
	Region: os.Getenv("OS_REGION_NAME"),
})

allPages, err := extensions.List(computeClient).AllPages()
allExtensions, err := extensions.ExtractExtensions(allPages)

for _, extension := range allExtensions{
	fmt.Printf("%+v\n", extension)
}

Example of Retrieving Network Extensions

ao, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.AuthenticatedClient(ao)
networkClient, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
	Region: os.Getenv("OS_REGION_NAME"),
})

allPages, err := extensions.List(networkClient).AllPages()
allExtensions, err := extensions.ExtractExtensions(allPages)

for _, extension := range allExtensions{
	fmt.Printf("%+v\n", extension)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtensionURL

func ExtensionURL(c *gophercloud.ServiceClient, name string) string

ExtensionURL generates the URL for an extension resource by name.

func List

List returns a Pager which allows you to iterate over the full collection of extensions. It does not accept query parameters.

func ListExtensionURL

func ListExtensionURL(c *gophercloud.ServiceClient) string

ListExtensionURL generates the URL for the extensions resource collection.

Types

type Extension

type Extension struct {
	Updated     string        `json:"updated"`
	Name        string        `json:"name"`
	Links       []interface{} `json:"links"`
	Namespace   string        `json:"namespace"`
	Alias       string        `json:"alias"`
	Description string        `json:"description"`
}

Extension is a struct that represents an OpenStack extension.

func ExtractExtensions

func ExtractExtensions(r pagination.Page) ([]Extension, error)

ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the elements into a slice of Extension structs. In other words, a generic collection is mapped into a relevant slice.

type ExtensionPage

type ExtensionPage struct {
	pagination.SinglePageBase
}

ExtensionPage is the page returned by a pager when traversing over a collection of extensions.

func (ExtensionPage) IsEmpty

func (r ExtensionPage) IsEmpty() (bool, error)

IsEmpty checks whether an ExtensionPage struct is empty.

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult temporarily stores the result of a Get call. Use its Extract() method to interpret it as an Extension.

func Get

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

Get retrieves information for a specific extension using its alias.

func (GetResult) Extract

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

Extract interprets a GetResult as an Extension.

Directories

Path Synopsis
common extensions unit tests
common extensions unit tests

Jump to

Keyboard shortcuts

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