# automatically generated by the FlatBuffers compiler, do not modify

# namespace: log

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


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

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

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

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

    # When the this run ended (Unix time in ns).
    # MRealmRun
    def Ended(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

    # Management realm CFC backend run ID (this is unique over all start-stop cycles of CFC, and constant per run).
    # MRealmRun
    def RunId(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        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

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

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

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

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

    # Current CFC management backend state.
    # MRealmRun
    def State(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0


def MRealmRunStart(builder):
    builder.StartObject(4)


def Start(builder):
    MRealmRunStart(builder)


def MRealmRunAddEnded(builder, ended):
    builder.PrependUint64Slot(0, ended, 0)


def AddEnded(builder, ended):
    MRealmRunAddEnded(builder, ended)


def MRealmRunAddRunId(builder, runId):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(runId), 0)


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


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


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


def MRealmRunAddStarted(builder, started):
    builder.PrependUint64Slot(2, started, 0)


def AddStarted(builder, started):
    MRealmRunAddStarted(builder, started)


def MRealmRunAddState(builder, state):
    builder.PrependUint8Slot(3, state, 0)


def AddState(builder, state):
    MRealmRunAddState(builder, state)


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


def End(builder):
    return MRealmRunEnd(builder)
