buildgrid.server.operations.filtering.sanitizer module

class buildgrid.server.operations.filtering.sanitizer.ValueSanitizer

Bases: ABC

Base sanitizer class.

property valid_values: List[str]

Return a list of valid values for the sanitizer.

This is only useful for sanitizers with a finite list of valid values.

Raises NotImplementedError for sanitizers which aren’t based on an enum of valid values.

sanitize(value_string: str) Any

Method that takes an input string, validates that input string, and transforms it to a value of another type if necessary.

Raises InvalidArgumentError if the sanitization fails. Returns a value of an arbitrary type if it succeeds.

class buildgrid.server.operations.filtering.sanitizer.RegexValueSanitizer(filter_name: str, regex_pattern: str)

Bases: ValueSanitizer

Sanitizer for regexable patterns.

sanitize(value_string: str) str

Method that takes an input string, validates that input string, and transforms it to a value of another type if necessary.

Raises InvalidArgumentError if the sanitization fails. Returns a value of an arbitrary type if it succeeds.

class buildgrid.server.operations.filtering.sanitizer.DatetimeValueSanitizer(filter_name: str)

Bases: ValueSanitizer

Sanitizer for ISO 8601 datetime strings.

sanitize(value_string: str) datetime

Method that takes an input string, validates that input string, and transforms it to a value of another type if necessary.

Raises InvalidArgumentError if the sanitization fails. Returns a value of an arbitrary type if it succeeds.

class buildgrid.server.operations.filtering.sanitizer.OperationStageValueSanitizer(filter_name: str)

Bases: ValueSanitizer

Sanitizer for the OperationStage type.

Matches valid OperationStage values and converts to the numeric representation of that stage.

property valid_values: List[str]

Return a list of valid values for the sanitizer.

This is only useful for sanitizers with a finite list of valid values.

Raises NotImplementedError for sanitizers which aren’t based on an enum of valid values.

sanitize(value_string: str) int

Method that takes an input string, validates that input string, and transforms it to a value of another type if necessary.

Raises InvalidArgumentError if the sanitization fails. Returns a value of an arbitrary type if it succeeds.

class buildgrid.server.operations.filtering.sanitizer.SortKeyValueSanitizer(filter_name: str)

Bases: ValueSanitizer

Sanitizer for sort orders.

Produces a SortKey tuple, which specifies both a key name and a boolean indicating ascending/descending order.

sanitize(value_string: str) SortKey

Method that takes an input string, validates that input string, and transforms it to a value of another type if necessary.

Raises InvalidArgumentError if the sanitization fails. Returns a value of an arbitrary type if it succeeds.