quota_management

package
v0.0.0-...-9b598c7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxAllowedInstances = 1

Functions

func GetDefaultMaxAllowedInstances

func GetDefaultMaxAllowedInstances() int

GetDefaultMaxAllowedInstances - Returns the default max allowed instances for both internal (users and orgs in quota list config) and external users

Types

type Account

type Account struct {
	Username            string    `yaml:"username"`
	MaxAllowedInstances int       `yaml:"max_allowed_instances"`
	GrantedQuota        QuotaList `yaml:"granted_quota,omitempty"`
}

func (Account) GetBillingModel

func (account Account) GetBillingModel(instanceTypeID string, billingModelID string) (BillingModel, bool)

func (Account) GetGrantedQuota

func (account Account) GetGrantedQuota() QuotaList

func (Account) GetMaxAllowedInstances

func (account Account) GetMaxAllowedInstances(instanceTypeID string, billingModelID string) int

func (Account) HasQuotaConfigurationFor

func (account Account) HasQuotaConfigurationFor(instanceTypeId string, billingModelID string) bool

func (Account) IsInstanceCountWithinLimit

func (account Account) IsInstanceCountWithinLimit(instanceTypeID string, billingModelID string, count int) bool

type AccountList

type AccountList []Account

func (AccountList) GetByUsername

func (allowedAccounts AccountList) GetByUsername(username string) (Account, bool)

type BillingModel

type BillingModel struct {
	Id                  string          `yaml:"id"`
	ExpirationDate      *ExpirationDate `yaml:"expiration_date,omitempty"`
	MaxAllowedInstances int             `yaml:"max_allowed_instances"`
}

func (*BillingModel) HasExpired

func (bm *BillingModel) HasExpired() bool

type BillingModelList

type BillingModelList []BillingModel

type ExpirationDate

type ExpirationDate time.Time

func (*ExpirationDate) HasExpired

func (e *ExpirationDate) HasExpired() bool

func (*ExpirationDate) MarshalJSON

func (e *ExpirationDate) MarshalJSON() ([]byte, error)

func (*ExpirationDate) MarshalYAML

func (e *ExpirationDate) MarshalYAML() (any, error)

func (*ExpirationDate) UnmarshalJSON

func (e *ExpirationDate) UnmarshalJSON(b []byte) error

func (*ExpirationDate) UnmarshalYAML

func (e *ExpirationDate) UnmarshalYAML(unmarshal func(any) error) error

type Organisation

type Organisation struct {
	Id                  string      `yaml:"id"`
	AnyUser             bool        `yaml:"any_user"`
	MaxAllowedInstances int         `yaml:"max_allowed_instances"`
	RegisteredUsers     AccountList `yaml:"registered_users"`
	GrantedQuota        QuotaList   `yaml:"granted_quota,omitempty"`
}

func (Organisation) GetBillingModel

func (org Organisation) GetBillingModel(instanceTypeID string, billingModelID string) (BillingModel, bool)

func (Organisation) GetGrantedQuota

func (org Organisation) GetGrantedQuota() QuotaList

func (Organisation) GetMaxAllowedInstances

func (org Organisation) GetMaxAllowedInstances(instanceTypeID string, billingModelID string) int

func (Organisation) HasQuotaConfigurationFor

func (org Organisation) HasQuotaConfigurationFor(instanceTypeId string, billingModelID string) bool

func (Organisation) HasUsersRegistered

func (org Organisation) HasUsersRegistered() bool

func (Organisation) IsInstanceCountWithinLimit

func (org Organisation) IsInstanceCountWithinLimit(instanceTypeID string, billingModelID string, count int) bool

func (Organisation) IsUserRegistered

func (org Organisation) IsUserRegistered(username string) bool

type OrganisationList

type OrganisationList []Organisation

func (OrganisationList) GetById

func (orgList OrganisationList) GetById(Id string) (Organisation, bool)

type Quota

type Quota struct {
	InstanceTypeID     string           `yaml:"instance_type_id"`
	KafkaBillingModels BillingModelList `yaml:"kafka_billing_models,omitempty"`
}

func (*Quota) GetKafkaBillingModelByID

func (quota *Quota) GetKafkaBillingModelByID(billingModelId string) (BillingModel, bool)

func (*Quota) GetKafkaBillingModels

func (quota *Quota) GetKafkaBillingModels() BillingModelList

type QuotaList

type QuotaList []Quota

type QuotaManagementListConfig

type QuotaManagementListConfig struct {
	QuotaList                  RegisteredUsersListConfiguration
	QuotaListConfigFile        string
	EnableInstanceLimitControl bool
}

func NewQuotaManagementListConfig

func NewQuotaManagementListConfig() *QuotaManagementListConfig

func (*QuotaManagementListConfig) AddFlags

func (c *QuotaManagementListConfig) AddFlags(fs *pflag.FlagSet)

func (*QuotaManagementListConfig) GetAllowedAccountByUsernameAndOrgId

func (c *QuotaManagementListConfig) GetAllowedAccountByUsernameAndOrgId(username string, orgId string) (Account, bool)

func (*QuotaManagementListConfig) ReadFiles

func (c *QuotaManagementListConfig) ReadFiles() error

type QuotaManagementListItem

type QuotaManagementListItem interface {
	// IsInstanceCountWithinLimit returns true if the given count is within limits
	IsInstanceCountWithinLimit(instanceTypeID string, billingModelID string, count int) bool
	// GetMaxAllowedInstances returns maximum number of allowed instances.
	GetMaxAllowedInstances(instanceTypeID string, billingModelID string) int
}

type RegisteredUsersListConfiguration

type RegisteredUsersListConfiguration struct {
	Organisations   OrganisationList `yaml:"registered_users_per_organisation"`
	ServiceAccounts AccountList      `yaml:"registered_service_accounts"`
}

Jump to

Keyboard shortcuts

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