Last active
April 19, 2019 02:54
-
-
Save pmeyerson/0ae38d53d0bb9893dfa41a45049af915 to your computer and use it in GitHub Desktop.
rest_ta event handlers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomHandler: | |
# response from API is in format {"result": [{}, {}, {}]} at least for cmdb tables | |
# credit http://www.georgestarcher.com/splunk-null-thinking/ | |
def __init__(self,**args): | |
pass | |
def __call__(self, response_object, raw_response_output,response_type,req_args,endpoint): | |
#if response_type == "json": | |
output = json.loads(raw_response_output) | |
for entry in output['result']: | |
clean_entry = {k: v for k, v in entry.items() if v} | |
print_xml_stream(json.dumps(clean_entry)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment