def _api_action(url, req, data=None):
requisite_headers = {'<STR_LIT>': '<STR_LIT:application/json>',<EOL>'<STR_LIT:Content-Type>': '<STR_LIT:application/json>'}<EOL>auth = (user, token)<EOL>if req == "<STR_LIT:GET>":<EOL><INDENT>response = requests.get(url, headers=requisite_headers, auth=auth)<EOL><DEDENT>elif req == "<STR_LIT>":<EOL><INDENT>response = requests.put(url, headers=requisite_headers, auth=auth,<EOL>data=data)<EOL><DEDENT>elif req == "<STR_LIT:POST>":<EOL><INDENT>response = requests.post(url, headers=requisite_headers, auth=auth,<EOL>data=data)<EOL><DEDENT>elif req == "<STR_LIT>":<EOL><INDENT>response = requests.delete(url, headers=requisite_headers, auth=auth)<EOL><DEDENT>return response.status_code, response.text<EOL>
Take action based on what kind of request is needed.