def _message_pb_to_mapping(message_pb): """Helper for :meth:`pull`, et aliae Performs "impedance matching" between the protobuf attrs and the keys expected in the JSON API. """ return { 'messageId': message_pb.message_id, 'data': message_pb.data, 'attributes': message_pb.attributes, 'publishTime': _pb_timestamp_to_rfc3339(message_pb.publish_time), }
def _log_entry_pb_to_mapping(entry_pb): """Helper for :meth:`list_entries`, et aliae Performs "impedance matching" between the protobuf attrs and the keys expected in the JSON API. """ mapping = { 'logName': entry_pb.log_name, 'resource': _mon_resource_pb_to_mapping(entry_pb.resource), 'severity': LogSeverity.Name(entry_pb.severity), 'insertId': entry_pb.insert_id, 'timestamp': _pb_timestamp_to_rfc3339(entry_pb.timestamp), 'labels': entry_pb.labels, } if entry_pb.HasField('text_payload'): mapping['textPayload'] = entry_pb.text_payload if entry_pb.HasField('json_payload'): mapping['jsonPayload'] = _struct_pb_to_mapping(entry_pb.json_payload) if entry_pb.HasField('proto_payload'): mapping['protoPayload'] = entry_pb.proto_payload if entry_pb.http_request: request = entry_pb.http_request mapping['httpRequest'] = { 'requestMethod': request.request_method, 'requestUrl': request.request_url, 'status': request.status, 'referer': request.referer, 'userAgent': request.user_agent, 'cacheHit': request.cache_hit, 'requestSize': request.request_size, 'responseSize': request.response_size, 'remoteIp': request.remote_ip, } if entry_pb.operation: operation = entry_pb.operation mapping['operation'] = { 'producer': operation.producer, 'id': operation.id, 'first': operation.first, 'last': operation.last, } return mapping
def _call_fut(self, timestamp): from google.cloud._helpers import _pb_timestamp_to_rfc3339 return _pb_timestamp_to_rfc3339(timestamp)