Module lum.odinson.rest.requests
Expand source code
from __future__ import annotations
import typing
from pydantic import BaseModel, ConfigDict
__all__ = ["GrammarRequest", "SimplePatternsRequest"]
class GrammarRequest(BaseModel):
grammar: str
metadataQuery: typing.Optional[str] = None
maxDocs: typing.Optional[int] = None
allowTriggerOverlaps: typing.Optional[bool] = None
pretty: typing.Optional[bool] = None
def model_dump(self, by_alias=True, **kwargs):
return super().model_dump(by_alias=by_alias, **kwargs)
def model_dump_json(self, by_alias=True, **kwargs):
return super().model_dump_json(by_alias=by_alias, **kwargs)
def dict(self, **kwargs):
return self.model_dump(**kwargs)
def json(self, **kwargs):
return self.model_dump_json(**kwargs)
class SimplePatternsRequest(BaseModel):
patterns: list[str]
metadataQuery: typing.Optional[str] = None
prevDoc: typing.Optional[int] = None
prevScore: typing.Optional[float] = None
enriched: typing.Optional[bool] = None
pretty: typing.Optional[bool] = None
def model_dump(self, by_alias=True, **kwargs):
return super().model_dump(by_alias=by_alias, **kwargs)
def model_dump_json(self, by_alias=True, **kwargs):
return super().model_dump_json(by_alias=by_alias, **kwargs)
def dict(self, **kwargs):
return self.model_dump(**kwargs)
def json(self, **kwargs):
return self.model_dump_json(**kwargs)
Classes
class GrammarRequest (**data: Any)-
A base model class for creating Pydantic models.
Attributes
model_config- Configuration settings for the model.
model_fields- Metadata about the fields defined on the model.
This replaces
Model.__fields__from Pydantic V1. __class_vars__- The names of classvars defined on the model.
__private_attributes__- Metadata about the private attributes of the model.
__signature__- The signature for instantiating the model.
__pydantic_complete__- Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__- The pydantic-core schema used to build the SchemaValidator and SchemaSerializer.
__pydantic_custom_init__- Whether the model has a custom
__init__function. __pydantic_decorators__- Metadata containing the decorators defined on the model.
This replaces
Model.__validators__andModel.__root_validators__from Pydantic V1. __pydantic_generic_metadata__- Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__- Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__- The name of the post-init method for the model, if defined.
__pydantic_root_model__- Whether the model is a
RootModel. __pydantic_serializer__- The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_validator__- The pydantic-core SchemaValidator used to validate instances of the model.
__pydantic_extra__- An instance attribute with the values of extra fields from validation when
model_config['extra'] == 'allow'. __pydantic_fields_set__- An instance attribute with the names of fields explicitly specified during validation.
__pydantic_private__- Instance attribute with the values of private attributes set on the model instance.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__instead of the more commonselffor the first arg to allowselfas a field name.Expand source code
class GrammarRequest(BaseModel): grammar: str metadataQuery: typing.Optional[str] = None maxDocs: typing.Optional[int] = None allowTriggerOverlaps: typing.Optional[bool] = None pretty: typing.Optional[bool] = None def model_dump(self, by_alias=True, **kwargs): return super().model_dump(by_alias=by_alias, **kwargs) def model_dump_json(self, by_alias=True, **kwargs): return super().model_dump_json(by_alias=by_alias, **kwargs) def dict(self, **kwargs): return self.model_dump(**kwargs) def json(self, **kwargs): return self.model_dump_json(**kwargs)Ancestors
- pydantic.main.BaseModel
Class variables
var allowTriggerOverlaps : Optional[bool]var grammar : strvar maxDocs : Optional[int]var metadataQuery : Optional[str]var model_configvar model_fieldsvar pretty : Optional[bool]
Methods
def dict(self, **kwargs)-
Expand source code
def dict(self, **kwargs): return self.model_dump(**kwargs) def json(self, **kwargs)-
Expand source code
def json(self, **kwargs): return self.model_dump_json(**kwargs) def model_dump(self, by_alias=True, **kwargs)-
Usage docs: https://docs.pydantic.dev/dev-v2/usage/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args
mode- The mode in which
to_pythonshould run. If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. include- A list of fields to include in the output.
exclude- A list of fields to exclude from the output.
by_alias- Whether to use the field's alias in the dictionary key if defined.
exclude_unset- Whether to exclude fields that are unset or None from the output.
exclude_defaults- Whether to exclude fields that are set to their default value from the output.
exclude_none- Whether to exclude fields that have a value of
Nonefrom the output. round_trip- Whether to enable serialization and deserialization round-trip support.
warnings- Whether to log warnings when invalid fields are encountered.
Returns
A dictionary representation of the model.
Expand source code
def model_dump(self, by_alias=True, **kwargs): return super().model_dump(by_alias=by_alias, **kwargs) def model_dump_json(self, by_alias=True, **kwargs)-
Usage docs: https://docs.pydantic.dev/dev-v2/usage/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's
to_jsonmethod.Args
indent- Indentation to use in the JSON output. If None is passed, the output will be compact.
include- Field(s) to include in the JSON output. Can take either a string or set of strings.
exclude- Field(s) to exclude from the JSON output. Can take either a string or set of strings.
by_alias- Whether to serialize using field aliases.
exclude_unset- Whether to exclude fields that have not been explicitly set.
exclude_defaults- Whether to exclude fields that have the default value.
exclude_none- Whether to exclude fields that have a value of
None. round_trip- Whether to use serialization/deserialization between JSON and class instance.
warnings- Whether to show any warnings that occurred during serialization.
Returns
A JSON string representation of the model.
Expand source code
def model_dump_json(self, by_alias=True, **kwargs): return super().model_dump_json(by_alias=by_alias, **kwargs)
class SimplePatternsRequest (**data: Any)-
A base model class for creating Pydantic models.
Attributes
model_config- Configuration settings for the model.
model_fields- Metadata about the fields defined on the model.
This replaces
Model.__fields__from Pydantic V1. __class_vars__- The names of classvars defined on the model.
__private_attributes__- Metadata about the private attributes of the model.
__signature__- The signature for instantiating the model.
__pydantic_complete__- Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__- The pydantic-core schema used to build the SchemaValidator and SchemaSerializer.
__pydantic_custom_init__- Whether the model has a custom
__init__function. __pydantic_decorators__- Metadata containing the decorators defined on the model.
This replaces
Model.__validators__andModel.__root_validators__from Pydantic V1. __pydantic_generic_metadata__- Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__- Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__- The name of the post-init method for the model, if defined.
__pydantic_root_model__- Whether the model is a
RootModel. __pydantic_serializer__- The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_validator__- The pydantic-core SchemaValidator used to validate instances of the model.
__pydantic_extra__- An instance attribute with the values of extra fields from validation when
model_config['extra'] == 'allow'. __pydantic_fields_set__- An instance attribute with the names of fields explicitly specified during validation.
__pydantic_private__- Instance attribute with the values of private attributes set on the model instance.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__instead of the more commonselffor the first arg to allowselfas a field name.Expand source code
class SimplePatternsRequest(BaseModel): patterns: list[str] metadataQuery: typing.Optional[str] = None prevDoc: typing.Optional[int] = None prevScore: typing.Optional[float] = None enriched: typing.Optional[bool] = None pretty: typing.Optional[bool] = None def model_dump(self, by_alias=True, **kwargs): return super().model_dump(by_alias=by_alias, **kwargs) def model_dump_json(self, by_alias=True, **kwargs): return super().model_dump_json(by_alias=by_alias, **kwargs) def dict(self, **kwargs): return self.model_dump(**kwargs) def json(self, **kwargs): return self.model_dump_json(**kwargs)Ancestors
- pydantic.main.BaseModel
Class variables
var enriched : Optional[bool]var metadataQuery : Optional[str]var model_configvar model_fieldsvar patterns : list[str]var pretty : Optional[bool]var prevDoc : Optional[int]var prevScore : Optional[float]
Methods
def dict(self, **kwargs)-
Expand source code
def dict(self, **kwargs): return self.model_dump(**kwargs) def json(self, **kwargs)-
Expand source code
def json(self, **kwargs): return self.model_dump_json(**kwargs) def model_dump(self, by_alias=True, **kwargs)-
Usage docs: https://docs.pydantic.dev/dev-v2/usage/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args
mode- The mode in which
to_pythonshould run. If mode is 'json', the dictionary will only contain JSON serializable types. If mode is 'python', the dictionary may contain any Python objects. include- A list of fields to include in the output.
exclude- A list of fields to exclude from the output.
by_alias- Whether to use the field's alias in the dictionary key if defined.
exclude_unset- Whether to exclude fields that are unset or None from the output.
exclude_defaults- Whether to exclude fields that are set to their default value from the output.
exclude_none- Whether to exclude fields that have a value of
Nonefrom the output. round_trip- Whether to enable serialization and deserialization round-trip support.
warnings- Whether to log warnings when invalid fields are encountered.
Returns
A dictionary representation of the model.
Expand source code
def model_dump(self, by_alias=True, **kwargs): return super().model_dump(by_alias=by_alias, **kwargs) def model_dump_json(self, by_alias=True, **kwargs)-
Usage docs: https://docs.pydantic.dev/dev-v2/usage/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic's
to_jsonmethod.Args
indent- Indentation to use in the JSON output. If None is passed, the output will be compact.
include- Field(s) to include in the JSON output. Can take either a string or set of strings.
exclude- Field(s) to exclude from the JSON output. Can take either a string or set of strings.
by_alias- Whether to serialize using field aliases.
exclude_unset- Whether to exclude fields that have not been explicitly set.
exclude_defaults- Whether to exclude fields that have the default value.
exclude_none- Whether to exclude fields that have a value of
None. round_trip- Whether to use serialization/deserialization between JSON and class instance.
warnings- Whether to show any warnings that occurred during serialization.
Returns
A JSON string representation of the model.
Expand source code
def model_dump_json(self, by_alias=True, **kwargs): return super().model_dump_json(by_alias=by_alias, **kwargs)