volume.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package pricing
  2. import (
  3. "maps"
  4. "slices"
  5. "time"
  6. "github.com/opencost/opencost/core/pkg/unit"
  7. )
  8. type VolumePricingProperties struct {
  9. Provider Provider `json:"provider,omitempty" yaml:"provider,omitempty"`
  10. Region string `json:"region,omitempty" yaml:"region,omitempty"`
  11. VolumeType VolumeType `json:"volumeType,omitempty" yaml:"volumeType,omitempty"`
  12. Cluster string `json:"cluster,omitempty" yaml:"cluster,omitempty"`
  13. ProviderID string `json:"providerID,omitempty" yaml:"providerID,omitempty"`
  14. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
  15. Start *time.Time `json:"start,omitempty" yaml:"start,omitempty"`
  16. End *time.Time `json:"end,omitempty" yaml:"end,omitempty"`
  17. }
  18. type VolumePricing struct {
  19. Properties VolumePricingProperties `json:"properties" yaml:"properties"`
  20. Prices Prices `json:"prices" yaml:"pricing"`
  21. }
  22. func (vp *VolumePricing) GetCurrencies() []unit.Currency {
  23. currencies := map[unit.Currency]struct{}{}
  24. for currency := range vp.Prices {
  25. currencies[currency] = struct{}{}
  26. }
  27. return slices.Collect(maps.Keys(currencies))
  28. }