-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-5479] Feature/network for imps (#29)
- Loading branch information
Showing
34 changed files
with
1,066 additions
and
361 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
__all__ = () | ||
from . import storage | ||
|
||
|
||
__all__ = ("storage",) |
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 @@ | ||
__all__ = () |
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,21 +1,20 @@ | ||
from addon_toolkit import RedirectResult | ||
from addon_toolkit.storage import ( | ||
ItemArg, | ||
PageArg, | ||
PagedResult, | ||
StorageAddonProtocol, | ||
ItemResult, | ||
ItemSampleResult, | ||
StorageAddonImp, | ||
) | ||
|
||
|
||
class MyBlargStorage(StorageAddonProtocol): | ||
class MyBlargStorage(StorageAddonImp): | ||
"""blarg?""" | ||
|
||
def download(self, item: ItemArg) -> RedirectResult: | ||
def download(self, item_id: str) -> RedirectResult: | ||
"""blarg blarg blarg""" | ||
return RedirectResult(f"http://blarg.example/{item.item_id}") | ||
return RedirectResult(f"/{item_id}") | ||
|
||
def blargblarg(self, item: ItemArg) -> PagedResult: | ||
return PagedResult(["hello"]) | ||
|
||
def opop(self, item: ItemArg, page: PageArg) -> PagedResult: | ||
return PagedResult(["hello"]) | ||
async def get_root_items(self, page_cursor: str = "") -> ItemSampleResult: | ||
return ItemSampleResult( | ||
items=[ItemResult(item_id="hello", item_name="Hello!?")], | ||
total_count=1, | ||
) |
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,28 @@ | ||
from asgiref.sync import async_to_sync | ||
|
||
from addon_service.common.aiohttp_session import get_aiohttp_client_session | ||
from addon_service.models import ConfiguredStorageAddon | ||
from addon_toolkit.constrained_aiohttp import AiohttpRequestor | ||
from addon_toolkit.storage import ( | ||
StorageAddonProtocol, | ||
StorageConfig, | ||
) | ||
|
||
|
||
def get_storage_addon_instance( | ||
configured_storage_addon: ConfiguredStorageAddon, | ||
) -> StorageAddonProtocol: | ||
_external_storage_service = ( | ||
configured_storage_addon.base_account.external_storage_service | ||
) | ||
_imp_cls = _external_storage_service.addon_imp.imp_cls | ||
return _imp_cls( | ||
config=StorageConfig( | ||
max_upload_mb=_external_storage_service.max_upload_mb, | ||
), | ||
network=AiohttpRequestor( | ||
client_session=async_to_sync(get_aiohttp_client_session)(), | ||
prefix_url=_external_storage_service.api_base_url, | ||
credentials=..., | ||
), | ||
) |
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
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.