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

feat: bucket client support int/dev env #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions ebrains_drive/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,18 @@ def send_request(self, method: str, url: str, *args, **kwargs):
class BucketApiClient(ClientBase):

def __init__(self, username=None, password=None, token=_I_AM_A_PUBLIC_BUCKET, env="") -> None:
if env != "":
raise NotImplementedError("non prod environment for dataproxy access has not yet been implemented.")
self._set_env(env)

super().__init__(username, password, token, env)

self.server = "https://data-proxy.ebrains.eu/api"
self.server = f"https://data-proxy{self.suffix}.ebrains.eu/api"

self.buckets = Buckets(self)

@on_401_raise_unauthorized("Failed. Note: BucketApiClient.create_new needs to have clb.drive:write as a part of scope.")
def create_new(self, bucket_name: str, title=None, description="Created by ebrains_drive"):
# attempt to create new collab
self.send_request("POST", "https://wiki.ebrains.eu/rest/v1/collabs", json={
self.send_request("POST", f"https://wiki{self.suffix}.ebrains.eu/rest/v1/collabs", json={
"name": bucket_name,
"title": title or bucket_name,
"description": description,
Expand Down
4 changes: 3 additions & 1 deletion ebrains_drive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ def get_content(self):
class DataproxyFile:
session = requests.Session()

def __init__(self, client, bucket, hash: str, last_modified: str, bytes: int, name: str, content_type: str) -> None:
def __init__(self, client, bucket, hash: str, last_modified: str, bytes: int, name: str, content_type: str, **kwargs) -> None:
# TODO kwargs may contain keys: storage, data

self.client = client
self.bucket = bucket

Expand Down