Skip to content

Commit

Permalink
fixed gitlab configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
opaduchak committed Dec 2, 2024
1 parent 1f74b60 commit a02f537
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions addon_imps/storage/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GitlabStorageImp(storage.StorageAddonHttpRequestorImp):
"""

async def get_external_account_id(self, _: dict[str, str]) -> str:
async with self.network.GET("user/preferences") as response:
async with self.network.GET("api/v4/user/preferences") as response:
resp_json = await response.json_content()
return resp_json.get("user_id", "")

Expand All @@ -55,7 +55,7 @@ async def list_root_items(self, page_cursor: str = "") -> storage.ItemSampleResu
"sort": "asc",
},
)
async with self.network.GET("projects", query=query_params) as response:
async with self.network.GET("api/v4/projects", query=query_params) as response:
resp = await response.json_content()
return ItemSampleResult(
items=[Repository.from_json(item).item_result for item in resp],
Expand Down Expand Up @@ -93,12 +93,12 @@ async def get_item_info(self, item_id: str) -> storage.ItemResult:
return (await self._get_repository(parsed_id.repo_id)).item_result

async def _get_repository(self, repo_id):
async with self.network.GET(f"projects/{repo_id}") as response:
async with self.network.GET(f"api/v4/projects/{repo_id}") as response:
content = await response.json_content()
return Repository.from_json(content)

async def get_file_or_folder(self, parsed_id: ItemId):
async with self.network.GET(f"projects/{parsed_id.repo_id}") as response:
async with self.network.GET(f"api/v4/projects/{parsed_id.repo_id}") as response:
content = await response.json_content()
ref = content.get("default_branch")
if file_item := await self._get_file(parsed_id, ref):
Expand All @@ -113,7 +113,7 @@ async def get_file_or_folder(self, parsed_id: ItemId):

async def _get_file(self, parsed_id, ref):
async with self.network.GET(
f"projects/{parsed_id.repo_id}/repository/files/{quote_plus(parsed_id.file_path)}",
f"api/v4/projects/{parsed_id.repo_id}/repository/files/{quote_plus(parsed_id.file_path)}",
query={"ref": ref},
) as response:
content = await response.json_content()
Expand Down Expand Up @@ -142,7 +142,7 @@ async def list_child_items(
},
)
async with self.network.GET(
f"projects/{parsed_id.repo_id}/repository/tree",
f"api/v4/projects/{parsed_id.repo_id}/repository/tree",
query=query_params,
) as response:
if response.http_status == HTTPStatus.NOT_FOUND:
Expand Down
2 changes: 1 addition & 1 deletion addon_imps/tests/storage/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _patch_get(self, return_value: dict | list, status=200, headers=None):

def _assert_get(self, url: str, query: dict = None):
extra_params = {"query": query} if query else {}
self.network.GET.assert_called_once_with(url, **extra_params)
self.network.GET.assert_called_once_with(f"api/v4/{url}", **extra_params)
self.network.GET.return_value.__aenter__.assert_awaited_once()
self.network.GET.return_value.__aenter__.return_value.json_content.assert_awaited_once()
self.network.GET.return_value.__aexit__.assert_awaited_once_with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ def get_api_base_url(self, external_service, osf_account):
if external_service.wb_key == "owncloud":
return f"{osf_account.profile_url.removesuffix('/')}/remote.php/dav/files/{osf_account.display_name}/"
elif external_service.wb_key == "gitlab":
return f"{osf_account.oauth_secret.removesuffix('/')}/api/v4/"
return f"{osf_account.oauth_secret.removesuffix('/')}"
elif external_service.wb_key == "dataverse":
return f"https://{osf_account.oauth_key}"

0 comments on commit a02f537

Please sign in to comment.