cost

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequestResourceEmpty    = errors.New("cost request info is not enough")
	ErrCostResultEmpty         = errors.New("cost information does not exist")
	ErrCostResultFormatInvalid = errors.New("cost result does not matching with interface")
)

Functions

This section is empty.

Types

type AwsAdditionalInfoParam added in v0.2.2

type AwsAdditionalInfoParam struct {
	OwnerId string   `json:"ownerId"`
	Regions []string `json:"regions"`
}

type AwsCostExplorerBaristaCostCollector added in v0.2.4

type AwsCostExplorerBaristaCostCollector struct {
	// contains filtered or unexported fields
}

func (*AwsCostExplorerBaristaCostCollector) GetCostInfos added in v0.2.4

func (*AwsCostExplorerBaristaCostCollector) Readyz added in v0.2.4

func (*AwsCostExplorerBaristaCostCollector) UpdateEstimateForecastCost added in v0.2.4

type CostCollector added in v0.2.2

func NewAwsCostExplorerSpiderCostCollector added in v0.2.2

func NewAwsCostExplorerSpiderCostCollector(sc *spider.SpiderClient, tc *tumblebug.TumblebugClient) CostCollector

type CostRepository

type CostRepository struct {
	// contains filtered or unexported fields
}

func NewCostRepository

func NewCostRepository(db *gorm.DB) *CostRepository

func (*CostRepository) BatchInsertAllEstimateCostResultTx added in v0.2.4

func (r *CostRepository) BatchInsertAllEstimateCostResultTx(ctx context.Context, created EstimateCostInfos) error

func (*CostRepository) GetEstimateForecastCostInfosTx added in v0.2.4

func (r *CostRepository) GetEstimateForecastCostInfosTx(ctx context.Context, param GetEstimateForecastCostParam) ([]GetEstimateForecastCostInfoResult, int64, error)

func (*CostRepository) GetMatchingEstimateCostInfosTx added in v0.2.4

func (r *CostRepository) GetMatchingEstimateCostInfosTx(ctx context.Context, param GetEstimateCostParam) (EstimateCostInfos, int64, error)

func (*CostRepository) GetMatchingEstimateCostTx added in v0.2.4

func (r *CostRepository) GetMatchingEstimateCostTx(ctx context.Context, param RecommendSpecParam, timeStandard time.Time, pricePolicy constant.PricePolicy) (EstimateCostInfos, error)

func (*CostRepository) GetMatchingEstimateCostWithoutTypeTx added in v0.2.4

func (r *CostRepository) GetMatchingEstimateCostWithoutTypeTx(ctx context.Context, param RecommendSpecParam, timeStandard time.Time, pricePolicy constant.PricePolicy) (EstimateCostInfos, error)

func (*CostRepository) UpsertCostInfo added in v0.2.2

func (r *CostRepository) UpsertCostInfo(ctx context.Context, costInfo EstimateForecastCostInfo) (int64, int64, error)

type CostResourceParam added in v0.2.2

type CostResourceParam struct {
	ResourceType constant.ResourceType
	ResourceIds  []string
}

type CostService

type CostService struct {
	// contains filtered or unexported fields
}

func NewCostService

func NewCostService(costRepo *CostRepository, priceCollector PriceCollector, costCollector CostCollector) *CostService

func (*CostService) GetEstimateCost added in v0.2.4

func (c *CostService) GetEstimateCost(param GetEstimateCostParam) (EstimateCostInfoResults, error)

func (*CostService) GetEstimateForecastCostInfos added in v0.2.4

func (c *CostService) GetEstimateForecastCostInfos(param GetEstimateForecastCostParam) (GetEstimateForecastCostInfoResults, error)

func (*CostService) Readyz added in v0.2.3

func (c *CostService) Readyz() error

func (*CostService) UpdateAndGetEstimateCost added in v0.2.4

func (c *CostService) UpdateAndGetEstimateCost(param UpdateAndGetEstimateCostParam) (EstimateCostResults, error)

func (*CostService) UpdateEstimateForecastCost added in v0.2.4

func (*CostService) UpdateEstimateForecastCostRaw added in v0.2.4

type EsimateCostSpecResults added in v0.2.4

type EsimateCostSpecResults struct {
	ProviderName                  string                         `json:"providerName,omitempty"`
	RegionName                    string                         `json:"regionName,omitempty"`
	InstanceType                  string                         `json:"instanceType,omitempty"`
	ImageName                     string                         `json:"imageName,omitempty"`
	SpecMinMonthlyPrice           float64                        `json:"totalMinMonthlyPrice,omitempty"`
	SpecMaxMonthlyPrice           float64                        `json:"totalMaxMonthlyPrice,omitempty"`
	EstimateCostSpecDetailResults []EstimateCostSpecDetailResult `json:"estimateForecastCostSpecDetailResults,omitempty"`
}

type EstimateCostInfo added in v0.2.4

type EstimateCostInfo struct {
	gorm.Model
	ProviderName           string `gorm:"index"`
	RegionName             string `gorm:"index"`
	InstanceType           string `gorm:"index"`
	ZoneName               string
	VCpu                   string `gorm:"index"`
	Memory                 string `gorm:"index"`
	MemoryUnit             constant.MemoryUnit
	OriginalMemory         string
	Storage                string
	OsType                 string `gorm:"index"`
	ProductDescription     string
	OriginalPricePolicy    string
	PricePolicy            constant.PricePolicy
	Price                  string
	Currency               constant.PriceCurrency
	Unit                   constant.PriceUnit
	OriginalUnit           string
	OriginalCurrency       string
	CalculatedMonthlyPrice float64 `gorm:"index"`
	PriceDescription       string
	LastUpdatedAt          time.Time
	ImageName              string `gorm:"index"`
}

type EstimateCostInfoResult added in v0.2.4

type EstimateCostInfoResult struct {
	ID           uint   `json:"id"`
	ProviderName string `json:"providerName"`
	RegionName   string `json:"regionName"`
	InstanceType string `json:"instanceType"`

	VCpu                   string                 `json:"vCpu,omitempty"`
	Memory                 string                 `json:"memory,omitempty"`
	Storage                string                 `json:"storage,omitempty"`
	OsType                 string                 `json:"osType,omitempty"`
	ProductDescription     string                 `json:"productDescription,omitempty"`
	OriginalPricePolicy    string                 `json:"originalPricePolicy,omitempty"`
	PricePolicy            constant.PricePolicy   `json:"pricePolicy,omitempty"`
	Unit                   constant.PriceUnit     `json:"unit,omitempty"`
	Currency               constant.PriceCurrency `json:"currency,omitempty"`
	Price                  string                 `json:"price,omitempty"`
	CalculatedMonthlyPrice float64                `json:"calculatedMonthlyPrice,omitempty"`
	PriceDescription       string                 `json:"priceDescription,omitempty"`
	LastUpdatedAt          time.Time              `json:"lastUpdatedAt,omitempty"`
}

type EstimateCostInfoResults added in v0.2.4

type EstimateCostInfoResults struct {
	EstimateCostInfoResult []EstimateCostInfoResult `json:"estimateCostInfoResult,omitempty"`
	ResultCount            int64                    `json:"resultCount"`
}

type EstimateCostInfos added in v0.2.4

type EstimateCostInfos []*EstimateCostInfo

type EstimateCostResults added in v0.2.4

type EstimateCostResults struct {
	EsimateCostSpecResults []EsimateCostSpecResults `json:"esimateCostSpecResults,omitempty"`
}

type EstimateCostSpecDetailResult added in v0.2.4

type EstimateCostSpecDetailResult struct {
	ID                     uint                   `json:"id"`
	VCpu                   string                 `json:"vCpu,omitempty"`
	Memory                 string                 `json:"memory,omitempty"`
	Storage                string                 `json:"storage,omitempty"`
	OsType                 string                 `json:"osType,omitempty"`
	ProductDescription     string                 `json:"productDescription,omitempty"`
	OriginalPricePolicy    string                 `json:"originalPricePolicy,omitempty"`
	PricePolicy            constant.PricePolicy   `json:"pricePolicy,omitempty"`
	Unit                   constant.PriceUnit     `json:"unit,omitempty"`
	Currency               constant.PriceCurrency `json:"currency,omitempty"`
	Price                  string                 `json:"price,omitempty"`
	CalculatedMonthlyPrice float64                `json:"calculatedMonthlyPrice,omitempty"`
	PriceDescription       string                 `json:"priceDescription,omitempty"`
	LastUpdatedAt          time.Time              `json:"lastUpdatedAt,omitempty"`
}

type EstimateForecastCostInfo added in v0.2.4

type EstimateForecastCostInfo struct {
	gorm.Model
	Provider            string `gorm:"index"`
	ConnectionName      string
	ResourceType        constant.ResourceType `gorm:"index"`
	Category            string                `gorm:"index"`
	Cost                float64
	Unit                string
	ActualResourceId    string `gorm:"index"`
	FormattedResourceId string
	Granularity         string    `gorm:"index"`
	StartDate           time.Time `gorm:"index"`
	EndDate             time.Time `gorm:"index"`
	NsId                string    `gorm:"index"`
	MciId               string    `gorm:"index"`
}

type EstimateForecastCostInfos added in v0.2.4

type EstimateForecastCostInfos []EstimateForecastCostInfo

type GetEstimateCostParam added in v0.2.4

type GetEstimateCostParam struct {
	ProviderName string
	RegionName   string
	InstanceType string

	VCpu   string
	Memory string
	OsType string

	TimeStandard time.Time
	PricePolicy  constant.PricePolicy
	Page         int
	Size         int
}

type GetEstimateForecastCostInfoResult added in v0.2.4

type GetEstimateForecastCostInfoResult struct {
	Provider         string    `json:"provider"`
	ResourceType     string    `json:"resourceType"`
	Category         string    `json:"category"`
	ActualResourceId string    `json:"resourceId"`
	Unit             string    `json:"unit"`
	Date             time.Time `json:"date"`
	TotalCost        float64   `json:"totalCost"`
}

type GetEstimateForecastCostInfoResults added in v0.2.4

type GetEstimateForecastCostInfoResults struct {
	GetEstimateForecastCostInfoResults []GetEstimateForecastCostInfoResult `json:"getEstimateForecastCostInfoResults,omitempty"`
	ResultCount                        int64                               `json:"resultCount"`
}

type GetEstimateForecastCostParam added in v0.2.4

type GetEstimateForecastCostParam struct {
	Page                int
	Size                int
	StartDate           time.Time
	EndDate             time.Time
	NsIds               []string
	MciIds              []string
	Providers           []string
	ResourceTypes       []constant.ResourceType
	ResourceIds         []string
	CostAggregationType constant.CostAggregationType
	DateOrder           constant.OrderType
	ResourceTypeOrder   constant.OrderType
}

type PriceCollector added in v0.2.3

type PriceCollector interface {
	Readyz(context.Context) error
	FetchPriceInfos(context.Context, RecommendSpecParam) (EstimateCostInfos, error)
}

func NewSpiderPriceCollector added in v0.2.3

func NewSpiderPriceCollector(sc *spider.SpiderClient) PriceCollector

type RecommendSpecParam added in v0.2.4

type RecommendSpecParam struct {
	ProviderName string `json:"providerName"`
	RegionName   string `json:"regionName"`
	InstanceType string `json:"instanceType"`
	Image        string `json:"image"`
}

func (RecommendSpecParam) Hash added in v0.2.4

func (r RecommendSpecParam) Hash() string

type SpiderPriceCollector added in v0.2.3

type SpiderPriceCollector struct {
	// contains filtered or unexported fields
}

func (*SpiderPriceCollector) FetchPriceInfos added in v0.2.4

func (*SpiderPriceCollector) Readyz added in v0.2.3

func (s *SpiderPriceCollector) Readyz(ctx context.Context) error

type UpdateAndGetEstimateCostParam added in v0.2.4

type UpdateAndGetEstimateCostParam struct {
	RecommendSpecs []RecommendSpecParam `json:"recommendSpecs"`

	TimeStandard time.Time            `json:"timeStandard"`
	PricePolicy  constant.PricePolicy `json:"pricePolicy"`
}

type UpdateEstimateForecastCostInfoResult added in v0.2.4

type UpdateEstimateForecastCostInfoResult struct {
	FetchedDataCount  int64 `json:"fetchedDataCount"`
	UpdatedDataCount  int64 `json:"updatedDataCount"`
	InsertedDataCount int64 `json:"insertedDataCount"`
}

type UpdateEstimateForecastCostParam added in v0.2.4

type UpdateEstimateForecastCostParam struct {
	NsId      string
	MciId     string
	StartDate time.Time
	EndDate   time.Time
}

type UpdateEstimateForecastCostRawParam added in v0.2.4

type UpdateEstimateForecastCostRawParam struct {
	Provider          string // currently only aws
	ConnectionName    string
	StartDate         time.Time
	EndDate           time.Time
	CostResources     []CostResourceParam
	AwsAdditionalInfo AwsAdditionalInfoParam
}

type UpdatePriceInfosParam added in v0.2.3

type UpdatePriceInfosParam struct {
	MigrationId  string
	ProviderName string
	RegionName   string
	InstanceType string

	TimeStandard time.Time
	PricePolicy  constant.PricePolicy
}

Jump to

Keyboard shortcuts

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