Skip to content

Commit 3dce75f

Browse files
authored
chore: remove WorkspaceList (#185)
1 parent 3ed52b3 commit 3dce75f

7 files changed

Lines changed: 38 additions & 65 deletions

File tree

src/deepset_mcp/api/workspace/models.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,3 @@ class Workspace(BaseModel):
2121
"Supported languages and their configuration settings"
2222
default_idle_timeout_in_seconds: int
2323
"Default timeout in seconds before workspace becomes idle"
24-
25-
26-
class WorkspaceList(BaseModel):
27-
"""Model representing a list of workspaces."""
28-
29-
data: list[Workspace]
30-
"List of workspace objects for the current page"
31-
has_more: bool = False
32-
"Whether there are more workspaces available beyond this page"
33-
total: int
34-
"Total number of workspaces across all pages"

src/deepset_mcp/api/workspace/protocols.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
from typing import Protocol
88

99
from deepset_mcp.api.shared_models import NoContentResponse
10-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
10+
from deepset_mcp.api.workspace.models import Workspace
1111

1212

1313
class WorkspaceResourceProtocol(Protocol):
1414
"""Protocol defining the interface for workspace resources."""
1515

16-
async def list(self) -> WorkspaceList:
16+
async def list(self) -> list[Workspace]:
1717
"""List all workspaces.
1818
19-
:returns: A WorkspaceList containing all workspaces.
19+
:returns: A list containing all workspaces.
2020
"""
2121
...
2222

src/deepset_mcp/api/workspace/resource.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from deepset_mcp.api.shared_models import NoContentResponse
1111
from deepset_mcp.api.transport import raise_for_status
12-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
12+
from deepset_mcp.api.workspace.models import Workspace
1313
from deepset_mcp.api.workspace.protocols import WorkspaceResourceProtocol
1414

1515
logger = logging.getLogger(__name__)
@@ -28,10 +28,10 @@ def __init__(self, client: "AsyncClientProtocol") -> None:
2828
"""
2929
self._client = client
3030

31-
async def list(self) -> WorkspaceList:
31+
async def list(self) -> list[Workspace]:
3232
"""List all workspaces.
3333
34-
:returns: A WorkspaceList containing all workspaces.
34+
:returns: A list containing all workspaces.
3535
"""
3636
resp = await self._client.request(
3737
endpoint="v1/workspaces",
@@ -42,13 +42,9 @@ async def list(self) -> WorkspaceList:
4242

4343
if resp.json is not None and isinstance(resp.json, list):
4444
workspaces = [Workspace.model_validate(item) for item in resp.json]
45-
return WorkspaceList(
46-
data=workspaces,
47-
has_more=False,
48-
total=len(workspaces),
49-
)
45+
return workspaces
5046
else:
51-
return WorkspaceList(data=[], has_more=False, total=0)
47+
return []
5248

5349
async def get(self, workspace_name: str) -> Workspace:
5450
"""Get a specific workspace by name.

src/deepset_mcp/tools/workspace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from deepset_mcp.api.exceptions import BadRequestError, ResourceNotFoundError, UnexpectedAPIError
88
from deepset_mcp.api.protocols import AsyncClientProtocol
99
from deepset_mcp.api.shared_models import NoContentResponse
10-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
10+
from deepset_mcp.api.workspace.models import Workspace
1111

1212

13-
async def list_workspaces(*, client: AsyncClientProtocol) -> WorkspaceList | str:
13+
async def list_workspaces(*, client: AsyncClientProtocol) -> list[Workspace] | str:
1414
"""Retrieves a list of all workspaces available to the user.
1515
1616
This tool provides an overview of all workspaces that the user has access to.

test/integration/test_integration_workspace_resource.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from deepset_mcp.api.client import AsyncDeepsetClient
1212
from deepset_mcp.api.exceptions import ResourceNotFoundError
13-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
13+
from deepset_mcp.api.workspace.models import Workspace
1414

1515
pytestmark = pytest.mark.integration
1616

@@ -23,13 +23,11 @@ async def test_list_workspaces(self) -> None:
2323
"""Test listing workspaces."""
2424
async with AsyncDeepsetClient() as client:
2525
workspaces = await client.workspaces().list()
26-
assert isinstance(workspaces, WorkspaceList)
27-
assert isinstance(workspaces.data, list)
28-
assert workspaces.total >= 0
26+
assert isinstance(workspaces, list)
2927

3028
# If we have workspaces, verify their structure
31-
if workspaces.data:
32-
workspace = workspaces.data[0]
29+
if workspaces:
30+
workspace = workspaces[0]
3331
assert isinstance(workspace, Workspace)
3432
assert isinstance(workspace.name, str)
3533
assert isinstance(workspace.workspace_id, uuid.UUID)

test/unit/api/workspace/test_workspace_resource.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from deepset_mcp.api.exceptions import BadRequestError, ResourceNotFoundError, UnexpectedAPIError
1212
from deepset_mcp.api.shared_models import NoContentResponse
1313
from deepset_mcp.api.transport import TransportResponse
14-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
14+
from deepset_mcp.api.workspace.models import Workspace
1515
from deepset_mcp.api.workspace.resource import WorkspaceResource
1616
from test.unit.conftest import BaseFakeClient
1717

@@ -52,22 +52,20 @@ def workspaces(self) -> WorkspaceResource:
5252
result = await resource.list()
5353

5454
# Assert
55-
assert isinstance(result, WorkspaceList)
56-
assert len(result.data) == 2
57-
assert result.total == 2
58-
assert not result.has_more
55+
assert isinstance(result, list)
56+
assert len(result) == 2
5957

6058
# Check first workspace
61-
assert result.data[0].name == "copilot-testing"
62-
assert result.data[0].workspace_id == UUID("76d361b5-a551-40e3-a5c9-fdbc20028021")
63-
assert result.data[0].languages == {}
64-
assert result.data[0].default_idle_timeout_in_seconds == 43200
59+
assert result[0].name == "copilot-testing"
60+
assert result[0].workspace_id == UUID("76d361b5-a551-40e3-a5c9-fdbc20028021")
61+
assert result[0].languages == {}
62+
assert result[0].default_idle_timeout_in_seconds == 43200
6563

6664
# Check second workspace
67-
assert result.data[1].name == "default"
68-
assert result.data[1].workspace_id == UUID("91ee7798-004d-4808-906a-1777ea262d1c")
69-
assert result.data[1].languages == {}
70-
assert result.data[1].default_idle_timeout_in_seconds == 43200
65+
assert result[1].name == "default"
66+
assert result[1].workspace_id == UUID("91ee7798-004d-4808-906a-1777ea262d1c")
67+
assert result[1].languages == {}
68+
assert result[1].default_idle_timeout_in_seconds == 43200
7169

7270
# Verify request was made correctly
7371
assert len(client.requests) == 1
@@ -93,10 +91,8 @@ def workspaces(self) -> WorkspaceResource:
9391
result = await resource.list()
9492

9593
# Assert
96-
assert isinstance(result, WorkspaceList)
97-
assert len(result.data) == 0
98-
assert result.total == 0
99-
assert not result.has_more
94+
assert isinstance(result, list)
95+
assert len(result) == 0
10096

10197
@pytest.mark.asyncio
10298
async def test_list_null_response(self) -> None:
@@ -117,10 +113,8 @@ def workspaces(self) -> WorkspaceResource:
117113
result = await resource.list()
118114

119115
# Assert
120-
assert isinstance(result, WorkspaceList)
121-
assert len(result.data) == 0
122-
assert result.total == 0
123-
assert not result.has_more
116+
assert isinstance(result, list)
117+
assert len(result) == 0
124118

125119
@pytest.mark.asyncio
126120
async def test_list_error_response(self) -> None:

test/unit/tools/test_workspace.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from deepset_mcp.api.exceptions import BadRequestError, ResourceNotFoundError, UnexpectedAPIError
1010
from deepset_mcp.api.shared_models import NoContentResponse
11-
from deepset_mcp.api.workspace.models import Workspace, WorkspaceList
11+
from deepset_mcp.api.workspace.models import Workspace
1212
from deepset_mcp.api.workspace.protocols import WorkspaceResourceProtocol
1313
from deepset_mcp.tools.workspace import create_workspace, get_workspace, list_workspaces
1414
from test.unit.conftest import BaseFakeClient
@@ -37,12 +37,12 @@ def __init__(
3737
self._create_exception = create_exception
3838
self._delete_exception = delete_exception
3939

40-
async def list(self) -> WorkspaceList:
40+
async def list(self) -> list[Workspace]:
4141
"""List all workspaces."""
4242
if self._list_exception:
4343
raise self._list_exception
4444
if self._list_response is not None:
45-
return WorkspaceList(data=self._list_response, has_more=False, total=len(self._list_response))
45+
return self._list_response
4646
raise NotImplementedError
4747

4848
async def get(self, workspace_name: str) -> Workspace:
@@ -101,12 +101,10 @@ async def test_list_workspaces_returns_workspace_list() -> None:
101101

102102
result = await list_workspaces(client=client)
103103

104-
assert isinstance(result, WorkspaceList)
105-
assert len(result.data) == 2
106-
assert result.data[0].name == "workspace1"
107-
assert result.data[1].name == "workspace2"
108-
assert result.total == 2
109-
assert result.has_more is False
104+
assert isinstance(result, list)
105+
assert len(result) == 2
106+
assert result[0].name == "workspace1"
107+
assert result[1].name == "workspace2"
110108

111109

112110
@pytest.mark.asyncio
@@ -237,7 +235,5 @@ async def test_list_workspaces_empty_response() -> None:
237235

238236
result = await list_workspaces(client=client)
239237

240-
assert isinstance(result, WorkspaceList)
241-
assert len(result.data) == 0
242-
assert result.total == 0
243-
assert result.has_more is False
238+
assert isinstance(result, list)
239+
assert len(result) == 0

0 commit comments

Comments
 (0)