Integration
Sequencing.com has already everything to simplify integration of AppChains API into your Python based project.
In order to integrate it, get code from our GitHub repository and paste it into your project. Code is Python 2.7 compatible.
Python module API
Method | Purpose | Arguments | Description |
---|---|---|---|
def __init__(self, token=None, hostname=None) | Constructor |
|
Use both arguments for creating chains instance in case reporting API is required |
def getReport(self, remote_method_name, app_method_name, source_id) | Reporting API |
|
|
def getReportBatch(self, remote_method_name, app_chain_param) | Batch reporting API |
|
Code snippet
Adding code to the project:
- Add AppChains.py into your source folder and import AppChains (from AppChains import AppChains) in your Python file.
For complete usage example, refer to our code in GitHub repository.
Single App Chain retrieval example
self.chains = AppChains('<your token>', 'api.sequencing.com')
chains_result = self.chains.getReport('StartApp', '<chain id>', '<file id>')
if chains_result.isSucceeded():
print('Request has succeeded')
else:
print('Request has failed')
for r in chains_result.getResults():
file_type = r.getValue().getType()
v = r.getValue()
if file_type == 'TEXT':
print('-> text result type {} = {}'.format(
r.getName(), v.getData()))
elif file_type == 'FILE':
print(' -> file result type {} = {}'.format(
r.getName(), v.getUrl()
))
v.saveTo('/tmp')
Batch App Chain retrieval example
class UsageExample(object):
token = '<your token goes here>'
url = 'api.sequencing.com'
def __init__(self):
self.chains = AppChains(self.token, self.url)
print(self.get_raw_report_test())
self.get_report_batch_test()
def get_report_batch_test(self):
chains_results = self.chains.getReportBatch(
'StartAppBatch', {'Chain85': '227680', 'Chain88': '227680'})
for chains_result in chains_results:
if chains_results[chains_result].isSucceeded():
print('Request has succeeded')
else:
print('Request has failed')
for r in chains_results[chains_result].getResults():
file_type = r.getValue().getType()
v = r.getValue()
if file_type == 'TEXT':
print('-> text result type {} = {}'.format(
r.getName(), v.getData()))
elif file_type == 'FILE':
print(' -> file result type {} = {}'.format(
r.getName(), v.getUrl()
))
v.saveTo('/tmp')
UsageExample()