# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):


import functools
from google.cloud.ndb import exceptions

_MAX_STRING_LENGTH = 1500


@functools.total_ordering
class BlobKey(object):
    """Key used to identify a blob in the blobstore.

    .. note::

        The blobstore was an early Google App Engine feature that later became
        Google Cloud Storage.

    This class is a simple wrapper a :class:`bytes` object. The bytes represent
    a key used internally by the Blobstore API  to identify application blobs
    (i.e. Google Cloud Storage objects). The key corresponds to the entity name
    of the underlying object.

    Args:
        blob_key (Optional[bytes]): The key used for the blobstore.

    Raises:
        .BadValueError: If the ``blob_key`` exceeds 1500 bytes.
        .BadValueError: If the ``blob_key`` is not :data:`None` or a
            :class:`bytes` instance.
    """

    def __init__(self, blob_key):
        if isinstance(blob_key, bytes):
            if len(blob_key) > _MAX_STRING_LENGTH:

# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):


# Path: google/cloud/ndb/_datastore_types.py
import functools
from google.cloud.ndb import exceptions


_MAX_STRING_LENGTH = 1500


@functools.total_ordering
class BlobKey(object):
    """Key used to identify a blob in the blobstore.

    .. note::

        The blobstore was an early Google App Engine feature that later became
        Google Cloud Storage.

    This class is a simple wrapper a :class:`bytes` object. The bytes represent
    a key used internally by the Blobstore API  to identify application blobs
    (i.e. Google Cloud Storage objects). The key corresponds to the entity name
    of the underlying object.

    Args:
        blob_key (Optional[bytes]): The key used for the blobstore.

    Raises:
        .BadValueError: If the ``blob_key`` exceeds 1500 bytes.
        .BadValueError: If the ``blob_key`` is not :data:`None` or a
            :class:`bytes` instance.
    """

    def __init__(self, blob_key):
        if isinstance(blob_key, bytes):
            if len(blob_key) > _MAX_STRING_LENGTH:

                raise exceptions.BadValueError(