def _api_call(self, endpoint, model=None, method=None, data=None, filters=None):
if not self.token:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if not method:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if model:<EOL><INDENT>endpoint = endpoint.format(**vars(model))<EOL><DEDENT>url = '<STR_LIT>'.format(self.base_url, endpoint)<EOL>headers = {<EOL>'<STR_LIT>': "<STR_LIT>".format(self.token),<EOL>'<STR_LIT:Content-Type>': '<STR_LIT:application/json>',<EOL>'<STR_LIT>': self._user_agent,<EOL>}<EOL>if filters:<EOL><INDENT>headers['<STR_LIT>'] = json.dumps(filters)<EOL><DEDENT>body = None<EOL>if data is not None:<EOL><INDENT>body = json.dumps(data)<EOL><DEDENT>response = method(url, headers=headers, data=body)<EOL>warning = response.headers.get('<STR_LIT>', None)<EOL>if warning:<EOL><INDENT>logger.warning('<STR_LIT>'.format(warning))<EOL><DEDENT>if <NUM_LIT> < response.status_code < <NUM_LIT>:<EOL><INDENT>j = None<EOL>error_msg = '<STR_LIT>'.format(response.status_code)<EOL>try:<EOL><INDENT>j = response.json()<EOL>if '<STR_LIT>' in j.keys():<EOL><INDENT>for e in j['<STR_LIT>']:<EOL><INDENT>error_msg += '<STR_LIT>'.format(e['<STR_LIT>'])if '<STR_LIT>' in e.keys() else '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>raise ApiError(error_msg, status=response.status_code, json=j)<EOL><DEDENT>if response.status_code != <NUM_LIT>:<EOL><INDENT>j = response.json()<EOL><DEDENT>else:<EOL><INDENT>j = None <EOL><DEDENT>return j<EOL>
Makes a call to the linode api.  Data should only be given if the method is
POST or PUT, and should be a dictionary