Refactor, and update changelog
This commit is contained in:
parent
ac188f42f5
commit
a5f7566361
6
Changelog
Normal file
6
Changelog
Normal 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
|
@ -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.
|
||||
|
4
tests.py
4
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)
|
||||
|
Loading…
Reference in New Issue
Block a user