rules

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MPL-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BillingModelReserved BillingModel = "RESERVED"
	BillingModelPayg     BillingModel = "PAYG"
	BillingModelDraas    BillingModel = "DRAAS"

	DisponibilityClassOneRoom    DisponibilityClass = "ONE-ROOM"
	DisponibilityClassHaDualRoom DisponibilityClass = "HA-DUAL-ROOM"
	DisponibilityClassDualRoom   DisponibilityClass = "DUAL-ROOM"

	ServiceClassEco  ServiceClass = "ECO"
	ServiceClassStd  ServiceClass = "STD"
	ServiceClassHp   ServiceClass = "HP"
	ServiceClassVoip ServiceClass = "VOIP"

	StorageProfileClassSilver       StorageProfileClass = "silver"
	StorageProfileClassSilverR1     StorageProfileClass = "silver_r1"
	StorageProfileClassSilverR2     StorageProfileClass = "silver_r2"
	StorageProfileClassGold         StorageProfileClass = "gold"
	StorageProfileClassGoldR1       StorageProfileClass = "gold_r1"
	StorageProfileClassGoldR2       StorageProfileClass = "gold_r2"
	StorageProfileClassGoldHm       StorageProfileClass = "gold_hm"
	StorageProfileClassPlatinum3k   StorageProfileClass = "platinum3k"
	StorageProfileClassPlatinum3kR1 StorageProfileClass = "platinum3k_r1"
	StorageProfileClassPlatinum3kR2 StorageProfileClass = "platinum3k_r2"
	StorageProfileClassPlatinum3kHm StorageProfileClass = "platinum3k_hm"
	StorageProfileClassPlatinum7k   StorageProfileClass = "platinum7k"
	StorageProfileClassPlatinum7kR1 StorageProfileClass = "platinum7k_r1"
	StorageProfileClassPlatinum7kR2 StorageProfileClass = "platinum7k_r2"
	StorageProfileClassPlatinum7kHm StorageProfileClass = "platinum7k_hm"
)

Variables

View Source
var (
	ErrServiceClassNotFound = fmt.Errorf("service class not found")

	ErrBillingModelNotAvailable = fmt.Errorf("billing model is not available")

	ErrDisponibilityClassNotFound = fmt.Errorf("disponibility class not found")

	ErrStorageProfileClassNotFound = fmt.Errorf("storage profile class not found")

	ErrStorageBillingModelNotFound = fmt.Errorf("storage billing model not found")

	ErrVCPUInMhzInvalid               = fmt.Errorf("VCPU in mhz is not valid")
	ErrCPUAllocatedInvalid            = fmt.Errorf("CPU allocated is not valid")
	ErrMemoryAllocatedInvalid         = fmt.Errorf("memory allocated is not valid")
	ErrStorageProfileDefault          = fmt.Errorf("only one storage profile can be default")
	ErrStorageProfileLimitInvalid     = fmt.Errorf("storage profile limit is not valid")
	ErrStorageProfileLimitNotIntegrer = fmt.Errorf("storage profile limit is not integrer")
)

Functions

func GetRulesDetails

func GetRulesDetails() string

GetRuleDetails returns one markdown table for each ServiceClass.

func GetStorageProfilesDetails added in v0.7.0

func GetStorageProfilesDetails() string

GetStorageProfilesDetails returns one markdown table for each ServiceClass.

func Validate

func Validate(data ValidateData, isUpdate bool) error

Validate returns true if the given BillingModel, DisponibilityClass and StorageProfileClass are valid for the given ServiceClass.

Types

type BillingModel

type BillingModel string

func ParseStorageBillingModel

func ParseStorageBillingModel(s string) (BillingModel, error)

ParseStorageBillingModel returns the StorageBillingModel from the given string.

type BillingModels

type BillingModels []BillingModel

func (BillingModels) String

func (bm BillingModels) String() string

String returns the string representation of the BillingModel.

type CPUAllocated

type CPUAllocated map[BillingModel]RuleValues

type DisponibilityClass

type DisponibilityClass string

type DisponibilityClasses

type DisponibilityClasses []DisponibilityClass

func (DisponibilityClasses) String

func (dc DisponibilityClasses) String() string

String returns the string representation of the DisponibilityClass.

type Rule

type Rule struct {
	// System
	VCPUInMhz       VCPUInMhz    `json:"cpu_in_mhz"`
	CPUAllocated    CPUAllocated `json:"cpu_allocated"`
	MemoryAllocated RuleValues   `json:"memory_allocated"`

	// Contract
	BillingModels        BillingModels        `json:"billing_model"`
	DisponibilityClasses DisponibilityClasses `json:"disponibility_class"`
	StorageProfiles      StorageProfiles      `json:"storage_profiles"`
	StorageBillingModel  StorageBillingModels `json:"storage_billing_model"`
}

func GetRuleByServiceClass

func GetRuleByServiceClass(sc ServiceClass) (Rule, error)

GetRuleByServiceClass returns the Rule for the given ServiceClass.

func (Rule) GetRuleDetails

func (r Rule) GetRuleDetails() string

GetRulesDetails returns the RuleValues for the given BillingModel and DisponibilityClass. Return markdown table with the following columns: - BillingModel - StorageBillingModels - DisponibilityClass - VCPUInMhz - CPUAllocated - MemoryAllocated

func (Rule) GetStorageProfileDetails added in v0.7.0

func (r Rule) GetStorageProfileDetails() string

GetStorageProfileDetails returns the RuleValues for the given StorageProfileClass. Return markdown table with the following columns: - StorageProfileClass - SizeLimit - IOPSLimit - BillingModels - DisponibilityClasses

type RuleValues

type RuleValues struct {
	Editable bool `json:"editable"`
	Min      *int `json:"min"`
	Max      *int `json:"max"`
	Equal    *int `json:"equal"`
}

func (RuleValues) String

func (rv RuleValues) String() string

String returns the string representation of the RuleValues.

type Rules

type Rules map[ServiceClass]Rule

type ServiceClass

type ServiceClass string

type ServiceClasses

type ServiceClasses []ServiceClass

func (ServiceClasses) String

func (sc ServiceClasses) String() string

String returns the string representation of the ServiceClass.

type StorageBillingModels

type StorageBillingModels []BillingModel

func (StorageBillingModels) String

func (sbm StorageBillingModels) String() string

String returns the string representation of the StorageBillingModel.

type StorageProfile added in v0.7.0

type StorageProfile struct {
	IOPSLimit            RuleValues
	SizeLimit            RuleValues
	BillingModels        BillingModels
	DisponibilityClasses DisponibilityClasses
}

type StorageProfileClass

type StorageProfileClass string

type StorageProfiles

type StorageProfiles map[StorageProfileClass]StorageProfile

func (StorageProfiles) String

func (sp StorageProfiles) String() string

String returns the string representation of the StorageProfileClass.

type StorageProfilesClasses

type StorageProfilesClasses []StorageProfileClass

type VCPUInMhz

type VCPUInMhz map[BillingModel]RuleValues

type ValidateData

type ValidateData struct {
	ServiceClass       ServiceClass
	BillingModel       BillingModel
	DisponibilityClass DisponibilityClass
	StorageProfiles    map[StorageProfileClass]struct {
		Limit   int
		Default bool
	}
	StorageBillingModel BillingModel
	VCPUInMhz           int
	CPUAllocated        int
	MemoryAllocated     int
}

Jump to

Keyboard shortcuts

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