Common Schemas¶
The following schemas are used throughout multiple packages.
-
class
BaseFilterRuleSchema(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ The basic filter rule validator and processor.
Because in many cases we will be using the filter definitions passed from the filters API endpoints, we need a common way to process and validate that the filters that are being passed are indeed valid filters before converting them into the appropriate format for the specified endpoint. This base schema lacks the output formatting necessary for use within the endpoints themselves and instead serves as starting point for subclassing.
-
filter_check¶ The flag determining if we should be checking against the filter ruleset. There are cases where we simply want to pass the data through into the desired format, and not validate the content aside from basic formatting.
Type: bool
Examples
Performing a validation with a given filter definition ruleset:
>>> schema = BaseFilterRuleSchema() >>> schema.load_filters(filterset) >>> schema.load(('port.port', 'eq', '137'))
Performing a validation without a ruleset:
>>> schema = BaseFilterRuleSchema() >>> schema.load(('port.port', 'eq', '137'))
Performing a validation against multiple filters at the same time:
>>> schema = BaseFilterRuleSchema() >>> schema.load_filters(filterset) >>> s.load(( ... ('port.port', 'eq', '137'), ... ('port.port', 'eq', '443')), ... many=True ... )
-