Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom handler for the REST API Modular Input to page over results from a call to Splunkbase REST API to list all Apps
class SplunkbaseHandler:
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)
offset = output["offset"]
total = output["total"]
for result in output["results"]:
print_xml_stream(json.dumps(result))
offset+=1
while offset < total:
req_args["params"]["offset"] = offset
next_response = requests.get(endpoint,**req_args)
output = json.loads(next_response.text)
offset = output["offset"]
total = output["total"]
for result in output["results"]:
print_xml_stream(json.dumps(result))
offset+=1
req_args["params"]["offset"] = 0
else:
print_xml_stream(raw_response_output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.