# automatically generated by the FlatBuffers compiler, do not modify

# namespace: cookiestore

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# Persistent cookies, as used in WAMP-Cookie authentication by router and proxy workers.
class Cookie(object):
    __slots__ = ["_tab"]

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

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

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

    # Database ID of this cookie record.
    # Cookie
    def Oid(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        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

    # Cookie
    def OidAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # Cookie
    def OidLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Cookie
    def OidIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # Timestamp when the cookie was created. Epoch time in ns.
    # Cookie
    def Created(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

    # Cookie maximum age (lifetime of the cookie in seconds, see http://tools.ietf.org/html/rfc6265#page-20), e.g. ``604800"``.
    # Cookie
    def MaxAge(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

    # Cookie name, as set in HTTP header, e.g. ``"cbtid"``.
    # Cookie
    def Name(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

    # Cookie value, as set in HTTP header, e.g. ``"gn2ri8fuAYQse50/L6N7jnt2"``.
    # Cookie
    def Value(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Timestamp when the cookie was authenticated (if any). Epoch time in ns.
    # Cookie
    def Authenticated(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

    # The Crossbar.io node (within the management domain) the cookie was authenticated on (if any).
    # Cookie
    def AuthenticatedOnNode(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        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

    # Cookie
    def AuthenticatedOnNodeAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # Cookie
    def AuthenticatedOnNodeLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Cookie
    def AuthenticatedOnNodeIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        return o == 0

    # The Crossbar.io worker (within the node) the cookie was authenticated on (if any).
    # Cookie
    def AuthenticatedOnWorker(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The client transport information for the connection the cookie was authenticated in (if any).
    # Cookie
    def AuthenticatedTransportInfo(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        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

    # Cookie
    def AuthenticatedTransportInfoAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # Cookie
    def AuthenticatedTransportInfoLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Cookie
    def AuthenticatedTransportInfoIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        return o == 0

    # The WAMP session ID of the original authenticating session.
    # Cookie
    def AuthenticatedSession(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # Timestamp when the original authenticating session was welcome by the router. Epoch time in ns.
    # Cookie
    def AuthenticatedJoinedAt(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # The (original) WAMP authentication method, after which the client was authenticated before setting this cookie.
    # Cookie
    def AuthenticatedAuthmethod(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authid a cookie-authenticating session is to be assigned.
    # Cookie
    def Authid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authrole a cookie-authenticating session is to join under.
    # Cookie
    def Authrole(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authmethod a cookie-authenticating session is to join under.
    # Cookie
    def Authmethod(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP realm a cookie-authenticating session is to join.
    # Cookie
    def Authrealm(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authentication extra data to be returned to the client performing cookie-based authentication.
    # Cookie
    def Authextra(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
        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

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

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

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


def CookieStart(builder):
    builder.StartObject(17)


def Start(builder):
    CookieStart(builder)


def CookieAddOid(builder, oid):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(oid), 0)


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


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


def StartOidVector(builder, numElems: int) -> int:
    return CookieStartOidVector(builder, numElems)


def CookieAddCreated(builder, created):
    builder.PrependUint64Slot(1, created, 0)


def AddCreated(builder, created):
    CookieAddCreated(builder, created)


def CookieAddMaxAge(builder, maxAge):
    builder.PrependUint64Slot(2, maxAge, 0)


def AddMaxAge(builder, maxAge):
    CookieAddMaxAge(builder, maxAge)


def CookieAddName(builder, name):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)


def AddName(builder, name):
    CookieAddName(builder, name)


def CookieAddValue(builder, value):
    builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)


def AddValue(builder, value):
    CookieAddValue(builder, value)


def CookieAddAuthenticated(builder, authenticated):
    builder.PrependUint64Slot(5, authenticated, 0)


def AddAuthenticated(builder, authenticated):
    CookieAddAuthenticated(builder, authenticated)


def CookieAddAuthenticatedOnNode(builder, authenticatedOnNode):
    builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(authenticatedOnNode), 0)


def AddAuthenticatedOnNode(builder, authenticatedOnNode):
    CookieAddAuthenticatedOnNode(builder, authenticatedOnNode)


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


def StartAuthenticatedOnNodeVector(builder, numElems: int) -> int:
    return CookieStartAuthenticatedOnNodeVector(builder, numElems)


def CookieAddAuthenticatedOnWorker(builder, authenticatedOnWorker):
    builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(authenticatedOnWorker), 0)


def AddAuthenticatedOnWorker(builder, authenticatedOnWorker):
    CookieAddAuthenticatedOnWorker(builder, authenticatedOnWorker)


def CookieAddAuthenticatedTransportInfo(builder, authenticatedTransportInfo):
    builder.PrependUOffsetTRelativeSlot(
        8, flatbuffers.number_types.UOffsetTFlags.py_type(authenticatedTransportInfo), 0
    )


def AddAuthenticatedTransportInfo(builder, authenticatedTransportInfo):
    CookieAddAuthenticatedTransportInfo(builder, authenticatedTransportInfo)


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


def StartAuthenticatedTransportInfoVector(builder, numElems: int) -> int:
    return CookieStartAuthenticatedTransportInfoVector(builder, numElems)


def CookieAddAuthenticatedSession(builder, authenticatedSession):
    builder.PrependUint64Slot(9, authenticatedSession, 0)


def AddAuthenticatedSession(builder, authenticatedSession):
    CookieAddAuthenticatedSession(builder, authenticatedSession)


def CookieAddAuthenticatedJoinedAt(builder, authenticatedJoinedAt):
    builder.PrependUint64Slot(10, authenticatedJoinedAt, 0)


def AddAuthenticatedJoinedAt(builder, authenticatedJoinedAt):
    CookieAddAuthenticatedJoinedAt(builder, authenticatedJoinedAt)


def CookieAddAuthenticatedAuthmethod(builder, authenticatedAuthmethod):
    builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(authenticatedAuthmethod), 0)


def AddAuthenticatedAuthmethod(builder, authenticatedAuthmethod):
    CookieAddAuthenticatedAuthmethod(builder, authenticatedAuthmethod)


def CookieAddAuthid(builder, authid):
    builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(authid), 0)


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


def CookieAddAuthrole(builder, authrole):
    builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(authrole), 0)


def AddAuthrole(builder, authrole):
    CookieAddAuthrole(builder, authrole)


def CookieAddAuthmethod(builder, authmethod):
    builder.PrependUOffsetTRelativeSlot(14, flatbuffers.number_types.UOffsetTFlags.py_type(authmethod), 0)


def AddAuthmethod(builder, authmethod):
    CookieAddAuthmethod(builder, authmethod)


def CookieAddAuthrealm(builder, authrealm):
    builder.PrependUOffsetTRelativeSlot(15, flatbuffers.number_types.UOffsetTFlags.py_type(authrealm), 0)


def AddAuthrealm(builder, authrealm):
    CookieAddAuthrealm(builder, authrealm)


def CookieAddAuthextra(builder, authextra):
    builder.PrependUOffsetTRelativeSlot(16, flatbuffers.number_types.UOffsetTFlags.py_type(authextra), 0)


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


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


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


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


def End(builder):
    return CookieEnd(builder)
