Skip to content

Commit f46990f

Browse files
committed
#1450 add slcli order quote-save feature
1 parent d7b2d59 commit f46990f

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

SoftLayer/CLI/order/quote_save.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Save a quote"""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
from SoftLayer.CLI import environment
6+
from SoftLayer.CLI import formatting
7+
from SoftLayer.managers import ordering
8+
from SoftLayer.utils import clean_time
9+
10+
11+
@click.command()
12+
@click.argument('quote')
13+
@environment.pass_env
14+
def cli(env, quote):
15+
"""Save a quote"""
16+
17+
manager = ordering.OrderingManager(env.client)
18+
result = manager.save_quote(quote)
19+
20+
table = formatting.Table([
21+
'Id', 'Name', 'Created', 'Modified', 'Status'
22+
])
23+
table.align['Name'] = 'l'
24+
25+
table.add_row([
26+
result.get('id'),
27+
result.get('name'),
28+
clean_time(result.get('createDate')),
29+
clean_time(result.get('modifyDate')),
30+
result.get('status'),
31+
])
32+
33+
env.fout(table)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
('order:place-quote', 'SoftLayer.CLI.order.place_quote:cli'),
228228
('order:quote-list', 'SoftLayer.CLI.order.quote_list:cli'),
229229
('order:quote-detail', 'SoftLayer.CLI.order.quote_detail:cli'),
230+
('order:quote-save', 'SoftLayer.CLI.order.quote_save:cli'),
230231
('order:quote', 'SoftLayer.CLI.order.quote:cli'),
231232
('order:lookup', 'SoftLayer.CLI.order.lookup:cli'),
232233

SoftLayer/fixtures/SoftLayer_Billing_Order_Quote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@
102102
]
103103
}
104104
}
105+
106+
saveQuote = getObject

SoftLayer/managers/ordering.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ def get_quote_details(self, quote_id):
169169
quote = self.client['Billing_Order_Quote'].getObject(id=quote_id, mask=mask)
170170
return quote
171171

172+
def save_quote(self, quote_id):
173+
"""Save a quote.
174+
175+
:param quote_id: ID number of target quote
176+
"""
177+
return self.client['Billing_Order_Quote'].saveQuote(id=quote_id)
178+
172179
def get_order_container(self, quote_id):
173180
"""Generate an order container from a quote object.
174181

0 commit comments

Comments
 (0)