def get_cache_index_key(resource):
if isinstance(resource, APIResource):<EOL><INDENT>attr, attr_value = list(resource.get_cache_index_keys().items())[<NUM_LIT:0>]<EOL>key = (type(resource), attr, attr_value)<EOL><DEDENT>else:<EOL><INDENT>key = tuple(resource)<EOL><DEDENT>if len(key) != <NUM_LIT:3>:<EOL><INDENT>raise TypeError('<STR_LIT>'.format(key))<EOL><DEDENT>if not issubclass(key[<NUM_LIT:0>], APIResource):<EOL><INDENT>raise TypeError('<STR_LIT>'.format(key[<NUM_LIT:0>]))<EOL><DEDENT>return key<EOL>
Return a usable cache lookup key for an already initialized resource

    Args:
        resource (APIResource|tuple): APIResource instance or 3-length tuple key returned from this function

    Raises:
        TypeError: If resource is not an APIResource instance or acceptable 3-length tuple cache key