From 5ef153730a49f2d5943b56073166e27f66e23b31 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 28 Oct 2025 13:42:51 +0000 Subject: [PATCH] Commit: ffca557b --- .openapi-generator/FILES | 3 + .../documentreader/webclient/gen/__init__.py | 9 + .../webclient/gen/api/__init__.py | 2 + .../webclient/gen/api/default_api.py | 270 ++++++++++++++++++ .../webclient/gen/api/transaction_api.py | 17 ++ .../webclient/gen/models/__init__.py | 4 + .../webclient/gen/models/database_document.py | 111 +++++++ .../gen/models/database_document_list.py | 90 ++++++ 8 files changed, 506 insertions(+) create mode 100644 regula/documentreader/webclient/gen/api/default_api.py create mode 100644 regula/documentreader/webclient/gen/models/database_document.py create mode 100644 regula/documentreader/webclient/gen/models/database_document_list.py diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index cd160da..2a0822d 100755 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -2,6 +2,7 @@ regula/__init__.py regula/documentreader/__init__.py regula/documentreader/webclient/gen/__init__.py regula/documentreader/webclient/gen/api/__init__.py +regula/documentreader/webclient/gen/api/default_api.py regula/documentreader/webclient/gen/api/healthcheck_api.py regula/documentreader/webclient/gen/api/process_api.py regula/documentreader/webclient/gen/api/transaction_api.py @@ -40,6 +41,8 @@ regula/documentreader/webclient/gen/models/container_list_list_inner.py regula/documentreader/webclient/gen/models/critical.py regula/documentreader/webclient/gen/models/cross_source_value_comparison.py regula/documentreader/webclient/gen/models/data_module.py +regula/documentreader/webclient/gen/models/database_document.py +regula/documentreader/webclient/gen/models/database_document_list.py regula/documentreader/webclient/gen/models/details_optical.py regula/documentreader/webclient/gen/models/details_rfid.py regula/documentreader/webclient/gen/models/device_info.py diff --git a/regula/documentreader/webclient/gen/__init__.py b/regula/documentreader/webclient/gen/__init__.py index d448a43..7044034 100644 --- a/regula/documentreader/webclient/gen/__init__.py +++ b/regula/documentreader/webclient/gen/__init__.py @@ -10,6 +10,7 @@ # Define package exports __all__ = [ + "DefaultApi", "HealthcheckApi", "ProcessApi", "TransactionApi", @@ -52,6 +53,8 @@ "Critical", "CrossSourceValueComparison", "DataModule", + "DatabaseDocument", + "DatabaseDocumentList", "DetailsOptical", "DetailsRFID", "DeviceInfo", @@ -254,6 +257,7 @@ if __import__("typing").TYPE_CHECKING: # import apis into sdk package + from regula.documentreader.webclient.gen.api.default_api import DefaultApi as DefaultApi from regula.documentreader.webclient.gen.api.healthcheck_api import HealthcheckApi as HealthcheckApi from regula.documentreader.webclient.gen.api.process_api import ProcessApi as ProcessApi from regula.documentreader.webclient.gen.api.transaction_api import TransactionApi as TransactionApi @@ -300,6 +304,8 @@ from regula.documentreader.webclient.gen.models.critical import Critical as Critical from regula.documentreader.webclient.gen.models.cross_source_value_comparison import CrossSourceValueComparison as CrossSourceValueComparison from regula.documentreader.webclient.gen.models.data_module import DataModule as DataModule + from regula.documentreader.webclient.gen.models.database_document import DatabaseDocument as DatabaseDocument + from regula.documentreader.webclient.gen.models.database_document_list import DatabaseDocumentList as DatabaseDocumentList from regula.documentreader.webclient.gen.models.details_optical import DetailsOptical as DetailsOptical from regula.documentreader.webclient.gen.models.details_rfid import DetailsRFID as DetailsRFID from regula.documentreader.webclient.gen.models.device_info import DeviceInfo as DeviceInfo @@ -508,6 +514,7 @@ ("__version__", __version__), ("__all__", __all__), """# import apis into sdk package +from regula.documentreader.webclient.gen.api.default_api import DefaultApi as DefaultApi from regula.documentreader.webclient.gen.api.healthcheck_api import HealthcheckApi as HealthcheckApi from regula.documentreader.webclient.gen.api.process_api import ProcessApi as ProcessApi from regula.documentreader.webclient.gen.api.transaction_api import TransactionApi as TransactionApi @@ -554,6 +561,8 @@ from regula.documentreader.webclient.gen.models.critical import Critical as Critical from regula.documentreader.webclient.gen.models.cross_source_value_comparison import CrossSourceValueComparison as CrossSourceValueComparison from regula.documentreader.webclient.gen.models.data_module import DataModule as DataModule +from regula.documentreader.webclient.gen.models.database_document import DatabaseDocument as DatabaseDocument +from regula.documentreader.webclient.gen.models.database_document_list import DatabaseDocumentList as DatabaseDocumentList from regula.documentreader.webclient.gen.models.details_optical import DetailsOptical as DetailsOptical from regula.documentreader.webclient.gen.models.details_rfid import DetailsRFID as DetailsRFID from regula.documentreader.webclient.gen.models.device_info import DeviceInfo as DeviceInfo diff --git a/regula/documentreader/webclient/gen/api/__init__.py b/regula/documentreader/webclient/gen/api/__init__.py index fcf303d..3fcf988 100644 --- a/regula/documentreader/webclient/gen/api/__init__.py +++ b/regula/documentreader/webclient/gen/api/__init__.py @@ -2,6 +2,7 @@ if __import__("typing").TYPE_CHECKING: # import apis into api package + from regula.documentreader.webclient.gen.api.default_api import DefaultApi from regula.documentreader.webclient.gen.api.healthcheck_api import HealthcheckApi from regula.documentreader.webclient.gen.api.process_api import ProcessApi from regula.documentreader.webclient.gen.api.transaction_api import TransactionApi @@ -13,6 +14,7 @@ LazyModule( *as_package(__file__), """# import apis into api package +from regula.documentreader.webclient.gen.api.default_api import DefaultApi from regula.documentreader.webclient.gen.api.healthcheck_api import HealthcheckApi from regula.documentreader.webclient.gen.api.process_api import ProcessApi from regula.documentreader.webclient.gen.api.transaction_api import TransactionApi diff --git a/regula/documentreader/webclient/gen/api/default_api.py b/regula/documentreader/webclient/gen/api/default_api.py new file mode 100644 index 0000000..23b17a9 --- /dev/null +++ b/regula/documentreader/webclient/gen/api/default_api.py @@ -0,0 +1,270 @@ +# coding: utf-8 + +""" + Generated by: https://openapi-generator.tech +""" +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from regula.documentreader.webclient.gen.models.database_document_list import DatabaseDocumentList + +from regula.documentreader.webclient.gen.api_client import ApiClient, RequestSerialized +from regula.documentreader.webclient.gen.api_response import ApiResponse +from regula.documentreader.webclient.gen.rest import RESTResponseType + + +class DefaultApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def doclist( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DatabaseDocumentList: + """Returns the list of documents stored in the database that the Web Service API is running with. + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._doclist_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DatabaseDocumentList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def doclist_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DatabaseDocumentList]: + """Returns the list of documents stored in the database that the Web Service API is running with. + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._doclist_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DatabaseDocumentList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def doclist_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Returns the list of documents stored in the database that the Web Service API is running with. + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._doclist_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DatabaseDocumentList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _doclist_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/doclist', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/regula/documentreader/webclient/gen/api/transaction_api.py b/regula/documentreader/webclient/gen/api/transaction_api.py index 285377b..e3f4646 100644 --- a/regula/documentreader/webclient/gen/api/transaction_api.py +++ b/regula/documentreader/webclient/gen/api/transaction_api.py @@ -1107,6 +1107,7 @@ def api_v2_transaction_transaction_id_process_post( self, transaction_id: Annotated[UUID, Field(description="Transaction id")], transaction_process_request: TransactionProcessRequest, + use_cache: Annotated[Optional[StrictBool], Field(description="Get processed values from storage in case transaction has already processed.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1127,6 +1128,8 @@ def api_v2_transaction_transaction_id_process_post( :type transaction_id: str :param transaction_process_request: (required) :type transaction_process_request: TransactionProcessRequest + :param use_cache: Get processed values from storage in case transaction has already processed. + :type use_cache: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1152,6 +1155,7 @@ def api_v2_transaction_transaction_id_process_post( _param = self._api_v2_transaction_transaction_id_process_post_serialize( transaction_id=transaction_id, transaction_process_request=transaction_process_request, + use_cache=use_cache, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1179,6 +1183,7 @@ def api_v2_transaction_transaction_id_process_post_with_http_info( self, transaction_id: Annotated[UUID, Field(description="Transaction id")], transaction_process_request: TransactionProcessRequest, + use_cache: Annotated[Optional[StrictBool], Field(description="Get processed values from storage in case transaction has already processed.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1199,6 +1204,8 @@ def api_v2_transaction_transaction_id_process_post_with_http_info( :type transaction_id: str :param transaction_process_request: (required) :type transaction_process_request: TransactionProcessRequest + :param use_cache: Get processed values from storage in case transaction has already processed. + :type use_cache: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1224,6 +1231,7 @@ def api_v2_transaction_transaction_id_process_post_with_http_info( _param = self._api_v2_transaction_transaction_id_process_post_serialize( transaction_id=transaction_id, transaction_process_request=transaction_process_request, + use_cache=use_cache, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1251,6 +1259,7 @@ def api_v2_transaction_transaction_id_process_post_without_preload_content( self, transaction_id: Annotated[UUID, Field(description="Transaction id")], transaction_process_request: TransactionProcessRequest, + use_cache: Annotated[Optional[StrictBool], Field(description="Get processed values from storage in case transaction has already processed.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1271,6 +1280,8 @@ def api_v2_transaction_transaction_id_process_post_without_preload_content( :type transaction_id: str :param transaction_process_request: (required) :type transaction_process_request: TransactionProcessRequest + :param use_cache: Get processed values from storage in case transaction has already processed. + :type use_cache: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -1296,6 +1307,7 @@ def api_v2_transaction_transaction_id_process_post_without_preload_content( _param = self._api_v2_transaction_transaction_id_process_post_serialize( transaction_id=transaction_id, transaction_process_request=transaction_process_request, + use_cache=use_cache, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1318,6 +1330,7 @@ def _api_v2_transaction_transaction_id_process_post_serialize( self, transaction_id, transaction_process_request, + use_cache, _request_auth, _content_type, _headers, @@ -1342,6 +1355,10 @@ def _api_v2_transaction_transaction_id_process_post_serialize( if transaction_id is not None: _path_params['transactionId'] = transaction_id # process the query parameters + if use_cache is not None: + + _query_params.append(('useCache', use_cache)) + # process the header parameters # process the form parameters # process the body parameter diff --git a/regula/documentreader/webclient/gen/models/__init__.py b/regula/documentreader/webclient/gen/models/__init__.py index e64f3d6..8a26a28 100644 --- a/regula/documentreader/webclient/gen/models/__init__.py +++ b/regula/documentreader/webclient/gen/models/__init__.py @@ -37,6 +37,8 @@ from regula.documentreader.webclient.gen.models.critical import Critical from regula.documentreader.webclient.gen.models.cross_source_value_comparison import CrossSourceValueComparison from regula.documentreader.webclient.gen.models.data_module import DataModule + from regula.documentreader.webclient.gen.models.database_document import DatabaseDocument + from regula.documentreader.webclient.gen.models.database_document_list import DatabaseDocumentList from regula.documentreader.webclient.gen.models.details_optical import DetailsOptical from regula.documentreader.webclient.gen.models.details_rfid import DetailsRFID from regula.documentreader.webclient.gen.models.device_info import DeviceInfo @@ -273,6 +275,8 @@ from regula.documentreader.webclient.gen.models.critical import Critical from regula.documentreader.webclient.gen.models.cross_source_value_comparison import CrossSourceValueComparison from regula.documentreader.webclient.gen.models.data_module import DataModule +from regula.documentreader.webclient.gen.models.database_document import DatabaseDocument +from regula.documentreader.webclient.gen.models.database_document_list import DatabaseDocumentList from regula.documentreader.webclient.gen.models.details_optical import DetailsOptical from regula.documentreader.webclient.gen.models.details_rfid import DetailsRFID from regula.documentreader.webclient.gen.models.device_info import DeviceInfo diff --git a/regula/documentreader/webclient/gen/models/database_document.py b/regula/documentreader/webclient/gen/models/database_document.py new file mode 100644 index 0000000..c40bf0d --- /dev/null +++ b/regula/documentreader/webclient/gen/models/database_document.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + Generated by: https://openapi-generator.tech +""" + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from regula.documentreader.webclient.gen.models.document_type import DocumentType +from typing import Optional, Set +from typing_extensions import Self +from pydantic import SkipValidation, Field + +class DatabaseDocument(BaseModel): + """ + DatabaseDocument + """ # noqa: E501 + barcode_fields: SkipValidation[bool] = Field(alias="barcode_fields", description="Whether the document has a barcode.") + country: SkipValidation[str] = Field(alias="country", description="Country name.") + createad: SkipValidation[str] = Field(alias="createad", description="Date when the document description was created in the database.") + doc_type: SkipValidation[DocumentType] = Field(alias="doc_type") + document: SkipValidation[str] = Field(alias="document", description="Document name.") + graphic_fields: SkipValidation[bool] = Field(alias="graphic_fields", description="The presence of graphic fields in the document.") + id: SkipValidation[int] = Field(alias="id", description="Document code.") + mrz: SkipValidation[bool] = Field(alias="mrz", description="The document has an MRZ.") + region: SkipValidation[Optional[str]] = Field(alias="region", default=None, description="Country region.") + rfid_chip: SkipValidation[bool] = Field(alias="rfid_chip", description="The document has an RFID chip.") + text_fields: SkipValidation[bool] = Field(alias="text_fields", description="The presence of text fields in the document.") + updated: SkipValidation[str] = Field(alias="updated", description="Date when the document description was updated in the database.") + year: SkipValidation[Optional[str]] = Field(alias="year", default=None, description="The year when the document was issued.") + sovereignty: SkipValidation[Optional[str]] = Field(alias="sovereignty", default=None, description="Guardian country.") + deprecated: SkipValidation[Optional[bool]] = Field(alias="deprecated", default=None, description="Whether the document is no longer in circulation.") + __properties: ClassVar[List[str]] = ["barcode_fields", "country", "createad", "doc_type", "document", "graphic_fields", "id", "mrz", "region", "rfid_chip", "text_fields", "updated", "year", "sovereignty", "deprecated"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + arbitrary_types_allowed=True, + use_enum_values=True + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DatabaseDocument from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DatabaseDocument from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "barcode_fields": obj.get("barcode_fields"), + "country": obj.get("country"), + "createad": obj.get("createad"), + "doc_type": obj.get("doc_type"), + "document": obj.get("document"), + "graphic_fields": obj.get("graphic_fields"), + "id": obj.get("id"), + "mrz": obj.get("mrz"), + "region": obj.get("region"), + "rfid_chip": obj.get("rfid_chip"), + "text_fields": obj.get("text_fields"), + "updated": obj.get("updated"), + "year": obj.get("year"), + "sovereignty": obj.get("sovereignty"), + "deprecated": obj.get("deprecated") + }) + return _obj + + diff --git a/regula/documentreader/webclient/gen/models/database_document_list.py b/regula/documentreader/webclient/gen/models/database_document_list.py new file mode 100644 index 0000000..9b36bd1 --- /dev/null +++ b/regula/documentreader/webclient/gen/models/database_document_list.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Generated by: https://openapi-generator.tech +""" + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from regula.documentreader.webclient.gen.models.database_document import DatabaseDocument +from typing import Optional, Set +from typing_extensions import Self +from pydantic import SkipValidation, Field + +class DatabaseDocumentList(BaseModel): + """ + DatabaseDocumentList + """ # noqa: E501 + items: SkipValidation[List[DatabaseDocument]] = Field(alias="items", description="The list of documents stored in the database.") + __properties: ClassVar[List[str]] = ["items"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + arbitrary_types_allowed=True, + use_enum_values=True + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DatabaseDocumentList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in items (list) + _items = [] + if self.items: + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) + _dict['items'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DatabaseDocumentList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "items": [DatabaseDocument.from_dict(_item) for _item in obj.get("items", []) if DatabaseDocument.from_dict(_item) is not None] + }) + return _obj + +