# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbr

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# XBR data service APIs published to (part of) catalogs.
class Api(object):
    __slots__ = ["_tab"]

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

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

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

    # The unique ID of the API.
    # Api
    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

    # Api
    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

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

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

    # The ID of the catalog this API is part of (was published to).
    # Api
    def CatalogOid(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

    # Api
    def CatalogOidAsNumpy(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

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

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

    # Database transaction time (epoch time in ns).
    # Api
    def Timestamp(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

    # Block number when the catalog was created.
    # Api
    def Published(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

    # Api
    def PublishedAsNumpy(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

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

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

    # Multihash of API Flatbuffers schema (required).
    # Api
    def Schema(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

    # Multihash of API meta-data (optional).
    # Api
    def Meta(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Transaction hash of the transaction this change was committed to the blockchain under.
    # Api
    def Tid(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

    # Api
    def TidAsNumpy(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

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

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

    # When signed off-chain and submitted via ``XBRCatalog.publishApiFor``.
    # Api
    def Signature(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        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

    # Api
    def SignatureAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # Api
    def SignatureLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Api
    def SignatureIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        return o == 0


def ApiStart(builder):
    builder.StartObject(8)


def Start(builder):
    ApiStart(builder)


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


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


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


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


def ApiAddCatalogOid(builder, catalogOid):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(catalogOid), 0)


def AddCatalogOid(builder, catalogOid):
    ApiAddCatalogOid(builder, catalogOid)


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


def StartCatalogOidVector(builder, numElems: int) -> int:
    return ApiStartCatalogOidVector(builder, numElems)


def ApiAddTimestamp(builder, timestamp):
    builder.PrependUint64Slot(2, timestamp, 0)


def AddTimestamp(builder, timestamp):
    ApiAddTimestamp(builder, timestamp)


def ApiAddPublished(builder, published):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(published), 0)


def AddPublished(builder, published):
    ApiAddPublished(builder, published)


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


def StartPublishedVector(builder, numElems: int) -> int:
    return ApiStartPublishedVector(builder, numElems)


def ApiAddSchema(builder, schema):
    builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(schema), 0)


def AddSchema(builder, schema):
    ApiAddSchema(builder, schema)


def ApiAddMeta(builder, meta):
    builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(meta), 0)


def AddMeta(builder, meta):
    ApiAddMeta(builder, meta)


def ApiAddTid(builder, tid):
    builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(tid), 0)


def AddTid(builder, tid):
    ApiAddTid(builder, tid)


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


def StartTidVector(builder, numElems: int) -> int:
    return ApiStartTidVector(builder, numElems)


def ApiAddSignature(builder, signature):
    builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(signature), 0)


def AddSignature(builder, signature):
    ApiAddSignature(builder, signature)


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


def StartSignatureVector(builder, numElems: int) -> int:
    return ApiStartSignatureVector(builder, numElems)


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


def End(builder):
    return ApiEnd(builder)
