Refactor, and update changelog

This commit is contained in:
Tyrel Souza 2016-05-25 13:28:10 -04:00
parent ac188f42f5
commit a5f7566361
No known key found for this signature in database
GPG Key ID: 2EECB5087209E6A5
3 changed files with 23 additions and 11 deletions

6
Changelog Normal file
View File

@ -0,0 +1,6 @@
# Change Log
## [Unreleased]
### Added
- Ability to download all imports/flows from Celigo
- Storing each flow in a subdirectory of an integration

View File

@ -117,13 +117,7 @@ class BackupCeligo(object):
L.info("Restored backup to %s", self.base_url + path)
return response
def backup(self, auto=False):
"""
Get all the flow data from Celigo.
Then loop over each flow and cache it's Import data in an instance
varable.
Once this is cached, save the imports.
"""
def _get_integration_placeholders(self):
try:
integrations = self._celigo_api_get("integrations/")
except requests.exceptions.RequestException:
@ -135,6 +129,8 @@ class BackupCeligo(object):
'name': integration['name'],
'slug': slugify(integration['name']),
'flows': []}
def _get_flow_configurations(self):
try:
flows = self._celigo_api_get("flows/")
for flow in flows:
@ -144,10 +140,23 @@ class BackupCeligo(object):
raise
L.info("Got all imports, writing now")
def _save_each_flow(self, auto=False):
for integration_id, integration in self.imports_cache.items():
for flow in integration['flows']:
self.save_flow(integration_id, flow, auto)
def backup(self, auto=False):
"""
Get all the flow data from Celigo.
Then loop over each flow and cache it's Import data in an instance
varable.
Once this is cached, save the imports.
"""
self._get_integration_placeholders()
self._get_flow_configurations()
self._save_each_flow(auto)
def restore(self, auto=False):
"""
Get all the import files in the import direcotry,
@ -182,7 +191,6 @@ class BackupCeligo(object):
self.restore_to_celigo(action)
del self.imports_cache[action]
def cache_import_remote(self, flow):
"""
Stores the import in self.imports_cache before write.

View File

@ -30,9 +30,7 @@ class CeligoTest(unittest.TestCase):
"""
data_dir = "fakedir"
os.environ['CELIGO_API_KEY'] = ''
with self.assertRaisesRegexp(
Exception,
'Please pass in api_key.*'):
with self.assertRaisesRegexp(Exception, 'Please pass in api_key.*'):
celigo.BackupCeligo(data_dir)
os.environ['CELIGO_API_KEY'] = self.FAKE_API_KEY
bc = celigo.BackupCeligo(data_dir)