Skip to content

Commit 2bb1d33

Browse files
caberoscaberos
authored andcommitted
new command on autoscale delete
1 parent 1220c26 commit 2bb1d33

File tree

7 files changed

+53
-1
lines changed

7 files changed

+53
-1
lines changed

SoftLayer/CLI/autoscale/delete.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Delete autoscale."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.managers.autoscale import AutoScaleManager
8+
9+
10+
@click.command()
11+
@click.argument('identifier')
12+
@environment.pass_env
13+
def cli(env, identifier):
14+
"""Sets a user's status to CANCEL_PENDING, which will immediately disable the account,
15+
16+
and will eventually be fully removed from the account by an automated internal process.
17+
18+
Example: slcli user delete userId
19+
20+
"""
21+
22+
autoscale = AutoScaleManager(env.client)
23+
result = autoscale.delete(identifier)
24+
25+
if result:
26+
click.secho("%s deleted successfully" % identifier, fg='green')
27+
else:
28+
click.secho("Failed to delete %s" % identifier, fg='red')

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@
377377
('autoscale:scale', 'SoftLayer.CLI.autoscale.scale:cli'),
378378
('autoscale:logs', 'SoftLayer.CLI.autoscale.logs:cli'),
379379
('autoscale:tag', 'SoftLayer.CLI.autoscale.tag:cli'),
380-
('autoscale:edit', 'SoftLayer.CLI.autoscale.edit:cli')
380+
('autoscale:edit', 'SoftLayer.CLI.autoscale.edit:cli'),
381+
('autoscale:delete', 'SoftLayer.CLI.autoscale.delete:cli'),
381382
]
382383

383384
ALL_ALIASES = {

SoftLayer/fixtures/SoftLayer_Scale_Group.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,4 @@
455455
]
456456

457457
editObject = True
458+
forceDeleteObject = True

SoftLayer/managers/autoscale.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,13 @@ def edit(self, identifier, template):
116116
.. _SoftLayer_Scale_Group: https://sldn.softlayer.com/reference/datatypes/SoftLayer_Scale_Group/
117117
"""
118118
return self.client.call('SoftLayer_Scale_Group', 'editObject', template, id=identifier)
119+
120+
def delete(self, identifier):
121+
"""Calls `SoftLayer_Scale_Group::forceDeleteObject()`_
122+
123+
:param identifier: SoftLayer_Scale_Group id
124+
125+
.. _SoftLayer_Scale_Group::forceDeleteObject():
126+
https://sldn.softlayer.com/reference/services/SoftLayer_Scale_Group/forceDeleteObject/
127+
"""
128+
return self.client.call('SoftLayer_Scale_Group', 'forceDeleteObject', id=identifier)

docs/cli/autoscale.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ For making changes to the triggers or the autoscale group itself, see the `Autos
3434
:prog: autoscale edit
3535
:show-nested:
3636

37+
.. click:: SoftLayer.CLI.autoscale.delete:cli
38+
:prog: autoscale delte
39+
:show-nested:
40+
3741

3842
.. _Autoscale Portal: https://cloud.ibm.com/classic/autoscale

tests/CLI/modules/autoscale_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ def test_autoscale_edit_userfile(self, manager):
8989
result = self.run_command(['autoscale', 'edit', '12345', '--userfile', userfile.name])
9090
self.assert_no_fail(result)
9191
manager.assert_called_with('12345', template)
92+
93+
def test_autoscale_delete(self):
94+
result = self.run_command(['autoscale', 'delete', '12345'])
95+
self.assert_no_fail(result)

tests/managers/autoscale_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,7 @@ def test_edit_object(self):
123123
'editObject',
124124
args=(template,),
125125
identifier=12345)
126+
127+
def test_delete_object(self):
128+
self.autoscale.delete(12345)
129+
self.assert_called_with('SoftLayer_Scale_Group', 'forceDeleteObject')

0 commit comments

Comments
 (0)