Search API

class LabGuruAPI._search_api.SearchInterface[source]

Represents an abstract interface for defining search operations and generating search operators.

This class provides methods and operator overloads for creating search operations (like comparison, string containment, null checks, etc.) and constructing corresponding logical expressions using searchable attributes. It is intended to be used as a base interface for entities requiring advanced search capabilities.

labguru_name

The external name used in the context of Labguru search operations, or None if not specified. Only used while initializing the searchable object.

Type:

str or None

asc()[source]

Represents an ascending sort operation for the given property name.

Returns:

An instance of LGSortOperator representing a sort operation in ascending order.

Return type:

LGSortOperator

desc()[source]

Represents a descending sort operation for the given property name.

Returns:

An instance of LGSortOperator representing a sort operation in descending order.

Return type:

LGSortOperator

__eq__(other: str | int | float | date | datetime) LGSearchOperator[source]

Checks equality between the current object and another object, returning a search operator.

Parameters:

other (LGSearchable | str | bool) – The object to compare with the current LGSearchable instance for equality. It can be an instance of LGSearchable, str, or bool.

Returns:

An operator indicating the equality condition between

the current object and the provided other object.

Return type:

LGSearchOperator

__ne__(other: str | int | float | date | datetime) LGSearchOperator[source]

Compares the current instance with another value for inequality.

Parameters:

other (LGSearchable) – The value to compare with the current instance.

Returns:

A search operator representing the inequality comparison.

Return type:

LGSearchOperator

__le__(other: str | int | float | date | datetime) LGSearchOperator[source]

Compares the current object with another object to check if it is less than or equal to the other object. Generates a logical search operator for this comparison.

Parameters:

other (LGSearchable) – The object to compare with the current object.

Returns:

A logical search operator representing the less-than-or-equal-to comparison.

Return type:

LGSearchOperator

__lt__(other: str | int | float | date | datetime) LGSearchOperator[source]

Compares the current object with another object to determine if the current object is less than the other object. This comparison generates a search operator encapsulating the comparison logic.

Parameters:

other (LGSearchable) – The object to compare with the current object.

Returns:

A search operator representing the less-than comparison.

Return type:

LGSearchOperator

__gt__(other: str | int | float | date | datetime) LGSearchOperator[source]

Compares the current object with another LGSearchable object to determine if the current object is greater than the other.

Parameters:

other – The LGSearchable object to compare against the current object.

Returns:

Represents the comparison operation indicating whether the current object is greater than the provided object.

Return type:

LGSearchOperator

__ge__(other: str | int | float | date | datetime) LGSearchOperator[source]

Compares the current instance with another LGSearchable object to determine if the current instance is greater than or equal to the other.

Parameters:

other (LGSearchable) – The LGSearchable instance to compare against.

Returns:

An operator encapsulating the logical comparison of greater than or equal.

Return type:

LGSearchOperator

contains(other)[source]

Generates and applies a search operation for containment check.

This method creates a search operator based on the specified containment logic. It uses the ‘contains’ operator to evaluate whether the current object contains the provided value.

Parameters:

other – The value to be checked for containment within the current object.

Returns:

The result of the search operation as an outcome of containment verification.

not_contains(other)[source]

Determines whether a value is not contained within another value.

Parameters:

other – The value to determine if it is not contained in the target.

Returns:

A new search operator object configured with the ‘doesnotcontain’ logic evaluating whether other is not contained in the subject.

starts_with(other: str) LGSearchOperator[source]

Creates a search operator that checks whether the current value starts with the specified string.

Parameters:

other (str) – The string to check if the current value starts with.

Returns:

A search operator for evaluating the condition.

Return type:

LGSearchOperator

ends_with(other: str) LGSearchOperator[source]

Creates and returns a search operator to determine if a string ends with a specified substring.

Parameters:

other (str) – The substring to check if the string ends with.

Returns:

An object representing the search operation for checking if the string ends with the specified substring.

Return type:

LGSearchOperator

is_null() LGSearchOperator[source]

Checks if the given attribute is null or empty.

Returns:

A search operator object for evaluating a “null” or “empty” condition.

Return type:

LGSearchOperator

Raises:

AttributeError – If the attribute base_type is not accessible.

is_not_null() LGSearchOperator[source]

Determines whether the value is not null or, in the case of string types, neither null nor empty, and creates a corresponding search operator.

Returns:

A search operator instance that represents the “is not null” check, tailored for the specific type of the class.

Return type:

LGSearchOperator