-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single list for Ingestion Model and adapted tests (#121)
# PR Context <!-- Additional info for the reviewer --> # Added <!-- New features and interfaces --> # Changes <!-- Changes in existing functionality --> - BulkIngestRequest contains now one single list "items" - tests for ingestion adapted to BulkIngestRequest-Model # Deprecated <!-- Soon-to-be removed features --> # Removed <!-- Definitely removed features --> - removed class _BaseBulkIngestRequest for ingestion model # Fixed <!-- Fixed bugs --> # Security <!-- Fixed vulnerabilities --> --------- Signed-off-by: vyvytranngoc <[email protected]> Co-authored-by: Nicolas Drebenstedt <[email protected]>
- Loading branch information
1 parent
428264c
commit 6f2655e
Showing
5 changed files
with
24 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,14 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from pydantic import ConfigDict, create_model | ||
|
||
from mex.common.models import ( | ||
EXTRACTED_MODEL_CLASSES_BY_NAME, | ||
AnyExtractedModel, | ||
BaseModel, | ||
) | ||
from mex.common.types import Identifier | ||
|
||
|
||
class _BaseBulkIngestRequest(BaseModel): | ||
class BulkIngestRequest(BaseModel): | ||
"""Request body for the bulk ingestion endpoint.""" | ||
|
||
model_config = ConfigDict( | ||
json_schema_extra={ | ||
"examples": [ | ||
{ | ||
"ExtractedPerson": [ | ||
{ | ||
"hadPrimarySource": "000001111122222", | ||
"identifierInPrimarySource": "jimmy", | ||
"email": ["[email protected]"], | ||
"givenName": "Jimmy", | ||
"memberOf": ["111112222233333"], | ||
} | ||
], | ||
"ExtractedContactPoint": [ | ||
{ | ||
"hadPrimarySource": "000001111122222", | ||
"identifierInPrimarySource": "sales", | ||
"email": ["[email protected]"], | ||
}, | ||
{ | ||
"hadPrimarySource": "000001111122222", | ||
"identifierInPrimarySource": "hr", | ||
"email": ["[email protected]"], | ||
}, | ||
], | ||
} | ||
] | ||
} | ||
) | ||
|
||
def get_all(self) -> list[AnyExtractedModel]: | ||
return [data for name in self.model_fields for data in getattr(self, name)] | ||
|
||
|
||
if TYPE_CHECKING: # pragma: no cover | ||
BulkIngestRequest = _BaseBulkIngestRequest | ||
else: | ||
BulkIngestRequest = create_model( | ||
"BulkIngestRequest", | ||
__base__=_BaseBulkIngestRequest, | ||
__module__=__name__, | ||
**{ | ||
name: (list[model], []) | ||
for name, model in EXTRACTED_MODEL_CLASSES_BY_NAME.items() | ||
}, | ||
) | ||
items: list[AnyExtractedModel] | ||
|
||
|
||
class BulkIngestResponse(BaseModel): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.