Documentation
¶
Overview ¶
Package limesresources contains data structures that appear on the Limes resource API.
Index ¶
- type BurstingMultiplier
- type ClusterAZResourceReport
- type ClusterAZResourceReports
- type ClusterAvailabilityZoneReport
- type ClusterAvailabilityZoneReports
- type ClusterReport
- type ClusterResourceReport
- type ClusterResourceReports
- type ClusterServiceReport
- type ClusterServiceReports
- type Commitment
- type CommitmentConfiguration
- type CommitmentDuration
- func (d CommitmentDuration) AddTo(t time.Time) time.Time
- func (d CommitmentDuration) MarshalJSON() ([]byte, error)
- func (d CommitmentDuration) MarshalYAML() (any, error)
- func (d *CommitmentDuration) Scan(src any) (err error)
- func (d CommitmentDuration) String() string
- func (d *CommitmentDuration) UnmarshalJSON(input []byte) error
- func (d *CommitmentDuration) UnmarshalYAML(unmarshal func(any) error) error
- func (d CommitmentDuration) Value() (driver.Value, error)
- type CommitmentRequest
- type CommitmentTransferStatus
- type DomainReport
- type DomainResourceReport
- type DomainResourceReports
- type DomainServiceReport
- type DomainServiceReports
- type ProjectAZResourceReport
- type ProjectAZResourceReports
- type ProjectBurstingInfo
- type ProjectReport
- type ProjectResourceReport
- type ProjectResourceReports
- type ProjectServiceReport
- type ProjectServiceReports
- type QuotaDistributionModel
- type QuotaRequest
- type ResourceInfo
- type ResourceQuotaRequest
- type ScalingBehavior
- type ServiceQuotaRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BurstingMultiplier ¶
type BurstingMultiplier float64
BurstingMultiplier is a multiplier for quota bursting.
func (BurstingMultiplier) ApplyTo ¶
func (m BurstingMultiplier) ApplyTo(quota uint64, qdModel QuotaDistributionModel) uint64
ApplyTo returns the bursted backend quota for the given approved quota.
type ClusterAZResourceReport ¶ added in v1.10.0
type ClusterAZResourceReport struct {
Capacity uint64 `json:"capacity"`
RawCapacity uint64 `json:"raw_capacity,omitempty"`
Usage *uint64 `json:"usage,omitempty"`
}
ClusterAZResourceReport is a substructure of ClusterResourceReport containing capacity and usage data for a single resource in an availability zone.
This type is part of the v2 API feature preview.
type ClusterAZResourceReports ¶ added in v1.10.0
type ClusterAZResourceReports map[limes.AvailabilityZone]*ClusterAZResourceReport
ClusterAZResourceReport is a substructure of ClusterResourceReport that breaks down capacity and usage data for a single resource by availability zone.
type ClusterAvailabilityZoneReport ¶
type ClusterAvailabilityZoneReport struct {
Name limes.AvailabilityZone `json:"name"`
Capacity uint64 `json:"capacity"`
RawCapacity uint64 `json:"raw_capacity,omitempty"`
Usage uint64 `json:"usage,omitempty"`
}
ClusterAvailabilityZoneReport is a substructure of ClusterResourceReport containing capacity and usage data for a single resource in an availability zone.
type ClusterAvailabilityZoneReports ¶
type ClusterAvailabilityZoneReports map[limes.AvailabilityZone]*ClusterAvailabilityZoneReport
ClusterAvailabilityZoneReports provides fast lookup of availability zones using a map, but serializes to JSON as a list.
func (ClusterAvailabilityZoneReports) MarshalJSON ¶
func (r ClusterAvailabilityZoneReports) MarshalJSON() ([]byte, error)
func (*ClusterAvailabilityZoneReports) UnmarshalJSON ¶
func (r *ClusterAvailabilityZoneReports) UnmarshalJSON(buf []byte) error
type ClusterReport ¶
type ClusterReport struct {
limes.ClusterInfo
Services ClusterServiceReports `json:"services"`
MaxScrapedAt *limes.UnixEncodedTime `json:"max_scraped_at,omitempty"`
MinScrapedAt *limes.UnixEncodedTime `json:"min_scraped_at,omitempty"`
}
ClusterReport contains aggregated data about resource usage in a cluster. It is returned by GET endpoints for clusters.
type ClusterResourceReport ¶
type ClusterResourceReport struct {
//Several fields are pointers to values to enable precise control over which fields are rendered in output.
ResourceInfo
QuotaDistributionModel QuotaDistributionModel `json:"quota_distribution_model,omitempty"`
Capacity *uint64 `json:"capacity,omitempty"`
RawCapacity *uint64 `json:"raw_capacity,omitempty"`
//PerAZ is only rendered by Limes when the v2 API feature preview is enabled.
//In this case, CapacityPerAZ will be omitted.
PerAZ ClusterAZResourceReports `json:"per_az,omitempty"`
CapacityPerAZ ClusterAvailabilityZoneReports `json:"per_availability_zone,omitempty"`
DomainsQuota *uint64 `json:"domains_quota,omitempty"`
Usage uint64 `json:"usage"`
BurstUsage uint64 `json:"burst_usage,omitempty"`
PhysicalUsage *uint64 `json:"physical_usage,omitempty"`
Subcapacities json.RawMessage `json:"subcapacities,omitempty"`
}
ClusterResourceReport is a substructure of ClusterReport containing data for a single resource.
type ClusterResourceReports ¶
type ClusterResourceReports map[string]*ClusterResourceReport
ClusterResourceReports provides fast lookup of resources by resource name, but serializes to JSON as a list.
func (ClusterResourceReports) MarshalJSON ¶
func (r ClusterResourceReports) MarshalJSON() ([]byte, error)
func (*ClusterResourceReports) UnmarshalJSON ¶
func (r *ClusterResourceReports) UnmarshalJSON(buf []byte) error
type ClusterServiceReport ¶
type ClusterServiceReport struct {
limes.ServiceInfo
Resources ClusterResourceReports `json:"resources"`
MaxScrapedAt *limes.UnixEncodedTime `json:"max_scraped_at,omitempty"`
MinScrapedAt *limes.UnixEncodedTime `json:"min_scraped_at,omitempty"`
}
ClusterServiceReport is a substructure of ClusterReport containing data for a single backend service.
type ClusterServiceReports ¶
type ClusterServiceReports map[string]*ClusterServiceReport
ClusterServiceReports provides fast lookup of services by service type, but serializes to JSON as a list.
func (ClusterServiceReports) MarshalJSON ¶
func (s ClusterServiceReports) MarshalJSON() ([]byte, error)
func (*ClusterServiceReports) UnmarshalJSON ¶
func (s *ClusterServiceReports) UnmarshalJSON(buf []byte) error
type Commitment ¶ added in v1.9.0
type Commitment struct {
ID int64 `json:"id"`
ServiceType string `json:"service_type"`
ResourceName string `json:"resource_name"`
AvailabilityZone limes.AvailabilityZone `json:"availability_zone"`
Amount uint64 `json:"amount"`
Unit limes.Unit `json:"unit"`
Duration CommitmentDuration `json:"duration"`
RequestedAt limes.UnixEncodedTime `json:"requested_at"`
// ConfirmedAt and ExpiresAt are only filled after the commitment was confirmed.
ConfirmedAt *limes.UnixEncodedTime `json:"confirmed_at,omitempty"`
ExpiresAt *limes.UnixEncodedTime `json:"expires_at,omitempty"`
// TransferStatus and TransferToken are only filled while the commitment is marked for transfer.
TransferStatus CommitmentTransferStatus `json:"transfer_status,omitempty"`
TransferToken string `json:"transfer_token,omitempty"`
}
Commitment is the API representation of an *existing* commitment as reported by Limes.
type CommitmentConfiguration ¶ added in v1.9.0
type CommitmentConfiguration struct {
// Allowed durations for commitments on this resource.
Durations []CommitmentDuration `json:"durations"`
}
CommitmentConfiguration describes how commitments are configured for a given resource.
This appears as a field on resource reports, if the respective resource allows commitments.
type CommitmentDuration ¶ added in v1.9.0
type CommitmentDuration struct {
//NOTE: this does not use uint etc. because time.Time.AddDate() wants int
Years int
Months int
Days int
Short time.Duration //represents durations of hours, minutes and seconds
}
CommitmentDuration is the parsed representation of a commitment duration.
The behavior of this type is similar to time.Duration or limesrates.Window for short durations (which are commonly used in automated tests for convenience and clarity), but also allows large durations with calendar-compatible calculations (e.g. "1y" is actually one year and not just 365 days).
func ParseCommitmentDuration ¶ added in v1.9.0
func ParseCommitmentDuration(input string) (CommitmentDuration, error)
ParseCommitmentDuration parses the string representation of a CommitmentDuration. Acceptable inputs include "5 hours" and "1year,2 \t months, 3days".
func (CommitmentDuration) AddTo ¶ added in v1.9.0
func (d CommitmentDuration) AddTo(t time.Time) time.Time
AddTo adds this duration to the given time.
func (CommitmentDuration) MarshalJSON ¶ added in v1.9.0
func (d CommitmentDuration) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (CommitmentDuration) MarshalYAML ¶ added in v1.9.0
func (d CommitmentDuration) MarshalYAML() (any, error)
MarshalYAML implements the yaml.Marshaler interface.
func (*CommitmentDuration) Scan ¶ added in v1.9.0
func (d *CommitmentDuration) Scan(src any) (err error)
Scan implements the sql.Scanner interface.
func (CommitmentDuration) String ¶ added in v1.9.0
func (d CommitmentDuration) String() string
String returns the canonical string representation of this duration.
func (*CommitmentDuration) UnmarshalJSON ¶ added in v1.9.0
func (d *CommitmentDuration) UnmarshalJSON(input []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
func (*CommitmentDuration) UnmarshalYAML ¶ added in v1.9.0
func (d *CommitmentDuration) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
type CommitmentRequest ¶ added in v1.9.0
type CommitmentRequest struct {
ServiceType string `json:"service_type"`
ResourceName string `json:"resource_name"`
AvailabilityZone limes.AvailabilityZone `json:"availability_zone"`
Amount uint64 `json:"amount"`
Duration CommitmentDuration `json:"duration"`
}
CommitmentRequest is the API representation of a *new* commitment as requested by a user.
type CommitmentTransferStatus ¶ added in v1.9.0
type CommitmentTransferStatus string
CommitmentTransferStatus is an enum.
const ( // CommitmentTransferStatusNone is the default transfer status, // meaning that the commitment is not marked for transfer. CommitmentTransferStatusNone CommitmentTransferStatus = "" // CommitmentTransferStatusPublic means that the commitment is marked for transfer, // and is visible as such to all other projects. CommitmentTransferStatusPublic CommitmentTransferStatus = "public" // CommitmentTransferStatusUnlisted means that the commitment is marked for transfer, // but the receiver needs to know the commitment's transfer token. CommitmentTransferStatusUnlisted CommitmentTransferStatus = "unlisted" )
type DomainReport ¶
type DomainReport struct {
limes.DomainInfo
Services DomainServiceReports `json:"services"`
}
DomainReport contains aggregated data about resource usage in a domain. It is returned by GET requests on domains.
type DomainResourceReport ¶
type DomainResourceReport struct {
//Several fields are pointers to values to enable precise control over which fields are rendered in output.
ResourceInfo
QuotaDistributionModel QuotaDistributionModel `json:"quota_distribution_model,omitempty"`
DomainQuota *uint64 `json:"quota,omitempty"`
ProjectsQuota *uint64 `json:"projects_quota,omitempty"`
Usage uint64 `json:"usage"`
BurstUsage uint64 `json:"burst_usage,omitempty"`
PhysicalUsage *uint64 `json:"physical_usage,omitempty"`
BackendQuota *uint64 `json:"backend_quota,omitempty"`
InfiniteBackendQuota *bool `json:"infinite_backend_quota,omitempty"`
Scaling *ScalingBehavior `json:"scales_with,omitempty"`
//Annotations may contain arbitrary metadata that was configured for this
//resource in this scope by Limes' operator.
Annotations map[string]any `json:"annotations,omitempty"`
}
DomainResourceReport is a substructure of DomainReport containing data for a single resource.
type DomainResourceReports ¶
type DomainResourceReports map[string]*DomainResourceReport
DomainResourceReports provides fast lookup of resources using a map, but serializes to JSON as a list.
func (DomainResourceReports) MarshalJSON ¶
func (r DomainResourceReports) MarshalJSON() ([]byte, error)
func (*DomainResourceReports) UnmarshalJSON ¶
func (r *DomainResourceReports) UnmarshalJSON(buf []byte) error
type DomainServiceReport ¶
type DomainServiceReport struct {
limes.ServiceInfo
Resources DomainResourceReports `json:"resources"`
MaxScrapedAt *limes.UnixEncodedTime `json:"max_scraped_at,omitempty"`
MinScrapedAt *limes.UnixEncodedTime `json:"min_scraped_at,omitempty"`
}
DomainServiceReport is a substructure of DomainReport containing data for a single backend service.
type DomainServiceReports ¶
type DomainServiceReports map[string]*DomainServiceReport
DomainServiceReports provides fast lookup of services using a map, but serializes to JSON as a list.
func (DomainServiceReports) MarshalJSON ¶
func (s DomainServiceReports) MarshalJSON() ([]byte, error)
func (*DomainServiceReports) UnmarshalJSON ¶
func (s *DomainServiceReports) UnmarshalJSON(buf []byte) error
type ProjectAZResourceReport ¶ added in v1.10.0
type ProjectAZResourceReport struct {
Quota *uint64 `json:"quota,omitempty"`
// The keys for the Committed map must be commitment durations as accepted
// by func ParseCommitmentDuration. We cannot use type CommitmentDuration
// directly here because Go does not allow struct types as map keys.
Committed map[string]uint64 `json:"committed,omitempty"`
Usage uint64 `json:"usage"`
PhysicalUsage *uint64 `json:"physical_usage,omitempty"`
Subresources json.RawMessage `json:"subresources,omitempty"`
}
ProjectAZResourceReport is a substructure of ProjectResourceReport containing quota and usage data for a single resource in an availability zone.
This type is part of the v2 API feature preview.
type ProjectAZResourceReports ¶ added in v1.10.0
type ProjectAZResourceReports map[limes.AvailabilityZone]*ProjectAZResourceReport
ProjectAZResourceReport is a substructure of ProjectResourceReport that breaks down quota and usage data for a single resource by availability zone.
type ProjectBurstingInfo ¶
type ProjectBurstingInfo struct {
Enabled bool `json:"enabled"`
Multiplier BurstingMultiplier `json:"multiplier"`
}
ProjectBurstingInfo is a substructure of ProjectReport containing information about quota bursting. (It is omitted if bursting is not supported for the project's cluster.)
type ProjectReport ¶
type ProjectReport struct {
limes.ProjectInfo
Bursting *ProjectBurstingInfo `json:"bursting,omitempty"`
Services ProjectServiceReports `json:"services"`
}
ProjectReport contains all data about resource usage in a project.
type ProjectResourceReport ¶
type ProjectResourceReport struct {
//Several fields are pointers to values to enable precise control over which fields are rendered in output.
ResourceInfo
QuotaDistributionModel QuotaDistributionModel `json:"quota_distribution_model,omitempty"`
CommitmentConfig *CommitmentConfiguration `json:"commitment_config,omitempty"`
//PerAZ is only rendered by Limes when the v2 API feature preview is enabled.
PerAZ ProjectAZResourceReports `json:"per_az,omitempty"`
Quota *uint64 `json:"quota,omitempty"`
DefaultQuota *uint64 `json:"default_quota,omitempty"`
UsableQuota *uint64 `json:"usable_quota,omitempty"`
Usage uint64 `json:"usage"`
BurstUsage uint64 `json:"burst_usage,omitempty"`
PhysicalUsage *uint64 `json:"physical_usage,omitempty"`
BackendQuota *int64 `json:"backend_quota,omitempty"`
Subresources json.RawMessage `json:"subresources,omitempty"`
Scaling *ScalingBehavior `json:"scales_with,omitempty"`
//Annotations may contain arbitrary metadata that was configured for this
//resource in this scope by Limes' operator.
Annotations map[string]any `json:"annotations,omitempty"`
}
ProjectResourceReport is a substructure of ProjectReport containing data for a single resource.
type ProjectResourceReports ¶
type ProjectResourceReports map[string]*ProjectResourceReport
ProjectResourceReports provides fast lookup of resources using a map, but serializes to JSON as a list.
func (ProjectResourceReports) MarshalJSON ¶
func (r ProjectResourceReports) MarshalJSON() ([]byte, error)
func (*ProjectResourceReports) UnmarshalJSON ¶
func (r *ProjectResourceReports) UnmarshalJSON(buf []byte) error
type ProjectServiceReport ¶
type ProjectServiceReport struct {
limes.ServiceInfo
Resources ProjectResourceReports `json:"resources"`
ScrapedAt *limes.UnixEncodedTime `json:"scraped_at,omitempty"`
}
ProjectServiceReport is a substructure of ProjectReport containing data for a single backend service.
type ProjectServiceReports ¶
type ProjectServiceReports map[string]*ProjectServiceReport
ProjectServiceReports provides fast lookup of services using a map, but serializes to JSON as a list.
func (ProjectServiceReports) MarshalJSON ¶
func (s ProjectServiceReports) MarshalJSON() ([]byte, error)
func (*ProjectServiceReports) UnmarshalJSON ¶
func (s *ProjectServiceReports) UnmarshalJSON(buf []byte) error
type QuotaDistributionModel ¶ added in v1.4.1
type QuotaDistributionModel string
QuotaDistributionModel is an enum.
const ( // HierarchicalQuotaDistribution is the default QuotaDistributionModel, // wherein quota is distributed to domains by the cloud admins, and then the // projects by the domain admins. Domains and projects start out at zero // quota. HierarchicalQuotaDistribution QuotaDistributionModel = "hierarchical" // CentralizedQuotaDistribution is an alternative QuotaDistributionModel, // wherein quota is directly given to projects by the cloud admins. Projects // start out at a generous default quota as configured by the Limes operator. // The domain quota cannot be edited and is always reported equal to the // projects quota. CentralizedQuotaDistribution QuotaDistributionModel = "centralized" )
type QuotaRequest ¶
type QuotaRequest map[string]ServiceQuotaRequest
QuotaRequest contains new quota values for resources in multiple services. The map key is the service type. This type is used to serialize JSON request bodies in PUT requests on domains and projects.
func (QuotaRequest) MarshalJSON ¶
func (r QuotaRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*QuotaRequest) UnmarshalJSON ¶
func (r *QuotaRequest) UnmarshalJSON(input []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type ResourceInfo ¶
type ResourceInfo struct {
Name string `json:"name"`
Unit limes.Unit `json:"unit,omitempty"`
//Category is an optional hint that UIs can use to group resources of one
//service into subgroups. If it is used, it should be set on all
//ResourceInfos reported by the same QuotaPlugin.
Category string `json:"category,omitempty"`
//If AutoApproveInitialQuota is non-zero, when a new project is scraped for
//the first time, a backend quota equal to this value will be approved
//automatically (i.e. Quota will be set equal to BackendQuota).
AutoApproveInitialQuota uint64 `json:"-"`
//If NoQuota is true, quota is not tracked at all for this resource. The
//resource will only report usage. This field is not shown in API responses.
//Check `res.Quota == nil` instead.
NoQuota bool `json:"-"`
//ContainedIn is an optional hint that UIs can use to group resources. If non-empty,
//this resource is semantically contained within the resource with that name
//in the same service.
ContainedIn string `json:"contained_in,omitempty"`
}
ResourceInfo contains the metadata for a resource (i.e. some thing for which quota and usage values can be retrieved from a backend service).
type ResourceQuotaRequest ¶
type ResourceQuotaRequest limes.ValueWithUnit
ResourceQuotaRequest contains new quota values for a single resource. This type appears in type ServiceQuotaRequest.
type ScalingBehavior ¶
type ScalingBehavior struct {
ScalesWithResourceName string `json:"resource_name"`
ScalesWithServiceType string `json:"service_type"`
ScalingFactor float64 `json:"factor"`
}
ScalingBehavior appears in type DomainResourceReport and type ProjectResourceReport and describes the scaling behavior of a single resource.
type ServiceQuotaRequest ¶
type ServiceQuotaRequest map[string]ResourceQuotaRequest
ServiceQuotaRequest contains new quota values for resources in a single service. The map key is the resource name. This type appears in type QuotaRequest.