def _entry_from_resource(self, resource, loggers): """Detect correct entry type from resource and instantiate. :type resource: dict :param resource: one entry resource from API response :type loggers: dict or None :param loggers: A mapping of logger fullnames -> loggers. If not passed, the entry will have a newly-created logger. :rtype; One of: :class:`gcloud.logging.entries.TextEntry`, :class:`gcloud.logging.entries.StructEntry`, :class:`gcloud.logging.entries.ProtobufEntry` :returns: the entry instance, constructed via the resource """ if 'textPayload' in resource: return TextEntry.from_api_repr(resource, self, loggers) elif 'jsonPayload' in resource: return StructEntry.from_api_repr(resource, self, loggers) elif 'protoPayload' in resource: return ProtobufEntry.from_api_repr(resource, self, loggers) raise ValueError('Cannot parse log entry resource')