Add the missing "detailed" parameter
Now the /invoices and /quotations API support 'detailed' parameter to indicate if needs to return a detailed invoice or quotation. But the support is missed in client, this patch fixes it. Change-Id: I9069f0d5715c419e45c93ec89d5b979cda0b7baf
This commit is contained in:
parent
3e19ace698
commit
a7c836b9dd
@ -36,11 +36,13 @@ class InvoicesTest(utils.TestCase):
|
|||||||
self.client.invoices.list('2017-1-1', '2018-2-1',
|
self.client.invoices.list('2017-1-1', '2018-2-1',
|
||||||
'project_id')
|
'project_id')
|
||||||
mock_list.assert_called_with('/v2/invoices?start=2017-1-1'
|
mock_list.assert_called_with('/v2/invoices?start=2017-1-1'
|
||||||
'&end=2018-2-1&project_id=project_id',
|
'&end=2018-2-1&detailed=False&'
|
||||||
|
'project_id=project_id',
|
||||||
'invoices')
|
'invoices')
|
||||||
|
|
||||||
@mock.patch.object(base.Manager, '_list')
|
@mock.patch.object(base.Manager, '_list')
|
||||||
def test_list_without_project_id(self, mock_list):
|
def test_list_without_project_id(self, mock_list):
|
||||||
self.client.invoices.list('2017-1-1', '2018-2-1')
|
self.client.invoices.list('2017-1-1', '2018-2-1')
|
||||||
mock_list.assert_called_with('/v2/invoices?start=2017-1-1'
|
mock_list.assert_called_with('/v2/invoices?start=2017-1-1'
|
||||||
'&end=2018-2-1', 'invoices')
|
'&end=2018-2-1&detailed=False',
|
||||||
|
'invoices')
|
||||||
|
@ -34,10 +34,12 @@ class QuotationsTest(utils.TestCase):
|
|||||||
@mock.patch.object(base.Manager, '_list')
|
@mock.patch.object(base.Manager, '_list')
|
||||||
def test_list_with_project_id(self, mock_list):
|
def test_list_with_project_id(self, mock_list):
|
||||||
self.client.quotations.list('project_id')
|
self.client.quotations.list('project_id')
|
||||||
mock_list.assert_called_with('/v2/quotations?project_id=project_id',
|
mock_list.assert_called_with('/v2/quotations?detailed=False&'
|
||||||
|
'project_id=project_id',
|
||||||
'quotations')
|
'quotations')
|
||||||
|
|
||||||
@mock.patch.object(base.Manager, '_list')
|
@mock.patch.object(base.Manager, '_list')
|
||||||
def test_list_without_project_id(self, mock_list):
|
def test_list_without_project_id(self, mock_list):
|
||||||
self.client.quotations.list()
|
self.client.quotations.list()
|
||||||
mock_list.assert_called_with('/v2/quotations', 'quotations')
|
mock_list.assert_called_with('/v2/quotations?detailed=False',
|
||||||
|
'quotations')
|
||||||
|
@ -17,20 +17,23 @@ from distilclient import base
|
|||||||
|
|
||||||
class InvoiceManager(base.Manager):
|
class InvoiceManager(base.Manager):
|
||||||
|
|
||||||
def list(self, start, end, project_id=None):
|
def list(self, start, end, project_id=None, detailed=False):
|
||||||
"""Retrieve a list of invoices.
|
"""Retrieve a list of invoices.
|
||||||
|
|
||||||
:param start: Start date of the query
|
:param start: Start date of the query
|
||||||
:param end: End date of the query
|
:param end: End date of the query
|
||||||
:param project_id: Project ID, there there is no project id given,
|
:param project_id: Project ID, there there is no project id given,
|
||||||
Distil will use the project ID from token.
|
Distil will use the project ID from token.
|
||||||
|
:param detailed: Default value is False, indicate if inlucding detailed
|
||||||
|
usage info in the response.
|
||||||
:returns: A list of invoices.
|
:returns: A list of invoices.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = "/v2/invoices?start={0}&end={1}"
|
url = "/v2/invoices?start={0}&end={1}&detailed={2}"
|
||||||
if project_id:
|
if project_id:
|
||||||
url = url.format(start, end) + "&project_id=" + project_id
|
url = (url.format(start, end, detailed) +
|
||||||
|
"&project_id=" + project_id)
|
||||||
else:
|
else:
|
||||||
url = url.format(start, end)
|
url = url.format(start, end, detailed)
|
||||||
|
|
||||||
return self._list(url, "invoices")
|
return self._list(url, "invoices")
|
||||||
|
@ -17,15 +17,17 @@ from distilclient import base
|
|||||||
|
|
||||||
class QuotationManager(base.Manager):
|
class QuotationManager(base.Manager):
|
||||||
|
|
||||||
def list(self, project_id=None):
|
def list(self, project_id=None, detailed=False):
|
||||||
"""Retrieve a list of quotations.
|
"""Retrieve a list of quotations.
|
||||||
|
|
||||||
:param project_id: Project ID, there there is no project id given,
|
:param project_id: Project ID, there there is no project id given,
|
||||||
Distil will use the project ID from token.
|
Distil will use the project ID from token.
|
||||||
|
:param detailed: Default value is False, indicate if inlucding detailed
|
||||||
|
usage info in the response.
|
||||||
:returns: A list of quotations.
|
:returns: A list of quotations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = "/v2/quotations"
|
url = "/v2/quotations?detailed=" + str(detailed)
|
||||||
if project_id:
|
if project_id:
|
||||||
url = url + "?project_id=" + project_id
|
url = url + "&project_id=" + project_id
|
||||||
return self._list(url, "quotations")
|
return self._list(url, "quotations")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user