Advance filters in Labstep using Python
Index
Overview of the filterEntities method
LabstepPy has the capability to fetch entities based on their attributes and their values,
as well as associated attributes and values of associated entitites. filterEntities() allows a user
to fetch entities of a certain class filtering them using a json object that contains the filter query.
Parameters
user(User)The user that is making the query.
- entityClass (
Entity class) The class of the entity that is being filtered.
- entityClass (
- filter (
List[Dict[str,Any], …] ) List required on this parameter is an array of dictionaries, where each dictionary represents a filter condition. The dictionary representing a filter conditions can have the following keys and are described below:
path(str) specifies the name of the entity class associated to the entity that is being filtered, i.e.metadatas,tags.
The paths that can be used differ depending on the entitites class.
type(str) specifies the logical operator of the filter condition. It can beandoror.predicates(List) specifies the filter condition and can have the following keys:attribute(str) specifies the name of attribute of the entity that is being filtered. i.e.name,datetime. The attributes that can be used differ depending on the entitites class.value(str,int,float) specifies the value of the attribute that is being filtered.comparison(str) specifies the comparison operator used in attribute values. It can beequal_to,not_equal_to,less_than,less_than_or_equal_to,greater_than,greater_than_or_equal_to,like,notLike,isNull,isNotNull.predicates(List) nested filter condition.
- filter (
- count (
int) Optional. Number of entities to fetch.
- count (
- pageSize (
int) Optional. Splits the total number of entities into pages of size pageSize. Its default value is 50.
- pageSize (
Examples
Return Resource Items that have not been assigned to a user
Python code
import labstep
# Import filterEntities method
from labstep.generic.entity.repository import filterEntities
# Import ResourceItem class model
from labstep.entities.resourceItem.model import ResourceItem
# Authenticate user
user = labstep.authenticate()
# Set workspace
user.setWorkspace(1)
# Define the filter
filter = [
{
"type":"and",
"predicates":
[
{
"type":"and",
"path":"assigned_to",
"predicates":
[
{
"attribute":"guid",
"comparison":"isNull",
}
]
}
]
}
]
# Call filter method
resource_items = filterEntities(user, ResourceItem, filter)
Return Resources that were created between two dates
Python code
import labstep
# Import filterEntities method
from labstep.generic.entity.repository import filterEntities
# Import Resource class model
from labstep.entities.resource.model import Resource
# Authenticate user
user = labstep.authenticate()
# Set workspace
user.setWorkspace(1)
# Define the filter
filter = [
{
"type":"and",
"predicates":
[
{
"type":"and",
"predicates":
[
{
"attribute":"created_at",
"comparison":"gte",
"value":"2025-01-01"
},
{
"attribute":"created_at",
"comparison":"lte",
"value":"2025-12-31"
}
]
}
]
}
]
# Call filter method
resources = filterEntities(user, Resource, filter)
Return deleted and non-deleted Resource Items that are under a specific Resource Category and their parent resource metadatas and item metadatas have been updated after a specific date
Python code
import labstep
# Import filterEntities method
from labstep.generic.entity.repository import filterEntities
# Import ResourceItem class model
from labstep.entities.resourceItem.model import ResourceItem
# Authenticate user
user = labstep.authenticate()
# Set workspace
user.setWorkspace(1)
#Get the resource category
reosurce_category= user.getResourceCategory(1)
# Set the last export time
LAST_EXPORT_TIME = "2025-02-07T11:50:19+00:00"
# Define the filter
filter = [
{
"type": "and",
"predicates": [
{
"path": "resource.template",
"type": "and",
"predicates": [
{
"attribute": "guid",
"comparison": "eq",
"value": reosurce_category.guid
}
]
}
]
},
{
"type": "or",
"predicates": [
{
'attribute': 'deletedAt',
'comparison': 'not_null',
}, {
'attribute': 'deletedAt',
'comparison': 'null',
},
]
},
{
"type": "or",
"predicates": [
{
"type": "and",
"predicates": [
{
'attribute': 'updated_at',
'comparison': 'greater_than',
'value': LAST_EXPORT_TIME,
},
]
},
{
"type": "and",
"path": "metadatas",
"predicates": [
{
'attribute': 'updated_at',
'comparison': 'greater_than',
'value': LAST_EXPORT_TIME,
},
]
},
{
"type": "and",
"path": "resource.metadatas",
"predicates": [
{
'attribute': 'updated_at',
'comparison': 'greater_than',
'value': LAST_EXPORT_TIME,
},
]
},
]
}]
# Call filter method
resources = filterEntities(user, ResourceItem, filter)
Supported Entities
Resource
Supported Paths
default
Supported Attributes
name
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
deletedAt
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
template
Supported value format
str
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
available_resource_item_count
Supported value format
int
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanor ``gt`
created_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanor ``gt`
author
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
assigned_to
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
entityUsers
Supported Attributes
is_assigned
Supported value format
boolean
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
entityUsers.user
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
metadatas
Supported Attributes
created_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
updated_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
deleted_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
label
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
value
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
options
Supported value format
str
Supported Operator Comparisons
containsorincludesorlikenot_containsorexcludesornotLike
date
Supported value format
Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
datetime
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
number
Supported value format
intfloat
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
unit
Supported value format
str
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
file
Supported Operator Comparisons
existsornot_nullorisNotNullnot_existsornullorisNull
metadatas.molecule
Supported Attributes
inchis
Supported value format
str
Supported Operator Comparisons
containsorincludesorlikenot_containsorexcludesornotLike
template
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneqcontainsorincludesorlikenot_containsorexcludesornotLike
tags
Supported Attributes
id
Supported value format
int
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
name
Supported value format
int
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
ResourceItem
Supported Paths
default
Supported Attributes
created_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanor ``gt`
updated_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanor ``gt`
deletedAt
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
not_existsornullorisNullexistsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
status
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
protocolValueOrigin
Supported Operator Comparisons
existsornot_nullorisNotNullnot_existsornullorisNull
author
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
assigned_to
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
entityUsers
Supported Attributes
is_assigned
Supported value format
boolean
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
entityUsers.user
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
metadatas
Supported Attributes
updated_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
label
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
value
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
options
Supported value format
str
Supported Operator Comparisons
containsorincludesorlikenot_containsorexcludesornotLike
date
Supported value format
Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
datetime
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
number
Supported value format
intfloat
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
unit
Supported value format
str
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
file
Supported Operator Comparisons
existsornot_nullorisNotNullnot_existsornullorisNull
resource.metadatas
Supported Attributes
updated_at
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
label
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
value
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
options
Supported value format
str
Supported Operator Comparisons
containsorincludesorlikenot_containsorexcludesornotLike
date
Supported value format
Date as
strin formatYYYY-MM-DD
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
datetime
Supported value format
Date as
strin formatYYYY-MM-DDTHH:MM:SS+00:00
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
number
Supported value format
intfloat
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
unit
Supported value format
str
Supported Operator Comparisons
existsornot_nullorisNotNullequalsorequal_tooreqnot_equalsornot_equal_toorneqless_than_or_equalsorless_than_or_equal_toorlteless_thanorltgreater_than_or_equalsorgreater_than_or_equal_toorgtegreater_thanorgt
file
Supported Operator Comparisons
existsornot_nullorisNotNullnot_existsornullorisNull
resourceLocation
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
resource.template
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq
resource
Supported Attributes
guid
Supported value format
str
Supported Operator Comparisons
equalsorequal_tooreqnot_equalsornot_equal_toorneq