refactor the JSON key insertion

This commit is contained in:
mischa 2022-06-22 14:14:30 +02:00
parent c05ea2ef78
commit 36c2ebf2a4
1 changed files with 12 additions and 28 deletions

40
push.py
View File

@ -262,41 +262,25 @@ for connector in config.sections():
logging.debug(f'API credentialid: {credential_types[connector_type]}')
body['credentialId'] = credential_types[connector_type]
if 'cxp' in body:
logging.debug(f"JSON cxp: {body['cxp']}")
if 'cxp' in section:
logging.debug(f"CONFIG cxp: {section['cxp']}")
body['cxp'] = section['cxp']
for key in ['cxp', 'size', 'group']:
if key in body:
logging.debug(f"JSON {key}: {body[key]}")
if key in section:
logging.debug(f"CONFIG {key}: {section[key]}")
body[key] = section[key]
if 'size' in body:
logging.debug(f"JSON size: {body['size']}")
if 'size' in section:
logging.debug(f"CONFIG size: {section['size']}")
body['size'] = section['size']
if 'segments' in body:
logging.debug(f"JSON segments: {body['segments'][0]}")
if 'segments' in section:
logging.debug(f"CONFIG segments: {section['segments']}")
body['segments'][0] = section['segments']
if 'group' in body:
logging.debug(f"JSON group: {body['group']}")
if 'group' in section:
logging.debug(f"CONFIG group: {section['group']}")
body['group'] = section['group']
for key in ['segments', 'billingTags']:
if key in body:
logging.debug(f"JSON key: {body[key][0]}")
if key in section:
logging.debug(f"CONFIG key: {section[key]}")
body[key][0] = section[key]
if 'group' not in body:
if 'group' in section:
logging.debug(f"CONFIG group: {section['group']}")
body['group'] = section['group']
if 'billingTags' in body:
logging.debug(f"JSON billingtags: {body['billingTags'][0]}")
if 'billingtags' in section:
logging.debug(f"CONFIG billingtags: {section['billingtags']}")
body['billingTags'][0] = section['billingtags']
if 'services' in connector_name and 'credentialId' in body and 'service_credentialid' in locals():
logging.debug(f'API credentialid: {service_credentialid}')
body['credentialId'] = service_credentialid