utils

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseEndpoint

func BaseEndpoint(endpoint string) (string, error)

BaseEndpoint will return a URL without the /vX.Y portion of the URL.

func BaseVersionedEndpoint added in v2.8.0

func BaseVersionedEndpoint(endpoint string) (string, error)

BaseVersionedEndpoint will return a URL with the /vX.Y portion of the URL, if present, but without a project ID or similar

func ParseMicroversion

func ParseMicroversion(version string) (major int, minor int, err error)

ParseMicroversion parses the version major.minor into separate integers major and minor. For example, "2.53" becomes 2 and 53.

func ParseVersion added in v2.8.0

func ParseVersion(version string) (major, minor int, err error)

ParseVersion parsed the version strings v{MAJOR} and v{MAJOR}.{MINOR} into separate integers major and minor. For example, "v2.1" becomes 2 and 1, "v3" becomes 3 and 0, and "1" becomes 1 and 0.

func RequireMicroversion

func RequireMicroversion(ctx context.Context, client gophercloud.ServiceClient, required string) (gophercloud.ServiceClient, error)

RequireMicroversion checks that the required microversion is supported and returns a ServiceClient with the microversion set.

Types

type Status added in v2.8.0

type Status string
const (
	StatusCurrent      Status = "CURRENT"
	StatusSupported    Status = "SUPPORTED"
	StatusDeprecated   Status = "DEPRECATED"
	StatusExperimental Status = "EXPERIMENTAL"
	StatusUnknown      Status = ""
)

func ParseStatus added in v2.8.0

func ParseStatus(status string) (Status, error)

type SupportedMicroversions

type SupportedMicroversions struct {
	// MaxMajor is the major version number of the maximum supported API microversion
	MaxMajor int
	// MaxMinor is the minor version number of the maximum supported API microversion
	MaxMinor int
	// MinMajor is the major version number of the minimum supported API microversion
	MinMajor int
	// MinMinor is the minor version number of the minimum supported API microversion
	MinMinor int
}

SupportedMicroversions stores a normalized form of the maximum and minimum API microversions supported by a given service.

func GetSupportedMicroversions

func GetSupportedMicroversions(ctx context.Context, client *gophercloud.ServiceClient) (SupportedMicroversions, error)

GetSupportedMicroversions returns the minimum and maximum microversion that is supported by the ServiceClient Endpoint.

func (SupportedMicroversions) IsSupported

func (supported SupportedMicroversions) IsSupported(version string) (bool, error)

IsSupported checks if a microversion falls in the supported interval. It returns true if the version is within the interval and false otherwise.

type SupportedVersion added in v2.8.0

type SupportedVersion struct {
	// Major is the major version number of the API
	Major int
	// Minor is the minor version number of the API
	Minor int
	// Status is the status of the API
	Status Status
	SupportedMicroversions
}

SupportedVersion stores a normalized form of the API version data. It handles APIs that support microversions as well as those that do not.

func GetServiceVersions added in v2.8.0

func GetServiceVersions(ctx context.Context, client *gophercloud.ProviderClient, endpointURL string, discoverVersions bool) ([]SupportedVersion, error)

GetServiceVersions returns the versions supported by the ServiceClient Endpoint. If the endpoint resolves to an unversioned discovery API, this should return one or more supported versions. If the endpoint resolves to a versioned discovery API, this should return exactly one supported version.

type Version

type Version struct {
	ID       string
	Suffix   string
	Priority int
}

Version is a supported API version, corresponding to a vN package within the appropriate service.

func ChooseVersion

func ChooseVersion(ctx context.Context, client *gophercloud.ProviderClient, recognized []*Version) (*Version, string, error)

ChooseVersion queries the base endpoint of an API to choose the identity service version. It will pick a version among the recognized, taking into account the priority and avoiding experimental alternatives from the published versions. However, if the client specifies a full endpoint that is among the recognized versions, it will be used regardless of priority. It returns the highest-Priority Version, OR exact match with client endpoint, among the alternatives that are provided, as well as its corresponding endpoint.

Directories

Path Synopsis
utils
utils

Jump to

Keyboard shortcuts

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