All Apps and Add-ons

Why is Python helper function not working for Create Alert Action python script?

goodoldie
Observer

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)

goodoldie_0-1647002333059.png

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?

Labels (1)
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Kindly post the error logs to see if we can understand more about the issue.

0 Karma

Steve_Baker_GRE
Engager

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!

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...