Skip to content

Commit 2ef60b6

Browse files
authored
Merge pull request #32 from Stackmasters/implement-setups-destroy
feat: add destroy option in setups command
2 parents 9a1347e + 8ddd00a commit 2ef60b6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

cycleops/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ def deploy(self, setup_id: int) -> Optional[Dict[str, Any]]:
156156
jobs_client: JobClient = JobClient(cycleops_client)
157157
return jobs_client.create(description=description, type=type, setup=setup_id)
158158

159+
def destroy(self, setup_id: int) -> Optional[Dict[str, Any]]:
160+
description: str = f"Destroying setup: {setup_id}"
161+
type: str = "Destruction"
162+
163+
jobs_client = JobClient(cycleops_client)
164+
return jobs_client.create(description=description, type=type, setup=setup_id)
165+
159166

160167
class UnitClient(SubClient):
161168
"""

cycleops/setups.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,26 @@ def deploy(
214214
return
215215

216216

217+
@app.command()
218+
def destroy(
219+
setup_identifier: str = typer.Argument(
220+
..., help="The ID or name of the setup. Names take precedence."
221+
),
222+
) -> None:
223+
"""
224+
Deploy the setup with the specified given ID or name.
225+
"""
226+
227+
try:
228+
setup = get_setup(setup_identifier)
229+
setup_client.destroy(setup["id"])
230+
231+
display_success_message(f"Setup {setup['id']} has been queued for destruction")
232+
except Exception as error:
233+
display_error_message(error)
234+
raise typer.Abort()
235+
236+
217237
def get_setup(setup_identifier: str) -> Optional[Dict[str, Any]]:
218238
"""
219239
Retrieves a Setup with either a name or ID. Names take precedence.

0 commit comments

Comments
 (0)