Documentation
¶
Overview ¶
Package entities contains the datastore entities and handles datestore manipulation.
Index ¶
- Constants
- func ApplyFilter(query *datastore.Query, filter *fleetcostAPI.ListCostIndicatorsFilter) (*datastore.Query, error)
- func DeleteCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity) error
- func ListCostIndicators(ctx context.Context, limit int, filter *fleetcostAPI.ListCostIndicatorsFilter) ([]*fleetcostpb.CostIndicator, error)
- type CachedCostResultEntity
- func (entity *CachedCostResultEntity) GetAllMeta() datastore.PropertyMap
- func (entity *CachedCostResultEntity) GetMeta(key string) (any, bool)
- func (entity *CachedCostResultEntity) Load(propertyMap datastore.PropertyMap) error
- func (entity *CachedCostResultEntity) Save(withMeta bool) (datastore.PropertyMap, error)
- func (entity *CachedCostResultEntity) SetMeta(key string, value any) bool
- type CostIndicatorEntity
- func GetCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity) (*CostIndicatorEntity, error)
- func NewCostIndicatorEntity(costIndicator *fleetcostpb.CostIndicator) *CostIndicatorEntity
- func UpdateCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity, fields []string) (*CostIndicatorEntity, error)
- func (indicator CostIndicatorEntity) Clone() *CostIndicatorEntity
- func (indicator *CostIndicatorEntity) GetAllMeta() datastore.PropertyMap
- func (indicator *CostIndicatorEntity) GetMeta(key string) (any, bool)
- func (indicator *CostIndicatorEntity) Load(propertyMap datastore.PropertyMap) error
- func (indicator *CostIndicatorEntity) Save(withMeta bool) (datastore.PropertyMap, error)
- func (indicator *CostIndicatorEntity) SetMeta(key string, value any) bool
Constants ¶
const CachedCostResultKind = "CachedCostResultKind"
CachedCostResultKind is the datastore type for a cached DUT.
const CostIndicatorKind = "CostIndicatorKind"
CostIndicatorKind is the datastore kind of a cost indicator entity.
Variables ¶
This section is empty.
Functions ¶
func ApplyFilter ¶
func ApplyFilter(query *datastore.Query, filter *fleetcostAPI.ListCostIndicatorsFilter) (*datastore.Query, error)
ApplyFilter applies filters to a datastore query and returns it.
func DeleteCostIndicatorEntity ¶
func DeleteCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity) error
DeleteCostIndicatorEntity deletes a cost indicator entity.
func ListCostIndicators ¶
func ListCostIndicators(ctx context.Context, limit int, filter *fleetcostAPI.ListCostIndicatorsFilter) ([]*fleetcostpb.CostIndicator, error)
ListCostIndicators lists the cost indicators in the database, up to a limit (not yet implemented).
Types ¶
type CachedCostResultEntity ¶
type CachedCostResultEntity struct { // The hostname or DeviceID are the two fields that are // useful for looking up a device. Hostname string `gae:"hostname"` DeviceID string `gae:"deviceid"` // ExpirationTime is the time that the cache entry is no longer valid. ExpirationTime time.Time `gae:"expiration_time"` CostResult *fleetcostpb.CostResult `gae:"cost_result"` // deprecated! Do not use. CostReport *fleetcostpb.CostReport `gae:"cost_report"` // contains filtered or unexported fields }
CachedCostResultEntity is the datastore type for cached DUT cost.
func (*CachedCostResultEntity) GetAllMeta ¶
func (entity *CachedCostResultEntity) GetAllMeta() datastore.PropertyMap
GetAllMeta returns all the meta keys. Just use the default implementation, it's fine.
func (*CachedCostResultEntity) GetMeta ¶
func (entity *CachedCostResultEntity) GetMeta(key string) (any, bool)
GetMeta gets a meta key. Compute the ID, fall back to the default implementation.
Use the entity and the hostname in order as the ID. This isn't IDeal (get it?) because we're realistically just using one or the other.
func (*CachedCostResultEntity) Load ¶
func (entity *CachedCostResultEntity) Load(propertyMap datastore.PropertyMap) error
Load loads an entity.
func (*CachedCostResultEntity) Save ¶
func (entity *CachedCostResultEntity) Save(withMeta bool) (datastore.PropertyMap, error)
Save saves an entity.
func (*CachedCostResultEntity) SetMeta ¶
func (entity *CachedCostResultEntity) SetMeta(key string, value any) bool
SetMeta always returns false. This communicates to the LUCI ORM that our meta keys cannot be changed.
This works better than not-implementing the method for reasons that I don't completely understand and don't really want to get into here.
type CostIndicatorEntity ¶
type CostIndicatorEntity struct { Extra datastore.PropertyMap `gae:",extra"` CostIndicator *fleetcostpb.CostIndicator `gae:"cost_indicator"` // Indexed fields for improved query performance. Board string `gae:"board"` Model string `gae:"model"` Sku string `gae:"sku"` Type string `gae:"type"` Location string `gae:"location"` AmortizationInYears float64 `gae:"amortization_in_years"` // contains filtered or unexported fields }
CostIndicatorEntity is a datastore entity storing a cost indicator.
TODO(gregorynisbet): Change the name of the database entries from the legacy names Board, Model, Sku to the new ones.
func GetCostIndicatorEntity ¶
func GetCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity) (*CostIndicatorEntity, error)
GetCostIndicatorEntity extracts a cost indicator from the database.
func NewCostIndicatorEntity ¶
func NewCostIndicatorEntity(costIndicator *fleetcostpb.CostIndicator) *CostIndicatorEntity
NewCostIndicatorEntity makes a cost indicator entity from an object extracted from a request.
func UpdateCostIndicatorEntity ¶
func UpdateCostIndicatorEntity(ctx context.Context, entity *CostIndicatorEntity, fields []string) (*CostIndicatorEntity, error)
UpdateCostIndicatorEntity extracts a cost indicator entity from the database and updates it.
func (CostIndicatorEntity) Clone ¶
func (indicator CostIndicatorEntity) Clone() *CostIndicatorEntity
Clone produces a deep copy of a cost indicator.
This method intentionally takes a non-pointer receiver to perform a shallow copy, and then replaces a field to perform a deep copy.
I don't actually know whether I also need to copy the datastore.PropertyMap.
func (*CostIndicatorEntity) GetAllMeta ¶
func (indicator *CostIndicatorEntity) GetAllMeta() datastore.PropertyMap
GetAllMeta transfers control to the default implementation of GetAllMeta. We need this function so that we can compute the ID.
func (*CostIndicatorEntity) GetMeta ¶
func (indicator *CostIndicatorEntity) GetMeta(key string) (any, bool)
GetMeta gets meta-values. The id ("$id") is computed. The other things (like $kind, for instance) get their default values.
func (*CostIndicatorEntity) Load ¶
func (indicator *CostIndicatorEntity) Load(propertyMap datastore.PropertyMap) error
Load loads an entity.
func (*CostIndicatorEntity) Save ¶
func (indicator *CostIndicatorEntity) Save(withMeta bool) (datastore.PropertyMap, error)
Save saves an entity.