Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect back end to front end #11

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions jupyter_drives/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ class DrivesConfig(Configurable):
help="The id of the access key for the bucket.",
)


secret_access_key= Unicode(
None,
config=True,
allow_none=True,
help="The secret access key for the bucket.",
)


region_name = Unicode(
"eu-north-1",
config = True,
config = True,
help = "Region name.",
)

api_base_url = Unicode(
config=True,
help="Base URL of the provider service REST API.",
Expand All @@ -50,10 +52,10 @@ def set_default_api_base_url(self):
# for AWS S3 drives
if self.provider == "s3":
return "https://s3.amazonaws.com/" # region? https://s3.<region>.amazonaws.com/

# for Google Cloud Storage drives
elif self.provider == "gcs":
return "https://www.googleapis.com/"
return "https://www.googleapis.com/"

provider = Enum(
MANAGERS.keys(),
Expand Down
13 changes: 7 additions & 6 deletions jupyter_drives/managers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ def per_page_argument(self) -> Optional[Tuple[str, int]]:
None: the provider does not support pagination
"""
return ("per_page", 100)

async def list_drives(self) -> List[Dict[str, str]]:
"""Get the list of available drives.

Returns:
The list of available drives
"""
# drives_url = "/get-listDrives"
# results = await self._call_s3(drives_url)
# results = await self._call_s3(drives_url)

data = []
error = ""
if (self._config.access_key_id and self._config.secret_access_key):
Expand All @@ -53,7 +53,7 @@ async def list_drives(self) -> List[Dict[str, str]]:
results = []
for drive in drives:
results += drive.list_containers()

for result in results:
data.append(
{
Expand All @@ -68,7 +68,7 @@ async def list_drives(self) -> List[Dict[str, str]]:
error = "No AWS credentials provided."

return data, error

async def _call_s3(
self,
url: str,
Expand Down Expand Up @@ -103,6 +103,7 @@ async def _call_s3(
"Authorization": f"session-token {self._config.session_token_token} access-key-id {self._config.access_key_id} secret-access-key {self._config.secret_access_key}",
}


return await super()._call_provider(
url,
load_json=load_json,
Expand Down
Loading
Loading