Skip to content

Commit

Permalink
Refactored DELETE payloads on API (#16)
Browse files Browse the repository at this point in the history
Making delete a query parameter to follow rfc7231
  • Loading branch information
kevinmessiaen authored Sep 11, 2024
1 parent 0468b42 commit 5dd9af9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
5 changes: 1 addition & 4 deletions src/giskard_hub/resources/conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ def update(
)

def delete(self, conversation_id: str | List[str]) -> None:
if isinstance(conversation_id, str):
conversation_id = [conversation_id]

return self._client.delete("/conversations", json=conversation_id)
return self._client.delete("/conversations", params={"conversation_ids": conversation_id})

def list(self, dataset_id: str) -> List[Conversation]:
data = self._client.get(f"/datasets/{dataset_id}/conversations?limit=100000")
Expand Down
5 changes: 1 addition & 4 deletions src/giskard_hub/resources/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ def update(
)

def delete(self, dataset_id: str | List[str]) -> None:
if isinstance(dataset_id, str):
dataset_id = [dataset_id]

self._client.delete("/datasets", json=dataset_id)
self._client.delete("/datasets", params={"datasets_ids": dataset_id})

def list(self, project_id: str) -> List[Dataset]:
return self._client.get(
Expand Down
7 changes: 2 additions & 5 deletions src/giskard_hub/resources/evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ def create_local(
cast_to=EvaluationRun,
)

def delete(self, project_id: str | List[str]):
if isinstance(project_id, str):
project_id = [project_id]

return self._client.delete("/executions", json=project_id)
def delete(self, execution_id: str | List[str]):
return self._client.delete("/executions", params={"execution_ids": execution_id})

def list(self, project_id: str):
return self._client.get(
Expand Down
5 changes: 1 addition & 4 deletions src/giskard_hub/resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ def update(
)

def delete(self, model_id: str | List[str]) -> None:
if isinstance(model_id, str):
model_id = [model_id]

self._client.delete("/models", json=model_id)
self._client.delete("/models", params={"model_ids": model_id})

def list(self, project_id: str) -> List[Model]:
return self._client.get(
Expand Down
5 changes: 1 addition & 4 deletions src/giskard_hub/resources/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ def update(
)

def delete(self, project_id: str | List[str]):
if isinstance(project_id, str):
project_id = [project_id]

return self._client.delete("/projects", json=project_id)
return self._client.delete("/projects", params={"project_ids": project_id})

def list(self):
return self._client.get("/projects", cast_to=Project)

0 comments on commit 5dd9af9

Please sign in to comment.