def get_public_groups() -> List[UserSerializer]: """ 获取一些社区公开的 Groups Returns: Group 列表 """ uri = f'/groups' method = 'GET' return Request.send(method, uri)
def get_user_info() -> UserDetailSerializer: """ 获取 TOKEN User 的详细信息 Returns: TOKEN User 的详细信息 """ uri = f'/user' method = 'GET' return Request.send(method, uri)
def get_group_users(id_: Union[int, str]) -> List[GroupUserSerializer]: """ 获取某个 Group 的成员 Args: id_: Group 的 {login} 或 {id} Returns: Group 成员列表 """ uri = f'/groups/{id_}/users' method = 'GET' return Request.send(method, uri)
def delete_group(id_: Union[int, str]) -> GroupDetailSerializer: """ 删除 Group Args: id_: Group 的 {login} 或 {id} Returns: 删除的 Group 详细信息 """ uri = f'/groups/{id_}' method = 'DELETE' return Request.send(method, uri)
def delete_group_user(group_id: Union[int, str], login: str): """ 从 Group 中删除 User Args: group_id: Group 的 {login} 或 {id} login: User 的 {login}, 不确定 {id} 是否可行 Returns: 删除的 User 的成员信息 """ uri = f'/groups/{group_id}/users/{login}' method = 'DELETE' return Request.send(method, uri)
def get_repo_docs(repo_id: Union[int, str]) -> List[DocSerializer]: """ 获取 Repo 的 Docs Args: repo_id: Repo id Returns: Repo 的全部 Docs 列表 """ uri = f'/repos/{repo_id}/docs' method = 'GET' return Request.send(method, uri)
def get_group_info(id_: Union[int, str]) -> GroupSerializer: """ 获取 Group Args: id_: Group {login} 或 {id} Returns: id_ 对应的 Group """ uri = f'/groups/{id_}' method = 'GET' anonymous = True return Request.send(method, uri, anonymous=anonymous)
def get_repo_toc(id_: Union[int, str]) -> List[RepoTocSerializer]: """ 获取 Repo 的目录结构 Args: id_: Repo id Returns: Repo 的目录结构 """ uri = f'/repos/{id_}/toc' method = 'GET' return Request.send(method, uri)
def delete_repo(id_: Union[int, str]) -> RepoDetailSerializer: """ 删除 Repo Args: id_: Repo id Returns: Repo 的详细信息 """ uri = f'/repos/{id_}' method = 'DELETE' return Request.send(method, uri)
def get_user_docs(**kwargs) -> List[DocSerializer]: """ 获取 TOKEN User 的全部 Docs Keyword Args: q (str): 文档标题模糊搜索 offset (int): 分页偏移, 每页 20 条 Returns: User Docs (20 条)列表 """ uri = f'/user/docs' method = 'GET' return Request.send(method, uri, data=kwargs)
def get_user_info_anonymous(id_: Union[int, str]) -> UserDetailSerializer: """ 获取某一 User 的详细信息 Args: id_: 用户的 {login} 或 {id} Returns: User 详细信息 """ uri = f'/users/{id_}' method = 'GET' anonymous = True return Request.send(method, uri, anonymous=anonymous)
def search_repos(q: str, type_: str = "") -> List: """ 在全部 Repos 中搜索 Args: q: 搜索关键词 type_: Book, Design Returns: 搜索 Repos 列表 """ uri = f'/search/repos?q={q}&type={type_}' method = 'GET' return Request.send(method, uri)
def get_user_groups(user_id: Union[int, str]) -> List[UserSerializer]: """ 获取指定 User 的全部 Groups Args: user_id: 指定 User 的 {login} 或 {id} Returns: Group 列表, 语雀这里将 Group 均视作 User. """ uri = f'/users/{user_id}/groups' method = 'GET' anonymous = True return Request.send(method, uri, anonymous=anonymous)
def delete_doc(repo_id: Union[int, str], id_: Union[int, str]) -> DocDetailSerializer: """ 删除 Repo 中的 Doc Args: repo_id: Repo id id_: Doc id, 可能不支持 {slug} Returns: 被删除的 Doc 的详细信息 """ uri = f'/repos/{repo_id}/docs/{id_}' method = 'DELETE' return Request.send(method, uri)
def create_group(**kwargs) -> GroupDetailSerializer: """ 创建 Group Keyword Args: name (str): Group 名称 login (str): Group 路径名 description (str): 介绍 Returns: 创建的 Group 详细信息 """ uri = f'/groups' method = 'POST' return Request.send(method, uri, data=kwargs)
def get_recent_updated(**kwargs ) -> Union[List[DocSerializer], List[RepoSerializer]]: """ 获取 TOKEN User 的最近更新动态 Keyword Args: type (str): 'Doc', 'Book' offset (int): 分页偏移, 每页 20 条 Returns: User 最近更新的 Doc 或 Repo 列表 """ uri = f'/user/recent-updated' method = 'GET' return Request.send(method, uri, data=kwargs)
def get_repo_info(id_: Union[int, str], **kwargs) -> RepoDetailSerializer: """ 获取 Repo Args: id_: Repo id Keyword Args: type (str): Repo 类型, Book, Design Returns: Repo 的详细信息 """ uri = f'/repos/{id_}' method = 'GET' anonymous = True return Request.send(method, uri, data=kwargs, anonymous=anonymous)
def add_or_update_group_user(group_id: Union[int, str], login: str, **kwargs) -> GroupUserSerializer: """ 向 Group 添加 User 或 更新 User 权限 Args: group_id: Group 的 {login} 或 {id} login: User 的 {login}, 不确定 {id} 是否可行 Keyword Args: role: 0: 管理员; 1: 普通成员 Returns: 添加或更新的 User 的成员信息 """ uri = f'/groups/{group_id}/users/{login}' method = 'PUT' return Request.send(method, uri, data=kwargs)
def get_doc_info(repo_id: Union[int, str], id_: Union[int, str], **kwargs) -> DocDetailSerializer: """ 获取某个 Repo 中某个 Doc Args: repo_id: Repo id id_: Doc {slug} 或 {id} Keyword Args: raw (int): raw=1 返回文档最原始的格式 Returns: Doc 的详细信息 """ uri = f'/repos/{repo_id}/docs/{id_}' method = 'GET' return Request.send(method, uri, kwargs)
def update_group_info(id_: Union[int, str], **kwargs) -> UserSerializer: """ 更新 Group 信息 Keyword Args: name (str): Group 名称 login (str): Group 路径名 description (str): 介绍 Args: id_: 更新的 Group 的 {login} 或 {id} Returns: 更新的 Group """ uri = f'/groups/{id_}' method = 'PUT' return Request.send(method, uri, data=kwargs)
def get_user_repos(user_id: Union[int, str], **kwargs) -> List[RepoSerializer]: """ 获取 User 的全部 Repos Args: user_id: User 的 {login} 或 {id} Keyword Args: type (str): Book, Design, all offset (int): 用于分页, 一页 20 条 Returns: User 的 Repos 列表 """ uri = f'/users/{user_id}/repos' method = 'GET' anonymous = True return Request.send(method, uri, data=kwargs, anonymous=anonymous)
def update_repo_info(id_: Union[int, str], **kwargs) -> RepoDetailSerializer: """ 更新 Repo Args: id_: Repo id Keyword Args: name (str): Repo 名称 slug (str): Repo 路径 toc (str): Repo 目录信息 description (str): Repo 介绍 public (int): 0: 私密, 1: 内网公开, 2: 全网公开 Returns: Repo 的详细信息 """ uri = f'/repos/{id_}' method = 'PUT' return Request.send(method, uri, data=kwargs)
def create_doc(repo_id: Union[int, str], **kwargs) -> DocDetailSerializer: """ 在 Repo 下创建 Doc Args: repo_id: Repo id Keyword Args: title: Doc 标题 slug: 文档路径名 public: 0 私密, 1 公开 format: markdown / lake, 默认 markdown body: format 描述的正文, 最大 5MB Returns: 创建的 Doc 的详细信息 """ uri = f'/repos/{repo_id}/docs' method = 'POST' return Request.send(method, uri, kwargs)
def create_group_repo(group_id: Union[int, str], **kwargs) -> RepoDetailSerializer: """ 在 Group 中创建 Repo Args: group_id: Group 的 {login} 或 {id} Keyword Args: name (str): Repo 名称 slug (str): Repo 路径 description (str): Repo 介绍 public (int): 0: 私密, 1: 内网公开, 2: 全网公开 type (str): Book, Design Returns: 创建的 Repo 的详细信息 """ uri = f'/groups/{group_id}/repos' method = 'POST' return Request.send(method, uri, data=kwargs)
def update_doc(repo_id: Union[int, str], id_: Union[int, str], **kwargs) -> DocDetailSerializer: """ 更新 Repo 中的 Doc Args: repo_id: Repo id id_: Doc id, 不允许使用 {slug} Keyword Args: title: Doc 标题 slug: 文档路径名 public: 0 私密, 1 公开 body: 仅支持 markdown, 不能更新原文为 lake 格式的 Doc, 最大 5MB Returns: 更新的 Doc 详细信息 """ uri = f'/repos/{repo_id}/docs/{id_}' method = 'PUT' return Request.send(method, uri, kwargs)