-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#38] merge branch 'develop' of https://github.com/I-GUIDE/catalogapi …
…into 38-update-to-pydantic-v2
- Loading branch information
Showing
31 changed files
with
8,339 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# import all adapters here to get them registered | ||
from api.adapters import hydroshare |
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,5 +1,22 @@ | ||
from enum import Enum | ||
from typing import Type, Union | ||
|
||
from api.adapters.base import AbstractRepositoryMetadataAdapter | ||
|
||
|
||
class RepositoryType(str, Enum): | ||
HYDROSHARE = 'HYDROSHARE' | ||
|
||
|
||
_adapter_registry = {} | ||
|
||
|
||
def register_adapter(repository_type: RepositoryType, adapter_class: Type[AbstractRepositoryMetadataAdapter]) -> None: | ||
_adapter_registry[repository_type] = adapter_class | ||
|
||
|
||
def get_adapter_by_type(repository_type: RepositoryType) -> Union[AbstractRepositoryMetadataAdapter, None]: | ||
adapter_cls = _adapter_registry.get(repository_type, None) | ||
if adapter_cls: | ||
return adapter_cls() | ||
return None |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import asyncio | ||
from api.config import get_settings | ||
from api.models.catalog import DatasetMetadataDOC | ||
|
||
from beanie import init_beanie | ||
from motor.motor_asyncio import AsyncIOMotorClient | ||
|
||
|
||
async def main(): | ||
db = AsyncIOMotorClient(get_settings().db_connection_string) | ||
await init_beanie(database=db[get_settings().database_name], document_models=[DatasetMetadataDOC]) | ||
# https://www.mongodb.com/docs/manual/reference/command/collMod/#change-streams-with-document-pre--and-post-images | ||
# This enables us to get the record id of a deleted submission within a trigger. We need this for removing | ||
# discovery records when a submission is deleted | ||
await db[get_settings().database_name].command( | ||
({'collMod': DatasetMetadataDOC.get_collection_name(), "changeStreamPreAndPostImages": {'enabled': True}})) | ||
db.close() | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
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
Oops, something went wrong.