diff --git a/.gitignore b/.gitignore index 00f981f8..db9daae2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,8 @@ pip-log.txt .coverage .tox nosetests.xml +coverage.xml +flake8.log # pyenv .python-version diff --git a/barbicanclient/base.py b/barbicanclient/base.py index 0736e5f9..5e63f882 100644 --- a/barbicanclient/base.py +++ b/barbicanclient/base.py @@ -26,3 +26,13 @@ class BaseEntityManager(object): for k in dictionary.keys(): if dictionary[k] is None: dictionary.pop(k) + + def total(self): + """ + Returns the total number of entities stored in Barbican. + """ + href = '{0}/{1}'.format(self.api.base_url, self.entity) + params = {'limit': 0, 'offset': 0} + resp = self.api.get(href, params) + + return resp['total'] diff --git a/barbicanclient/test/test_client.py b/barbicanclient/test/test_client.py index 2b42b027..89052643 100644 --- a/barbicanclient/test/test_client.py +++ b/barbicanclient/test/test_client.py @@ -46,28 +46,6 @@ class FakeResp(object): return self.content -class SecretData(object): - def __init__(self): - self.name = 'Self destruction sequence' - self.payload = 'the magic words are squeamish ossifrage' - self.payload_content_type = 'text/plain' - self.content = 'text/plain' - self.algorithm = 'AES' - self.created = str(timeutils.utcnow()) - - self.secret_dict = {'name': self.name, - 'status': 'ACTIVE', - 'algorithm': self.algorithm, - 'created': self.created} - - def get_dict(self, secret_ref, content_types_dict=None): - secret_dict = self.secret_dict - secret_dict['secret_ref'] = secret_ref - if content_types_dict: - secret_dict['content_types'] = content_types_dict - return secret_dict - - class WhenTestingClientInit(unittest.TestCase): def setUp(self): self.auth_endpoint = 'https://localhost:5000/v2.0/'