I am trying to create a setup page which lets user add multiple accounts. ( The number of accounts to be added is unknown so I decided to use the Global Account options for this)
I want to get the value of the 'Account Name' column in the python script generated by add on builder called 'modalert_appname.py'. By default, the script comes with a helper function called helper.get_user_credential("<account_name>"). The problem is that this function takes in the parameter 'username' and I want to use a function which takes in the 'account_id' as its argument.
Technically, this would be possible by using the method helper.get_user_credential_by_id(account_id) as mentioned in the python helper function documentation. But when i try to use this function, it gives me the error saying that 'object has no attribute' (meaning that it is not defined for this helper function).
Any ideas about how to overcome this problem?
Kindly post the error logs to see if we can understand more about the issue.
I know this is an old dead question ... but, the issue still exists!
The problem is that in the "alert_actions_base.py" wrapper file that is put in TA/bin/ta_name/alert_actions_base.py has get_user_credential defined to wrap get_credential_by_username and does not provide a wrapper for by_account_id.
Adding the definition below for get_user_credential_by_account_id from the ./aob_py3/splunktaucclib/alert_actions_base.py into the TA/bin/ta_name/alert_actions_base.py solves the issue an allows an alert action to request credentials by account id.
def get_user_credential_by_account_id(self, account_id):
"""
if the account_id exists, return
{
"username": username,
"password": credential
}
"""
return self.setup_util.get_credential_by_id(account_id)
Would love to see this change integrated into the next release of the add on builder!