Skip to content

Commit 145eca8

Browse files
caberoscaberos
authored andcommitted
New command: slcli order quote-delete
1 parent 298cb14 commit 145eca8

File tree

7 files changed

+45
-0
lines changed

7 files changed

+45
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Delete the quote of an order"""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
from SoftLayer.CLI.command import SLCommand as SLCommand
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
from SoftLayer.managers import ordering
9+
from SoftLayer.utils import lookup
10+
11+
12+
@click.command(cls=SLCommand)
13+
@click.argument('identifier')
14+
@environment.pass_env
15+
def cli(env, identifier):
16+
"""View a quote"""
17+
18+
manager = ordering.OrderingManager(env.client)
19+
result = manager.delete_quote(identifier)
20+
21+
if result:
22+
env.fout("Quote id: {} was deleted.".format(identifier))

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
('order:place-quote', 'SoftLayer.CLI.order.place_quote:cli'),
276276
('order:quote-list', 'SoftLayer.CLI.order.quote_list:cli'),
277277
('order:quote-detail', 'SoftLayer.CLI.order.quote_detail:cli'),
278+
('order:quote-delete', 'SoftLayer.CLI.order.quote_delete:cli'),
278279
('order:quote-save', 'SoftLayer.CLI.order.quote_save:cli'),
279280
('order:quote', 'SoftLayer.CLI.order.quote:cli'),
280281
('order:lookup', 'SoftLayer.CLI.order.lookup:cli'),

SoftLayer/fixtures/SoftLayer_Billing_Order_Quote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@
104104
}
105105

106106
saveQuote = getObject
107+
deleteQuote = getObject

SoftLayer/managers/ordering.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,11 @@ def get_regions(self, package_id, location=None):
737737
if location:
738738
_filter = {"regions": {"location": {"location": {"name": {"operation": location}}}}}
739739
return self.client.call('SoftLayer_Product_Package', 'getRegions', id=package_id, filter=_filter)
740+
741+
def delete_quote(self, quote_id):
742+
"""Delete the quote of an order.
743+
744+
:param quote_id: ID number of target quote
745+
"""
746+
747+
return self.client['SoftLayer_Billing_Order_Quote'].deleteQuote(id=quote_id)

docs/cli/ordering.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Quotes
139139
:prog: order place-quote
140140
:show-nested:
141141

142+
.. click:: SoftLayer.CLI.order.quote_delete:cli
143+
:prog: order place-delete
144+
:show-nested:
145+
142146
Lookup
143147
======
144148
.. click:: SoftLayer.CLI.order.lookup:cli

tests/CLI/modules/order_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ def test_order_lookup(self):
442442
self.assertIn('Ordered By', result.output)
443443
self.assertIn('Initial Invoice', result.output)
444444

445+
def test_quote_delete(self):
446+
result = self.run_command(['order', 'quote-delete', '12345'])
447+
self.assert_no_fail(result)
448+
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'deleteQuote', identifier='12345')
449+
445450

446451
def _get_all_packages():
447452
package_type = {'keyName': 'BARE_METAL_CPU'}

tests/managers/ordering_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,7 @@ def test_get_items(self):
901901
def test_get_regions(self):
902902
self.ordering.get_regions(123)
903903
self.assert_called_with('SoftLayer_Product_Package', 'getRegions')
904+
905+
def test_delete_quote(self):
906+
self.ordering.delete_quote(123)
907+
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'deleteQuote')

0 commit comments

Comments
 (0)