limes

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Overview

Package limes contains data structures that appear on the Limes API. This package only has basic types that are shared between the resource API and the rate API. The concrete types for each of these sub-APIs are in the packages in the two subdirectories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityZone added in v1.9.0

type AvailabilityZone string

AvailabilityZone is the name of an availability zone. Some special values are enumerated below.

const (
	// AvailabilityZoneAny marks values that are not bound to a specific AZ.
	AvailabilityZoneAny AvailabilityZone = "any"
	// AvailabilityZoneUnknown marks values that are bound to an unknown AZ.
	AvailabilityZoneUnknown AvailabilityZone = "unknown"
)

type ClusterInfo added in v1.4.0

type ClusterInfo struct {
	ID string `json:"id"`
}

ClusterInfo contains the metadata for a cluster that appears in both resource data and rate data reports.

type DomainInfo added in v1.4.0

type DomainInfo struct {
	UUID string `json:"id"`
	Name string `json:"name"`
}

DomainInfo contains the metadata for a domain that appears in both resource data and rate data reports.

type FractionalValueError

type FractionalValueError struct {
	Source ValueWithUnit
	Target Unit
}

FractionalValueError is returned by ValueWithUnit.ConvertTo() when the conversion would yield a fractional value in the target unit.

func (FractionalValueError) Error

func (e FractionalValueError) Error() string

Error implements the error interface.

type IncompatibleUnitsError

type IncompatibleUnitsError struct {
	Source Unit
	Target Unit
}

IncompatibleUnitsError is returned by ValueWithUnit.ConvertTo() when the original and target unit are incompatible and cannot be converted into each other.

func (IncompatibleUnitsError) Error

func (e IncompatibleUnitsError) Error() string

Error implements the error interface.

type ProjectInfo added in v1.4.0

type ProjectInfo struct {
	UUID       string `json:"id"`
	Name       string `json:"name"`
	ParentUUID string `json:"parent_id"`
}

ProjectInfo contains the metadata for a project that appears in both resource data and rate data reports.

type ServiceInfo

type ServiceInfo struct {
	// Type returns the service type that the backend service for this
	// plugin implements. This string must be identical to the type string from
	// the Keystone service catalog.
	Type ServiceType `json:"type"`
	// ProductName returns the name of the product that is the reference
	// implementation for this service. For example, ProductName = "nova" for
	// Type = "compute".
	ProductName string `json:"-"`
	// Area is a hint that UIs can use to group similar services.
	Area string `json:"area"`
}

ServiceInfo contains the metadata for a backend service that appears in both resource data and rate data reports.

type ServiceType added in v1.10.11

type ServiceType string

ServiceType identifies a backend service that can have resources or rates. This type is used to distinguish service types from other types of string values in function signatures.

type Unit

type Unit string

Unit enumerates allowed values for the unit a resource's quota/usage is measured in.

const (
	// UnitNone is used for countable (rather than measurable) resources.
	UnitNone Unit = ""
	// UnitBytes is exactly that.
	UnitBytes Unit = "B"
	// UnitKibibytes is exactly that.
	UnitKibibytes Unit = "KiB"
	// UnitMebibytes is exactly that.
	UnitMebibytes Unit = "MiB"
	// UnitGibibytes is exactly that.
	UnitGibibytes Unit = "GiB"
	// UnitTebibytes is exactly that.
	UnitTebibytes Unit = "TiB"
	// UnitPebibytes is exactly that.
	UnitPebibytes Unit = "PiB"
	// UnitExbibytes is exactly that.
	UnitExbibytes Unit = "EiB"
	// UnitUnspecified is used as a placeholder when the unit is not known.
	UnitUnspecified Unit = "UNSPECIFIED"
)

func (Unit) Base

func (u Unit) Base() (Unit, uint64)

Base returns the base unit of this unit. For units defined as a multiple of another unit, that unit is the base unit. Otherwise, the same unit and a multiple of 1 is returned.

func (Unit) Parse

func (u Unit) Parse(str string) (uint64, error)

Parse parses the string representation of a value with this unit (or any unit that can be converted to it).

UnitMebibytes.Parse("10 MiB") -> 10
UnitMebibytes.Parse("10 GiB") -> 10240
UnitMebibytes.Parse("10 KiB") -> returns FractionalValueError
UnitMebibytes.Parse("10")     -> returns syntax error (missing unit)
UnitNone.Parse("42")          -> 42
UnitNone.Parse("42 MiB")      -> returns syntax error (unexpected unit)

func (*Unit) UnmarshalYAML

func (u *Unit) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface. This method validates that units in the config file actually exist.

type UnixEncodedTime added in v1.4.0

type UnixEncodedTime struct {
	time.Time
}

UnixEncodedTime is a time.Time that marshals into JSON as a UNIX timestamp.

This is a single-member struct instead of a newtype because the former enables directly calling time.Time methods on this type, e.g. t.String() instead of time.Time(t).String().

func (UnixEncodedTime) MarshalJSON added in v1.4.0

func (t UnixEncodedTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*UnixEncodedTime) UnmarshalJSON added in v1.4.0

func (t *UnixEncodedTime) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type ValueWithUnit

type ValueWithUnit struct {
	Value uint64 `json:"value" yaml:"value"`
	Unit  Unit   `json:"unit"  yaml:"unit"`
}

ValueWithUnit is used to represent values with units in subresources.

func (ValueWithUnit) ConvertTo

func (v ValueWithUnit) ConvertTo(u Unit) (ValueWithUnit, error)

ConvertTo returns an equal value in the given Unit. IncompatibleUnitsError is returned if the source unit cannot be converted into the target unit. FractionalValueError is returned if the conversion does not yield an integer value in the new unit.

func (ValueWithUnit) String

func (v ValueWithUnit) String() string

String appends the unit (if any) to the given value. This should only be used for error messages; actual UIs should be more clever about formatting values (e.g. ValueWithUnit{1048576,UnitMebibytes}.String() returns "1048576 MiB" where "1 TiB" would be more appropriate).

Directories

Path Synopsis
Package limesrates contains data structures that appear on the Limes rate API.
Package limesrates contains data structures that appear on the Limes rate API.
Package limesresources contains data structures that appear on the Limes resource API.
Package limesresources contains data structures that appear on the Limes resource API.

Jump to

Keyboard shortcuts

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