|
| 1 | +#! /usr/bin/env python3 |
| 2 | + |
| 3 | +import os |
| 4 | +import sys |
| 5 | +from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException |
| 6 | + |
| 7 | +engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) |
| 8 | +add_response = bytearray() |
| 9 | +current_config = bytearray() |
| 10 | +current_config_id = bytearray() |
| 11 | +new_config = bytearray() |
| 12 | +new_config_id = bytearray() |
| 13 | + |
| 14 | +try: |
| 15 | + g2_config = G2Config() |
| 16 | + g2_config_mgr = G2ConfigMgr() |
| 17 | + |
| 18 | + g2_config.init('G2Config', engine_config_json, False) |
| 19 | + g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) |
| 20 | + |
| 21 | + g2_config_mgr.getDefaultConfigID(current_config_id) |
| 22 | + g2_config_mgr.getConfig(current_config_id, current_config) |
| 23 | + |
| 24 | + config_handle = g2_config.load(current_config) |
| 25 | + g2_config.addDataSource(config_handle, '{"DSRC_CODE": "CUSTOMERS"}', add_response) |
| 26 | + g2_config.addDataSource(config_handle, '{"DSRC_CODE": "WATCHLIST"}', add_response) |
| 27 | + g2_config.addDataSource(config_handle, '{"DSRC_CODE": "REFERENCE"}', add_response) |
| 28 | + g2_config.addDataSource(config_handle, '{"DSRC_CODE": "MYTEST"}', add_response) |
| 29 | + g2_config.save(config_handle, new_config) |
| 30 | + |
| 31 | + g2_config_mgr.addConfig(new_config, 'Test data sources added', new_config_id) |
| 32 | + g2_config_mgr.setDefaultConfigID(new_config_id) |
| 33 | + |
| 34 | + g2_config.destroy() |
| 35 | + g2_config_mgr.destroy() |
| 36 | + |
| 37 | +except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: |
| 38 | + print(ex) |
| 39 | + sys.exit(-1) |
| 40 | + |
| 41 | +print(f'Datasources added, new default config ID: {new_config_id.decode()}') |
0 commit comments