def generate_func(self, as_global=False):
keywords = []<EOL>params_def = []<EOL>params_doc = "<STR_LIT>"<EOL>original_names = {}<EOL>params = dict(<EOL>(param['<STR_LIT:name>'], param)<EOL>for param in self.params<EOL>)<EOL>for param in self.url_params:<EOL><INDENT>if param not in params:<EOL><INDENT>param = {<EOL>'<STR_LIT:name>': param,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT:description>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>params[param['<STR_LIT:name>']] = param<EOL><DEDENT>else:<EOL><INDENT>params[param]['<STR_LIT>'] = True<EOL><DEDENT><DEDENT>req_params = []<EOL>nonreq_params = []<EOL>for param in six.itervalues(params):<EOL><INDENT>if param['<STR_LIT>']:<EOL><INDENT>req_params.append(param)<EOL><DEDENT>else:<EOL><INDENT>nonreq_params.append(param)<EOL><DEDENT><DEDENT>for param in req_params + nonreq_params:<EOL><INDENT>params_doc += self.create_param_doc(param) + "<STR_LIT:\n>"<EOL>local_name = param['<STR_LIT:name>']<EOL>if param['<STR_LIT:name>'] == '<STR_LIT>':<EOL><INDENT>local_name = '<STR_LIT>'<EOL><DEDENT>original_names[local_name] = param['<STR_LIT:name>']<EOL>keywords.append(local_name)<EOL>if param['<STR_LIT>']:<EOL><INDENT>params_def.append("<STR_LIT:%s>" % local_name)<EOL><DEDENT>else:<EOL><INDENT>params_def.append("<STR_LIT>" % local_name)<EOL><DEDENT><DEDENT>func_head = '<STR_LIT>'.format(<EOL>as_global and self.get_global_method_name() or self.name,<EOL>'<STR_LIT:U+002CU+0020>'.join(params_def)<EOL>)<EOL>code_body = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>code_body = code_body.format(<EOL>http_method=self.http_method.lower(),<EOL>url=self.url,<EOL>url_params=self.url_params,<EOL>keywords=keywords,<EOL>original_names=original_names,<EOL>)<EOL>code = [<EOL>func_head,<EOL>'<STR_LIT>',<EOL>self.short_desc,<EOL>'<STR_LIT>',<EOL>params_doc,<EOL>'<STR_LIT>',<EOL>code_body,<EOL>]<EOL>code = '<STR_LIT:\n>'.join(code)<EOL>six.exec_(code)<EOL>function = locals()[self.name]<EOL>setattr(function, '<STR_LIT>', self)<EOL>return function<EOL>
Generate function for specific method and using specific api

:param as_global: if set, will use the global function name, instead of
    the class method (usually {resource}_{class_method}) when defining
    the function