Searching
opengate_data.searching.filter
FilterBuilder Objects
Filter Builder
and_
Combines conditions using the logical AND operator.
Arguments:
*conditions- The conditions to combine.
Returns:
FilterBuilder- Returns itself to allow for method chaining.
Example:
builder.and_(eq(“device.operationalStatus”, “NORMAL”), like(“device.name”, “device_.*”) )
or_
Combines conditions using the logical OR operator.
Arguments:
*conditions- The conditions to combine.
Returns:
FilterBuilder- Returns itself to allow for method chaining.
Example:
builder.or_(eq(“device.operationalStatus”, “NORMAL”), like(“device.name”, “device_.*”) )
build
Builds the final filter.
Returns:
dict- The final filter.
Raises:
ValueError- If there is an incomplete condition.
Example:
builder.build()
opengate_data.searching.search_base
SearchBuilderBase Objects
Search Base Builder
build
Finalizes the construction of the search configuration.
build_execute
Short-cut for build().execute()
with_format
Formats the flat entities data based on the specified format (‘csv’, ‘dict’, or ‘pandas’).
Arguments:
format_datastr - The format to use for the data.
Example:
builder.with_format(‘dict’) builder.with_format(‘csv’) builder.with_format(‘pandas’)
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_flattened
Flatten the data
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_utc
Set UTC flag
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_summary
Set summary flag
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_default_sorted
Set default sorted flag
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_case_sensitive
Set case-sensitive flag
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
opengate_data.searching.select
SelectBuilder Objects
A flexible builder for constructing SELECT clauses for several OpenGate entities.
This builder supports three independent modes, which cannot be mixed inside the same instance:
- Simple mode (Datasets, Timeseries search):
.add("field_name")- Produces: [“field1”, “field2”, …]
- Extended mode (Structured search):
.add("path.to.resource", ["field", ("other", "alias")])- Produces: [ { “name”: “…”, “fields”: [{ “field”: “…”, “alias”: “…” }] } ]
- Column mode (Timeseries EXPORT):
.add_column("FIRST").add_column("bucket_id", output={"parquet": {"type": "INT"}})- Produces: [ { “column”: “FIRST” }, { “column”: “bucket_id”, “output”: {…} } ]
You cannot mix modes. Each builder instance must use only one mode.
Examples:
Simple mode: SelectBuilder().add(“Gross”).add(“Temp”)
Extended mode: SelectBuilder().add(“provision.device.identifier”, [(“value”, “id”), “date”])
Column mode (Timeseries Export): SelectBuilder().add_column(“FIRST”).add_column(“LAST”)
Use .build() to retrieve the final SELECT list.
add
Add a SELECT entry in either simple or extended mode.
Arguments:
namestr - Field name (simple mode) or entity name (extended mode).fieldslist, optional - Only for extended mode; list of strings or tuples (field, alias).
Returns:
SelectBuilder- fluent API.
add_column
Add a Timeseries Export column entry.
Produces backend-compatible objects like: { “column”: “FIRST” } { “column”: “bucket_id”, “output”: {…} }
Arguments:
column_namestr - Name of the export column.outputdict, optional - Optional output descriptor such as: { “parquet”: { “type”: “INT” } } { “name”: “serial_number”, “parquet”: { “type”: “STRING” } }
Returns:
SelectBuilder- fluent API.
build
Return the constructed SELECT list.
Raises:
ValueError- If no select elements were added.
Returns:
list- Dicts (column mode), strings (simple mode) or dicts (extended mode).
opengate_data.searching.builder.rules_search
RulesSearchBuilder
RulesSearchBuilder Objects
Rules Search Builder
with_format
Formats the flat entities data based on the specified format (‘dict’, or ‘pandas’).
Arguments:
format_datastr - The format to use for the data.
Returns:
RulesSearchBuilder- Returns itself to allow for method chaining.
Example:
execute
Executes the rule search based on the built configuration.
Returns:
dict- The response data.
Raises:
Exception- If the build() method was not called before execute().
Example:
opengate_data.searching.builder.alarm_search
AlarmSearchBuilder
AlarmSearchBuilder Objects
Alarm Search Builder
Searches the alarms raised by the platform’s rules, over
/v80/search/entities/alarms. Compose the query with the inherited
with_filter, with_select, with_limit and with_format methods, then
close it with build() and execute(), or with build_execute().
Example:
validate_builds
Checks the combination of methods called before the search is sent.
Returns:
AlarmSearchBuilder- Returns itself to allow for method chaining.
Raises:
ValueError- Ifwith_formatreceived something other than “dict”, “csv” or “pandas”.Exception- If “csv” is combined withwith_limit, or used withoutwith_select— the CSV output needs to know its columns.
execute
Executes the alarm search based on the built configuration.
with_summary() switches the request to /search/entities/alarms/summary
and returns the aggregated counters instead of the alarms themselves.
Returns:
str | pandas.DataFrame: A JSON string for the “dict” format, raw text
for “csv”, or a DataFrame of flattened records for “pandas”.
Raises:
Exception- Ifbuild()was not the last call beforeexecute(), or if neitherbuild()norbuild_execute()was called.
Example:
opengate_data.searching.builder.operations_search
OperationsBuilder
OperationsSearchBuilder Objects
Builder Operations Search
execute
Executes the operation search based on the built configuration.
Returns:
dict, csv or dataframe: The response data in the specified format.
Raises:
Exception- If the build() method was not called before execute().
Example:
opengate_data.searching.builder.datasets_search
DatasetsSearchBuilder
DatasetsSearchBuilder Objects
Dataset Search Builder
with_organization_name
Set organization name
Arguments:
organization_namestr - The name of the organization that owns the data set.
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
with_identifier
Set identifier
Arguments:
identifierstr - The identifier of the data set to query.
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
with_utc
Set UTC
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
with_format
Formats the flat entities data based on the specified format (‘csv’, ‘dict’, or ‘pandas’).
Arguments:
format_datastr - The format to use for the data.
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
with_sort
Set the sort identifier.
The value must be the identifier of one of the sorts declared in the dataset definition “sorts” section (the auto-generated reverse sorts are also valid). When omitted, results are sorted by the identifier column ascending.
The sort is sent in the payload for every format. NOTE: the platform currently ignores the sort for ‘csv’ and ‘pandas’ exports (a server/database limitation, not an SDK decision); it is still sent so the SDK stays forward-compatible if the backend starts honoring it.
Arguments:
sortstr - The sort identifier declared in the dataset definition.
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
add_sort_by
Deprecated for datasets. The dataset search API no longer accepts the object-based sort format; sorts are now declared in the dataset definition and referenced by identifier.
Raises:
NotImplementedError- Always. Use with_sort() instead.
execute
Executes the data set search based on the built configuration.
Returns:
dict, csv or dataframe: The response data in the specified format.
Raises:
Exception- If the build() method was not called before execute().
Example:
opengate_data.searching.builder.datapoints_search
DataPointsSearchBuilder Objects
Datapoints Search Builder
with_transpose
Enables transposing the data in the result.
This function allows the data returned by the search to be transposed, meaning that rows and columns are swapped. This can be useful for certain data analyses where it is preferred to have datastreams as columns and entities as rows.
Notes:
This function can only be used with the ‘pandas’ format.
Returns:
DataPointsSearchBuilder- Returns the builder instance to allow for method chaining.
Example:
with_mapped_transpose
Enables transposing the data with a specific mapping.
This function allows the data returned by the search to be transposed and mapped according to a provided mapping dictionary. The mapping specifies how complex data should be transformed into flat columns.
Arguments:
mappingdict[str, dict[str, str]] - The mapping of complex data to flat columns. The main key is the column name, and its value another dictionary defining the mapping of the substructures.
Notes:
This function can only be used with the ‘pandas’ format.
Returns:
DataPointsSearchBuilder- Returns the builder instance to allow for method chaining.
Example:
execute
Execute the configured operation and return the response.
This method executes the operation that has been configured using the builder pattern.
It ensures that the build method has been called and that it is the last method invoked before execute.
Depending on the configured method (e.g., create, find, update, delete),
it calls the appropriate internal execution method.
Returns:
requests.Response- The response object from the executed request.
Raises:
Exception:
If the build method has not been called or if it is not the last method invoked before execute.
ValueError- If the configured method is unsupported.
Example:
opengate_data.searching.builder.timeseries_search
TimeseriesSearchBuilder Objects
Timeseries Search Builder
with_organization_name
Set organization name
Arguments:
organization_namestr - The name of the organization that owns the timeseries.
with_identifier
Set identifier
Arguments:
identifierstr - The identifier of the timeseries to query.
with_utc
Set UTC flag for date-time parsing
with_format
Formats the timeseries data based on the specified format (‘csv’, ‘dict’, or ‘pandas’).
Arguments:
format_datastr - The format to return the data in: ‘dict’, ‘csv’ or ‘pandas’.
with_sort
Set sort identifier
Arguments:
sortstr - The identifier of a sort declared in the timeseries definition.
execute
Executes the timeseries search based on the built configuration.
opengate_data.searching.builder
opengate_data.searching.builder.entities_search
EntitiesSearchBuilder
EntitiesSearchBuilder Objects
Entities Search Builder
execute
Executes the entities search based on the built configuration.
Returns:
dict, csv or dataframe: The response data in the specified format.
Raises:
Exception- If the build() method was not called before execute().
Example:
opengate_data.searching.search
SearchBuilder
SearchBuilder Objects
Search Builder
with_filter
Adds a filter to the search.
Arguments:
filter_dataUnion[dict, FilterBuilder] - The filter data to apply. Can be a dictionary or a FilterBuilder instance.
Returns:
SearchBuilder- Returns itself to allow for method chaining.
Example:
search_builder.with_filter(filter_builder.build()) search_builder.with_filter({
"and"- [{"eq"- {“device.operationalStatus”: “NORMAL”}},{"like"- {“device.communicationModules[].mobile.imei”: “351873000102290”}} ] })
with_select
Adds selection criteria to the search.
Arguments:
select_datalist[dict] | SelectBuilder - The selection criteria to apply. Can be a list of dictionaries or a SelectBuilder instance.
Returns:
SearchBuilder- Returns itself to allow for method chaining.
with_limit
Adds pagination parameters to the search.
Arguments:
sizeint - The number of entities to retrieve per page. Limit size value 1000startint, optional - Page number you request. By default, is 1.
Returns:
SearchBuilder- Returns itself to allow for method chaining.
Example:
search_builder.with_limit(1000, 2)
add_by_group
Adds a field to the group.
Arguments:
field_namestr - The name of the field to group by.
Returns:
SearchBuilder- Returns itself to allow for method chaining.
Example:
builder.add_by_group(“provision.device.model”) builder.add_by_group(“provision.device.software”)
add_sort_by
Adds a field to the sort.
Arguments:
field_namestr - The name of the field to sort by.orderstr - The order of sorting, either ‘ASCENDING’ or ‘DESCENDING’.
Returns:
SearchBuilder- Returns itself to allow for method chaining.
Example:
builder.add_sort_by(“datapoints._current.at”, “DESCENDING”) builder.add_sort_by(“devices._current.at”, “ASCENDING”)