def _lookup(self, fail_on_missing=False, fail_on_found=False, include_debug_header=True, **kwargs):
read_params = {}<EOL>for field_name in self.identity:<EOL><INDENT>if field_name in kwargs:<EOL><INDENT>read_params[field_name] = kwargs[field_name]<EOL><DEDENT><DEDENT>if '<STR_LIT:id>' in self.identity and len(self.identity) == <NUM_LIT:1>:<EOL><INDENT>return {}<EOL><DEDENT>if not read_params:<EOL><INDENT>raise exc.BadRequest('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>existing_data = self.get(include_debug_header=include_debug_header, **read_params)<EOL>if fail_on_found:<EOL><INDENT>raise exc.Found('<STR_LIT>' %<EOL>read_params)<EOL><DEDENT>return existing_data<EOL><DEDENT>except exc.NotFound:<EOL><INDENT>if fail_on_missing:<EOL><INDENT>raise exc.NotFound('<STR_LIT>' %<EOL>read_params)<EOL><DEDENT>return {}<EOL><DEDENT>
=====API DOCS=====
Attempt to perform a lookup that is expected to return a single result, and return the record.

This method is a wrapper around `get` that strips out non-unique keys, and is used internally by
`write` and `delete`.

:param fail_on_missing: Flag that raise exception if no resource is found.
:type fail_on_missing: bool
:param fail_on_found: Flag that raise exception if a resource is found.
:type fail_on_found: bool
:param include_debug_header: Flag determining whether to print debug messages when querying
                             Tower backend.
:type include_debug_header: bool
:param `**kwargs`: Keyword arguments list of available fields used for searching resource.
:returns: A JSON object containing details of the resource returned by Tower backend.
:rtype: dict

:raises tower_cli.exceptions.BadRequest: When no field are provided in kwargs.
:raises tower_cli.exceptions.Found: When a resource is found and fail_on_found flag is on.
:raises tower_cli.exceptions.NotFound: When no resource is found and fail_on_missing flag
                                       is on.
=====API DOCS=====