metadata_entities.py 838 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from collections.abc import Sequence
  2. from typing import Literal, Optional
  3. from pydantic import BaseModel, Field
  4. SupportedComparisonOperator = Literal[
  5. # for string or array
  6. "contains",
  7. "not contains",
  8. "start with",
  9. "end with",
  10. "is",
  11. "is not",
  12. "empty",
  13. "not empty",
  14. # for number
  15. "=",
  16. "≠",
  17. ">",
  18. "<",
  19. "≥",
  20. "≤",
  21. # for time
  22. "before",
  23. "after",
  24. ]
  25. class Condition(BaseModel):
  26. """
  27. Conditon detail
  28. """
  29. name: str
  30. comparison_operator: SupportedComparisonOperator
  31. value: str | Sequence[str] | None | int | float = None
  32. class MetadataCondition(BaseModel):
  33. """
  34. Metadata Condition.
  35. """
  36. logical_operator: Optional[Literal["and", "or"]] = "and"
  37. conditions: Optional[list[Condition]] = Field(default=None, deprecated=True)