dp3.api.routers.entity ¶
check_etype
async
¶
Middleware to check entity type existence
get_eid_master_record_handler ¶
get_eid_master_record_handler(etype: str, eid: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None)
Handler for getting master record of EID
Source code in dp3/api/routers/entity.py
get_eid_snapshots_handler ¶
get_eid_snapshots_handler(etype: str, eid: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None)
Handler for getting snapshots of EID
Source code in dp3/api/routers/entity.py
list_entity_type_eids
async
¶
list_entity_type_eids(etype: str, eid_filter: str = eid_filter_query_param, fulltext_filters: Json = None, generic_filter: Json = None, skip: NonNegativeInt = 0, limit: NonNegativeInt = 20) -> EntityEidList
List latest snapshots of all id
s present in database under etype
.
Contains only latest snapshot.
Uses pagination.
Setting limit
to 0 is interpreted as no limit (return all results).
Returns only documents matching generic_filter
and fulltext_filters
(JSON object in format: attribute - fulltext filter).
Fulltext filters are interpreted as regular expressions.
Only string values may be filtered this way. There's no validation that queried attribute
can be fulltext filtered.
Only plain and observation attributes with string-based data types can be queried.
Array and set data types are supported as well as long as they are not multi value
at the same time.
If you need to filter EIDs, use attribute eid
(eid_filter
is deprecated and you should
migrate to fulltext_filters["eid"]
).
Generic filter allows filtering using generic MongoDB query (including $and
, $or
,
$lt
, etc.).
There are no attribute name checks (may be added in the future).
Generic and fulltext filters are merged - fulltext overrides conflicting keys.
Source code in dp3/api/routers/entity.py
get_eid_data
async
¶
get_eid_data(etype: str, eid: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None) -> EntityEidData
Get data of etype
's eid
.
Contains all snapshots and master record. Snapshots are ordered by ascending creation time.
Combines function of /{etype}/{eid}/master
and /{etype}/{eid}/snapshots
.
Source code in dp3/api/routers/entity.py
get_eid_master_record
async
¶
get_eid_master_record(etype: str, eid: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None) -> EntityEidMasterRecord
Get master record of etype
's eid
.
Source code in dp3/api/routers/entity.py
get_eid_snapshots
async
¶
get_eid_snapshots(etype: str, eid: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None) -> EntityEidSnapshots
Get snapshots of etype
's eid
.
Source code in dp3/api/routers/entity.py
get_eid_attr_value
async
¶
get_eid_attr_value(etype: str, eid: str, attr: str, date_from: Optional[datetime] = None, date_to: Optional[datetime] = None) -> EntityEidAttrValueOrHistory
Get attribute value
Value is either of: - current value: in case of plain attribute - current value and history: in case of observation attribute - history: in case of timeseries attribute
Source code in dp3/api/routers/entity.py
set_eid_attr_value
async
¶
set_eid_attr_value(etype: str, eid: str, attr: str, body: EntityEidAttrValue, request: Request) -> SuccessResponse
Set current value of attribute
Internally just creates datapoint for specified attribute and value.
This endpoint is meant for editable
plain attributes -- for direct user edit on DP3 web UI.
Source code in dp3/api/routers/entity.py
get_distinct_attribute_values
async
¶
Gets distinct attribute values and their counts based on latest snapshots
Useful for displaying <select>
enumeration fields.
Works for all plain and observation data types except dict
and json
.
Source code in dp3/api/routers/entity.py
extend_eid_ttls
async
¶
Extend TTLs of the specified entity
Source code in dp3/api/routers/entity.py
delete_eid_record
async
¶
Delete the master record and snapshots of the specified entity.
Notice that this does not delete any raw datapoints, or block the re-creation of the entity if new datapoints are received.