Documentation ¶
Index ¶
- Constants
- Variables
- type Abilities
- type Ability
- type BookDetailSerializer
- type BookSerializer
- type Client
- func (c *Client) AuthenticatedUser() (*UserSerializer, error)
- func (c *Client) CreateGroup(cgp *CreateGroupParams) (*UserSerializer, error)
- func (c *Client) CreateGroupRepository(id string, crp *CreateRepoParams) (*BookDetailSerializer, error)
- func (c *Client) CreateRepositoryDoc(id string, crd *CreateRepoDocParams) (*DocDetailSerializer, error)
- func (c *Client) CreateUserRepository(id string, crp *CreateRepoParams) (*BookDetailSerializer, error)
- func (c *Client) DeleteGroup(id string) (*UserSerializer, error)
- func (c *Client) DeleteGroupUser(groupID, userID string) (*GroupUserSerializer, error)
- func (c *Client) DeleteRepository(id string) (*BookDetailSerializer, error)
- func (c *Client) DeleteRepositoryDoc(namespace string, docID int) (*DocDetailSerializer, error)
- func (c *Client) GetGroupDetail(id string) (*UserSerializer, error)
- func (c *Client) GetRepositoryDetail(id string, grd *GetRepoDetailParams) (*BookDetailSerializer, error)
- func (c *Client) GetRepositoryDocDetail(id, slug string, grd *GetRepoDocDetailParams) (*DocDetailSerializer, error)
- func (c *Client) GetRepositoryToc(id string) ([]*Toc, error)
- func (c *Client) Hello() (*Hello, error)
- func (c *Client) IndividualUser(id string) (*UserSerializer, error)
- func (c *Client) ListGroupRepositories(id string, lrp *ListReposParams) ([]*BookSerializer, error)
- func (c *Client) ListGroupUsers(id string) ([]*GroupUserSerializer, error)
- func (c *Client) ListPublicGroups() ([]*UserSerializer, error)
- func (c *Client) ListRepositoryDocs(id string) ([]*DocSerializer, error)
- func (c *Client) ListUserJoinedGroup(login string) ([]*UserSerializer, error)
- func (c *Client) ListUserRepositories(id string, lrp *ListReposParams) ([]*BookSerializer, error)
- func (c *Client) UpdateGroupDetail(id string, ugd *UpdateGroupDetailParams) (*UserSerializer, error)
- func (c *Client) UpdateGroupUser(groupID, userID string, ugu *UpdateGroupUsersParams) (*GroupUserSerializer, error)
- func (c *Client) UpdateRepository(id string, urp *UpdateRepoParams) (*BookDetailSerializer, error)
- func (c *Client) UpdateRepositoryDoc(namespace string, docID int, urd *UpdateRepoDocParams) (*DocDetailSerializer, error)
- func (c *Client) XRateLimitLimit() int
- func (c *Client) XRateLimitRemaining() int
- type CreateGroupParams
- type CreateRepoDocParams
- type CreateRepoParams
- type DocDetailSerializer
- type DocSerializer
- type GetRepoDetailParams
- type GetRepoDocDetailParams
- type GroupUserSerializer
- type Hello
- type ListReposParams
- type Meta
- type Response
- type Toc
- type UpdateGroupDetailParams
- type UpdateGroupUsersParams
- type UpdateRepoDocParams
- type UpdateRepoParams
- type UserSerializer
Constants ¶
const ( APIDomain = "https://www.yuque.com/api/v2" APIHello = APIDomain + "/hello" // user APIUsers = APIDomain + "/users/%s" APIUser = APIDomain + "/user" // repo APIUsersRepos = APIDomain + "/users/%s/repos" APIGroupsRepos = APIDomain + "/groups/%s/repos" APIRepos = APIDomain + "/repos/%s" APIReposToc = APIDomain + "/repos/%s/toc" // doc APIReposDocs = APIDomain + "/repos/%s/docs" APIReposDocsDetail = APIDomain + "/repos/%s/docs/%s" // group APIUsersGroups = APIDomain + "/users/%s/groups" APIGroups = APIDomain + "/groups" APIGroupsDetail = APIDomain + "/groups/%s" APIGroupsUsers = APIDomain + "/groups/%s/users" APIGroupsUsersUpdate = APIDomain + "/groups/%s/users/%s" SlugLength = 6 RepositoryNamePrefix = "AutoCreate" )
API 路径
const ( Book = "Book" Design = "Design" All = "All" )
知识库类型
const ( Private = iota // 私密 Open // 所有人 SpaceMember // 空间成员 SpaceOpen // 空间所有人 RepositoryMember // 知识库成员 )
知识库访问权限
const ( Markdown = "markdown" Lake = "lake" )
文档格式
const DefaultUserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"
DefaultUserAgent 默认的 user agent
Variables ¶
var ( ErrCodeNotDefine = errors.New("未定义的错误码") ErrMsg = map[int]error{ 200: errors.New("成功"), 400: errors.New("请求的参数不正确,或缺少必要信息,请对比文档"), 401: errors.New("需要用户认证的接口用户信息不正确"), 403: errors.New("缺少对应功能的权限"), 404: errors.New("数据不存在,或未开放"), 500: errors.New("服务器异常"), } )
var ( ErrNoFound = errors.New("http resp err: not found") ErrInvalidToken = errors.New("invalid token") )
Functions ¶
This section is empty.
Types ¶
type BookDetailSerializer ¶
type BookDetailSerializer struct { BookSerializer Toc string `json:"toc"` TocYml string `json:"toc_yml"` PinnedAt string `json:"pinned_at"` ArchivedAt string `json:"archived_at"` Abilities Abilities `json:"abilities"` }
func (*BookDetailSerializer) String ¶
func (bds *BookDetailSerializer) String() string
type BookSerializer ¶
type BookSerializer struct { ID int `json:"id"` Type string `json:"type"` Slug string `json:"slug"` Name string `json:"name"` Namespace string `json:"namespace"` UserID int `json:"user_id"` User UserSerializer `json:"user"` Description string `json:"description"` CreatorID int `json:"creator_id"` Public int `json:"public"` ItemsCount int `json:"items_count"` LikesCount int `json:"likes_count"` WatchesCount int `json:"watches_count"` ContentUpdatedAt string `json:"content_updated_at"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Serializer string `json:"_serializer"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AuthenticatedUser ¶
func (c *Client) AuthenticatedUser() (*UserSerializer, error)
AuthenticatedUser 获取认证的用户的个人信息
func (*Client) CreateGroup ¶
func (c *Client) CreateGroup(cgp *CreateGroupParams) (*UserSerializer, error)
CreateGroup 创建 Group
func (*Client) CreateGroupRepository ¶
func (c *Client) CreateGroupRepository(id string, crp *CreateRepoParams) (*BookDetailSerializer, error)
CreateGroupRepository 往团队创建知识库 notes: 未测试
func (*Client) CreateRepositoryDoc ¶
func (c *Client) CreateRepositoryDoc(id string, crd *CreateRepoDocParams) (*DocDetailSerializer, error)
CreateRepositoryDoc 创建文档
func (*Client) CreateUserRepository ¶
func (c *Client) CreateUserRepository(id string, crp *CreateRepoParams) (*BookDetailSerializer, error)
CreateUserRepository 往自己下面创建知识库
func (*Client) DeleteGroup ¶
func (c *Client) DeleteGroup(id string) (*UserSerializer, error)
DeleteGroup 删除组织
func (*Client) DeleteGroupUser ¶
func (c *Client) DeleteGroupUser(groupID, userID string) (*GroupUserSerializer, error)
DeleteGroupUser 删除组织成员 notes: 未测试
func (*Client) DeleteRepository ¶
func (c *Client) DeleteRepository(id string) (*BookDetailSerializer, error)
DeleteRepository 删除知识库
func (*Client) DeleteRepositoryDoc ¶
func (c *Client) DeleteRepositoryDoc(namespace string, docID int) (*DocDetailSerializer, error)
DeleteRepositoryDoc 删除文档
func (*Client) GetGroupDetail ¶
func (c *Client) GetGroupDetail(id string) (*UserSerializer, error)
GetGroupDetail 获取单个组织的详细信息
func (*Client) GetRepositoryDetail ¶
func (c *Client) GetRepositoryDetail(id string, grd *GetRepoDetailParams) (*BookDetailSerializer, error)
GetRepositoryDetail 获取知识库详情
func (*Client) GetRepositoryDocDetail ¶
func (c *Client) GetRepositoryDocDetail(id, slug string, grd *GetRepoDocDetailParams) (*DocDetailSerializer, error)
GetRepositoryDocDetail 获取单篇文档的详细信息
func (*Client) GetRepositoryToc ¶
GetRepositoryToc 获取一个知识库的目录结构
func (*Client) IndividualUser ¶
func (c *Client) IndividualUser(id string) (*UserSerializer, error)
IndividualUser 获取单个用户信息 id: 1: 用户编号 (数字), 2: 用户个人路径 (字符串)
func (*Client) ListGroupRepositories ¶
func (c *Client) ListGroupRepositories(id string, lrp *ListReposParams) ([]*BookSerializer, error)
ListGroupRepositories 获取某个团队的知识库列表
func (*Client) ListGroupUsers ¶
func (c *Client) ListGroupUsers(id string) ([]*GroupUserSerializer, error)
ListGroupUsers 获取组织成员信息
func (*Client) ListPublicGroups ¶
func (c *Client) ListPublicGroups() ([]*UserSerializer, error)
ListPublicGroups 获取公开组织列表
func (*Client) ListRepositoryDocs ¶
func (c *Client) ListRepositoryDocs(id string) ([]*DocSerializer, error)
ListRepositoryDocs 获取一个仓库的文档列表
func (*Client) ListUserJoinedGroup ¶
func (c *Client) ListUserJoinedGroup(login string) ([]*UserSerializer, error)
ListUserJoinedGroup 获取某个用户的加入的组织列表
func (*Client) ListUserRepositories ¶
func (c *Client) ListUserRepositories(id string, lrp *ListReposParams) ([]*BookSerializer, error)
ListUserRepositories 获取某个用户的知识库列表
func (*Client) UpdateGroupDetail ¶
func (c *Client) UpdateGroupDetail(id string, ugd *UpdateGroupDetailParams) (*UserSerializer, error)
UpdateGroupDetail 更新单个组织的详细信息
func (*Client) UpdateGroupUser ¶
func (c *Client) UpdateGroupUser(groupID, userID string, ugu *UpdateGroupUsersParams) (*GroupUserSerializer, error)
UpdateGroupUsers 增加或更新组织成员 notes: 未测试
func (*Client) UpdateRepository ¶
func (c *Client) UpdateRepository(id string, urp *UpdateRepoParams) (*BookDetailSerializer, error)
UpdateRepository 更新知识库信息
func (*Client) UpdateRepositoryDoc ¶
func (c *Client) UpdateRepositoryDoc(namespace string, docID int, urd *UpdateRepoDocParams) (*DocDetailSerializer, error)
UpdateRepositoryDoc 更新文档
func (*Client) XRateLimitLimit ¶
func (*Client) XRateLimitRemaining ¶
type CreateGroupParams ¶
type CreateGroupParams struct { Name string `json:"name"` Login string `json:"login"` // 用户个人路径 Description string `json:"description"` }
func (*CreateGroupParams) Reader ¶
func (cgp *CreateGroupParams) Reader() io.Reader
type CreateRepoDocParams ¶
type CreateRepoDocParams struct { Title string `json:"title"` Slug string `json:"slug"` Public int `json:"public"` Format string `json:"format"` Body string `json:"body"` }
func (*CreateRepoDocParams) Reader ¶
func (crd *CreateRepoDocParams) Reader() io.Reader
type CreateRepoParams ¶
type CreateRepoParams struct { Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` Public int `json:"public"` Type string `json:"type"` }
func (*CreateRepoParams) Reader ¶
func (crp *CreateRepoParams) Reader() io.Reader
type DocDetailSerializer ¶
type DocDetailSerializer struct { DocSerializer Creator UserSerializer `json:"creator"` Body string `json:"body"` BodyDraft string `json:"body_draft"` BodyHTML string `json:"body_html"` BodyLake string `json:"body_lake"` BodyDraftLake string `json:"body_draft_lake"` CreatorID int `json:"creator_id"` DeletedAt string `json:"deleted_at"` Hits int `json:"hits"` }
type DocSerializer ¶
type DocSerializer struct { ID int `json:"id"` Slug string `json:"slug"` Title string `json:"title"` Description string `json:"description"` UserID int `json:"user_id"` BookID int `json:"book_id"` Format string `json:"format"` Public int `json:"public"` Status int `json:"status"` ViewStatus int `json:"view_status"` ReadStatus int `json:"read_status"` LikesCount int `json:"likes_count"` CommentsCount int `json:"comments_count"` ContentUpdatedAt string `json:"content_updated_at"` Book BookSerializer `json:"book"` LastEditor UserSerializer `json:"last_editor"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` PublishedAt string `json:"published_at"` FirstPublishedAt string `json:"first_published_at"` DraftVersion int `json:"draft_version"` LastEditorID int `json:"last_editor_id"` WordCount int `json:"word_count"` Cover string `json:"cover"` CustomDescription string `json:"custom_description"` Serializer string `json:"_serializer"` }
type GetRepoDetailParams ¶
type GetRepoDetailParams struct {
Type string `json:"type"`
}
func (*GetRepoDetailParams) String ¶
func (grd *GetRepoDetailParams) String() string
type GetRepoDocDetailParams ¶
type GetRepoDocDetailParams struct {
Raw int `json:"raw"`
}
func (*GetRepoDocDetailParams) String ¶
func (grd *GetRepoDocDetailParams) String() string
type GroupUserSerializer ¶
type GroupUserSerializer struct { ID int `json:"id"` GroupID int `json:"group_id"` UserID int `json:"user_id"` User UserSerializer `json:"user"` Role int `json:"role"` Status int `json:"status"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Group UserSerializer `json:"group"` Serializer string `json:"_serializer"` }
type ListReposParams ¶
func (*ListReposParams) String ¶
func (lrp *ListReposParams) String() string
type Response ¶
type Response struct { Abilities Abilities `json:"abilities"` Meta Meta `json:"meta"` Data json.RawMessage `json:"data"` }
type Toc ¶
type Toc struct { Type string `json:"type"` Title string `json:"title"` Uuid string `json:"uuid"` Url string `json:"url"` PrevUuid string `json:"prev_uuid"` SiblingUuid string `json:"sibling_uuid"` ChildUuid string `json:"child_uuid"` ParentUuid string `json:"parent_uuid"` Level int `json:"level"` OpenWindow int `json:"open_window"` Visible int `json:"visible"` Depth int `json:"depth"` Slug string `json:"slug"` ID json.RawMessage `json:"id"` DocID json.RawMessage `json:"doc_id"` }
func (*Toc) UnmarshalDocID ¶
func (*Toc) UnmarshalID ¶
type UpdateGroupDetailParams ¶
type UpdateGroupDetailParams struct { Name string `json:"name"` Login string `json:"login"` Description string `json:"description"` }
func (*UpdateGroupDetailParams) Reader ¶
func (ugd *UpdateGroupDetailParams) Reader() io.Reader
type UpdateGroupUsersParams ¶
type UpdateGroupUsersParams struct {
Role int `json:"role"` // 0: 管理员, 1: 普通成员
}
func (*UpdateGroupUsersParams) Reader ¶
func (ugu *UpdateGroupUsersParams) Reader() io.Reader
type UpdateRepoDocParams ¶
type UpdateRepoDocParams struct { Title string `json:"title"` Slug string `json:"slug"` Public int `json:"public"` Body string `json:"body"` }
func (*UpdateRepoDocParams) Reader ¶
func (urd *UpdateRepoDocParams) Reader() io.Reader
type UpdateRepoParams ¶
type UpdateRepoParams struct { Name string `json:"name"` Slug string `json:"slug"` Toc string `json:"toc"` Description string `json:"description"` Public int `json:"public"` }
func (*UpdateRepoParams) Reader ¶
func (urp *UpdateRepoParams) Reader() io.Reader
type UserSerializer ¶
type UserSerializer struct { ID int `json:"id"` Type string `json:"type"` SpaceID int `json:"space_id"` OrganizationID int `json:"organization_id"` AccountID int `json:"account_id"` Login string `json:"login"` Name string `json:"name"` AvatarUrl string `json:"avatar_url"` OwnerID int `json:"owner_id"` BooksCount int `json:"books_count"` PublicBooksCount int `json:"public_books_count"` TopicsCount int `json:"topics_count"` PublicTopicsCount int `json:"public_topics_count"` MembersCount int `json:"members_count"` FollowersCount int `json:"followers_count"` FollowingCount int `json:"following_count"` Public int `json:"public"` Description string `json:"description"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Serializer string `json:"_serializer"` }
func (*UserSerializer) String ¶
func (us *UserSerializer) String() string