Skip to content

Commit

Permalink
chore: bump @daytonaio/api-client to 0.13.0; add workspace method set…
Browse files Browse the repository at this point in the history
…AutostopInterval

Signed-off-by: MDzaja <[email protected]>
  • Loading branch information
MDzaja committed Feb 5, 2025
1 parent 7c63738 commit 9c18e26
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
"pydantic>=2.4.2,<3.0.0",
"python-dateutil>=2.8.2,<3.0.0",
"urllib3>=2.0.7,<3.0.0",
"daytona_api_client>=0.12.2,<1.0.0"
"daytona_api_client>=0.13.0,<1.0.0"
]
classifiers = [
"Development Status :: 3 - Alpha",
Expand Down
17 changes: 16 additions & 1 deletion packages/python/src/daytona_sdk/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,19 @@ def wait_for_workspace_stop(self) -> None:
time.sleep(0.1)
attempts += 1

raise Exception("Workspace {self.id} failed to become stopped within the timeout period")
raise Exception("Workspace {self.id} failed to become stopped within the timeout period")

def set_autostop_interval(self, interval: float | int) -> None:
"""Sets the auto-stop interval for the workspace.
Args:
interval: Number of minutes after which the workspace will automatically stop.
Set to 0 to disable auto-stop.
Raises:
ValueError: If minutes is negative
"""
if interval < 0:
raise ValueError("Auto-stop interval cannot be negative")

self.workspace_api.set_autostop_interval(self.id, interval)
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@babel/preset-typescript": "^7.22.0",
"@types/jest": "^29.5.0",
"@types/node": "^22.10.0",
"@daytonaio/api-client": "~0.12.2",
"@daytonaio/api-client": "~0.13.0",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"typescript": "^5.0.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/typescript/src/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,17 @@ export class Workspace {
: null
}
}

/**
* Sets the auto-stop interval for the workspace
* @param {number} interval - Number of minutes after which the workspace will automatically stop. Set to 0 to disable auto-stop.
* @throws {Error} If minutes is negative
*/
public async setAutostopInterval(interval: number): Promise<void> {
if (interval < 0) {
throw new Error("Auto-stop interval cannot be negative");
}

await this.workspaceApi.setAutostopInterval(this.id, interval)
}
}

0 comments on commit 9c18e26

Please sign in to comment.