Skip to content

Commit

Permalink
Added workspace filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Feb 21, 2020
1 parent 1e505c1 commit 6091884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions seatsio/workspaces/workspacesClient.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from seatsio.domain import Workspace
from seatsio.pagination.listableObjectsClient import ListableObjectsClient
from seatsio.pagination.lister import Lister
from seatsio.pagination.pageFetcher import PageFetcher
from seatsio.workspaces.UpdateWorkspaceRequest import UpdateWorkspaceRequest
from seatsio.workspaces.createWorkspaceRequest import CreateWorkspaceRequest

Expand All @@ -20,3 +22,11 @@ def update(self, key, name):

def retrieve(self, key):
return self.http_client.url("/workspaces/{key}", key=key).get_as(Workspace)

def list(self, filter=None):
page_fetcher = PageFetcher(Workspace, self.http_client, "/workspaces")

if filter is not None:
page_fetcher.set_query_param("filter", filter)

return Lister(page_fetcher).list()
9 changes: 9 additions & 0 deletions tests/workspaces/listAllWorkspacesTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ def test(self):
workspaces = self.client.workspaces.list()

assert_that(workspaces).extracting("name").contains_exactly("ws3", "ws2", "ws1", "Main workspace")

def test_filter(self):
self.client.workspaces.create("someWorkspace")
self.client.workspaces.create("anotherWorkspace")
self.client.workspaces.create("anotherAnotherWorkspace")

workspaces = self.client.workspaces.list("another")

assert_that(workspaces).extracting("name").contains_exactly("anotherAnotherWorkspace", "anotherWorkspace")

0 comments on commit 6091884

Please sign in to comment.