diff --git a/Changelog b/Changelog new file mode 100644 index 0000000..2a49cda --- /dev/null +++ b/Changelog @@ -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 diff --git a/celigo/core.py b/celigo/core.py index e4c55e5..9309994 100644 --- a/celigo/core.py +++ b/celigo/core.py @@ -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. diff --git a/tests.py b/tests.py index 6dc9a2c..3eafdff 100644 --- a/tests.py +++ b/tests.py @@ -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)