niklib.api package#
Submodules#
niklib.api.apps module#
- class niklib.api.apps.StandaloneApplication(app, options=None)[source]#
Bases:
BaseApplication
A runner to help us parse
argparse
next togunicorn
argsNote
For options, you can visit https://docs.gunicorn.org/en/latest/settings.html
niklib.api.database module#
niklib.api.models module#
- class niklib.api.models.PayloadExample(**data)[source]#
Bases:
BaseModel
API payload provided by user
Validation of API payload where it has a domain specific value or has fixed data. In that case, it is expected that developer first created an interface to have access to these fixed data or domain-specific knowledge as a validator function.
sex
is an example were it could be fixed, hence anenum.Enum
with fixed members has been defined inniklib.data.constant.ExampleSex
that contains it.funds
is a domain-specific knowledge that in this example, cannot be negative. or in some cases it could not surpass a specific value. For this, developer can add this manually here (not recommended) or creates an validator in where data actually has been first processed (e.g.niklib.data.preprocessor
).- Raises:
ValueError – _description_
ValueError – _description_
- _abc_impl = <_abc._abc_data object>#
- model_config: ClassVar[ConfigDict] = {'orm_mode': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'funds': FieldInfo(annotation=float, required=False, default=8000.0, title='Amount of fund', description='Amount of money you are going to bring and probably spend.', metadata=[Gt(gt=1000.0)]), 'sex': FieldInfo(annotation=str, required=False, default=<enum 'ExampleSex'>)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.