I am trying to create a list of python class objects.
Basically I am expecting for list which should be as follows:
[<Report {u'invoice_id': u'demo-1-2016-dummy', u'tenant_id': u'27724b57e3b744f89cbf1336da062b43'}>, <Report {u'invoice_id': u'demo-2-2016', u'tenant_id': u'27724b57e3b744f89cbf1336da062b43'}>, <Report {u'invoice_id': u'admin-2-2016', u'tenant_id': u'6cd02afa3f0f403489153c41e98d07bc'}>]
I have tried the following code for the same.
from cloudkittyclient.common import base
import json
class ReportResult(base.Resource):
key = 'report'
def __repr__(self):
return "<Report %s>" % self._info
class ReportManager(base.CrudManager):
base_url = '/v1/report'
resource_class = ReportResult
key = "report"
collection_key = "reports"
# List the invoices, can accept all-tenants arg
def list_invoice(self, all_tenants=None):
url = self.base_url + "/list_invoice"
filters = list()
if all_tenants:
filters.append("all_tenants=%s" % all_tenants)
if filters:
url += "?%s" % ('&'.join(filters))
return self.client.get(url).json()
So here my requirement is that "return self.client.get(url).json()" should return the above mentioned List which consists of class objects.
But it is returning the results as follows:
[{u'invoice_id': u'demo-1-2016-dummy', u'tenant_id': u'27724b57e3b744f89cbf1336da062b43'}, {u'invoice_id': u'demo-2-2016', u'tenant_id': u'27724b57e3b744f89cbf1336da062b43'}, {u'invoice_id': u'admin-2-2016', u'tenant_id': u'6cd02afa3f0f403489153c41e98d07bc'}]
I know the fact that I am missing something right here.
As I am novice user in python I am unable to find that where I am going wrong.
Can anyone be able to assist me with getting the result I expected.