Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cirro/cirro_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cirro.config import AppConfig
from cirro.services import FileService, DatasetService, ProjectService, ProcessService, ExecutionService, \
MetricsService, MetadataService, BillingService, ReferenceService, UserService, ComputeEnvironmentService, \
ShareService
ShareService, WorkspaceService


class CirroApi:
Expand Down Expand Up @@ -59,6 +59,7 @@ def __init__(self, auth_info: AuthInfo = None, base_url: str = None, user_agent:
self._references_service = ReferenceService(self._api_client, file_service=self._file_service)
self._shares_service = ShareService(self._api_client)
self._users_service = UserService(self._api_client)
self._workspace_service = WorkspaceService(self._api_client)

@property
def datasets(self) -> DatasetService:
Expand Down Expand Up @@ -137,6 +138,13 @@ def users(self) -> UserService:
"""
return self._users_service

@property
def workspaces(self) -> WorkspaceService:
"""
Manage workspaces
"""
return self._workspace_service

@property
def file(self) -> FileService:
"""
Expand Down
5 changes: 4 additions & 1 deletion cirro/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from .references import ReferenceService
from .share import ShareService
from .user import UserService
from .workspace import WorkspaceService


__all__ = [
'BillingService',
Expand All @@ -23,5 +25,6 @@
'ProjectService',
'ReferenceService',
'ShareService',
'UserService'
'UserService',
'WorkspaceService',
]
75 changes: 75 additions & 0 deletions cirro/services/workspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from cirro_api_client.v1.api.workspaces import get_workspaces, get_workspace, get_workspace_environments, \
create_workspace, delete_workspace, start_workspace, stop_workspace
from cirro_api_client.v1.models import Workspace, WorkspaceInput, CreateResponse, WorkspaceEnvironment

from cirro.services.base import BaseService


class WorkspaceService(BaseService):
"""
Service for interacting with the Workspace endpoints
"""
def list_environments(self) -> list[WorkspaceEnvironment]:
"""
List available workspace environments
"""
return get_workspace_environments.sync(client=self._api_client)

def list(self, project_id: str) -> list[Workspace]:
"""
Retrieves a list of workspaces that the user has access to

Args:
project_id (str): ID of the Project
"""
return get_workspaces.sync(project_id, client=self._api_client)

def get(self, project_id: str, workspace_id: str) -> Workspace:
"""
Get details of a workspace

Args:
project_id (str): ID of the Project
workspace_id (str): ID of the Workspace
"""
return get_workspace.sync(project_id=project_id, workspace_id=workspace_id, client=self._api_client)

def create(self, project_id: str, workspace: WorkspaceInput) -> CreateResponse:
"""
Create a new workspace in the given project

Args:
project_id (str): ID of the Project
workspace (WorkspaceInput): Workspace object to create
"""
return create_workspace.sync(project_id=project_id, client=self._api_client, body=workspace)

def delete(self, project_id: str, workspace_id: str) -> None:
"""
Delete a workspace in the given project

Args:
project_id (str): ID of the Project
workspace_id (str): ID of the Workspace
"""
delete_workspace.sync_detailed(project_id=project_id, workspace_id=workspace_id, client=self._api_client)

def start(self, project_id: str, workspace_id: str) -> None:
"""
Start a workspace environment

Args:
project_id (str): ID of the Project
workspace_id (str): ID of the Workspace
"""
start_workspace.sync_detailed(project_id=project_id, workspace_id=workspace_id, client=self._api_client)

def stop(self, project_id: str, workspace_id: str) -> None:
"""
Stop a workspace environment

Args:
project_id (str): ID of the Project
workspace_id (str): ID of the Workspace
"""
stop_workspace.sync_detailed(project_id=project_id, workspace_id=workspace_id, client=self._api_client)
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packages = [{include = "cirro"}]
[tool.poetry.dependencies]
python = ">3.9.1,<4.0"
attrs = ">=21.3.0"
cirro_api_client = "1.1.0"
cirro_api_client = "1.2.2"
click = "^8.1.3"
boto3 = "~=1.38"
questionary = "^2.0.1"
Expand Down
Loading