state

package
v0.0.0-...-7220889 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package state` provides interfaces for managing DataStore entities that correspond to device states

Index

Constants

View Source
const DutStateKind string = "DutState"

DutStateKind is the datastore entity kind of dut state.

Dut state is only specific to OS devices for now.

View Source
const RecordKind string = "State"

RecordKind is the datastore entity kind of state.

Variables

This section is empty.

Functions

func BatchUpdateStates

func BatchUpdateStates(ctx context.Context, states []*ufspb.StateRecord) ([]*ufspb.StateRecord, error)

BatchUpdateStates updates the states to UFS.

This can be used inside a transaction

func DeleteDutStates

func DeleteDutStates(ctx context.Context, resourceNames []string) *ufsds.OpResults

DeleteDutStates deletes a batch of dut states

func DeleteStates

func DeleteStates(ctx context.Context, resourceNames []string) *ufsds.OpResults

DeleteStates deletes a batch of states

func GetAllDutStates

func GetAllDutStates(ctx context.Context) (*ufsds.OpResults, error)

GetAllDutStates returns all dut states in datastore.

func GetAllStates

func GetAllStates(ctx context.Context) (*ufsds.OpResults, error)

GetAllStates returns all states in datastore.

func GetDutState

func GetDutState(ctx context.Context, id string) (*chromeosLab.DutState, error)

GetDutState returns dut state for the given id from datastore.

func GetDutStateACL

func GetDutStateACL(ctx context.Context, id string) (*chromeosLab.DutState, error)

GetDutStateACL returns the DutState for the requested id if the user has permissions to do so.

func GetStateIndexedFieldName

func GetStateIndexedFieldName(input string) (string, error)

GetStateIndexedFieldName returns the index name

func GetStateRecord

func GetStateRecord(ctx context.Context, id string) (*ufspb.StateRecord, error)

GetStateRecord returns the state for a given resource name.

func ListDutStates

func ListDutStates(ctx context.Context, pageSize int32, pageToken string, filterMap map[string][]interface{}, keysOnly bool) (res []*chromeosLab.DutState, nextPageToken string, err error)

ListDutStates lists the DutStates.

Does a query over DutState entities. Returns up to pageSize entities, plus non-nil cursor (if there are more results). pageSize must be positive.

func ListDutStatesACL

func ListDutStatesACL(ctx context.Context, pageSize int32, pageToken string, filterMap map[string][]interface{}, keysOnly bool) (res []*chromeosLab.DutState, nextPageToken string, err error)

func ListStateRecords

func ListStateRecords(ctx context.Context, pageSize int32, pageToken string, filterMap map[string][]interface{}) (res []*ufspb.StateRecord, nextPageToken string, err error)

ListStateRecords lists all the states

func QueryDutStateByPropertyNames

func QueryDutStateByPropertyNames(ctx context.Context, propertyMap map[string]string, keysOnly bool) ([]*chromeosLab.DutState, error)

QueryDutStateByPropertyNames queries DutState Entity in the datastore. If keysOnly is true, then only key field is populated in returned DutStates.

func UpdateDutStates

func UpdateDutStates(ctx context.Context, dutStates []*chromeosLab.DutState) ([]*chromeosLab.DutState, error)

UpdateDutStates updates dut states in datastore.

func UpdateStateRecord

func UpdateStateRecord(ctx context.Context, stateRecord *ufspb.StateRecord) (*ufspb.StateRecord, error)

UpdateStateRecord updates a state record in datastore.

Types

type DutStateEntity

type DutStateEntity struct {
	Extra datastore.PropertyMap `gae:",extra"`
	// refer to the device id
	ID       string `gae:"$id"`
	Hostname string `gae:"hostname"`
	// lab.DutState cannot be directly used as it contains pointer (timestamp).
	DutState []byte `gae:",noindex"`
	Realm    string `gae:"realm"`
	// contains filtered or unexported fields
}

DutStateEntity is a datastore entity that tracks dut state.

func (*DutStateEntity) GetProto

func (e *DutStateEntity) GetProto() (proto.Message, error)

GetProto returns the unmarshaled dut state.

func (*DutStateEntity) GetRealm

func (e *DutStateEntity) GetRealm() string

func (*DutStateEntity) Validate

func (e *DutStateEntity) Validate() error

Validate returns whether a DutStateEntity is valid

type RecordEntity

type RecordEntity struct {
	Extra datastore.PropertyMap `gae:",extra"`
	// refer to the hostname
	ResourceName string `gae:"$id"`
	ResourceType string `gae:"resource_type"`
	State        string `gae:"state"`
	// ufspb.StateRecord cannot be directly used as it contains pointer (timestamp).
	StateRecord []byte `gae:",noindex"`
	// contains filtered or unexported fields
}

RecordEntity is a datastore entity that tracks dhcp.

func (*RecordEntity) GetProto

func (e *RecordEntity) GetProto() (proto.Message, error)

GetProto returns the unmarshaled DHCP.

func (*RecordEntity) Validate

func (e *RecordEntity) Validate() error

Validate returns whether a RecordEntity is valid

Jump to

Keyboard shortcuts

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