

def set_firewall_apikey(session_key, apikey):
    'Given a splunk session_key sets the firewall API key in the Splunk password store'
    try:
        delete_firewall_apikey(session_key)
        apikey = {
            'name': 'firewall_api_key',
            'password': apikey,
        }
        apikey_entity = entity.Entity(['admin', 'passwords'], 'firewall_api_key', namespace=APPNAME, owner='nobody', contents=apikey)
        entity.setEntity(apikey_entity, sessionKey=session_key, strictCreate=False)
    except Exception as e:
        stack = traceback.format_exc()
        logger.warn(stack)
        logger.warn('entity exception')
        exit_with_error(('Could not set %s firewall apikey from splunk. Error: %s' % (APPNAME, str(e))))

dataset/ETHPy150Open PaloAltoNetworks/SplunkforPaloAltoNetworks/bin/lib/common.py set_firewall_apikey/original