# automatically generated by the FlatBuffers compiler, do not modify

# namespace: arealm

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# Application realm client principals.
class Principal(object):
    __slots__ = ["_tab"]

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

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

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

    # ID of this principal.
    # Principal
    def Oid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from ..oid_t import oid_t

            obj = oid_t()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Timestamp when the principal was last modified
    # Principal
    def Modified(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0

    # ID of the application realm the authenticated principal will be joined to.
    # Principal
    def ArealmOid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = o + self._tab.Pos
            from ..oid_t import oid_t

            obj = oid_t()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # WAMP authid of the principal, must be unique within the application realm at any moment in time.
    # Principal
    def Authid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # ID of the role the authenticated principal will be joined to the application realm.
    # Principal
    def RoleOid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = o + self._tab.Pos
            from ..oid_t import oid_t

            obj = oid_t()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Optional authextra information returned to the authenticating principal (CBOR serialized).
    # Principal
    def Authextra(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        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

    # Principal
    def AuthextraAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # Principal
    def AuthextraLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Principal
    def AuthextraIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0


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


def Start(builder):
    PrincipalStart(builder)


def PrincipalAddOid(builder, oid):
    builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(oid), 0)


def AddOid(builder, oid):
    PrincipalAddOid(builder, oid)


def PrincipalAddModified(builder, modified):
    builder.PrependInt32Slot(1, modified, 0)


def AddModified(builder, modified):
    PrincipalAddModified(builder, modified)


def PrincipalAddArealmOid(builder, arealmOid):
    builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(arealmOid), 0)


def AddArealmOid(builder, arealmOid):
    PrincipalAddArealmOid(builder, arealmOid)


def PrincipalAddAuthid(builder, authid):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(authid), 0)


def AddAuthid(builder, authid):
    PrincipalAddAuthid(builder, authid)


def PrincipalAddRoleOid(builder, roleOid):
    builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(roleOid), 0)


def AddRoleOid(builder, roleOid):
    PrincipalAddRoleOid(builder, roleOid)


def PrincipalAddAuthextra(builder, authextra):
    builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(authextra), 0)


def AddAuthextra(builder, authextra):
    PrincipalAddAuthextra(builder, authextra)


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


def StartAuthextraVector(builder, numElems: int) -> int:
    return PrincipalStartAuthextraVector(builder, numElems)


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


def End(builder):
    return PrincipalEnd(builder)
