Skip to content

Commit 475a3f9

Browse files
Merge pull request #1892 from caberos/issue1889
new feature on account hook-delete
2 parents 77c5057 + 8b0e140 commit 475a3f9

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Delete a provisioning script"""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
7+
from SoftLayer.CLI.command import SLCommand as SLCommand
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.managers.account import AccountManager as AccountManager
10+
11+
12+
@click.command(cls=SLCommand)
13+
@click.argument('identifier')
14+
@environment.pass_env
15+
def cli(env, identifier):
16+
"""Delete a provisioning script"""
17+
18+
manager = AccountManager(env.client)
19+
20+
try:
21+
manager.delete_provisioning(identifier)
22+
click.secho("%s deleted successfully" % identifier, fg='green')
23+
except SoftLayer.SoftLayerAPIError as ex:
24+
click.secho("Failed to delete %s\n%s" % (identifier, ex), fg='red')

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
('account:bandwidth-pools', 'SoftLayer.CLI.account.bandwidth_pools:cli'),
2727
('account:hooks', 'SoftLayer.CLI.account.hooks:cli'),
2828
('account:hook-create', 'SoftLayer.CLI.account.hook_create:cli'),
29+
('account:hook-delete', 'SoftLayer.CLI.account.hook_delete:cli'),
2930

3031
('virtual', 'SoftLayer.CLI.virt'),
3132
('virtual:bandwidth', 'SoftLayer.CLI.virt.bandwidth:cli'),

SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
'uri': 'http://slclitest.com',
66
'hookType': {}
77
}
8+
deleteObject = True

SoftLayer/managers/account.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,12 @@ def create_provisioning(self, name, uri):
407407
'uri': uri
408408
}
409409
return self.client.call('SoftLayer_Provisioning_Hook', 'createObject', template)
410+
411+
def delete_provisioning(self, identifier):
412+
"""Delete a provisioning script
413+
414+
param: identifier provisioning script identifier
415+
416+
Returns: boolean
417+
"""
418+
return self.client.call("SoftLayer_Provisioning_Hook", "deleteObject", id=identifier)

docs/cli/account.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ Account Commands
5959
.. click:: SoftLayer.CLI.account.hook_create:cli
6060
:prog: account hook-create
6161
:show-nested:
62+
63+
.. click:: SoftLayer.CLI.account.hook_delete:cli
64+
:prog: account hook-delete
65+
:show-nested:

tests/CLI/modules/account_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,8 @@ def test_created_provisioning_hook(self):
169169
result = self.run_command(['account', 'hook-create', '--name', 'testslcli', '--uri', 'http://slclitest.com'])
170170
self.assert_no_fail(result)
171171
self.assert_called_with('SoftLayer_Provisioning_Hook', 'createObject')
172+
173+
def test_delete_provisioning_hook(self):
174+
result = self.run_command(['account', 'hook-delete', '123456'])
175+
self.assert_no_fail(result)
176+
self.assert_called_with('SoftLayer_Provisioning_Hook', 'deleteObject')

tests/managers/account_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,7 @@ def test_get_provisioning_scripts(self):
184184
def test_create_provisioning_scripts(self):
185185
self.manager.create_provisioning('testslcli', 'http://slclitest.com')
186186
self.assert_called_with('SoftLayer_Provisioning_Hook', 'createObject')
187+
188+
def test_delete_provisioning_scripts(self):
189+
self.manager.delete_provisioning(123456)
190+
self.assert_called_with("SoftLayer_Provisioning_Hook", "deleteObject")

0 commit comments

Comments
 (0)