    def _share_list_model(self, query, kind="share"):
        """Finish a share query, returning the _model_"""
        offset, limit = self.get_api_pagination()
        if kind == "share":
            model_method = self.share_model
        elif kind == "code":
            model_method = self.share_code_model
        else:
            raise ValueError(
                f"kind must be `share` or `code`, not {kind!r}"
            )  # pragma: no cover

        if kind == "share":
            class_ = orm.Share
        elif kind == "code":
            class_ = orm.ShareCode

        total_count = query.count()
        query = query.order_by(class_.id.asc()).offset(offset).limit(limit)
        share_list = [model_method(share) for share in query if not share.expired]
        return self.paginated_model(share_list, offset, limit, total_count)
Finish a share query, returning the _model_
jupyterhub/apihandlers/shares.py