# automatically generated by the FlatBuffers compiler, do not modify

# namespace: log

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class MNodeSession(object):
    __slots__ = ["_tab"]

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = MNodeSession()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsMNodeSession(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

    # MNodeSession
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # When the his run started (Unix time in ns).
    # MNodeSession
    def Left(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # WAMP session ID of the CF node uplink management session to this CFC instance.
    # MNodeSession
    def Session(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # Management realm CFC backend run ID
    # MNodeSession
    def RunId(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # MNodeSession
    def RunIdAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # MNodeSession
    def RunIdLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # MNodeSession
    def RunIdIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # The CF node ID (which is dual-used as WAMP session authid).
    # MNodeSession
    def NodeId(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # MNodeSession
    def NodeIdAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # MNodeSession
    def NodeIdLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # MNodeSession
    def NodeIdIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0

    # When the CF node management session joined this CFC instance.
    # MNodeSession
    def Joined(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # When the last heartbeat was received on this CF node session.
    # MNodeSession
    def LastHeartbeat(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0


def MNodeSessionStart(builder):
    builder.StartObject(6)


def Start(builder):
    MNodeSessionStart(builder)


def MNodeSessionAddLeft(builder, left):
    builder.PrependUint64Slot(0, left, 0)


def AddLeft(builder, left):
    MNodeSessionAddLeft(builder, left)


def MNodeSessionAddSession(builder, session):
    builder.PrependUint64Slot(1, session, 0)


def AddSession(builder, session):
    MNodeSessionAddSession(builder, session)


def MNodeSessionAddRunId(builder, runId):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(runId), 0)


def AddRunId(builder, runId):
    MNodeSessionAddRunId(builder, runId)


def MNodeSessionStartRunIdVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartRunIdVector(builder, numElems: int) -> int:
    return MNodeSessionStartRunIdVector(builder, numElems)


def MNodeSessionAddNodeId(builder, nodeId):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(nodeId), 0)


def AddNodeId(builder, nodeId):
    MNodeSessionAddNodeId(builder, nodeId)


def MNodeSessionStartNodeIdVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartNodeIdVector(builder, numElems: int) -> int:
    return MNodeSessionStartNodeIdVector(builder, numElems)


def MNodeSessionAddJoined(builder, joined):
    builder.PrependUint64Slot(4, joined, 0)


def AddJoined(builder, joined):
    MNodeSessionAddJoined(builder, joined)


def MNodeSessionAddLastHeartbeat(builder, lastHeartbeat):
    builder.PrependUint64Slot(5, lastHeartbeat, 0)


def AddLastHeartbeat(builder, lastHeartbeat):
    MNodeSessionAddLastHeartbeat(builder, lastHeartbeat)


def MNodeSessionEnd(builder):
    return builder.EndObject()


def End(builder):
    return MNodeSessionEnd(builder)
