def _get_remote_defs(self):
res = self.session.get(<EOL>'<STR_LIT>' % (self.url, '<STR_LIT>' % self.api_version),<EOL>timeout=self.get_timeout('<STR_LIT:GET>'),<EOL>**self._req_params<EOL>)<EOL>if res.ok:<EOL><INDENT>data = json.loads(res.text)<EOL>defs_path = os.path.join(self.cache_dir, '<STR_LIT>')<EOL>if not os.path.exists(defs_path):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(defs_path)<EOL><DEDENT>except Exception:<EOL><INDENT>logger.debug('<STR_LIT>', defs_path)<EOL>return data<EOL><DEDENT><DEDENT>cache_fn = '<STR_LIT>' % (<EOL>defs_path, self.version,<EOL>self.api_version,<EOL>)<EOL>try:<EOL><INDENT>with open(cache_fn, '<STR_LIT:w>') as cache_fd:<EOL><INDENT>cache_fd.write(json.dumps(data, indent=<NUM_LIT:4>, default=str))<EOL>logger.debug('<STR_LIT>', cache_fn)<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>logger.debug('<STR_LIT>', cache_fn)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if res.status_code == <NUM_LIT>:<EOL><INDENT>logger.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>res.url,<EOL>)<EOL><DEDENT>raise ForemanVersionException(<EOL>"<STR_LIT>"<EOL>% (self.url, '<STR_LIT>' % self.api_version)<EOL>)<EOL><DEDENT>return data<EOL>
Retrieves the json definitions from remote foreman instance.