Skip to content

Commit

Permalink
worker route for get pieces repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
vinicvaz committed Jan 8, 2024
1 parent cb10e7d commit 877b425
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
36 changes: 34 additions & 2 deletions rest/routers/piece_repository_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ def get_piece_repository_release_data(
status.HTTP_500_INTERNAL_SERVER_ERROR: {'model': SomethingWrongError},
status.HTTP_403_FORBIDDEN: {'model': ForbiddenError},
},
# TODO - I commented this to make it easier to test, but we should solve the auth service
# dependencies=[Depends(auth_service.workspace_access_authorizer)]
dependencies=[Depends(auth_service.workspace_access_authorizer)]
)
def get_pieces_repositories(
workspace_id: int,
Expand All @@ -142,6 +141,39 @@ def get_pieces_repositories(
raise HTTPException(status_code=e.status_code, detail=e.message)


@router.get(
path="/worker",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {'model': GetWorkspaceRepositoriesResponse},
status.HTTP_500_INTERNAL_SERVER_ERROR: {'model': SomethingWrongError},
status.HTTP_403_FORBIDDEN: {'model': ForbiddenError},
},
)
def get_pieces_repositories_worker(
workspace_id: int,
page: Optional[int] = 0,
page_size: Optional[int] = 100,
filters: ListRepositoryFilters = Depends(),
) -> GetWorkspaceRepositoriesResponse:
"""
Get pieces repositories for workspace.
This endpoint is used by the worker to get the repositories to be processed.
Is the same endpoint as the one above, but without the auth service.
The authorization is done by our service mesh Authorization Policy.
"""
try:
response = piece_repository_service.get_pieces_repositories(
workspace_id=workspace_id,
page=page,
page_size=page_size,
filters=filters
)
return response
except (BaseException, ForbiddenException) as e:
raise HTTPException(status_code=e.status_code, detail=e.message)


@router.delete(
path="/{piece_repository_id}",
status_code=status.HTTP_204_NO_CONTENT,
Expand Down
10 changes: 1 addition & 9 deletions src/domino/client/domino_backend_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,8 @@ def get_piece_secrets(self, piece_repository_id: int, piece_name: str) -> reques
)
return response

def get_piece_repository(self, piece_repository_id: int) -> requests.Response:
resource = f"/pieces-repositories/{piece_repository_id}"
response = self.request(
method='get',
resource=resource
)
return response

def get_piece_repositories_from_workspace_id(self, params: dict) -> requests.Response:
resource = "/pieces-repositories"
resource = "/pieces-repositories/worker"
response = self.request(
method='get',
resource=resource,
Expand Down

0 comments on commit 877b425

Please sign in to comment.