Skip to content

Instantly share code, notes, and snippets.

@pmeyerson
Last active April 19, 2019 02:54
Show Gist options
  • Save pmeyerson/0ae38d53d0bb9893dfa41a45049af915 to your computer and use it in GitHub Desktop.
Save pmeyerson/0ae38d53d0bb9893dfa41a45049af915 to your computer and use it in GitHub Desktop.
rest_ta event handlers
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