gitcode

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 18 Imported by: 0

README

GitCode API Client

Go 语言的 GitCode / AtomGit API 客户端库,提供对 GitCode 平台几乎所有 REST API (/api/v5) 的类型安全访问。

Go Reference Go Version

功能特性

  • 认证 — Bearer Token / PRIVATE-TOKEN Header / access_token Query 三种鉴权 + OAuth 2.0 授权码流程
  • 仓库 — 创建/更新/删除/Fork/归档/转让,组织仓库,文件 CRUD,Tree/Blob,Raw,文件&图片上传,Fork 同步,远程镜像,许可协议,CLA
  • Issue — 仓库 Issue CRUD、评论、标签、里程碑、操作日志、关联 PR、时间线、订阅者、依赖关系、关联分支、看板字段、修改历史;用户/组织/企业级 Issue 查询
  • Pull Request — CRUD、合并、文件/提交/评论/审查、标签、审查人/测试人分配、操作日志、关联 Issue、Diff/Patch、讨论回复、检视意见、修改历史
  • 讨论 — 仓库/组织级讨论、评论、回复
  • 分支 — 列表/创建/删除,保护分支规则,提交比较,提交历史
  • Webhook — CRUD、测试推送,Push/TagPull/Issue/PullRequest/Note 事件解析
  • 用户 — 当前用户/指定用户、SSH 公钥、邮箱、动态、Star/Watch 仓库、Namespace、关注/取关、更新资料、用户 PR 列表
  • 组织 / 企业 — 组织信息/成员/关注者/公开成员/屏蔽用户,企业成员、企业 Issue/PR、Issue 扩展状态、企业标签、组织自定义角色、组织讨论
  • 组织团队 — 团队 CRUD、成员管理、仓库关联
  • 组织 Webhook — 组织级 Webhook CRUD
  • 组织标签 — 组织级标签 CRUD
  • 搜索 — 仓库 / Issue / 用户
  • 协作者 — 仓库协作者 CRUD、权限查询
  • Topics — 仓库主题管理
  • Commit Status — 提交状态、合并状态 (CI/CD 集成)
  • Deploy Keys — 部署密钥 CRUD
  • Git References — Git 引用 CRUD
  • Git Tags — 轻量/注释标签、Release 资产管理
  • Reactions — Issue/评论/PR 表情回应
  • Wiki — Wiki 页面 CRUD
  • 通知 — 增强通知操作(标记已读、线程详情、仓库通知)
  • 仓库邀请 — 接受/拒绝仓库邀请
  • 模板 — Issue 模板、PR 合并模板、Gitignore/License/Label 模板
  • Markdown — Markdown 渲染
  • 仓库统计 — 参与度、代码频率、提交活动、Punch Card
  • 仓库归档 — 下载仓库压缩包
  • 仓库设置 — Push 配置、PR 设置、模块开关、审查规则、下载统计
  • 保护标签 — 保护标签规则 CRUD
  • Release 增强 — 最新 Release、上传 URL、下载附件
  • 企业 — 企业成员/里程碑/标签/自定义角色/Issue 自定义字段/组织关联企业
  • 看板 (Dashboard) — 组织看板 CRUD、看板条目管理
  • Actions/CI — 工作流/运行记录/Jobs/日志/Artifacts/Runners/Runner Groups
  • 类型友好FlexInt/FlexString/NullableTime 等 JSON 容错类型,适配 GitCode 返回值类型漂移

环境要求

  • Go ≥ 1.26(go.mod 已锁定)
  • 一个 GitCode 个人访问令牌(PAT)或 OAuth 应用凭据

安装

go get github.com/yi-nology/gitcode_api@latest

当前最新版本为 v0.6.0,完整版本历史见 releases

快速开始

package main

import (
    "context"
    "fmt"
    "log"

    gitcode "github.com/yi-nology/gitcode_api"
)

func main() {
    client := gitcode.NewClient("your-gitcode-token")
    ctx := context.Background()

    user, err := client.GetCurrentUser(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("当前用户: %s (%s)\n", user.Name, user.Login)

    repos, err := client.ListRepositories(ctx, gitcode.ListRepositoriesOptions{
        ListOptions: gitcode.ListOptions{Page: 1, PerPage: 10},
    })
    if err != nil {
        log.Fatal(err)
    }
    for _, r := range repos {
        fmt.Printf("- %s\n", r.FullName)
    }
}

更完整的示例参见 examples/main.go

客户端与认证

获取 Token

访问 GitCode → 个人设置 → 私人令牌 创建 Token。

三种鉴权方式

Client 默认使用 Authorization: Bearer <token>,可通过 SetAuthStyle 切换:

client := gitcode.NewClient("your-token")                       // Bearer (默认)
client.SetAuthStyle(gitcode.AuthStylePrivateToken)              // PRIVATE-TOKEN Header
client.SetAuthStyle(gitcode.AuthStyleAccessToken)               // access_token Query 参数
私有部署 / 自定义 HTTP 客户端
client := gitcode.NewClientWithBaseURL("https://your-gitcode.com/api/v5", "token")
client.SetHTTPClient(&http.Client{Timeout: 60 * time.Second})   // 自定义超时

默认 BaseURL 为 https://api.gitcode.com/api/v5,默认超时 30s。

OAuth 2.0

适用于需要用户授权而非固定 Token 的场景:

oauth := gitcode.NewOAuthClient("client-id", "client-secret", "https://app.example.com/callback")

// 1. 引导用户跳转授权
url := oauth.AuthorizeURL("user_info projects", "random-state")
http.Redirect(w, r, url, http.StatusFound)

// 2. 用回调拿到的 code 换 token
token, err := oauth.ExchangeToken(ctx, code)

// 3. 用 token 创建 API 客户端
client := gitcode.NewClientFromOAuthToken(token)

// 4. 后续可用 refresh token 续期
token, err = oauth.RefreshToken(ctx, token.RefreshToken)

API 示例

下文示例中 ctx := context.Background(),owner/repo 为仓库所有者和路径名。

仓库与文件
// 创建仓库(私有)
private := false
repo, _ := client.CreateRepository(ctx, gitcode.CreateRepositoryOptions{
    Name:        "my-repo",
    Description: "描述",
    Private:     &private,
    AutoInit:    &private, // true,初始化 README
})

// 更新 / 删除 / Fork
client.UpdateRepository(ctx, "owner", "my-repo", gitcode.UpdateRepositoryOptions{Description: "新描述"})
client.DeleteRepository(ctx, "owner", "my-repo")
client.ForkRepository(ctx, "owner", "repo", nil)

// 组织下创建仓库
client.CreateOrgRepository(ctx, "my-org", gitcode.CreateOrgRepoOptions{Name: "team-repo"})

// 文件 CRUD(content 需 base64 编码)
content, _ := client.GetRepositoryContent(ctx, "owner", "repo", "README.md", "main")
res, _ := client.CreateFile(ctx, "owner", "repo", "a.txt", gitcode.CreateFileOptions{
    Message: "add a",
    Content: base64.StdEncoding.EncodeToString([]byte("hi")),
    Branch:  "main",
})
client.UpdateFile(ctx, "owner", "repo", "a.txt", gitcode.UpdateFileOptions{
    Message: "upd", Content: "...", SHA: res.Content.SHA, Branch: "main",
})

// 原始内容 / Tree / Blob / 贡献者 / 语言
raw, _      := client.GetRawFile(ctx, "owner", "repo", "README.md", "main")
tree, _     := client.GetTree(ctx, "owner", "repo", "main", true)
blob, _     := client.GetBlob(ctx, "owner", "repo", sha)
contribs, _ := client.ListContributors(ctx, "owner", "repo")
langs, _    := client.GetLanguages(ctx, "owner", "repo")

// 标签 / Release
tags, _     := client.ListTags(ctx, "owner", "repo")
release, _  := client.CreateRelease(ctx, "owner", "repo", gitcode.CreateReleaseOptions{
    TagName: "v1.0.0", Title: "v1.0.0", Body: "release notes",
})
client.DeleteRelease(ctx, "owner", "repo", release.TagName)
仓库归档与统计
// 下载仓库压缩包
tarGz, _ := client.GetRepositoryArchive(ctx, "owner", "repo", "main.tar.gz")
zip, _   := client.GetRepositoryArchive(ctx, "owner", "repo", "main.zip")

// 仓库统计
participation, _ := client.GetRepoParticipation(ctx, "owner", "repo")
codeFreq, _      := client.GetRepoCodeFrequency(ctx, "owner", "repo")
commitActivity, _ := client.GetRepoCommitActivity(ctx, "owner", "repo")
punchCard, _      := client.GetRepoPunchCard(ctx, "owner", "repo")
仓库主题 (Topics)
// 列出主题
topics, _ := client.ListRepositoryTopics(ctx, "owner", "repo")

// 更新主题
client.UpdateRepositoryTopics(ctx, "owner", "repo", []string{"golang", "api", "sdk"})

// 添加/删除单个主题
client.AddRepositoryTopic(ctx, "owner", "repo", "new-topic")
client.DeleteRepositoryTopic(ctx, "owner", "repo", "old-topic")
Fork 同步 / 远程镜像 / 许可协议 / CLA
// Fork 同步
syncStatus, _ := client.GetForkSyncStatus(ctx, "owner", "fork-repo")
fmt.Printf("behind=%d ahead=%d\n", syncStatus.BehindBy, syncStatus.AheadBy)
client.SyncForkRepository(ctx, "owner", "fork-repo") // 同步源仓库

// 远程镜像
mirror, _ := client.GetRepoRemoteMirror(ctx, "owner", "repo")
mirrors, _ := client.ListPushRemoteMirrors(ctx, "owner", "repo", gitcode.ListOptions{})

// 许可协议
license, _ := client.GetRepoLicense(ctx, "owner", "repo")

// CLA
clas, _ := client.ListRepoCLAs(ctx, "owner", "repo")
client.ConfigureRepoCLA(ctx, "owner", "repo", &gitcode.RepoCLA{Name: "CLA", Content: "...", Enabled: true})
讨论 (Discussions)
// 仓库讨论
discussions, _ := client.ListDiscussions(ctx, "owner", "repo", gitcode.ListOptions{})
discussion, _  := client.GetDiscussion(ctx, "owner", "repo", 1)
comments, _    := client.ListDiscussionComments(ctx, "owner", "repo", 1, gitcode.ListOptions{})
replies, _     := client.ListDiscussionCommentReplies(ctx, "owner", "repo", 1, commentID, gitcode.ListOptions{})

// 组织讨论
orgDiscussions, _ := client.ListOrgDiscussions(ctx, "my-org", gitcode.ListOptions{})
orgDiscussion, _  := client.GetOrgDiscussion(ctx, "my-org", 1)
协作者
// 列出协作者
collabs, _ := client.ListCollaborators(ctx, "owner", "repo", gitcode.ListOptions{})

// 添加协作者
client.AddCollaborator(ctx, "owner", "repo", "username", &gitcode.AddCollaboratorOptions{
    Permission: "push", // pull, push, admin
})

// 检查是否为协作者
isCollab, _ := client.IsCollaborator(ctx, "owner", "repo", "username")

// 获取协作者权限
perm, _ := client.GetCollaboratorPermission(ctx, "owner", "repo", "username")

// 移除协作者
client.RemoveCollaborator(ctx, "owner", "repo", "username")
Deploy Keys
// 列出部署密钥
keys, _ := client.ListDeployKeys(ctx, "owner", "repo", gitcode.ListOptions{})

// 创建部署密钥
readOnly := true
key, _ := client.CreateDeployKey(ctx, "owner", "repo", gitcode.CreateDeployKeyOptions{
    Title:    "deploy",
    Key:      "ssh-ed25519 AAAA...",
    ReadOnly: &readOnly,
})

// 获取/删除
client.GetDeployKey(ctx, "owner", "repo", key.ID)
client.DeleteDeployKey(ctx, "owner", "repo", key.ID)
Issue / 标签 / 里程碑
// Issue CRUD
issue, _ := client.CreateIssue(ctx, "owner", "repo", gitcode.CreateIssueOptions{
    Title:  "Bug 报告",
    Body:   "问题描述",
    Labels: []string{"bug"},
})
client.UpdateIssue(ctx, "owner", "repo", int(issue.Number), gitcode.UpdateIssueOptions{State: gitcode.IssueStateClosed})
client.ReopenIssue(ctx, "owner", "repo", int(issue.Number))

// 评论
client.CreateIssueComment(ctx, "owner", "repo", int(issue.Number), "+1")
client.ListIssueComments(ctx, "owner", "repo", int(issue.Number))

// 仓库标签
client.CreateIssueLabel(ctx, "owner", "repo", "bug", "#ee0701")
client.UpdateIssueLabel(ctx, "owner", "repo", "bug", gitcode.UpdateLabelOptions{Color: "#d73a4a"})
client.AddIssueLabels(ctx, "owner", "repo", int(issue.Number), []string{"bug"})
client.ReplaceIssueLabels(ctx, "owner", "repo", int(issue.Number), []string{"bug", "p0"})

// 里程碑
ms, _ := client.CreateMilestone(ctx, "owner", "repo", "v2.0", "下个版本")
client.ListMilestones(ctx, "owner", "repo")
client.UpdateMilestone(ctx, "owner", "repo", int(ms.ID), gitcode.UpdateMilestoneOptions{State: "closed"})

// 操作日志 / 关联 PR
logs, _ := client.GetIssueOperateLogs(ctx, "owner", "repo", int(issue.Number))
prs, _  := client.GetIssueLinkedPRs(ctx, "owner", "repo", int(issue.Number))

// 时间线事件
timeline, _ := client.ListIssueTimelineEvents(ctx, "owner", "repo", int(issue.Number), gitcode.ListOptions{})

// 订阅者
subscribers, _ := client.ListIssueSubscribers(ctx, "owner", "repo", int(issue.Number), gitcode.ListOptions{})
client.SubscribeToIssue(ctx, "owner", "repo", int(issue.Number), "username")
client.UnsubscribeFromIssue(ctx, "owner", "repo", int(issue.Number), "username")

// Issue 依赖关系
deps, _ := client.ListIssueDependencies(ctx, "owner", "repo", int(issue.Number), gitcode.ListOptions{})
client.CreateIssueDependency(ctx, "owner", "repo", int(issue.Number), 42) // 依赖 issue #42
client.DeleteIssueDependency(ctx, "owner", "repo", int(issue.Number), 42)

// 指派人
assignees, _ := client.ListRepoAssignees(ctx, "owner", "repo", gitcode.ListOptions{})
client.AddIssueAssignees(ctx, "owner", "repo", int(issue.Number), []string{"user1", "user2"})
client.RemoveIssueAssignees(ctx, "owner", "repo", int(issue.Number), []string{"user1"})

// 关联分支
branches, _ := client.ListIssueRelatedBranches(ctx, "owner", "repo", int(issue.Number))
client.SetIssueRelatedBranches(ctx, "owner", "repo", int(issue.Number), []string{"feature-branch"})

// 看板字段
client.UpdateIssueKanbanValues(ctx, "owner", "repo", int(issue.Number), []gitcode.KanbanValue{
    {FieldID: 1, FieldName: "priority", ValueID: 2, ValueName: "high"},
})

// 修改历史
history, _ := client.ListIssueModifyHistory(ctx, "owner", "repo", int(issue.Number), gitcode.ListOptions{})
commentHistory, _ := client.ListIssueCommentModifyHistory(ctx, "owner", "repo", commentID, gitcode.ListOptions{})

// 企业 Issue 状态
statuses, _ := client.ListEnterpriseIssueStatuses(ctx, "my-enterprise")
Issue 表情回应 (Reactions)
// 添加表情
client.CreateIssueReaction(ctx, "owner", "repo", int(issue.Number), gitcode.ReactionHeart)
client.CreateIssueReaction(ctx, "owner", "repo", int(issue.Number), gitcode.ReactionPlusOne)

// 列出表情
reactions, _ := client.ListIssueReactions(ctx, "owner", "repo", int(issue.Number), gitcode.ListOptions{})

// 删除表情
client.DeleteIssueReaction(ctx, "owner", "repo", int(issue.Number), reactions[0].ID)

// 评论表情
client.CreateIssueCommentReaction(ctx, "owner", "repo", commentID, gitcode.ReactionRocket)
client.ListIssueCommentReactions(ctx, "owner", "repo", commentID, gitcode.ListOptions{})
Pull Request
pr, _ := client.CreatePullRequest(ctx, "owner", "repo", gitcode.CreatePullRequestOptions{
    Title: "feat: xxx", Head: "feature", Base: "main",
})

// 合并 (Squash)
client.MergePullRequest(ctx, "owner", "repo", pr.Number, &gitcode.MergePullRequestOptions{
    CommitMessage: "merge feat",
    Squash:        true,
})

// 文件 / 提交 / 评论 / 审查
client.ListPullRequestFiles(ctx, "owner", "repo", pr.Number)
client.ListPullRequestCommits(ctx, "owner", "repo", pr.Number)
client.CreatePullRequestReview(ctx, "owner", "repo", pr.Number, "LGTM", "APPROVE")

// 标签 / 审查人 / 测试人
client.AddPullRequestLabels(ctx, "owner", "repo", pr.Number, []string{"review"})
client.AssignPullRequestReviewers(ctx, "owner", "repo", pr.Number, "user1,user2")
client.AssignPullRequestTesters(ctx, "owner", "repo", pr.Number, "qa1")
client.HandlePullRequestReview(ctx, "owner", "repo", pr.Number, false) // force=false

// 关联 Issue / 操作日志
issues, _ := client.GetPullRequestLinkedIssues(ctx, "owner", "repo", pr.Number, gitcode.ListOptions{})
logs, _   := client.GetPullRequestOperateLogs(ctx, "owner", "repo", pr.Number)

// Diff / Patch
diff, _  := client.GetPullRequestDiff(ctx, "owner", "repo", pr.Number)
patch, _ := client.GetPullRequestPatch(ctx, "owner", "repo", pr.Number)

// 审查人管理
reviewers, _ := client.ListPullRequestReviewers(ctx, "owner", "repo", pr.Number)
client.RequestPullRequestReviewers(ctx, "owner", "repo", pr.Number, gitcode.PullRequestReviewRequest{
    Reviewers: []string{"reviewer1", "reviewer2"},
})

// 审查操作
review, _ := client.GetPullRequestReview(ctx, "owner", "repo", pr.Number, reviewID)
client.SubmitPullRequestReview(ctx, "owner", "repo", pr.Number, reviewID, "LGTM", "APPROVE")
client.DismissPullRequestReview(ctx, "owner", "repo", pr.Number, reviewID, "Dismissed")

// PR 表情回应
client.CreatePullRequestCommentReaction(ctx, "owner", "repo", commentID, gitcode.ReactionHooray)

// PR 关联/取消关联 Issue
client.LinkPullRequestIssue(ctx, "owner", "repo", pr.Number, 42)
client.UnlinkPullRequestIssue(ctx, "owner", "repo", pr.Number, 42)

// 取消测试人/审查人
client.UnassignPullRequestTesters(ctx, "owner", "repo", pr.Number, "qa1")
client.UnassignPullRequestReviewers(ctx, "owner", "repo", pr.Number, "user1")

// 可选测试人/审查人列表
availableTesters, _ := client.ListPullRequestAvailableTesters(ctx, "owner", "repo", pr.Number, gitcode.ListOptions{})
availableReviewers, _ := client.ListPullRequestAvailableReviewers(ctx, "owner", "repo", pr.Number, gitcode.ListOptions{})

// 评审人 (approval-reviewers)
client.AssignPullRequestApprovalReviewers(ctx, "owner", "repo", pr.Number, "reviewer1,reviewer2")
client.UnassignPullRequestApprovalReviewers(ctx, "owner", "repo", pr.Number, "reviewer1")

// 讨论回复 / 检视意见
client.ReplyPullRequestComment(ctx, "owner", "repo", pr.Number, "discussion-id", "Reply body")
client.ResolvePullRequestDiscussion(ctx, "owner", "repo", pr.Number, "discussion-id", true)

// 修改历史
prHistory, _ := client.ListPullRequestModifyHistory(ctx, "owner", "repo", pr.Number, gitcode.ListOptions{})
prCommentHistory, _ := client.ListPullRequestCommentModifyHistory(ctx, "owner", "repo", commentID, gitcode.ListOptions{})

// 刷新评论位置
client.RefreshPullRequestCommentPosition(ctx, "owner", "repo", pr.Number)

// 文件变更 JSON
fileChanges, _ := client.ListPullRequestFilesJSON(ctx, "owner", "repo", pr.Number, gitcode.ListOptions{})
Commit Status (CI/CD 集成)
// 创建提交状态
client.CreateCommitStatus(ctx, "owner", "repo", sha, gitcode.CreateCommitStatusOptions{
    State:       "success", // pending, success, error, failure
    TargetURL:   "https://ci.example.com/build/123",
    Description: "Build passed",
    Context:     "ci/build",
})

// 列出提交状态
statuses, _ := client.ListCommitStatuses(ctx, "owner", "repo", sha, gitcode.ListOptions{})

// 获取合并状态(CI 整体状态)
combined, _ := client.GetCombinedStatus(ctx, "owner", "repo", sha)
fmt.Printf("总状态: %d 个检查\n", combined.TotalCount)
Commit 评论
// 创建提交评论
comment, _ := client.CreateCommitComment(ctx, "owner", "repo", sha, gitcode.CreateCommitCommentOptions{
    Body:     "Nice work!",
    Path:     "main.go",
    Position: 10,
})

// 列出/获取/更新/删除
client.ListCommitComments(ctx, "owner", "repo", sha, gitcode.ListOptions{})
client.GetCommitComment(ctx, "owner", "repo", comment.ID)
client.UpdateCommitComment(ctx, "owner", "repo", comment.ID, gitcode.UpdateCommitCommentOptions{Body: "Updated"})
client.DeleteCommitComment(ctx, "owner", "repo", comment.ID)

// 列出仓库所有提交评论
client.ListRepoCommitComments(ctx, "owner", "repo", gitcode.ListOptions{})
分支与提交
client.CreateBranch(ctx, "owner", "repo", gitcode.CreateBranchOptions{
    BranchName: "dev", Refs: "main",
})
client.DeleteBranch(ctx, "owner", "repo", "dev")

// 保护分支规则
client.CreateBranchProtection(ctx, "owner", "repo", gitcode.CreateBranchProtectionOptions{
    Name:                     "main",
    RequiredApprovingReviews: 2,
    AllowForcePushes:         false,
})
client.ListBranchProtections(ctx, "owner", "repo")
client.DeleteBranchProtection(ctx, "owner", "repo", "main")

// 提交
commits, _ := client.ListCommits(ctx, "owner", "repo", gitcode.ListCommitsOptions{Branch: "main"})
commit, _  := client.GetCommit(ctx, "owner", "repo", commits[0].SHA)
cmp, _     := client.CompareCommits(ctx, "owner", "repo", "main", "dev")
fmt.Printf("ahead=%d behind=%d\n", cmp.AheadBy, cmp.BehindBy)
Git References
// 列出引用
refs, _ := client.ListGitReferences(ctx, "owner", "repo", gitcode.ListOptions{})

// 列出分支引用
heads, _ := client.ListGitRefSubPaths(ctx, "owner", "repo", "heads/")

// 获取引用
ref, _ := client.GetGitReference(ctx, "owner", "repo", "heads/main")

// 创建引用
client.CreateGitReference(ctx, "owner", "repo", gitcode.CreateReferenceOptions{
    Ref: "refs/heads/new-branch",
    SHA: "abc123...",
})

// 更新引用
client.UpdateGitReference(ctx, "owner", "repo", "heads/main", gitcode.UpdateReferenceOptions{
    SHA:   "def456...",
    Force: false,
})

// 删除引用
client.DeleteGitReference(ctx, "owner", "repo", "heads/old-branch")
Git Tags (注释标签)
// 创建注释标签
annotatedTag, _ := client.CreateAnnotatedTag(ctx, "owner", "repo", gitcode.CreateAnnotatedTagOptions{
    Tag:     "v2.0.0",
    Message: "Release v2.0.0",
    Object:  "abc123...",
    Type:    "commit",
})

// 获取注释标签
client.GetAnnotatedTag(ctx, "owner", "repo", annotatedTag.SHA)

// Release 资产
assets, _ := client.ListReleaseAssets(ctx, "owner", "repo", releaseID, gitcode.ListOptions{})
client.GetReleaseAsset(ctx, "owner", "repo", assetID)
client.DeleteReleaseAsset(ctx, "owner", "repo", assetID)

// 通过标签获取 Release
release, _ := client.GetReleaseByTag(ctx, "owner", "repo", "v1.0.0")

// 更新 Release
client.UpdateRelease(ctx, "owner", "repo", releaseID, gitcode.UpdateReleaseOptions{
    Body: "Updated release notes",
})
Webhook
active := true
hook, _ := client.CreateWebhook(ctx, "owner", "repo", gitcode.CreateWebhookOptions{
    URL:    "https://example.com/hook",
    Secret: "s3cret",
    Events: []string{"push", "pull_request"},
    Active: &active,
})
client.TestWebhook(ctx, "owner", "repo", hook.ID)
client.DeleteWebhook(ctx, "owner", "repo", hook.ID)

接收并解析事件(以 Gin 为例):

payload, _ := io.ReadAll(r.Body)
switch r.Header.Get("X-Gitcode-Event") {
case "push":
    e, _ := client.ParsePushEvent(payload)
    log.Printf("push %s -> %s", e.Before[:8], e.After[:8])
case "pull_request":
    e, _ := client.ParsePullRequestEvent(payload)
    log.Printf("PR #%d %s", e.Number, e.Action)
case "issues":
    e, _ := client.ParseIssueEvent(payload)
    log.Printf("issue #%d %s", int(e.Issue.Number), e.Action)
case "note":
    e, _ := client.ParseNoteEvent(payload)
    log.Printf("note on %s", e.NoteType)
case "tag_push":
    e, _ := client.ParseTagPushEvent(payload)
    log.Printf("tag %s", e.Ref)
}

还提供了 PushEvent/PullRequestWebhookEvent/IssueWebhookEvent/NoteWebhookEvent/TagPushEvent 五种事件类型,见 webhooks.go

用户 / SSH 公钥 / 邮箱
me, _     := client.GetCurrentUser(ctx)
user, _   := client.GetUser(ctx, "somebody")
emails, _ := client.ListEmails(ctx)

key, _ := client.CreateSSHKey(ctx, gitcode.CreateSSHKeyOptions{
    Title: "mbp", Key: "ssh-ed25519 AAAA...",
})
client.ListSSHKeys(ctx, gitcode.ListOptions{PerPage: 50})
client.DeleteSSHKey(ctx, key.ID)

events, _ := client.GetUserEvents(ctx, me.Login, "2025", "") // 年度动态
starred, _ := client.ListStarredRepositories(ctx, gitcode.ListStarredReposOptions{})
ns, _      := client.GetNamespace(ctx, "somepath")

// Watch 了的仓库
watched, _ := client.ListUserWatchedRepositories(ctx, "username", gitcode.ListOptions{})
myWatched, _ := client.ListCurrentUserWatchedRepositories(ctx, gitcode.ListOptions{})

// 更新个人资料
client.UpdateCurrentUser(ctx, gitcode.UpdateCurrentUserOptions{
    Name: "New Name", Bio: "Go developer",
})

// 用户 PR 列表
myPRs, _ := client.ListUserPullRequests(ctx, gitcode.ListPullRequestsOptions{
    State: gitcode.PullRequestStateOpen,
})
用户关注
// 列出关注者/被关注者
followers, _ := client.ListUserFollowers(ctx, "username", gitcode.ListOptions{})
following, _ := client.ListUserFollowing(ctx, "username", gitcode.ListOptions{})

// 当前用户的关注关系
myFollowers, _ := client.ListCurrentUserFollowers(ctx, gitcode.ListOptions{})
myFollowing, _ := client.ListCurrentUserFollowing(ctx, gitcode.ListOptions{})

// 关注/取关
client.FollowUser(ctx, "target-user")
client.UnfollowUser(ctx, "target-user")

// 检查是否关注
isFollowing, _ := client.IsFollowing(ctx, "target-user")
组织 / 企业
// 组织
client.ListUserOrganizations(ctx, "username", gitcode.ListOptions{})
org, _      := client.GetOrgInfo(ctx, "my-org")
client.UpdateOrganization(ctx, "my-org", gitcode.UpdateOrgOptions{Description: "..."})
client.InviteOrgMember(ctx, "my-org", "newbie", gitcode.InviteMemberOptions{Permission: "write"})
client.RemoveOrgMember(ctx, "my-org", "newbie")
client.ListOrgMembers(ctx, "my-org", "admin", gitcode.ListOptions{})

// 企业
client.ListEnterpriseMembers(ctx, "my-ent", "", gitcode.ListOptions{})
client.UpdateEnterpriseMember(ctx, "my-ent", "user", gitcode.UpdateEnterpriseMemberOptions{Role: "admin"})

// 企业 Issue / PR
client.ListEnterpriseIssues(ctx, "my-ent", gitcode.ListUserIssuesOptions{State: "open"})
client.ListEnterprisePullRequests(ctx, "my-ent", gitcode.ListEnterprisePRsOptions{State: "open"})
client.ListEnterpriseLabels(ctx, "my-ent")
client.GetOrgIssueExtendSettings(ctx, "my-org") // 自定义状态扩展
组织公开成员 / 屏蔽
// 公开成员
publicMembers, _ := client.ListOrgPublicMembers(ctx, "my-org", gitcode.ListOptions{})
client.PublicizeOrgMembership(ctx, "my-org", "username")
client.ConcealOrgMembership(ctx, "my-org", "username")
isPublic, _ := client.IsOrgPublicMember(ctx, "my-org", "username")

// 屏蔽用户
blocked, _ := client.ListOrgBlockedUsers(ctx, "my-org", gitcode.ListOptions{})
client.BlockOrgUser(ctx, "my-org", "spammer")
client.UnblockOrgUser(ctx, "my-org", "spammer")
isBlocked, _ := client.IsOrgBlockedUser(ctx, "my-org", "spammer")

// 组织自定义角色
roles, _ := client.ListOrgCustomizedRoles(ctx, "my-org")
组织团队
// 创建团队
team, _ := client.CreateTeam(ctx, "my-org", gitcode.CreateTeamOptions{
    Name:       "backend",
    Permission: "write",
    Privacy:    "closed",
})

// 列出/获取/更新/删除团队
teams, _ := client.ListOrgTeams(ctx, "my-org", gitcode.ListOptions{})
client.GetTeam(ctx, team.ID)
client.UpdateTeam(ctx, team.ID, gitcode.UpdateTeamOptions{Name: "backend-team"})
client.DeleteTeam(ctx, team.ID)

// 团队成员管理
client.ListTeamMembers(ctx, team.ID, gitcode.ListOptions{})
client.AddTeamMember(ctx, team.ID, "new-member")
client.RemoveTeamMember(ctx, team.ID, "old-member")

// 团队仓库管理
client.ListTeamRepositories(ctx, team.ID, gitcode.ListOptions{})
client.AddTeamRepository(ctx, team.ID, "my-org", "my-repo")
client.RemoveTeamRepository(ctx, team.ID, "my-org", "my-repo")
组织 Webhook
// 创建组织 Webhook
active := true
hook, _ := client.CreateOrgWebhook(ctx, "my-org", gitcode.CreateOrgWebhookOptions{
    URL:    "https://example.com/org-hook",
    Events: []string{"push", "repository"},
    Active: &active,
})

// 列出/获取/更新/删除
hooks, _ := client.ListOrgWebhooks(ctx, "my-org", gitcode.ListOptions{})
client.GetOrgWebhook(ctx, "my-org", hook.ID)
client.UpdateOrgWebhook(ctx, "my-org", hook.ID, gitcode.UpdateOrgWebhookOptions{URL: "https://new-url.com"})
client.DeleteOrgWebhook(ctx, "my-org", hook.ID)
组织标签
// 创建组织标签
label, _ := client.CreateOrgLabel(ctx, "my-org", gitcode.CreateOrgLabelOptions{
    Name:  "priority:high",
    Color: "#ff0000",
})

// 列出/获取/更新/删除
labels, _ := client.ListOrgLabels(ctx, "my-org", gitcode.ListOptions{})
client.GetOrgLabel(ctx, "my-org", label.ID)
client.UpdateOrgLabel(ctx, "my-org", label.ID, gitcode.UpdateOrgLabelOptions{Color: "#cc0000"})
client.DeleteOrgLabel(ctx, "my-org", label.ID)
搜索
repos, _ := client.SearchRepositories(ctx, gitcode.SearchRepositoriesOptions{
    Query: "gin web", Sort: "stars_count",
})
issues, _ := client.SearchIssues(ctx, gitcode.SearchIssuesOptions{
    Query: "memory leak", Repo: "owner/repo", State: "open",
})
users, _ := client.SearchUsers(ctx, gitcode.SearchUsersOptions{Query: "octocat"})
Star / Watch / 通知
client.StarRepository(ctx, "owner", "repo")
starred, _ := client.IsRepositoryStarred(ctx, "owner", "repo") // bool
client.UnstarRepository(ctx, "owner", "repo")

stargazers, _ := client.ListStargazers(ctx, "owner", "repo", gitcode.ListOptions{})
watchers, _   := client.ListWatchers(ctx, "owner", "repo", gitcode.ListOptions{})
增强通知
// 列出通知(带筛选)
notifs, _ := client.ListNotificationsWithOptions(ctx, gitcode.ListNotificationsOptions{
    ListOptions: gitcode.ListOptions{PerPage: 50},
    Status:      "unread",
})

// 获取通知线程详情
thread, _ := client.GetNotificationThread(ctx, threadID)

// 标记单个线程已读
client.MarkNotificationThreadAsRead(ctx, threadID)

// 标记所有通知已读
client.MarkNotificationsAsRead(ctx, gitcode.MarkNotificationsOptions{All: true})

// 仓库通知
repoNotifs, _ := client.ListRepoNotifications(ctx, "owner", "repo", gitcode.ListNotificationsOptions{})
client.MarkRepoNotificationsAsRead(ctx, "owner", "repo", gitcode.MarkNotificationsOptions{All: true})
Wiki
// 列出 Wiki 页面
pages, _ := client.ListWikiPages(ctx, "owner", "repo", gitcode.ListOptions{})

// 获取单个页面
page, _ := client.GetWikiPage(ctx, "owner", "repo", "Home")

// 创建页面
content := base64.StdEncoding.EncodeToString([]byte("# Hello Wiki"))
client.CreateWikiPage(ctx, "owner", "repo", gitcode.CreateWikiPageOptions{
    Title:         "New Page",
    ContentBase64: content,
    Message:       "Create new page",
})

// 更新/删除
client.UpdateWikiPage(ctx, "owner", "repo", "New-Page", gitcode.UpdateWikiPageOptions{
    ContentBase64: content,
    Message:       "Update page",
})
client.DeleteWikiPage(ctx, "owner", "repo", "Old-Page")
仓库邀请
// 列出待处理邀请
invitations, _ := client.ListPendingRepoInvitations(ctx, gitcode.ListOptions{})

// 接受/拒绝邀请
client.AcceptRepoInvitation(ctx, invitationID)
client.DeclineRepoInvitation(ctx, invitationID)
模板
// Issue 模板
issueTemplates, _ := client.ListIssueTemplates(ctx, "owner", "repo")
client.GetIssueTemplate(ctx, "owner", "repo", "bug_report")

// PR 合并模板
mergeTemplates, _ := client.ListPullRequestMergeTemplates(ctx, "owner", "repo")

// Gitignore 模板
gitignoreTemplates, _ := client.ListGitignoreTemplates(ctx)
client.GetGitignoreTemplate(ctx, "Go")

// License 模板
licenses, _ := client.ListLicenseTemplates(ctx)
client.GetLicenseTemplate(ctx, "mit")

// Label 模板
labelTemplates, _ := client.ListLabelTemplates(ctx)
client.GetLabelTemplate(ctx, "default")
Markdown 渲染
html, _ := client.RenderMarkdown(ctx, "**bold** and *italic*", "gfm", "owner/repo")
html, _ = client.RenderMarkdownRaw(ctx, "# Raw Markdown")
仓库设置类
client.UpdateRepoSettings(ctx, "owner", "repo", &gitcode.RepoSettings{HasIssues: true})
client.UpdatePushConfig(ctx, "owner", "repo", &gitcode.PushConfig{MaxFileSize: 104857600})
client.UpdatePRSettings(ctx, "owner", "repo", &gitcode.PRSettings{DefaultMergeMethod: "merge"})
client.SetModuleSetting(ctx, "owner", "repo", gitcode.ModuleSetting{Wiki: false})
client.UpdateReviewerConfig(ctx, "owner", "repo", gitcode.ReviewerConfig{MinApprovingReviews: 1})

// 归档 / 转让
client.ArchiveRepository(ctx, "owner", "repo")
client.TransferRepository(ctx, "owner", "repo", gitcode.TransferRepoOptions{NewOwner: "new-owner"})

// 限流
rl, _ := client.GetRateLimit(ctx)

高级功能

结构化错误处理

所有 API 错误都返回结构化类型,可通过类型断言区分:

_, err := client.GetRepository(ctx, "owner", "missing")
if err != nil {
    switch {
    case gitcode.IsNotFound(err):
        fmt.Println("仓库不存在")
    case gitcode.IsUnauthorized(err):
        fmt.Println("认证失败")
    case gitcode.IsRateLimit(err):
        fmt.Println("触发限流")
    case gitcode.IsForbidden(err):
        fmt.Println("权限不足")
    case gitcode.IsConflict(err):
        fmt.Println("资源已存在")
    default:
        fmt.Printf("其他错误: %v\n", err)
    }
}
Rate Limit 自动重试

配置自动重试策略,遇到 429/5xx 自动等待重试:

client.SetRetryPolicy(gitcode.RetryPolicy{
    MaxRetries:           3,
    InitialBackoff:       1 * time.Second,
    MaxBackoff:           30 * time.Second,
    Multiplier:           2.0,
    RetryableStatusCodes: []int{429, 500, 502, 503, 504},
})
自动分页

自动遍历所有分页,无需手动处理 Page 参数:

// 收集所有结果到一个 slice
allIssues, _ := gitcode.CollectAll(ctx, func(opts gitcode.ListOptions) ([]*gitcode.Issue, error) {
    return client.ListIssues(ctx, "owner", "repo", gitcode.ListIssuesOptions{
        ListOptions: opts,
        State:       gitcode.IssueStateOpen,
    })
})

// 使用迭代器逐页处理
for items, err := range gitcode.Paginate(ctx, func(opts gitcode.ListOptions) ([]*gitcode.Repository, error) {
    return client.ListRepositories(ctx, gitcode.ListRepositoriesOptions{ListOptions: opts})
}) {
    if err != nil { log.Fatal(err) }
    for _, repo := range items {
        fmt.Println(repo.FullName)
    }
}
Webhook 签名验证

验证 Webhook 请求的 HMAC-SHA256 签名:

func handleWebhook(w http.ResponseWriter, r *http.Request) {
    payload, _ := io.ReadAll(r.Body)
    signature := r.Header.Get("X-Gitcode-Signature")

    if !gitcode.VerifyWebhookSignature(payload, "your-webhook-secret", signature) {
        http.Error(w, "Invalid signature", http.StatusUnauthorized)
        return
    }

    // 签名有效,处理事件
    event, _ := client.ParsePushEvent(payload)
    fmt.Printf("Push to %s\n", event.Ref)
}

// 计算签名 (用于测试)
sig := gitcode.ComputeWebhookSignature(payload, secret)
请求/响应中间件 (Hooks)

添加请求前后的拦截器,用于日志、监控、调试:

// 请求前 Hook
client.AddRequestHook(func(req *http.Request) error {
    log.Printf("[REQ] %s %s", req.Method, req.URL.Path)
    req.Header.Set("X-Request-ID", uuid.New().String())
    return nil
})

// 响应后 Hook
client.AddResponseHook(func(resp *http.Response) error {
    log.Printf("[RESP] %d %s", resp.StatusCode, resp.Request.URL.Path)
    return nil
})

// 清除所有 Hook
client.ClearHooks()
Multipart 文件上传

使用 io.Reader 上传文件内容:

// 上传字节
result, _ := client.UploadFileBytes(ctx, "owner", "repo", "hello.txt", []byte("Hello"))

// 上传 io.Reader
file, _ := os.Open("local-file.go")
defer file.Close()
result, _ = client.UploadFileReader(ctx, "owner", "repo", "remote-name.go", file)

// 上传图片
img, _ := os.Open("screenshot.png")
defer img.Close()
result, _ = client.UploadImageReader(ctx, "owner", "repo", "screenshot.png", img)
输入校验

客户端自动校验必填字段,提前返回友好错误:

// owner 或 repo 为空时返回 ValidationErrorField
_, err := client.GetRepository(ctx, "", "repo")
// err: "validation error: owner - owner is required"

if gitcode.IsValidationError(err) {
    fmt.Println(err)
}
并发安全

SetAuthStyleSetHTTPClientAddRequestHookAddResponseHook 等方法均使用 sync.RWMutex 保护,可安全在多个 goroutine 中调用。


通用类型

types.go 中定义了若干容错类型,用于处理 GitCode API 返回值类型不稳定的情况:

类型 用途
FlexInt 同一字段可能是 123"123"
FlexString 同一字段可能是 "abc"123
NullableTime 时间字段可能为空字符串
Timestamp 字符串格式时间(RFC3339)
Error API 错误响应结构(见下)

错误处理

Client 在 HTTP 状态码 ≥ 400 时返回标准 error(fmt.Errorf),错误信息包含方法、路径、状态码和响应体:

_, err := client.GetRepository(ctx, "owner", "missing")
if err != nil {
    log.Println(err)
    // 输出形如: GitCode API GET /repos/owner/missing returned 404: {"message":"404 Not Found"}
}

如需进一步解析错误体,可使用 types.Error:

var apiErr gitcode.Error
if json.Unmarshal([]byte(extractBody(err)), &apiErr) == nil {
    log.Printf("message=%s", apiErr.Message)
}

项目结构

gitcode_api/
├── client.go                   # Client 构造、鉴权、HTTP 请求、User、ListOptions、RateLimit
├── oauth.go                    # OAuthClient 授权码流程
├── repos.go                    # 仓库 / 文件 / Tree / Blob / 标签 / Release / 设置 / 归档 / 转让
├── repos_collaborators.go      # 仓库协作者 CRUD、权限查询
├── repos_topics.go             # 仓库主题管理
├── repos_statuses.go           # 提交状态、合并状态 (CI/CD)
├── repos_deploy_keys.go        # 部署密钥 CRUD
├── repos_reactions.go          # Issue / 评论 / PR 表情回应
├── repos_wiki.go               # Wiki 页面 CRUD
├── repos_invitations.go        # 仓库邀请
├── repos_templates.go          # Issue / PR 模板
├── repos_commits_comments.go   # 提交评论
├── repos_archive.go            # 仓库归档下载、统计
├── repos_assignees.go          # 指派人管理
├── repos_reviewers.go          # PR 审查人、Diff、Patch
├── repos_issues_timeline.go    # Issue 时间线、订阅者、依赖关系
├── repos_discussions.go        # 仓库讨论、评论、回复 / Fork 同步 / 远程镜像 / 许可协议 / CLA
├── issues.go                   # Issue CRUD / 评论 / 标签 / 里程碑
├── issues_enhanced.go          # Issue 关联分支 / 看板字段 / 修改历史 / 企业状态 / 表态
├── enterprise_issues.go        # 用户 / 组织 / 企业级 Issue、操作日志、关联 PR
├── pulls.go                    # Pull Request 全套 + 审查 / 测试 / 标签 / 企业 PR
├── pulls_enhanced.go           # PR 关联 Issue / 测试人管理 / 评审人 / 讨论回复 / 修改历史 / 表态
├── branches.go                 # 分支 / 保护分支 / 提交 / 比较
├── webhooks.go                 # Webhook CRUD + 5 类事件解析
├── search.go                   # 搜索仓库 / Issue / 用户
├── users.go                    # SSH 公钥 / 邮箱 / 动态 / Star / Namespace
├── users_enhanced.go           # Watch 仓库 / 更新资料 / 用户 PR 列表
├── user_followers.go           # 用户关注 / 取关
├── orgs.go                     # 组织 / 企业成员管理 / Issue 扩展配置
├── orgs_enhanced.go            # 组织自定义角色 / 组织讨论
├── org_teams.go                # 组织团队 CRUD / 成员 / 仓库
├── org_hooks.go                # 组织 Webhook CRUD
├── org_labels.go               # 组织标签 CRUD
├── org_members_enhanced.go     # 公开成员 / 屏蔽用户 / 创建删除组织
├── milestones.go               # 里程碑(带选项版本)
├── labels.go                   # 仓库标签更新 / 替换 / 企业标签
├── git_refs.go                 # Git 引用 CRUD
├── git_tags.go                 # 注释标签 / Release 资产
├── notifications_enhanced.go   # 增强通知操作
├── misc.go                     # Gitignore/License/Label 模板 / Markdown / 用户仓库
├── types.go                    # FlexInt/FlexString/NullableTime/Error 等通用类型 + Star/通知 API
├── errors.go                   # 结构化错误类型: NotFound/Unauthorized/RateLimit/Conflict/Validation
├── retry.go                    # Rate Limit 自动重试 + 指数退避
├── pagination.go               # 自动分页迭代器 (泛型)
├── hooks.go                    # 请求/响应中间件
├── validate.go                 # 输入校验
├── webhook_verify.go           # Webhook HMAC-SHA256 签名验证
├── upload.go                   # Multipart 文件上传
├── gitcode_test.go             # 单元测试 + 真实 API 集成测试
├── client_enhanced_test.go     # 新功能单元测试
└── examples/
    └── main.go                 # 完整使用示例

API 覆盖率

本库覆盖了 GitCode 官方文档 (docs.gitcode.com/docs/apis) 中的绝大部分 API:

模块 API 数量 状态
认证 & 用户 20+ ✅ 完整
仓库 CRUD & 文件 40+ ✅ 完整
讨论 (Discussions) 10 ✅ 完整
Fork 同步 / 远程镜像 / CLA 7 ✅ 完整
Issue / 标签 / 里程碑 30+ ✅ 完整
Issue 增强 (分支/看板/历史) 8 ✅ 完整
Pull Request 40+ ✅ 完整
PR 增强 (关联/评审/讨论/历史) 15 ✅ 完整
分支 & 提交 17 ✅ 完整
保护标签 5 ✅ 完整
Release 增强 8 ✅ 完整
Webhook 5 CRUD + 5 解析 ✅ 完整
组织 / 企业 40+ ✅ 完整
企业里程碑 / 标签 / 自定义字段 14 ✅ 完整
看板 (Dashboard) 7 ✅ 完整
Actions/CI (工作流/Runner/Artifact) 23 ✅ 完整
组织团队 12 ✅ 完整
搜索 3 ✅ 完整
协作者 5 ✅ 完整
Topics 4 ✅ 完整
Commit Status 3 ✅ 完整
Deploy Keys 4 ✅ 完整
Git References 6 ✅ 完整
Reactions 12 ✅ 完整
Wiki 5 ✅ 完整
通知 6 ✅ 完整
模板 7 ✅ 完整
总计 428

测试

测试分为两类:纯函数测试(不需要网络)和 真实 API 集成测试(会在你的账户下创建/删除临时仓库)。

# 默认运行(需在 gitcode_test.go 顶部填入有效 Token)
GITCODE_TOKEN="your-token" go test -v ./...

# 跳过需要联网的集成测试
go test -short ./...

集成测试会真实创建仓库(test-api-<timestamp>),测试结束后自动清理。请使用测试账号的 Token。

与 gitcode-cli 的关系

本项目参考了 gitcode-cli 的设计理念,提供 Go 语言的 API 客户端实现:

gitcode-cli (gc) gitcode_api
gc auth login NewClient(token) / OAuthClient
gc repo list ListRepositories()
gc issue create CreateIssue()
gc pr create CreatePullRequest()

相关项目

许可证

MIT。

Documentation

Index

Constants

View Source
const (
	ReactionPlusOne  = "+1"
	ReactionMinusOne = "-1"
	ReactionLaugh    = "laugh"
	ReactionConfused = "confused"
	ReactionHeart    = "heart"
	ReactionHooray   = "hooray"
	ReactionRocket   = "rocket"
	ReactionEyes     = "eyes"
)

ReactionContent constants for reaction types.

View Source
const (
	DefaultBaseURL = "https://api.gitcode.com/api/v5"
)
View Source
const (
	DefaultOAuthBaseURL = "https://gitcode.com"
)

Variables

This section is empty.

Functions

func CollectAll added in v0.6.0

func CollectAll[T any](ctx context.Context, fetch func(ListOptions) ([]T, error)) ([]T, error)

CollectAll collects all pages into a single slice.

func ComputeWebhookSignature added in v0.6.0

func ComputeWebhookSignature(payload []byte, secret string) string

ComputeWebhookSignature computes the HMAC-SHA256 signature for a payload. Returns the signature in the format "sha256=<hex>".

func IsConflict added in v0.6.0

func IsConflict(err error) bool

IsConflict checks if an error is a ConflictError.

func IsForbidden added in v0.6.0

func IsForbidden(err error) bool

IsForbidden checks if an error is a ForbiddenError.

func IsNotFound added in v0.6.0

func IsNotFound(err error) bool

IsNotFound checks if an error is a NotFoundError.

func IsRateLimit added in v0.6.0

func IsRateLimit(err error) bool

IsRateLimit checks if an error is a RateLimitError.

func IsUnauthorized added in v0.6.0

func IsUnauthorized(err error) bool

IsUnauthorized checks if an error is an UnauthorizedError.

func IsValidation added in v0.6.0

func IsValidation(err error) bool

IsValidation checks if an error is a ValidationError.

func IsValidationError added in v0.6.0

func IsValidationError(err error) bool

IsValidationError checks if an error is a client-side validation error.

func Paginate added in v0.6.0

func Paginate[T any](ctx context.Context, fetch func(ListOptions) ([]T, error)) iter.Seq2[[]T, error]

Paginate creates an iterator that automatically fetches all pages of results. Usage:

for items, err := range client.Paginate(ctx, func(opts ListOptions) ([]*Issue, error) {
    return client.ListIssues(ctx, owner, repo, ListIssuesOptions{ListOptions: opts})
}) {
    if err != nil { return err }
    for _, issue := range items {
        // process issue
    }
}

func VerifyWebhookSignature added in v0.6.0

func VerifyWebhookSignature(payload []byte, secret, signature string) bool

VerifyWebhookSignature verifies the signature of a webhook payload. The signature is expected in the format "sha256=<hex>".

Example usage:

func handleWebhook(w http.ResponseWriter, r *http.Request) {
    payload, _ := io.ReadAll(r.Body)
    signature := r.Header.Get("X-Gitcode-Signature")
    if !gitcode.VerifyWebhookSignature(payload, "your-secret", signature) {
        http.Error(w, "Invalid signature", http.StatusUnauthorized)
        return
    }
    // Process webhook...
}

Types

type APIError added in v0.6.0

type APIError struct {
	StatusCode int    `json:"status_code"`
	Message    string `json:"message"`
	URL        string `json:"url,omitempty"`
	Method     string `json:"method,omitempty"`
	Body       string `json:"body,omitempty"`
}

APIError represents a structured GitCode API error.

func (*APIError) Error added in v0.6.0

func (e *APIError) Error() string

type ActionArtifact added in v0.5.0

type ActionArtifact struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Size       int64     `json:"size"`
	ArchiveURL string    `json:"archive_download_url,omitempty"`
	Expired    bool      `json:"expired"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	RunID      int64     `json:"run_id,omitempty"`
}

ActionArtifact represents a workflow artifact.

type ActionJob added in v0.5.0

type ActionJob struct {
	ID          int64         `json:"id"`
	RunID       int64         `json:"run_id"`
	Name        string        `json:"name"`
	Status      string        `json:"status"`
	Conclusion  string        `json:"conclusion,omitempty"`
	StartedAt   time.Time     `json:"started_at"`
	CompletedAt *time.Time    `json:"completed_at,omitempty"`
	RunnerID    int64         `json:"runner_id,omitempty"`
	RunnerName  string        `json:"runner_name,omitempty"`
	Steps       []*ActionStep `json:"steps,omitempty"`
}

ActionJob represents a workflow job.

type ActionRun added in v0.5.0

type ActionRun struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	WorkflowID   int64     `json:"workflow_id"`
	Status       string    `json:"status"`
	Conclusion   string    `json:"conclusion,omitempty"`
	Branch       string    `json:"head_branch"`
	SHA          string    `json:"head_sha"`
	Event        string    `json:"event"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	RunStartedAt time.Time `json:"run_started_at,omitempty"`
	HTMLURL      string    `json:"html_url,omitempty"`
}

ActionRun represents a workflow run.

type ActionRunner added in v0.5.0

type ActionRunner struct {
	ID         int64    `json:"id"`
	Name       string   `json:"name"`
	Status     string   `json:"status"`
	OS         string   `json:"os,omitempty"`
	Arch       string   `json:"arch,omitempty"`
	Labels     []string `json:"labels,omitempty"`
	RunnerType string   `json:"runner_type,omitempty"`
}

ActionRunner represents a CI/CD runner.

type ActionStep added in v0.5.0

type ActionStep struct {
	Name        string     `json:"name"`
	Status      string     `json:"status"`
	Conclusion  string     `json:"conclusion,omitempty"`
	Number      int        `json:"number"`
	StartedAt   time.Time  `json:"started_at,omitempty"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`
}

ActionStep represents a step in a workflow job.

type ActionWorkflow added in v0.5.0

type ActionWorkflow struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Path      string    `json:"path"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ActionWorkflow represents a CI/CD workflow.

type AddCollaboratorOptions added in v0.4.0

type AddCollaboratorOptions struct {
	Permission string `json:"permission,omitempty"` // pull, push, admin
}

AddCollaboratorOptions specifies options for adding a collaborator.

type AddToKanbanBoardOptions added in v0.5.0

type AddToKanbanBoardOptions struct {
	IssueNumber int    `json:"issue_number,omitempty"`
	PRNumber    int    `json:"pr_number,omitempty"`
	Status      string `json:"status,omitempty"`
}

AddToKanbanBoardOptions specifies options for adding an item to a kanban board.

type AnnotatedTag added in v0.4.0

type AnnotatedTag struct {
	SHA     string        `json:"sha"`
	URL     string        `json:"url"`
	Tag     string        `json:"tag"`
	Message string        `json:"message"`
	Object  *GitObject    `json:"object"`
	Tagger  *CommitAuthor `json:"tagger"`
}

AnnotatedTag represents an annotated git tag.

type ArchiveStatus

type ArchiveStatus struct {
	Archived bool `json:"archived"`
}

type AuthStyle

type AuthStyle int

AuthStyle defines how authentication tokens are sent.

const (
	// AuthStyleBearer sends "Authorization: Bearer <token>" header.
	AuthStyleBearer AuthStyle = iota
	// AuthStylePrivateToken sends "PRIVATE-TOKEN: <token>" header.
	AuthStylePrivateToken
	// AuthStyleAccessToken sends "?access_token=<token>" query parameter.
	AuthStyleAccessToken
)

type Branch

type Branch struct {
	Name          string              `json:"name"`
	Commit        *BranchCommitDetail `json:"commit"`
	DefaultBranch bool                `json:"default_branch,omitempty"`
	Protected     bool                `json:"protected"`
}

type BranchCommitDetail

type BranchCommitDetail struct {
	SHA    string `json:"sha"`
	URL    string `json:"url"`
	Commit *struct {
		Author    *CommitAuthor `json:"author"`
		Committer *CommitAuthor `json:"committer"`
		Message   string        `json:"message"`
	} `json:"commit"`
}

type BranchProtection

type BranchProtection struct {
	Enabled                  bool `json:"enabled"`
	RequiredStatusChecks     bool `json:"required_status_checks"`
	RequiredApprovingReviews int  `json:"required_approving_reviews"`
	AllowForcePushes         bool `json:"allow_force_pushes"`
	AllowDeletions           bool `json:"allow_deletions"`
}

type BranchProtectionRule

type BranchProtectionRule struct {
	ID                       int64  `json:"id"`
	RepositoryID             int64  `json:"repository_id"`
	Name                     string `json:"name"`
	RequiredStatusChecks     bool   `json:"required_status_checks"`
	RequiredApprovingReviews int    `json:"required_approving_reviews"`
	AllowForcePushes         bool   `json:"allow_force_pushes"`
	AllowDeletions           bool   `json:"allow_deletions"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the GitCode API client.

func NewClient

func NewClient(token string) *Client

NewClient creates a new GitCode API client with the given token.

func NewClientFromOAuthToken

func NewClientFromOAuthToken(token *OAuthToken) *Client

func NewClientWithBaseURL

func NewClientWithBaseURL(baseURL, token string) *Client

NewClientWithBaseURL creates a new GitCode API client with a custom base URL.

func (*Client) AcceptRepoInvitation added in v0.4.0

func (c *Client) AcceptRepoInvitation(ctx context.Context, invitationID int64) error

AcceptRepoInvitation accepts a repository invitation.

PATCH /user/repository_invitations/{id}

func (*Client) AddCollaborator added in v0.4.0

func (c *Client) AddCollaborator(ctx context.Context, owner, repo, username string, opts *AddCollaboratorOptions) error

AddCollaborator adds a collaborator to a repository.

PUT /repos/{owner}/{repo}/collaborators/{username}

func (*Client) AddIssueAssignees added in v0.4.0

func (c *Client) AddIssueAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, error)

AddIssueAssignees adds assignees to an issue.

POST /repos/{owner}/{repo}/issues/{index}/assignees

func (*Client) AddIssueLabels

func (c *Client) AddIssueLabels(ctx context.Context, owner, repo string, number int, labels []string) error

func (*Client) AddPullRequestLabels

func (c *Client) AddPullRequestLabels(ctx context.Context, owner, repo string, number int, labels []string) error

func (*Client) AddRepositoryTopic added in v0.4.0

func (c *Client) AddRepositoryTopic(ctx context.Context, owner, repo, topic string) error

AddRepositoryTopic adds a single topic to a repository.

PUT /repos/{owner}/{repo}/topics/{topic}

func (*Client) AddRequestHook added in v0.6.0

func (c *Client) AddRequestHook(hook RequestHook)

AddRequestHook adds a hook that runs before each HTTP request.

func (*Client) AddResponseHook added in v0.6.0

func (c *Client) AddResponseHook(hook ResponseHook)

AddResponseHook adds a hook that runs after each HTTP response.

func (*Client) AddTeamMember added in v0.4.0

func (c *Client) AddTeamMember(ctx context.Context, teamID int64, username string) error

AddTeamMember adds a member to a team.

PUT /teams/{team_id}/members/{username}

func (*Client) AddTeamRepository added in v0.4.0

func (c *Client) AddTeamRepository(ctx context.Context, teamID int64, org, repo string) error

AddTeamRepository adds a repository to a team.

PUT /teams/{team_id}/repos/{org}/{repo}

func (*Client) AddToKanbanBoard added in v0.5.0

func (c *Client) AddToKanbanBoard(ctx context.Context, org string, boardID int64, opts AddToKanbanBoardOptions) (*KanbanBoardItem, error)

AddToKanbanBoard adds an issue or pull request to a kanban board.

POST /orgs/{org}/kanban/boards/{id}/items

func (*Client) ArchiveRepository

func (c *Client) ArchiveRepository(ctx context.Context, owner, repo string) error

func (*Client) AssignPullRequestApprovalReviewers added in v0.4.0

func (c *Client) AssignPullRequestApprovalReviewers(ctx context.Context, owner, repo string, number int, reviewers string) error

AssignPullRequestApprovalReviewers assigns users as approval reviewers for a pull request.

POST /repos/{owner}/{repo}/pulls/{number}/approval-reviewers

func (*Client) AssignPullRequestReviewers

func (c *Client) AssignPullRequestReviewers(ctx context.Context, owner, repo string, number int, assignees string) error

func (*Client) AssignPullRequestTesters

func (c *Client) AssignPullRequestTesters(ctx context.Context, owner, repo string, number int, testers string) error

func (*Client) BlockOrgUser added in v0.4.0

func (c *Client) BlockOrgUser(ctx context.Context, org, username string) error

BlockOrgUser blocks a user from an organization.

PUT /orgs/{org}/blocks/{username}

func (*Client) ClearHooks added in v0.6.0

func (c *Client) ClearHooks()

ClearHooks removes all request and response hooks.

func (*Client) CloseIssue

func (c *Client) CloseIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)

func (*Client) ClosePullRequest

func (c *Client) ClosePullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

func (*Client) CompareCommits

func (c *Client) CompareCommits(ctx context.Context, owner, repo, base, head string) (*CommitComparison, error)

func (*Client) ConcealOrgMembership added in v0.4.0

func (c *Client) ConcealOrgMembership(ctx context.Context, org, username string) error

ConcealOrgMembership makes the authenticated user's membership private.

DELETE /orgs/{org}/public_members/{username}

func (*Client) ConfigureRepoCLA added in v0.4.0

func (c *Client) ConfigureRepoCLA(ctx context.Context, owner, repo string, opts *RepoCLA) (*RepoCLA, error)

ConfigureRepoCLA configures the CLA for a repository.

PUT /repos/{owner}/{repo}/clas

func (*Client) CreateAnnotatedTag added in v0.4.0

func (c *Client) CreateAnnotatedTag(ctx context.Context, owner, repo string, opts CreateAnnotatedTagOptions) (*AnnotatedTag, error)

CreateAnnotatedTag creates a new annotated tag.

POST /repos/{owner}/{repo}/git/tags

func (*Client) CreateBranch

func (c *Client) CreateBranch(ctx context.Context, owner, repo string, opts CreateBranchOptions) (*Branch, error)

func (*Client) CreateBranchProtection

func (c *Client) CreateBranchProtection(ctx context.Context, owner, repo string, opts CreateBranchProtectionOptions) (*BranchProtectionRule, error)

func (*Client) CreateCommitComment added in v0.4.0

func (c *Client) CreateCommitComment(ctx context.Context, owner, repo, sha string, opts CreateCommitCommentOptions) (*CommitComment, error)

CreateCommitComment creates a new commit comment.

POST /repos/{owner}/{repo}/commits/{sha}/comments

func (*Client) CreateCommitStatus added in v0.4.0

func (c *Client) CreateCommitStatus(ctx context.Context, owner, repo, sha string, opts CreateCommitStatusOptions) (*CommitStatus, error)

CreateCommitStatus creates a commit status.

POST /repos/{owner}/{repo}/statuses/{sha}

func (*Client) CreateDeployKey added in v0.4.0

func (c *Client) CreateDeployKey(ctx context.Context, owner, repo string, opts CreateDeployKeyOptions) (*DeployKey, error)

CreateDeployKey creates a new deploy key for a repository.

POST /repos/{owner}/{repo}/keys

func (*Client) CreateEnterpriseLabel added in v0.5.0

func (c *Client) CreateEnterpriseLabel(ctx context.Context, enterprise string, opts CreateEnterpriseLabelOptions) (*EnterpriseLabel, error)

CreateEnterpriseLabel creates a new enterprise label.

POST /enterprises/{enterprise}/labels

func (*Client) CreateEnterpriseMilestone added in v0.5.0

func (c *Client) CreateEnterpriseMilestone(ctx context.Context, enterprise string, opts CreateEnterpriseMilestoneOptions) (*EnterpriseMilestone, error)

CreateEnterpriseMilestone creates a new enterprise milestone.

POST /enterprises/{enterprise}/milestones

func (*Client) CreateFile

func (c *Client) CreateFile(ctx context.Context, owner, repo, path string, opts CreateFileOptions) (*FileResult, error)

func (*Client) CreateGitReference added in v0.4.0

func (c *Client) CreateGitReference(ctx context.Context, owner, repo string, opts CreateReferenceOptions) (*GitReference, error)

CreateGitReference creates a new reference.

POST /repos/{owner}/{repo}/git/refs

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, owner, repo string, opts CreateIssueOptions) (*Issue, error)

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)

func (*Client) CreateIssueCommentReaction added in v0.4.0

func (c *Client) CreateIssueCommentReaction(ctx context.Context, owner, repo string, commentID int64, content string) (*Reaction, error)

CreateIssueCommentReaction adds a reaction to an issue comment.

POST /repos/{owner}/{repo}/issues/comments/{id}/reactions

func (*Client) CreateIssueDependency added in v0.4.0

func (c *Client) CreateIssueDependency(ctx context.Context, owner, repo string, number int, dependsOnNumber int) (*IssueDependency, error)

CreateIssueDependency creates a dependency between two issues.

POST /repos/{owner}/{repo}/issues/{index}/dependencies

func (*Client) CreateIssueLabel

func (c *Client) CreateIssueLabel(ctx context.Context, owner, repo string, name, color string) (*Label, error)

func (*Client) CreateIssueReaction added in v0.4.0

func (c *Client) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, error)

CreateIssueReaction adds a reaction to an issue.

POST /repos/{owner}/{repo}/issues/{index}/reactions

func (*Client) CreateMilestone

func (c *Client) CreateMilestone(ctx context.Context, owner, repo string, title, description string) (*Milestone, error)

func (*Client) CreateMilestoneWithOptions

func (c *Client) CreateMilestoneWithOptions(ctx context.Context, owner, repo string, opts CreateMilestoneOptions) (*Milestone, error)

func (*Client) CreateOrgLabel added in v0.4.0

func (c *Client) CreateOrgLabel(ctx context.Context, org string, opts CreateOrgLabelOptions) (*OrgLabel, error)

CreateOrgLabel creates a new organization label.

POST /orgs/{org}/labels

func (*Client) CreateOrgRepository

func (c *Client) CreateOrgRepository(ctx context.Context, org string, opts CreateOrgRepoOptions) (*Repository, error)

func (*Client) CreateOrgWebhook added in v0.4.0

func (c *Client) CreateOrgWebhook(ctx context.Context, org string, opts CreateOrgWebhookOptions) (*OrgWebhook, error)

CreateOrgWebhook creates a new organization webhook.

POST /orgs/{org}/hooks

func (*Client) CreateOrganization added in v0.4.0

func (c *Client) CreateOrganization(ctx context.Context, opts CreateOrgOptions) (*Organization, error)

CreateOrganization creates a new organization.

POST /orgs

func (*Client) CreateProtectedTag added in v0.5.0

func (c *Client) CreateProtectedTag(ctx context.Context, owner, repo string, opts CreateProtectedTagOptions) (*ProtectedTag, error)

CreateProtectedTag creates a new protected tag rule.

POST /repos/{owner}/{repo}/protected-tags

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, owner, repo string, opts CreatePullRequestOptions) (*PullRequest, error)

func (*Client) CreatePullRequestComment

func (c *Client) CreatePullRequestComment(ctx context.Context, owner, repo string, number int, body, path string, position, commitID string) (*PullRequestComment, error)

func (*Client) CreatePullRequestCommentReaction added in v0.4.0

func (c *Client) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID int64, content string) (*Reaction, error)

CreatePullRequestCommentReaction adds a reaction to a pull request comment.

POST /repos/{owner}/{repo}/pulls/comments/{id}/reactions

func (*Client) CreatePullRequestInlineComment

func (c *Client) CreatePullRequestInlineComment(ctx context.Context, owner, repo string, number int, opts CreatePullRequestInlineCommentOptions) (*PullRequestComment, error)

func (*Client) CreatePullRequestReview

func (c *Client) CreatePullRequestReview(ctx context.Context, owner, repo string, number int, body, event string) (*PullRequestReview, error)

func (*Client) CreateRelease

func (c *Client) CreateRelease(ctx context.Context, owner, repo string, opts CreateReleaseOptions) (*Release, error)

func (*Client) CreateRepository

func (c *Client) CreateRepository(ctx context.Context, opts CreateRepositoryOptions) (*Repository, error)

func (*Client) CreateSSHKey

func (c *Client) CreateSSHKey(ctx context.Context, opts CreateSSHKeyOptions) (*SSHKey, error)

func (*Client) CreateTag added in v0.4.0

func (c *Client) CreateTag(ctx context.Context, owner, repo string, opts CreateTagOptions) (*Tag, error)

CreateTag creates a new lightweight tag.

POST /repos/{owner}/{repo}/tags

func (*Client) CreateTeam added in v0.4.0

func (c *Client) CreateTeam(ctx context.Context, org string, opts CreateTeamOptions) (*Team, error)

CreateTeam creates a new team in an organization.

POST /orgs/{org}/teams

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, owner, repo string, opts CreateWebhookOptions) (*Webhook, error)

func (*Client) CreateWikiPage added in v0.4.0

func (c *Client) CreateWikiPage(ctx context.Context, owner, repo string, opts CreateWikiPageOptions) (*WikiPage, error)

CreateWikiPage creates a new wiki page.

POST /repos/{owner}/{repo}/wiki/new

func (*Client) DeclineRepoInvitation added in v0.4.0

func (c *Client) DeclineRepoInvitation(ctx context.Context, invitationID int64) error

DeclineRepoInvitation declines a repository invitation.

DELETE /user/repository_invitations/{id}

func (*Client) DeleteActionArtifact added in v0.5.0

func (c *Client) DeleteActionArtifact(ctx context.Context, owner, repo string, artifactID int64) error

DeleteActionArtifact deletes an artifact.

DELETE /repos/{owner}/{repo}/actions/artifacts/{id}

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(ctx context.Context, owner, repo, branch string) error

func (*Client) DeleteBranchProtection

func (c *Client) DeleteBranchProtection(ctx context.Context, owner, repo, name string) error

func (*Client) DeleteCommitComment added in v0.4.0

func (c *Client) DeleteCommitComment(ctx context.Context, owner, repo string, commentID int64) error

DeleteCommitComment deletes a commit comment.

DELETE /repos/{owner}/{repo}/comments/{id}

func (*Client) DeleteDeployKey added in v0.4.0

func (c *Client) DeleteDeployKey(ctx context.Context, owner, repo string, keyID int64) error

DeleteDeployKey deletes a deploy key.

DELETE /repos/{owner}/{repo}/keys/{id}

func (*Client) DeleteEnterpriseLabel added in v0.5.0

func (c *Client) DeleteEnterpriseLabel(ctx context.Context, enterprise string, labelID int64) error

DeleteEnterpriseLabel deletes an enterprise label.

DELETE /enterprises/{enterprise}/labels/{id}

func (*Client) DeleteEnterpriseMember added in v0.5.0

func (c *Client) DeleteEnterpriseMember(ctx context.Context, enterprise, username string) error

DeleteEnterpriseMember removes a member from an enterprise.

DELETE /enterprises/{enterprise}/members/{username}

func (*Client) DeleteEnterpriseMilestone added in v0.5.0

func (c *Client) DeleteEnterpriseMilestone(ctx context.Context, enterprise string, milestoneID int64) error

DeleteEnterpriseMilestone deletes an enterprise milestone.

DELETE /enterprises/{enterprise}/milestones/{id}

func (*Client) DeleteFile

func (c *Client) DeleteFile(ctx context.Context, owner, repo, path string, opts DeleteFileOptions) (*FileResult, error)

func (*Client) DeleteGitReference added in v0.4.0

func (c *Client) DeleteGitReference(ctx context.Context, owner, repo, ref string) error

DeleteGitReference deletes a reference.

DELETE /repos/{owner}/{repo}/git/refs/{ref}

func (*Client) DeleteIssueComment

func (c *Client) DeleteIssueComment(ctx context.Context, owner, repo string, commentID int64) error

func (*Client) DeleteIssueCommentReaction added in v0.4.0

func (c *Client) DeleteIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) error

DeleteIssueCommentReaction removes a reaction from an issue comment.

DELETE /repos/{owner}/{repo}/issues/comments/{id}/reactions/{id}

func (*Client) DeleteIssueDependency added in v0.4.0

func (c *Client) DeleteIssueDependency(ctx context.Context, owner, repo string, number int, dependencyNumber int) error

DeleteIssueDependency removes a dependency between two issues.

DELETE /repos/{owner}/{repo}/issues/{index}/dependencies/{dependency}

func (*Client) DeleteIssueLabel

func (c *Client) DeleteIssueLabel(ctx context.Context, owner, repo string, name string) error

func (*Client) DeleteIssueReaction added in v0.4.0

func (c *Client) DeleteIssueReaction(ctx context.Context, owner, repo string, number int, reactionID int64) error

DeleteIssueReaction removes a reaction from an issue.

DELETE /repos/{owner}/{repo}/issues/{index}/reactions/{id}

func (*Client) DeleteMilestone

func (c *Client) DeleteMilestone(ctx context.Context, owner, repo string, number int) error

func (*Client) DeleteOrgLabel added in v0.4.0

func (c *Client) DeleteOrgLabel(ctx context.Context, org string, labelID int64) error

DeleteOrgLabel deletes an organization label.

DELETE /orgs/{org}/labels/{id}

func (*Client) DeleteOrgWebhook added in v0.4.0

func (c *Client) DeleteOrgWebhook(ctx context.Context, org string, hookID int64) error

DeleteOrgWebhook deletes an organization webhook.

DELETE /orgs/{org}/hooks/{id}

func (*Client) DeleteOrganization added in v0.4.0

func (c *Client) DeleteOrganization(ctx context.Context, org string) error

DeleteOrganization deletes an organization.

DELETE /orgs/{org}

func (*Client) DeleteProtectedTag added in v0.5.0

func (c *Client) DeleteProtectedTag(ctx context.Context, owner, repo, tag string) error

DeleteProtectedTag deletes a protected tag rule.

DELETE /repos/{owner}/{repo}/protected-tags/{tag}

func (*Client) DeletePullRequestComment

func (c *Client) DeletePullRequestComment(ctx context.Context, owner, repo string, commentID string) error

func (*Client) DeletePullRequestCommentReaction added in v0.4.0

func (c *Client) DeletePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) error

DeletePullRequestCommentReaction removes a reaction from a pull request comment.

DELETE /repos/{owner}/{repo}/pulls/comments/{id}/reactions/{id}

func (*Client) DeleteRelease

func (c *Client) DeleteRelease(ctx context.Context, owner, repo string, tagName string) error

func (*Client) DeleteReleaseAsset added in v0.4.0

func (c *Client) DeleteReleaseAsset(ctx context.Context, owner, repo string, assetID int64) error

DeleteReleaseAsset deletes a release asset.

DELETE /repos/{owner}/{repo}/releases/assets/{id}

func (*Client) DeleteReleaseByID added in v0.4.0

func (c *Client) DeleteReleaseByID(ctx context.Context, owner, repo string, releaseID int64) error

DeleteReleaseByID deletes a release by ID.

DELETE /repos/{owner}/{repo}/releases/{id}

func (*Client) DeleteRepository

func (c *Client) DeleteRepository(ctx context.Context, owner, repo string) error

func (*Client) DeleteRepositoryTopic added in v0.4.0

func (c *Client) DeleteRepositoryTopic(ctx context.Context, owner, repo, topic string) error

DeleteRepositoryTopic removes a single topic from a repository.

DELETE /repos/{owner}/{repo}/topics/{topic}

func (*Client) DeleteSSHKey

func (c *Client) DeleteSSHKey(ctx context.Context, id int64) error

func (*Client) DeleteTag

func (c *Client) DeleteTag(ctx context.Context, owner, repo, tagName string) error

func (*Client) DeleteTeam added in v0.4.0

func (c *Client) DeleteTeam(ctx context.Context, teamID int64) error

DeleteTeam deletes a team.

DELETE /teams/{team_id}

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, owner, repo string, hookID int64) error

func (*Client) DeleteWikiPage added in v0.4.0

func (c *Client) DeleteWikiPage(ctx context.Context, owner, repo, pageName string) error

DeleteWikiPage deletes a wiki page.

DELETE /repos/{owner}/{repo}/wiki/page/{pageName}

func (*Client) DismissPullRequestReview added in v0.4.0

func (c *Client) DismissPullRequestReview(ctx context.Context, owner, repo string, number int, reviewID int64, message string) error

DismissPullRequestReview dismisses a pull request review.

PUT /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/dismissals

func (*Client) DownloadActionArtifact added in v0.5.0

func (c *Client) DownloadActionArtifact(ctx context.Context, owner, repo string, artifactID int64) ([]byte, error)

DownloadActionArtifact downloads an artifact.

GET /repos/{owner}/{repo}/actions/artifacts/{id}/download

func (*Client) DownloadReleaseAsset added in v0.5.0

func (c *Client) DownloadReleaseAsset(ctx context.Context, owner, repo string, assetID int64) ([]byte, error)

DownloadReleaseAsset downloads a release asset by ID.

GET /repos/{owner}/{repo}/releases/assets/{id}

func (*Client) DownloadRepository added in v0.4.0

func (c *Client) DownloadRepository(ctx context.Context, owner, repo, format string) ([]byte, error)

DownloadRepository downloads a repository as a zip or tarball.

GET /repos/{owner}/{repo}/{format}

func (*Client) ExitOrganization

func (c *Client) ExitOrganization(ctx context.Context, org string) error

func (*Client) FollowUser added in v0.4.0

func (c *Client) FollowUser(ctx context.Context, username string) error

FollowUser follows a user.

PUT /user/following/{username}

func (*Client) ForkRepository

func (c *Client) ForkRepository(ctx context.Context, owner, repo string, opts *CreateRepositoryOptions) (*Repository, error)

func (*Client) GenerateRepositoryArchive added in v0.4.0

func (c *Client) GenerateRepositoryArchive(ctx context.Context, owner, repo, ref, format string) ([]byte, error)

GenerateRepositoryArchive generates a repository archive.

GET /repos/{owner}/{repo}/archive

func (*Client) GetActionArtifact added in v0.5.0

func (c *Client) GetActionArtifact(ctx context.Context, owner, repo string, artifactID int64) (*ActionArtifact, error)

GetActionArtifact gets a single artifact.

GET /repos/{owner}/{repo}/actions/artifacts/{id}

func (*Client) GetActionJob added in v0.5.0

func (c *Client) GetActionJob(ctx context.Context, owner, repo string, jobID int64) (*ActionJob, error)

GetActionJob gets a single workflow job.

GET /repos/{owner}/{repo}/actions/jobs/{id}

func (*Client) GetActionJobLogs added in v0.5.0

func (c *Client) GetActionJobLogs(ctx context.Context, owner, repo string, jobID int64) ([]byte, error)

GetActionJobLogs gets the logs for a workflow job.

GET /repos/{owner}/{repo}/actions/jobs/{id}/logs

func (*Client) GetActionJobStepLogs added in v0.5.0

func (c *Client) GetActionJobStepLogs(ctx context.Context, owner, repo string, jobID int64) ([]byte, error)

GetActionJobStepLogs gets the step-level logs for a workflow job.

GET /repos/{owner}/{repo}/actions/jobs/{id}/logs/step

func (*Client) GetActionRun added in v0.5.0

func (c *Client) GetActionRun(ctx context.Context, owner, repo string, runID int64) (*ActionRun, error)

GetActionRun gets a single workflow run.

GET /repos/{owner}/{repo}/actions/runs/{id}

func (*Client) GetAnnotatedTag added in v0.4.0

func (c *Client) GetAnnotatedTag(ctx context.Context, owner, repo, sha string) (*AnnotatedTag, error)

GetAnnotatedTag gets an annotated tag by SHA.

GET /repos/{owner}/{repo}/git/tags/{sha}

func (*Client) GetArchiveStatus

func (c *Client) GetArchiveStatus(ctx context.Context, owner, repo string) (*ArchiveStatus, error)

func (*Client) GetBlob

func (c *Client) GetBlob(ctx context.Context, owner, repo, sha string) (*GitBlob, error)

func (*Client) GetBranch

func (c *Client) GetBranch(ctx context.Context, owner, repo, branch string) (*Branch, error)

func (*Client) GetCollaboratorPermission added in v0.4.0

func (c *Client) GetCollaboratorPermission(ctx context.Context, owner, repo, username string) (*CollaboratorPermission, error)

GetCollaboratorPermission gets the permission of a collaborator for a repository.

GET /repos/{owner}/{repo}/collaborators/{username}/permission

func (*Client) GetCombinedStatus added in v0.4.0

func (c *Client) GetCombinedStatus(ctx context.Context, owner, repo, sha string) (*CombinedStatus, error)

GetCombinedStatus gets the combined status for a commit.

GET /repos/{owner}/{repo/commits/{sha}/status

func (*Client) GetCommit

func (c *Client) GetCommit(ctx context.Context, owner, repo, sha string) (*Commit, error)

func (*Client) GetCommitComment added in v0.4.0

func (c *Client) GetCommitComment(ctx context.Context, owner, repo string, commentID int64) (*CommitComment, error)

GetCommitComment gets a single commit comment.

GET /repos/{owner}/{repo}/comments/{id}

func (*Client) GetCommitDiff added in v0.5.0

func (c *Client) GetCommitDiff(ctx context.Context, owner, repo, sha string) ([]byte, error)

GetCommitDiff returns the diff of a commit.

GET /repos/{owner}/{repo}/commits/{sha}.diff

func (*Client) GetCommitPatch added in v0.5.0

func (c *Client) GetCommitPatch(ctx context.Context, owner, repo, sha string) ([]byte, error)

GetCommitPatch returns the patch of a commit.

GET /repos/{owner}/{repo}/commits/{sha}.patch

func (*Client) GetContributorStatistics

func (c *Client) GetContributorStatistics(ctx context.Context, owner, repo string) ([]*ContributorStatistic, error)

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser(ctx context.Context) (*User, error)

GetCurrentUser returns the authenticated user's profile.

func (*Client) GetCustomizedRoles

func (c *Client) GetCustomizedRoles(ctx context.Context, owner, repo string) ([]*CustomizedRole, error)

func (*Client) GetDeployKey added in v0.4.0

func (c *Client) GetDeployKey(ctx context.Context, owner, repo string, keyID int64) (*DeployKey, error)

GetDeployKey gets a single deploy key.

GET /repos/{owner}/{repo}/keys/{id}

func (*Client) GetDiscussion added in v0.4.0

func (c *Client) GetDiscussion(ctx context.Context, owner, repo string, number int) (*Discussion, error)

GetDiscussion gets a single discussion by number.

GET /repos/{owner}/{repo}/discuss/{number}

func (*Client) GetDownloadStatistics

func (c *Client) GetDownloadStatistics(ctx context.Context, owner, repo string) ([]*DownloadStatistic, error)

func (*Client) GetEnterpriseIssue

func (c *Client) GetEnterpriseIssue(ctx context.Context, enterprise string, number int) (*Issue, error)

func (*Client) GetEnterpriseIssueLinkedPRs

func (c *Client) GetEnterpriseIssueLinkedPRs(ctx context.Context, enterprise string, number int) ([]*PullRequest, error)

func (*Client) GetEnterpriseMember

func (c *Client) GetEnterpriseMember(ctx context.Context, enterprise, username string) (*EnterpriseMember, error)

func (*Client) GetEnterpriseMilestone added in v0.5.0

func (c *Client) GetEnterpriseMilestone(ctx context.Context, enterprise string, milestoneID int64) (*EnterpriseMilestone, error)

GetEnterpriseMilestone gets a single enterprise milestone.

GET /enterprises/{enterprise}/milestones/{id}

func (*Client) GetExtendedUser added in v0.4.0

func (c *Client) GetExtendedUser(ctx context.Context, username string) (*ExtendedUser, error)

GetExtendedUser gets extended information about a user.

GET /users/{username}

func (*Client) GetForkSyncStatus added in v0.4.0

func (c *Client) GetForkSyncStatus(ctx context.Context, owner, repo string) (*ForkSyncStatus, error)

GetForkSyncStatus checks the sync status of a forked repository.

GET /repos/{owner}/{repo}/sync-repo

func (*Client) GetGitReference added in v0.4.0

func (c *Client) GetGitReference(ctx context.Context, owner, repo, ref string) (*GitReference, error)

GetGitReference gets a single reference.

GET /repos/{owner}/{repo}/git/refs/{ref}

func (*Client) GetGitignoreTemplate added in v0.4.0

func (c *Client) GetGitignoreTemplate(ctx context.Context, name string) (*GitignoreTemplate, error)

GetGitignoreTemplate gets a gitignore template by name.

GET /gitignore/templates/{name}

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)

func (*Client) GetIssueComment

func (c *Client) GetIssueComment(ctx context.Context, owner, repo string, commentID int64) (*IssueComment, error)

func (*Client) GetIssueLinkedPRs

func (c *Client) GetIssueLinkedPRs(ctx context.Context, owner, repo string, number int) ([]*PullRequest, error)

func (*Client) GetIssueOperateLogs

func (c *Client) GetIssueOperateLogs(ctx context.Context, owner, repo string, number int) ([]*IssueOperateLog, error)

func (*Client) GetIssueTemplate added in v0.4.0

func (c *Client) GetIssueTemplate(ctx context.Context, owner, repo, name string) (*IssueTemplate, error)

GetIssueTemplate gets a single issue template by name.

GET /repos/{owner}/{repo}/issue_templates/{name}

func (*Client) GetKanbanBoard added in v0.5.0

func (c *Client) GetKanbanBoard(ctx context.Context, org string, boardID int64) (*KanbanBoard, error)

GetKanbanBoard gets a single kanban board.

GET /orgs/{org}/kanban/boards/{id}

func (*Client) GetLabelTemplate added in v0.4.0

func (c *Client) GetLabelTemplate(ctx context.Context, name string) ([]*Label, error)

GetLabelTemplate gets a label template by name.

GET /label/templates/{name}

func (*Client) GetLanguages

func (c *Client) GetLanguages(ctx context.Context, owner, repo string) (Language, error)

func (*Client) GetLatestRelease added in v0.5.0

func (c *Client) GetLatestRelease(ctx context.Context, owner, repo string) (*Release, error)

GetLatestRelease gets the latest release for a repository.

GET /repos/{owner}/{repo}/releases/latest

func (*Client) GetLicenseTemplate added in v0.4.0

func (c *Client) GetLicenseTemplate(ctx context.Context, name string) (*LicenseTemplate, error)

GetLicenseTemplate gets a license template by key.

GET /licenses/{name}

func (*Client) GetMilestone

func (c *Client) GetMilestone(ctx context.Context, owner, repo string, number int) (*Milestone, error)

func (*Client) GetNamespace

func (c *Client) GetNamespace(ctx context.Context, path string) (*Namespace, error)

func (*Client) GetNotificationThread added in v0.4.0

func (c *Client) GetNotificationThread(ctx context.Context, threadID int64) (*NotificationThread, error)

GetNotificationThread gets a single notification thread.

GET /notifications/threads/{id}

func (*Client) GetOrgDiscussion added in v0.4.0

func (c *Client) GetOrgDiscussion(ctx context.Context, org string, number int) (*OrgDiscussion, error)

GetOrgDiscussion gets a single organization discussion by number.

GET /orgs/{org}/discuss/{number}

func (*Client) GetOrgEnterprise added in v0.5.0

func (c *Client) GetOrgEnterprise(ctx context.Context, org string) (*OrgEnterprise, error)

GetOrgEnterprise gets the enterprise associated with an organization.

GET /orgs/{org}/enterprise

func (*Client) GetOrgInfo

func (c *Client) GetOrgInfo(ctx context.Context, org string) (*Organization, error)

func (*Client) GetOrgIssueExtendSettings

func (c *Client) GetOrgIssueExtendSettings(ctx context.Context, org string) ([]*IssueExtendSetting, error)

func (*Client) GetOrgLabel added in v0.4.0

func (c *Client) GetOrgLabel(ctx context.Context, org string, labelID int64) (*OrgLabel, error)

GetOrgLabel gets a single organization label.

GET /orgs/{org}/labels/{id}

func (*Client) GetOrgMemberDetail

func (c *Client) GetOrgMemberDetail(ctx context.Context, org, username string) (*OrgMemberDetail, error)

func (*Client) GetOrgWebhook added in v0.4.0

func (c *Client) GetOrgWebhook(ctx context.Context, org string, hookID int64) (*OrgWebhook, error)

GetOrgWebhook gets a single organization webhook.

GET /orgs/{org}/hooks/{id}

func (*Client) GetOrganization

func (c *Client) GetOrganization(ctx context.Context, org string) (*Organization, error)

func (*Client) GetPRSettings

func (c *Client) GetPRSettings(ctx context.Context, owner, repo string) (*PRSettings, error)

func (*Client) GetProtectedTag added in v0.5.0

func (c *Client) GetProtectedTag(ctx context.Context, owner, repo, tag string) (*ProtectedTag, error)

GetProtectedTag gets a single protected tag rule.

GET /repos/{owner}/{repo}/protected-tags/{tag}

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

func (*Client) GetPullRequestComment

func (c *Client) GetPullRequestComment(ctx context.Context, owner, repo string, commentID int64) (*PullRequestComment, error)

func (*Client) GetPullRequestDiff added in v0.4.0

func (c *Client) GetPullRequestDiff(ctx context.Context, owner, repo string, number int) ([]byte, error)

GetPullRequestDiff returns the diff of a pull request.

GET /repos/{owner}/{repo}/pulls/{index}.diff

func (*Client) GetPullRequestLinkedIssues

func (c *Client) GetPullRequestLinkedIssues(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*Issue, error)

func (*Client) GetPullRequestOperateLogs

func (c *Client) GetPullRequestOperateLogs(ctx context.Context, owner, repo string, number int) ([]*PROperateLog, error)

func (*Client) GetPullRequestPatch added in v0.4.0

func (c *Client) GetPullRequestPatch(ctx context.Context, owner, repo string, number int) ([]byte, error)

GetPullRequestPatch returns the patch of a pull request.

GET /repos/{owner}/{repo}/pulls/{index}.patch

func (*Client) GetPullRequestReview added in v0.4.0

func (c *Client) GetPullRequestReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, error)

GetPullRequestReview gets a single pull request review.

GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}

func (*Client) GetPushConfig

func (c *Client) GetPushConfig(ctx context.Context, owner, repo string) (*PushConfig, error)

func (*Client) GetRateLimit

func (c *Client) GetRateLimit(ctx context.Context) (*RateLimit, error)

GetRateLimit returns the current rate limit status.

func (*Client) GetRawFile

func (c *Client) GetRawFile(ctx context.Context, owner, repo, path, ref string) ([]byte, error)

func (*Client) GetRelease added in v0.4.0

func (c *Client) GetRelease(ctx context.Context, owner, repo string, releaseID int64) (*Release, error)

GetRelease gets a single release by ID.

GET /repos/{owner}/{repo}/releases/{id}

func (*Client) GetReleaseAsset added in v0.4.0

func (c *Client) GetReleaseAsset(ctx context.Context, owner, repo string, assetID int64) (*ReleaseAsset, error)

GetReleaseAsset gets a single release asset.

GET /repos/{owner}/{repo}/releases/assets/{id}

func (*Client) GetReleaseByTag added in v0.4.0

func (c *Client) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*Release, error)

GetReleaseByTag gets a release by its tag name.

GET /repos/{owner}/{repo}/releases/tags/{tag}

func (*Client) GetReleaseUploadURL added in v0.5.0

func (c *Client) GetReleaseUploadURL(ctx context.Context, owner, repo string, releaseID int64, name, label string) (*ReleaseUploadURL, error)

GetReleaseUploadURL gets the upload URL for a release asset.

POST /repos/{owner}/{repo}/releases/{id}/assets/upload_url

func (*Client) GetRepoBranchDetail added in v0.4.0

func (c *Client) GetRepoBranchDetail(ctx context.Context, owner, repo, branch string) (*RepoBranchInfo, error)

GetRepoBranch gets a single branch with full details.

GET /repos/{owner}/{repo}/branches/{branch}

func (*Client) GetRepoCodeFrequency added in v0.4.0

func (c *Client) GetRepoCodeFrequency(ctx context.Context, owner, repo string) ([]CodeFrequencyEntry, error)

GetRepoCodeFrequency returns a weekly aggregate of the number of additions and deletions.

GET /repos/{owner}/{repo}/stats/code_frequency

func (*Client) GetRepoCommitActivity added in v0.4.0

func (c *Client) GetRepoCommitActivity(ctx context.Context, owner, repo string) ([]*CommitActivity, error)

GetRepoCommitActivity returns a weekly aggregate of the number of commits.

GET /repos/{owner}/{repo}/stats/commit_activity

func (*Client) GetRepoLicense added in v0.4.0

func (c *Client) GetRepoLicense(ctx context.Context, owner, repo string) (*RepoLicense, error)

GetRepoLicense gets the license of a repository.

GET /repos/{owner}/{repo}/license

func (*Client) GetRepoParticipation added in v0.4.0

func (c *Client) GetRepoParticipation(ctx context.Context, owner, repo string) (*ParticipationStats, error)

GetRepoParticipation returns the total commit counts for the owner and all contributors.

GET /repos/{owner}/{repo}/stats/participation

func (*Client) GetRepoPunchCard added in v0.4.0

func (c *Client) GetRepoPunchCard(ctx context.Context, owner, repo string) ([]PunchCardEntry, error)

GetRepoPunchCard returns the number of commits per hour in each day.

GET /repos/{owner}/{repo}/stats/punch_card

func (*Client) GetRepoRemoteMirror added in v0.4.0

func (c *Client) GetRepoRemoteMirror(ctx context.Context, owner, repo string) (*RemoteMirror, error)

GetRepoRemoteMirror gets the remote mirror configuration of a repository.

GET /repos/{owner}/{repo}/repo-remote-mirror

func (*Client) GetRepoSettings

func (c *Client) GetRepoSettings(ctx context.Context, owner, repo string) (*RepoSettings, error)

func (*Client) GetRepoVisibility added in v0.4.0

func (c *Client) GetRepoVisibility(ctx context.Context, owner, repo string) (bool, error)

GetRepoVisibility returns whether a repository is public or private.

GET /repos/{owner}/{repo}

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, owner, repo string) (*Repository, error)

func (*Client) GetRepositoryArchive added in v0.4.0

func (c *Client) GetRepositoryArchive(ctx context.Context, owner, repo, archive string) ([]byte, error)

GetRepositoryArchive downloads a repository archive (tar.gz, zip, etc.).

GET /repos/{owner}/{repo}/archive/{archive}

func (*Client) GetRepositoryContent

func (c *Client) GetRepositoryContent(ctx context.Context, owner, repo, path, ref string) (*RepositoryContent, error)

func (*Client) GetRunnerGroup added in v0.5.0

func (c *Client) GetRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, error)

GetRunnerGroup gets a single runner group.

GET /orgs/{org}/actions/runner-groups/{id}

func (*Client) GetSSHKey

func (c *Client) GetSSHKey(ctx context.Context, id int64) (*SSHKey, error)

func (*Client) GetTag added in v0.4.0

func (c *Client) GetTag(ctx context.Context, owner, repo, tagName string) (*Tag, error)

GetTag gets a single tag by name.

GET /repos/{owner}/{repo}/tags/{tag}

func (*Client) GetTeam added in v0.4.0

func (c *Client) GetTeam(ctx context.Context, teamID int64) (*Team, error)

GetTeam gets a team by ID.

GET /teams/{team_id}

func (*Client) GetTeamMember added in v0.4.0

func (c *Client) GetTeamMember(ctx context.Context, teamID int64, username string) (*User, error)

GetTeamMember gets a team member.

GET /teams/{team_id}/members/{username}

func (*Client) GetTree

func (c *Client) GetTree(ctx context.Context, owner, repo, sha string, recursive bool) (*GitTree, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, username string) (*User, error)

GetUser returns a user by username.

func (*Client) GetUserEvents

func (c *Client) GetUserEvents(ctx context.Context, username, year, next string) (*UserEventsResponse, error)

func (*Client) GetUserMembership

func (c *Client) GetUserMembership(ctx context.Context, org string) (*UserMembership, error)

func (*Client) GetWebhook

func (c *Client) GetWebhook(ctx context.Context, owner, repo string, hookID int64) (*Webhook, error)

func (*Client) GetWikiPage added in v0.4.0

func (c *Client) GetWikiPage(ctx context.Context, owner, repo, pageName string) (*WikiPage, error)

GetWikiPage gets a single wiki page by title.

GET /repos/{owner}/{repo}/wiki/page/{pageName}

func (*Client) HandlePullRequestReview

func (c *Client) HandlePullRequestReview(ctx context.Context, owner, repo string, number int, force bool) error

func (*Client) HandlePullRequestTest

func (c *Client) HandlePullRequestTest(ctx context.Context, owner, repo string, number int, force bool) error

func (*Client) InviteEnterpriseMember added in v0.5.0

func (c *Client) InviteEnterpriseMember(ctx context.Context, enterprise string, username string, opts InviteMemberOptions) error

InviteEnterpriseMember invites a user to an enterprise.

POST /enterprises/{enterprise}/members

func (*Client) InviteOrgMember

func (c *Client) InviteOrgMember(ctx context.Context, org, username string, opts InviteMemberOptions) (*User, error)

func (*Client) IsCollaborator added in v0.4.0

func (c *Client) IsCollaborator(ctx context.Context, owner, repo, username string) (bool, error)

IsCollaborator checks if a user is a collaborator of a repository.

GET /repos/{owner}/{repo}/collaborators/{username}

func (*Client) IsFollowing added in v0.4.0

func (c *Client) IsFollowing(ctx context.Context, username string) (bool, error)

IsFollowing checks if the authenticated user is following a user.

GET /user/following/{username}

func (*Client) IsOrgBlockedUser added in v0.4.0

func (c *Client) IsOrgBlockedUser(ctx context.Context, org, username string) (bool, error)

IsOrgBlockedUser checks if a user is blocked by an organization.

GET /orgs/{org}/blocks/{username}

func (*Client) IsOrgPublicMember added in v0.4.0

func (c *Client) IsOrgPublicMember(ctx context.Context, org, username string) (bool, error)

IsOrgPublicMember checks if a user is a public member of an organization.

GET /orgs/{org}/public_members/{username}

func (*Client) IsPullRequestMerged

func (c *Client) IsPullRequestMerged(ctx context.Context, owner, repo string, number int) (bool, error)

func (*Client) IsRepoAssignee added in v0.4.0

func (c *Client) IsRepoAssignee(ctx context.Context, owner, repo, username string) (bool, error)

IsRepoAssignee checks if a user is an assignee for issues in a repository.

GET /repos/{owner}/{repo}/assignees/{username}

func (*Client) IsRepositoryStarred

func (c *Client) IsRepositoryStarred(ctx context.Context, owner, repo string) (bool, error)

func (*Client) LinkPullRequestIssue added in v0.4.0

func (c *Client) LinkPullRequestIssue(ctx context.Context, owner, repo string, number int, issueNumber int) error

LinkPullRequestIssue links an issue to a pull request.

POST /repos/{owner}/{repo}/pulls/{number}/linked-issues

func (*Client) ListActionArtifacts added in v0.5.0

func (c *Client) ListActionArtifacts(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionArtifact, error)

ListActionArtifacts lists all artifacts for a repository.

GET /repos/{owner}/{repo}/actions/artifacts

func (*Client) ListActionJobs added in v0.5.0

func (c *Client) ListActionJobs(ctx context.Context, owner, repo string, runID int64, opts ListOptions) ([]*ActionJob, error)

ListActionJobs lists all jobs for a workflow run.

GET /repos/{owner}/{repo}/actions/runs/{id}/jobs

func (*Client) ListActionRunArtifacts added in v0.5.0

func (c *Client) ListActionRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts ListOptions) ([]*ActionArtifact, error)

ListActionRunArtifacts lists all artifacts for a specific workflow run.

GET /repos/{owner}/{repo}/actions/runs/{id}/artifacts

func (*Client) ListActionRuns added in v0.5.0

func (c *Client) ListActionRuns(ctx context.Context, owner, repo string, opts ListActionRunsOptions) ([]*ActionRun, error)

ListActionRuns lists all workflow runs for a repository.

GET /repos/{owner}/{repo}/actions/runs

func (*Client) ListActionWorkflows added in v0.5.0

func (c *Client) ListActionWorkflows(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionWorkflow, error)

ListActionWorkflows lists all workflows for a repository.

GET /repos/{owner}/{repo}/actions/workflows

func (*Client) ListBranchProtections

func (c *Client) ListBranchProtections(ctx context.Context, owner, repo string) ([]*BranchProtectionRule, error)

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context, owner, repo string) ([]*Branch, error)

func (*Client) ListCollaborators added in v0.4.0

func (c *Client) ListCollaborators(ctx context.Context, owner, repo string, opts ListOptions) ([]*Collaborator, error)

ListCollaborators lists all collaborators of a repository.

GET /repos/{owner}/{repo}/collaborators

func (*Client) ListCommitComments added in v0.4.0

func (c *Client) ListCommitComments(ctx context.Context, owner, repo, sha string, opts ListOptions) ([]*CommitComment, error)

ListCommitComments lists all comments for a commit.

GET /repos/{owner}/{repo}/commits/{sha}/comments

func (*Client) ListCommitStatuses added in v0.4.0

func (c *Client) ListCommitStatuses(ctx context.Context, owner, repo, sha string, opts ListOptions) ([]*CommitStatus, error)

ListCommitStatuses lists all statuses for a commit.

GET /repos/{owner}/{repo}/statuses/{sha}

func (*Client) ListCommits

func (c *Client) ListCommits(ctx context.Context, owner, repo string, opts ListCommitsOptions) ([]*Commit, error)

func (*Client) ListContributors

func (c *Client) ListContributors(ctx context.Context, owner, repo string) ([]*Contributor, error)

func (*Client) ListCurrentUserFollowers added in v0.4.0

func (c *Client) ListCurrentUserFollowers(ctx context.Context, opts ListOptions) ([]*User, error)

ListCurrentUserFollowers lists the followers of the authenticated user.

GET /user/followers

func (*Client) ListCurrentUserFollowing added in v0.4.0

func (c *Client) ListCurrentUserFollowing(ctx context.Context, opts ListOptions) ([]*User, error)

ListCurrentUserFollowing lists the users that the authenticated user is following.

GET /user/following

func (*Client) ListCurrentUserRepositories added in v0.4.0

func (c *Client) ListCurrentUserRepositories(ctx context.Context, opts ListRepositoriesOptions) ([]*Repository, error)

ListCurrentUserRepositories lists the authenticated user's repositories.

GET /user/repos

func (*Client) ListCurrentUserWatchedRepositories added in v0.4.0

func (c *Client) ListCurrentUserWatchedRepositories(ctx context.Context, opts ListOptions) ([]*Repository, error)

ListCurrentUserWatchedRepositories lists repositories watched by the authenticated user.

GET /user/subscriptions

func (*Client) ListDeployKeys added in v0.4.0

func (c *Client) ListDeployKeys(ctx context.Context, owner, repo string, opts ListOptions) ([]*DeployKey, error)

ListDeployKeys lists all deploy keys of a repository.

GET /repos/{owner}/{repo}/keys

func (*Client) ListDiscussionCommentReplies added in v0.4.0

func (c *Client) ListDiscussionCommentReplies(ctx context.Context, owner, repo string, number int, commentID int64, opts ListOptions) ([]*DiscussionCommentReply, error)

ListDiscussionCommentReplies lists all replies for a discussion comment.

GET /repos/{owner}/{repo}/discuss/{number}/comment/{comment_id}/reply

func (*Client) ListDiscussionComments added in v0.4.0

func (c *Client) ListDiscussionComments(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*DiscussionComment, error)

ListDiscussionComments lists all comments for a discussion.

GET /repos/{owner}/{repo}/discuss/{number}/comment

func (*Client) ListDiscussions added in v0.4.0

func (c *Client) ListDiscussions(ctx context.Context, owner, repo string, opts ListOptions) ([]*Discussion, error)

ListDiscussions lists all discussions for a repository.

GET /repos/{owner}/{repo}/discuss

func (*Client) ListEmails

func (c *Client) ListEmails(ctx context.Context) ([]*Email, error)

func (*Client) ListEnterpriseCustomizedRoles added in v0.5.0

func (c *Client) ListEnterpriseCustomizedRoles(ctx context.Context, enterprise string) ([]*EnterpriseCustomizedRole, error)

ListEnterpriseCustomizedRoles lists all customized roles for an enterprise.

GET /enterprises/{enterprise}/customized-roles

func (*Client) ListEnterpriseIssueComments

func (c *Client) ListEnterpriseIssueComments(ctx context.Context, enterprise string, number int, opts ListOptions) ([]*IssueComment, error)

func (*Client) ListEnterpriseIssueCustomFields added in v0.5.0

func (c *Client) ListEnterpriseIssueCustomFields(ctx context.Context, enterprise string) ([]*IssueCustomField, error)

ListEnterpriseIssueCustomFields lists all custom fields for enterprise issues.

GET /enterprises/{enterprise}/issue-custom-fields

func (*Client) ListEnterpriseIssueLabels

func (c *Client) ListEnterpriseIssueLabels(ctx context.Context, enterprise string, issueID int64) ([]*Label, error)

func (*Client) ListEnterpriseIssueStatuses added in v0.4.0

func (c *Client) ListEnterpriseIssueStatuses(ctx context.Context, enterprise string) ([]*EnterpriseIssueStatus, error)

ListEnterpriseIssueStatuses lists all enterprise issue statuses.

GET /enterprises/{enterprise}/issue-statuses

func (*Client) ListEnterpriseIssues

func (c *Client) ListEnterpriseIssues(ctx context.Context, enterprise string, opts ListUserIssuesOptions) ([]*Issue, error)

func (*Client) ListEnterpriseLabels

func (c *Client) ListEnterpriseLabels(ctx context.Context, enterprise string) ([]*EnterpriseLabel, error)

func (*Client) ListEnterpriseMembers

func (c *Client) ListEnterpriseMembers(ctx context.Context, enterprise, role string, opts ListOptions) ([]*EnterpriseMember, error)

func (*Client) ListEnterpriseMilestoneRepos added in v0.5.0

func (c *Client) ListEnterpriseMilestoneRepos(ctx context.Context, enterprise string, milestoneID int64, opts ListOptions) ([]*Repository, error)

ListEnterpriseMilestoneRepos lists repositories that can be associated with an enterprise milestone.

GET /enterprises/{enterprise}/milestones/{id}/repos

func (*Client) ListEnterpriseMilestones added in v0.5.0

func (c *Client) ListEnterpriseMilestones(ctx context.Context, enterprise string, opts ListMilestonesOptions) ([]*EnterpriseMilestone, error)

ListEnterpriseMilestones lists all milestones for an enterprise.

GET /enterprises/{enterprise}/milestones

func (*Client) ListEnterprisePullRequests

func (c *Client) ListEnterprisePullRequests(ctx context.Context, enterprise string, opts ListEnterprisePRsOptions) ([]*PullRequest, error)

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, owner, repo string) ([]*FileListEntry, error)

func (*Client) ListForks

func (c *Client) ListForks(ctx context.Context, owner, repo string, opts ListOptions) ([]*Repository, error)

func (*Client) ListGitRefSubPaths added in v0.4.0

func (c *Client) ListGitRefSubPaths(ctx context.Context, owner, repo, refPrefix string) ([]*GitReference, error)

ListGitRefSubPaths lists references filtered by prefix (e.g. "heads/", "tags/").

GET /repos/{owner}/{repo}/git/refs/{refPrefix}

func (*Client) ListGitReferences added in v0.4.0

func (c *Client) ListGitReferences(ctx context.Context, owner, repo string, opts ListOptions) ([]*GitReference, error)

ListGitReferences lists all references of a repository.

GET /repos/{owner}/{repo}/git/refs

func (*Client) ListGitignoreTemplates added in v0.4.0

func (c *Client) ListGitignoreTemplates(ctx context.Context) ([]string, error)

ListGitignoreTemplates lists all available gitignore templates.

GET /gitignore/templates

func (*Client) ListIssueBlockingIssues added in v0.4.0

func (c *Client) ListIssueBlockingIssues(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*Issue, error)

ListIssueBlockingIssues lists all issues that this issue blocks.

GET /repos/{owner}/{repo}/issues/{index}/blocks

func (*Client) ListIssueCommentModifyHistory added in v0.4.0

func (c *Client) ListIssueCommentModifyHistory(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*ModifyHistoryEntry, error)

ListIssueCommentModifyHistory lists the modification history of an issue comment.

GET /repos/{owner}/{repo}/issues/comment/{comment_id}/modify-history

func (*Client) ListIssueCommentReactions added in v0.4.0

func (c *Client) ListIssueCommentReactions(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*Reaction, error)

ListIssueCommentReactions lists all reactions for an issue comment.

GET /repos/{owner}/{repo}/issues/comments/{id}/reactions

func (*Client) ListIssueCommentUserReactions added in v0.4.0

func (c *Client) ListIssueCommentUserReactions(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*IssueUserReaction, error)

ListIssueCommentUserReactions lists user reactions for an issue comment.

GET /repos/{owner}/{repo}/issues/comment/{comment_id}/user-reactions

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]*IssueComment, error)

func (*Client) ListIssueDependencies added in v0.4.0

func (c *Client) ListIssueDependencies(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*IssueDependency, error)

ListIssueDependencies lists all dependencies of an issue.

GET /repos/{owner}/{repo}/issues/{index}/dependencies

func (*Client) ListIssueLabels

func (c *Client) ListIssueLabels(ctx context.Context, owner, repo string) ([]*Label, error)

func (*Client) ListIssueModifyHistory added in v0.4.0

func (c *Client) ListIssueModifyHistory(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*ModifyHistoryEntry, error)

ListIssueModifyHistory lists the modification history of an issue.

GET /repos/{owner}/{repo}/issues/{number}/modify-history

func (*Client) ListIssueReactions added in v0.4.0

func (c *Client) ListIssueReactions(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*Reaction, error)

ListIssueReactions lists all reactions for an issue.

GET /repos/{owner}/{repo}/issues/{index}/reactions

func (*Client) ListIssueRelatedBranches added in v0.4.0

func (c *Client) ListIssueRelatedBranches(ctx context.Context, owner, repo string, number int) ([]*IssueRelatedBranch, error)

ListIssueRelatedBranches lists all branches related to an issue.

GET /repos/{owner}/{repo}/issues/{number}/related-branches

func (*Client) ListIssueSubscribers added in v0.4.0

func (c *Client) ListIssueSubscribers(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*IssueSubscriber, error)

ListIssueSubscribers lists all subscribers of an issue.

GET /repos/{owner}/{repo}/issues/{index}/subscribers

func (*Client) ListIssueTemplates added in v0.4.0

func (c *Client) ListIssueTemplates(ctx context.Context, owner, repo string) ([]*IssueTemplate, error)

ListIssueTemplates lists all issue templates of a repository.

GET /repos/{owner}/{repo}/issue_templates

func (*Client) ListIssueTimelineEvents added in v0.4.0

func (c *Client) ListIssueTimelineEvents(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*IssueTimelineEvent, error)

ListIssueTimelineEvents lists all timeline events for an issue.

GET /repos/{owner}/{repo}/issues/{index}/timeline

func (*Client) ListIssueUserReactions added in v0.4.0

func (c *Client) ListIssueUserReactions(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*IssueUserReaction, error)

ListIssueUserReactions lists user reactions for an issue.

GET /repos/{owner}/{repo}/issues/{number}/user-reactions

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context, owner, repo string, opts ListIssuesOptions) ([]*Issue, error)

func (*Client) ListKanbanBoardItems added in v0.5.0

func (c *Client) ListKanbanBoardItems(ctx context.Context, org string, boardID int64, opts ListOptions) ([]*KanbanBoardItem, error)

ListKanbanBoardItems lists all items on a kanban board.

GET /orgs/{org}/kanban/boards/{id}/items

func (*Client) ListKanbanBoards added in v0.5.0

func (c *Client) ListKanbanBoards(ctx context.Context, org string, opts ListOptions) ([]*KanbanBoard, error)

ListKanbanBoards lists all kanban boards for an organization.

GET /orgs/{org}/kanban/boards

func (*Client) ListLabelTemplates added in v0.4.0

func (c *Client) ListLabelTemplates(ctx context.Context) ([]string, error)

ListLabelTemplates lists all available label templates.

GET /label/templates

func (*Client) ListLicenseTemplates added in v0.4.0

func (c *Client) ListLicenseTemplates(ctx context.Context) ([]*LicenseTemplate, error)

ListLicenseTemplates lists all available license templates.

GET /licenses

func (*Client) ListMilestones

func (c *Client) ListMilestones(ctx context.Context, owner, repo string) ([]*Milestone, error)

func (*Client) ListMilestonesWithOptions

func (c *Client) ListMilestonesWithOptions(ctx context.Context, owner, repo string, opts ListMilestonesOptions) ([]*Milestone, error)

func (*Client) ListNotifications

func (c *Client) ListNotifications(ctx context.Context) ([]*Notification, error)

func (*Client) ListNotificationsWithOptions added in v0.4.0

func (c *Client) ListNotificationsWithOptions(ctx context.Context, opts ListNotificationsOptions) ([]*NotificationThread, error)

ListNotificationsWithOptions lists the current user's notifications with options.

GET /notifications

func (*Client) ListOrgBlockedUsers added in v0.4.0

func (c *Client) ListOrgBlockedUsers(ctx context.Context, org string, opts ListOptions) ([]*User, error)

ListOrgBlockedUsers lists all blocked users of an organization.

GET /orgs/{org}/blocks

func (*Client) ListOrgCustomizedRoles added in v0.4.0

func (c *Client) ListOrgCustomizedRoles(ctx context.Context, org string) ([]*OrgCustomizedRole, error)

ListOrgCustomizedRoles lists all customized roles for an organization.

GET /org/{org}/customized-roles

func (*Client) ListOrgDiscussionCommentReplies added in v0.4.0

func (c *Client) ListOrgDiscussionCommentReplies(ctx context.Context, org string, number int, commentID int64, opts ListOptions) ([]*OrgDiscussionCommentReply, error)

ListOrgDiscussionCommentReplies lists all replies for an organization discussion comment.

GET /orgs/{org}/discuss/{number}/comment/{comment_id}/reply

func (*Client) ListOrgDiscussionComments added in v0.4.0

func (c *Client) ListOrgDiscussionComments(ctx context.Context, org string, number int, opts ListOptions) ([]*OrgDiscussionComment, error)

ListOrgDiscussionComments lists all comments for an organization discussion.

GET /orgs/{org}/discuss/{number}/comment

func (*Client) ListOrgDiscussions added in v0.4.0

func (c *Client) ListOrgDiscussions(ctx context.Context, org string, opts ListOptions) ([]*OrgDiscussion, error)

ListOrgDiscussions lists all discussions for an organization.

GET /orgs/{org}/discuss

func (*Client) ListOrgFollowers

func (c *Client) ListOrgFollowers(ctx context.Context, org string, opts ListOptions) ([]*OrgFollowers, error)

func (*Client) ListOrgIssues

func (c *Client) ListOrgIssues(ctx context.Context, org string, opts ListUserIssuesOptions) ([]*Issue, error)

func (*Client) ListOrgLabels added in v0.4.0

func (c *Client) ListOrgLabels(ctx context.Context, org string, opts ListOptions) ([]*OrgLabel, error)

ListOrgLabels lists all labels of an organization.

GET /orgs/{org}/labels

func (*Client) ListOrgMembers

func (c *Client) ListOrgMembers(ctx context.Context, org, role string, opts ListOptions) ([]*OrgMember, error)

func (*Client) ListOrgPublicMembers added in v0.4.0

func (c *Client) ListOrgPublicMembers(ctx context.Context, org string, opts ListOptions) ([]*User, error)

ListOrgPublicMembers lists all public members of an organization.

GET /orgs/{org}/public_members

func (*Client) ListOrgPullRequests

func (c *Client) ListOrgPullRequests(ctx context.Context, org string, opts ListEnterprisePRsOptions) ([]*PullRequest, error)

func (*Client) ListOrgRepositories

func (c *Client) ListOrgRepositories(ctx context.Context, org, repoType string, opts ListOptions) ([]*Repository, error)

func (*Client) ListOrgRunnerGroups added in v0.5.0

func (c *Client) ListOrgRunnerGroups(ctx context.Context, org string, opts ListOptions) ([]*RunnerGroup, error)

ListOrgRunnerGroups lists all runner groups for an organization.

GET /orgs/{org}/actions/runner-groups

func (*Client) ListOrgTeams added in v0.4.0

func (c *Client) ListOrgTeams(ctx context.Context, org string, opts ListOptions) ([]*Team, error)

ListOrgTeams lists all teams in an organization.

GET /orgs/{org}/teams

func (*Client) ListOrgWebhooks added in v0.4.0

func (c *Client) ListOrgWebhooks(ctx context.Context, org string, opts ListOptions) ([]*OrgWebhook, error)

ListOrgWebhooks lists all webhooks of an organization.

GET /orgs/{org}/hooks

func (*Client) ListOrganizationMembers

func (c *Client) ListOrganizationMembers(ctx context.Context, org string) ([]*Member, error)

func (*Client) ListOrganizations

func (c *Client) ListOrganizations(ctx context.Context) ([]*Organization, error)

func (*Client) ListOrganizationsWithOptions

func (c *Client) ListOrganizationsWithOptions(ctx context.Context, admin bool, opts ListOptions) ([]*Organization, error)

func (*Client) ListPendingRepoInvitations added in v0.4.0

func (c *Client) ListPendingRepoInvitations(ctx context.Context, opts ListOptions) ([]*RepoInvitation, error)

ListPendingRepoInvitations lists pending repository invitations for the authenticated user.

GET /user/repository_invitations

func (*Client) ListProtectedTags added in v0.5.0

func (c *Client) ListProtectedTags(ctx context.Context, owner, repo string, opts ListOptions) ([]*ProtectedTag, error)

ListProtectedTags lists all protected tag rules for a repository.

GET /repos/{owner}/{repo}/protected-tags

func (*Client) ListPullRequestAvailableReviewers added in v0.4.0

func (c *Client) ListPullRequestAvailableReviewers(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*User, error)

ListPullRequestAvailableReviewers lists users available as approval reviewers for a pull request.

GET /repos/{owner}/{repo}/pulls/{number}/option-approval-reviewers

func (*Client) ListPullRequestAvailableTesters added in v0.4.0

func (c *Client) ListPullRequestAvailableTesters(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*User, error)

ListPullRequestAvailableTesters lists users available as testers for a pull request.

GET /repos/{owner}/{repo}/pulls/{number}/option-approval-testers

func (*Client) ListPullRequestCommentModifyHistory added in v0.4.0

func (c *Client) ListPullRequestCommentModifyHistory(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*ModifyHistoryEntry, error)

ListPullRequestCommentModifyHistory lists the modification history of a PR comment.

GET /repos/{owner}/{repo}/pulls/comment/{comment_id}/modify-history

func (*Client) ListPullRequestCommentReactions added in v0.4.0

func (c *Client) ListPullRequestCommentReactions(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*Reaction, error)

ListPullRequestCommentReactions lists all reactions for a pull request comment.

GET /repos/{owner}/{repo}/pulls/comments/{id}/reactions

func (*Client) ListPullRequestCommentUserReactions added in v0.4.0

func (c *Client) ListPullRequestCommentUserReactions(ctx context.Context, owner, repo string, commentID int64, opts ListOptions) ([]*IssueUserReaction, error)

ListPullRequestCommentUserReactions lists user reactions for a PR comment.

GET /repos/{owner}/{repo}/pulls/comment/{comment_id}/user-reactions

func (*Client) ListPullRequestComments

func (c *Client) ListPullRequestComments(ctx context.Context, owner, repo string, number int) ([]*PullRequestComment, error)

func (*Client) ListPullRequestCommits

func (c *Client) ListPullRequestCommits(ctx context.Context, owner, repo string, number int) ([]*Commit, error)

func (*Client) ListPullRequestFiles

func (c *Client) ListPullRequestFiles(ctx context.Context, owner, repo string, number int) ([]*PullRequestFile, error)

func (*Client) ListPullRequestFilesJSON added in v0.4.0

func (c *Client) ListPullRequestFilesJSON(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*PullRequestFileChange, error)

ListPullRequestFilesJSON lists files changed in a pull request in JSON format.

GET /repos/{owner}/{repo}/pulls/{number}/files.json

func (*Client) ListPullRequestLabels

func (c *Client) ListPullRequestLabels(ctx context.Context, owner, repo string, number int) ([]*Label, error)

func (*Client) ListPullRequestMergeTemplates added in v0.4.0

func (c *Client) ListPullRequestMergeTemplates(ctx context.Context, owner, repo string) ([]*PRMergeTemplate, error)

ListPullRequestMergeTemplates lists all pull request merge templates of a repository.

GET /repos/{owner}/{repo}/merge_templates

func (*Client) ListPullRequestModifyHistory added in v0.4.0

func (c *Client) ListPullRequestModifyHistory(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*ModifyHistoryEntry, error)

ListPullRequestModifyHistory lists the modification history of a pull request.

GET /repos/{owner}/{repo}/pulls/{number}/modify-history

func (*Client) ListPullRequestReviewers added in v0.4.0

func (c *Client) ListPullRequestReviewers(ctx context.Context, owner, repo string, number int) ([]*Reviewer, error)

ListPullRequestReviewers lists all reviewers requested for a pull request.

GET /repos/{owner}/{repo}/pulls/{index}/requested_reviewers

func (*Client) ListPullRequestReviews

func (c *Client) ListPullRequestReviews(ctx context.Context, owner, repo string, number int) ([]*PullRequestReview, error)

func (*Client) ListPullRequestUserReactions added in v0.4.0

func (c *Client) ListPullRequestUserReactions(ctx context.Context, owner, repo string, number int, opts ListOptions) ([]*IssueUserReaction, error)

ListPullRequestUserReactions lists user reactions for a pull request.

GET /repos/{owner}/{repo}/pulls/{number}/user-reactions

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(ctx context.Context, owner, repo string, opts ListPullRequestsOptions) ([]*PullRequest, error)

func (*Client) ListPushRemoteMirrors added in v0.4.0

func (c *Client) ListPushRemoteMirrors(ctx context.Context, owner, repo string, opts ListOptions) ([]*RemoteMirror, error)

ListPushRemoteMirrors lists all push remote mirrors of a repository.

GET /repos/{owner}/{repo}/push-remote-mirrors

func (*Client) ListReleaseAssets added in v0.4.0

func (c *Client) ListReleaseAssets(ctx context.Context, owner, repo string, releaseID int64, opts ListOptions) ([]*ReleaseAsset, error)

ListReleaseAssets lists all assets for a release.

GET /repos/{owner}/{repo}/releases/{id}/assets

func (*Client) ListReleases

func (c *Client) ListReleases(ctx context.Context, owner, repo string) ([]*Release, error)

func (*Client) ListRepoAllIssueComments

func (c *Client) ListRepoAllIssueComments(ctx context.Context, owner, repo string, opts ListOptions) ([]*IssueComment, error)

func (*Client) ListRepoAssignees added in v0.4.0

func (c *Client) ListRepoAssignees(ctx context.Context, owner, repo string, opts ListOptions) ([]*User, error)

ListRepoAssignees lists all available assignees for issues in a repository.

GET /repos/{owner}/{repo}/assignees

func (*Client) ListRepoBranchesPaginated added in v0.4.0

func (c *Client) ListRepoBranchesPaginated(ctx context.Context, owner, repo string, opts ListOptions) ([]*RepoBranchInfo, error)

ListRepoBranches lists all branches of a repository with pagination.

GET /repos/{owner}/{repo}/branches

func (*Client) ListRepoCLAs added in v0.4.0

func (c *Client) ListRepoCLAs(ctx context.Context, owner, repo string) ([]*RepoCLA, error)

ListRepoCLAs lists all CLAs for a repository.

GET /repos/{owner}/{repo}/clas

func (*Client) ListRepoCommitComments added in v0.4.0

func (c *Client) ListRepoCommitComments(ctx context.Context, owner, repo string, opts ListOptions) ([]*CommitComment, error)

ListRepoCommitComments lists all commit comments for a repository.

GET /repos/{owner}/{repo}/comments

func (*Client) ListRepoEvents

func (c *Client) ListRepoEvents(ctx context.Context, owner, repo string, opts ListOptions) ([]*RepoEvent, error)

func (*Client) ListRepoHostRunners added in v0.5.0

func (c *Client) ListRepoHostRunners(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionRunner, error)

ListRepoHostRunners lists all host runners for a repository.

GET /repos/{owner}/{repo}/actions/runners/host

func (*Client) ListRepoK8SRunners added in v0.5.0

func (c *Client) ListRepoK8SRunners(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionRunner, error)

ListRepoK8SRunners lists all K8S runners for a repository.

GET /repos/{owner}/{repo}/actions/runners/k8s

func (*Client) ListRepoNotifications added in v0.4.0

func (c *Client) ListRepoNotifications(ctx context.Context, owner, repo string, opts ListNotificationsOptions) ([]*NotificationThread, error)

ListRepoNotifications lists notifications for a repository.

GET /repos/{owner}/{repo}/notifications

func (*Client) ListRepoReviewers added in v0.4.0

func (c *Client) ListRepoReviewers(ctx context.Context, owner, repo string, opts ListOptions) ([]*Reviewer, error)

ListRepoReviewers lists all available reviewers for a repository.

GET /repos/{owner}/{repo}/reviewers

func (*Client) ListRepoSharedHostRunners added in v0.5.0

func (c *Client) ListRepoSharedHostRunners(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionRunner, error)

ListRepoSharedHostRunners lists all shared host runners for a repository.

GET /repos/{owner}/{repo}/actions/runners/shared-host

func (*Client) ListRepoSharedK8SRunners added in v0.5.0

func (c *Client) ListRepoSharedK8SRunners(ctx context.Context, owner, repo string, opts ListOptions) ([]*ActionRunner, error)

ListRepoSharedK8SRunners lists all shared K8S runners for a repository.

GET /repos/{owner}/{repo}/actions/runners/shared-k8s

func (*Client) ListRepositories

func (c *Client) ListRepositories(ctx context.Context, opts ListRepositoriesOptions) ([]*Repository, error)

func (*Client) ListRepositoryContents

func (c *Client) ListRepositoryContents(ctx context.Context, owner, repo, path, ref string) ([]*RepositoryContent, error)

func (*Client) ListRepositoryTopics added in v0.4.0

func (c *Client) ListRepositoryTopics(ctx context.Context, owner, repo string) ([]string, error)

ListRepositoryTopics lists all topics of a repository.

GET /repos/{owner}/{repo}/topics

func (*Client) ListRunnerGroupHostRunners added in v0.5.0

func (c *Client) ListRunnerGroupHostRunners(ctx context.Context, org string, groupID int64, opts ListOptions) ([]*ActionRunner, error)

ListRunnerGroupHostRunners lists all host runners in a runner group.

GET /orgs/{org}/actions/runner-groups/{id}/host-runners

func (*Client) ListRunnerGroupK8SRunners added in v0.5.0

func (c *Client) ListRunnerGroupK8SRunners(ctx context.Context, org string, groupID int64, opts ListOptions) ([]*ActionRunner, error)

ListRunnerGroupK8SRunners lists all K8S runners in a runner group.

GET /orgs/{org}/actions/runner-groups/{id}/k8s-runners

func (*Client) ListRunnerGroupRepos added in v0.5.0

func (c *Client) ListRunnerGroupRepos(ctx context.Context, org string, groupID int64, opts ListOptions) ([]*Repository, error)

ListRunnerGroupRepos lists all repositories that have access to a runner group.

GET /orgs/{org}/actions/runner-groups/{id}/repos

func (*Client) ListSSHKeys

func (c *Client) ListSSHKeys(ctx context.Context, opts ListOptions) ([]*SSHKey, error)

func (*Client) ListStargazers

func (c *Client) ListStargazers(ctx context.Context, owner, repo string, opts ListOptions) ([]*User, error)

func (*Client) ListStarredRepositories

func (c *Client) ListStarredRepositories(ctx context.Context, opts ListStarredReposOptions) ([]*Repository, error)

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, owner, repo string) ([]*Tag, error)

func (*Client) ListTagsWithOptions added in v0.4.0

func (c *Client) ListTagsWithOptions(ctx context.Context, owner, repo string, opts ListOptions) ([]*Tag, error)

ListTagsWithOptions lists all tags with pagination options.

GET /repos/{owner}/{repo}/tags

func (*Client) ListTeamMembers added in v0.4.0

func (c *Client) ListTeamMembers(ctx context.Context, teamID int64, opts ListOptions) ([]*TeamMember, error)

ListTeamMembers lists all members of a team.

GET /teams/{team_id}/members

func (*Client) ListTeamRepositories added in v0.4.0

func (c *Client) ListTeamRepositories(ctx context.Context, teamID int64, opts ListOptions) ([]*Repository, error)

ListTeamRepositories lists all repositories of a team.

GET /teams/{team_id}/repos

func (*Client) ListUserFollowers added in v0.4.0

func (c *Client) ListUserFollowers(ctx context.Context, username string, opts ListOptions) ([]*User, error)

ListUserFollowers lists the followers of a user.

GET /users/{username}/followers

func (*Client) ListUserFollowing added in v0.4.0

func (c *Client) ListUserFollowing(ctx context.Context, username string, opts ListOptions) ([]*User, error)

ListUserFollowing lists the users that a user is following.

GET /users/{username}/following

func (*Client) ListUserIssues

func (c *Client) ListUserIssues(ctx context.Context, opts ListUserIssuesOptions) ([]*Issue, error)

func (*Client) ListUserOrganizations

func (c *Client) ListUserOrganizations(ctx context.Context, username string, opts ListOptions) ([]*Organization, error)

func (*Client) ListUserPullRequests added in v0.4.0

func (c *Client) ListUserPullRequests(ctx context.Context, opts ListPullRequestsOptions) ([]*PullRequest, error)

ListUserPullRequests lists pull requests for the authenticated user.

GET /users/merge-requests

func (*Client) ListUserRepositories added in v0.4.0

func (c *Client) ListUserRepositories(ctx context.Context, username string, opts ListOptions) ([]*Repository, error)

ListUserRepositories lists a user's public repositories.

GET /users/{username}/repos

func (*Client) ListUserWatchedRepositories added in v0.4.0

func (c *Client) ListUserWatchedRepositories(ctx context.Context, username string, opts ListOptions) ([]*Repository, error)

ListUserWatchedRepositories lists repositories watched by a user.

GET /users/{username}/subscriptions

func (*Client) ListWatchers

func (c *Client) ListWatchers(ctx context.Context, owner, repo string, opts ListOptions) ([]*User, error)

func (*Client) ListWebhooks

func (c *Client) ListWebhooks(ctx context.Context, owner, repo string) ([]*Webhook, error)

func (*Client) ListWikiPages added in v0.4.0

func (c *Client) ListWikiPages(ctx context.Context, owner, repo string, opts ListOptions) ([]*WikiPage, error)

ListWikiPages lists all wiki pages of a repository.

GET /repos/{owner}/{repo}/wiki/pages

func (*Client) MarkNotificationThreadAsRead added in v0.4.0

func (c *Client) MarkNotificationThreadAsRead(ctx context.Context, threadID int64) error

MarkNotificationThreadAsRead marks a single notification thread as read.

PATCH /notifications/threads/{id}

func (*Client) MarkNotificationsAsRead added in v0.4.0

func (c *Client) MarkNotificationsAsRead(ctx context.Context, opts MarkNotificationsOptions) error

MarkNotificationsAsRead marks all notifications as read.

PUT /notifications

func (*Client) MarkRepoNotificationsAsRead added in v0.4.0

func (c *Client) MarkRepoNotificationsAsRead(ctx context.Context, owner, repo string, opts MarkNotificationsOptions) error

MarkRepoNotificationsAsRead marks all notifications for a repository as read.

PUT /repos/{owner}/{repo}/notifications

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(ctx context.Context, owner, repo string, number int, opts *MergePullRequestOptions) error

func (*Client) ParseIssueEvent

func (c *Client) ParseIssueEvent(payload []byte) (*IssueWebhookEvent, error)

func (*Client) ParseNoteEvent

func (c *Client) ParseNoteEvent(payload []byte) (*NoteWebhookEvent, error)

func (*Client) ParsePullRequestEvent

func (c *Client) ParsePullRequestEvent(payload []byte) (*PullRequestWebhookEvent, error)

func (*Client) ParsePushEvent

func (c *Client) ParsePushEvent(payload []byte) (*PushEvent, error)

func (*Client) ParseTagPushEvent

func (c *Client) ParseTagPushEvent(payload []byte) (*TagPushEvent, error)

func (*Client) PublicizeOrgMembership added in v0.4.0

func (c *Client) PublicizeOrgMembership(ctx context.Context, org, username string) error

PublicizeOrgMembership makes the authenticated user's membership public.

PUT /orgs/{org}/public_members/{username}

func (*Client) RefreshPullRequestCommentPosition added in v0.4.0

func (c *Client) RefreshPullRequestCommentPosition(ctx context.Context, owner, repo string, number int) error

RefreshPullRequestCommentPosition refreshes the position/expired status of PR comments.

POST /repos/{owner}/{repo}/pulls/{number}/refresh-position

func (*Client) RemoveAllIssueLabels

func (c *Client) RemoveAllIssueLabels(ctx context.Context, owner, repo string, number int) error

func (*Client) RemoveCollaborator added in v0.4.0

func (c *Client) RemoveCollaborator(ctx context.Context, owner, repo, username string) error

RemoveCollaborator removes a collaborator from a repository.

DELETE /repos/{owner}/{repo}/collaborators/{username}

func (*Client) RemoveFromKanbanBoard added in v0.5.0

func (c *Client) RemoveFromKanbanBoard(ctx context.Context, org string, boardID, itemID int64) error

RemoveFromKanbanBoard removes an item from a kanban board.

DELETE /orgs/{org}/kanban/boards/{id}/items/{item_id}

func (*Client) RemoveIssueAssignees added in v0.4.0

func (c *Client) RemoveIssueAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, error)

RemoveIssueAssignees removes assignees from an issue.

DELETE /repos/{owner}/{repo}/issues/{index}/assignees

func (*Client) RemoveIssueLabel

func (c *Client) RemoveIssueLabel(ctx context.Context, owner, repo string, number int, name string) error

func (*Client) RemoveOrgMember

func (c *Client) RemoveOrgMember(ctx context.Context, org, username string) error

func (*Client) RemovePullRequestLabel

func (c *Client) RemovePullRequestLabel(ctx context.Context, owner, repo string, number int, name string) error

func (*Client) RemovePullRequestReviewer added in v0.4.0

func (c *Client) RemovePullRequestReviewer(ctx context.Context, owner, repo string, number int, opts PullRequestReviewRequest) error

RemovePullRequestReviewer removes a requested reviewer from a pull request.

DELETE /repos/{owner}/{repo}/pulls/{index}/requested_reviewers

func (*Client) RemoveTeamMember added in v0.4.0

func (c *Client) RemoveTeamMember(ctx context.Context, teamID int64, username string) error

RemoveTeamMember removes a member from a team.

DELETE /teams/{team_id}/members/{username}

func (*Client) RemoveTeamRepository added in v0.4.0

func (c *Client) RemoveTeamRepository(ctx context.Context, teamID int64, org, repo string) error

RemoveTeamRepository removes a repository from a team.

DELETE /teams/{team_id}/repos/{org}/{repo}

func (*Client) RenderMarkdown added in v0.4.0

func (c *Client) RenderMarkdown(ctx context.Context, text, mode, context string) (string, error)

RenderMarkdown renders a markdown document as HTML.

POST /markdown

func (*Client) RenderMarkdownRaw added in v0.4.0

func (c *Client) RenderMarkdownRaw(ctx context.Context, markdown string) (string, error)

RenderMarkdownRaw renders raw markdown as HTML.

POST /markdown/raw

func (*Client) ReopenIssue

func (c *Client) ReopenIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)

func (*Client) ReopenPullRequest

func (c *Client) ReopenPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

func (*Client) ReplaceIssueLabels

func (c *Client) ReplaceIssueLabels(ctx context.Context, owner, repo string, number int, labels []string) error

func (*Client) ReplacePullRequestLabels

func (c *Client) ReplacePullRequestLabels(ctx context.Context, owner, repo string, number int, labels []string) error

func (*Client) ReplyPullRequestComment added in v0.4.0

func (c *Client) ReplyPullRequestComment(ctx context.Context, owner, repo string, number int, discussionID string, body string) (*PRDiscussionComment, error)

ReplyPullRequestComment replies to a pull request review comment.

POST /repos/{owner}/{repo}/pulls/{number}/discussions/{discussions_id}/comments

func (*Client) RequestPullRequestReviewers added in v0.4.0

func (c *Client) RequestPullRequestReviewers(ctx context.Context, owner, repo string, number int, opts PullRequestReviewRequest) error

RequestPullRequestReviewers requests reviewers for a pull request.

POST /repos/{owner}/{repo}/pulls/{index}/requested_reviewers

func (*Client) ResetPullRequestReviewStatus

func (c *Client) ResetPullRequestReviewStatus(ctx context.Context, owner, repo string, number int, resetAll bool) error

func (*Client) ResetPullRequestTestStatus

func (c *Client) ResetPullRequestTestStatus(ctx context.Context, owner, repo string, number int, resetAll bool) error

func (*Client) ResolvePullRequestDiscussion added in v0.4.0

func (c *Client) ResolvePullRequestDiscussion(ctx context.Context, owner, repo string, number int, discussionID string, resolved bool) error

ResolvePullRequestDiscussion resolves or unresolves a review discussion.

PUT /repos/{owner}/{repo}/pulls/{number}/comments/discussions/{id}

func (*Client) RunActionWorkflow added in v0.5.0

func (c *Client) RunActionWorkflow(ctx context.Context, owner, repo string, opts RunActionWorkflowOptions) error

RunActionWorkflow manually triggers a workflow run.

POST /repos/{owner}/{repo}/actions/run

func (*Client) SearchIssues

func (c *Client) SearchIssues(ctx context.Context, opts SearchIssuesOptions) ([]*SearchIssueResult, error)

func (*Client) SearchRepositories

func (c *Client) SearchRepositories(ctx context.Context, opts SearchRepositoriesOptions) ([]*SearchRepositoryResult, error)

func (*Client) SearchUsers

func (c *Client) SearchUsers(ctx context.Context, opts SearchUsersOptions) ([]*SearchUserResult, error)

func (*Client) SetAuthStyle

func (c *Client) SetAuthStyle(style AuthStyle)

SetAuthStyle sets the authentication style for the client.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

SetHTTPClient sets a custom HTTP client.

func (*Client) SetIssueRelatedBranches added in v0.4.0

func (c *Client) SetIssueRelatedBranches(ctx context.Context, owner, repo string, number int, branches []string) error

SetIssueRelatedBranches sets the branches related to an issue.

PUT /repos/{owner}/{repo}/issues/{number}/related-branches

func (*Client) SetModuleSetting

func (c *Client) SetModuleSetting(ctx context.Context, owner, repo string, setting ModuleSetting) error

func (*Client) SetRepoVisibility added in v0.4.0

func (c *Client) SetRepoVisibility(ctx context.Context, owner, repo string, private bool) (*Repository, error)

SetRepoVisibility sets a repository's visibility (public/private).

PATCH /repos/{owner}/{repo}

func (*Client) SetRetryPolicy added in v0.6.0

func (c *Client) SetRetryPolicy(policy RetryPolicy)

SetRetryPolicy sets the retry policy for the client.

func (*Client) StarRepository

func (c *Client) StarRepository(ctx context.Context, owner, repo string) error

func (*Client) SubmitPullRequestReview added in v0.4.0

func (c *Client) SubmitPullRequestReview(ctx context.Context, owner, repo string, number int, reviewID int64, body, event string) (*PullRequestReview, error)

SubmitPullRequestReview submits a pull request review.

POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}

func (*Client) SubscribeToIssue added in v0.4.0

func (c *Client) SubscribeToIssue(ctx context.Context, owner, repo string, number int, username string) error

SubscribeToIssue subscribes the authenticated user to an issue.

PUT /repos/{owner}/{repo}/issues/{index}/subscribers/{username}

func (*Client) SyncForkRepository added in v0.4.0

func (c *Client) SyncForkRepository(ctx context.Context, owner, repo string) error

SyncForkRepository syncs a forked repository with its upstream.

PUT /repos/{owner}/{repo}/sync-repo

func (*Client) TestWebhook

func (c *Client) TestWebhook(ctx context.Context, owner, repo string, hookID int64) error

func (*Client) TransferRepository

func (c *Client) TransferRepository(ctx context.Context, owner, repo string, opts TransferRepoOptions) error

func (*Client) TransferToOrg

func (c *Client) TransferToOrg(ctx context.Context, org, repo, newOwner string) error

func (*Client) UnassignPullRequestApprovalReviewers added in v0.4.0

func (c *Client) UnassignPullRequestApprovalReviewers(ctx context.Context, owner, repo string, number int, reviewers string) error

UnassignPullRequestApprovalReviewers removes approval reviewers from a pull request.

DELETE /repos/{owner}/{repo}/pulls/{number}/approval-reviewers

func (*Client) UnassignPullRequestReviewers

func (c *Client) UnassignPullRequestReviewers(ctx context.Context, owner, repo string, number int, assignees string) error

func (*Client) UnassignPullRequestTesters added in v0.4.0

func (c *Client) UnassignPullRequestTesters(ctx context.Context, owner, repo string, number int, testers string) error

UnassignPullRequestTesters removes testers from a pull request.

DELETE /repos/{owner}/{repo}/pulls/{number}/testers

func (*Client) UnblockOrgUser added in v0.4.0

func (c *Client) UnblockOrgUser(ctx context.Context, org, username string) error

UnblockOrgUser unblocks a user from an organization.

DELETE /orgs/{org}/blocks/{username}

func (*Client) UnfollowUser added in v0.4.0

func (c *Client) UnfollowUser(ctx context.Context, username string) error

UnfollowUser unfollows a user.

DELETE /user/following/{username}

func (*Client) UnlinkPullRequestIssue added in v0.4.0

func (c *Client) UnlinkPullRequestIssue(ctx context.Context, owner, repo string, number int, issueNumber int) error

UnlinkPullRequestIssue removes an issue link from a pull request.

DELETE /repos/{owner}/{repo}/pulls/{number}/issues

func (*Client) UnstarRepository

func (c *Client) UnstarRepository(ctx context.Context, owner, repo string) error

func (*Client) UnsubscribeFromIssue added in v0.4.0

func (c *Client) UnsubscribeFromIssue(ctx context.Context, owner, repo string, number int, username string) error

UnsubscribeFromIssue unsubscribes the authenticated user from an issue.

DELETE /repos/{owner}/{repo}/issues/{index}/subscribers/{username}

func (*Client) UpdateBranchProtection

func (c *Client) UpdateBranchProtection(ctx context.Context, owner, repo, wildcard string, opts UpdateBranchProtectionOptions) error

func (*Client) UpdateCommitComment added in v0.4.0

func (c *Client) UpdateCommitComment(ctx context.Context, owner, repo string, commentID int64, opts UpdateCommitCommentOptions) (*CommitComment, error)

UpdateCommitComment updates a commit comment.

PATCH /repos/{owner}/{repo}/comments/{id}

func (*Client) UpdateCurrentUser added in v0.4.0

func (c *Client) UpdateCurrentUser(ctx context.Context, opts UpdateCurrentUserOptions) (*User, error)

UpdateCurrentUser updates the authenticated user's profile.

PATCH /user

func (*Client) UpdateEnterpriseLabel added in v0.5.0

func (c *Client) UpdateEnterpriseLabel(ctx context.Context, enterprise string, labelID int64, opts UpdateEnterpriseLabelOptions) (*EnterpriseLabel, error)

UpdateEnterpriseLabel updates an enterprise label.

PATCH /enterprises/{enterprise}/labels/{id}

func (*Client) UpdateEnterpriseMember

func (c *Client) UpdateEnterpriseMember(ctx context.Context, enterprise, username string, opts UpdateEnterpriseMemberOptions) (*EnterpriseMember, error)

func (*Client) UpdateEnterpriseMilestone added in v0.5.0

func (c *Client) UpdateEnterpriseMilestone(ctx context.Context, enterprise string, milestoneID int64, opts UpdateEnterpriseMilestoneOptions) (*EnterpriseMilestone, error)

UpdateEnterpriseMilestone updates an enterprise milestone.

PATCH /enterprises/{enterprise}/milestones/{id}

func (*Client) UpdateFile

func (c *Client) UpdateFile(ctx context.Context, owner, repo, path string, opts UpdateFileOptions) (*FileResult, error)

func (*Client) UpdateGitReference added in v0.4.0

func (c *Client) UpdateGitReference(ctx context.Context, owner, repo, ref string, opts UpdateReferenceOptions) (*GitReference, error)

UpdateGitReference updates a reference.

PATCH /repos/{owner}/{repo}/git/refs/{ref}

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(ctx context.Context, owner, repo string, number int, opts UpdateIssueOptions) (*Issue, error)

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)

func (*Client) UpdateIssueKanbanValues added in v0.4.0

func (c *Client) UpdateIssueKanbanValues(ctx context.Context, owner, repo string, number int, values []KanbanValue) error

UpdateIssueKanbanValues updates the kanban field values of an issue.

PUT /repos/{owner}/{repo}/issues/{number}/kanban-values

func (*Client) UpdateIssueLabel

func (c *Client) UpdateIssueLabel(ctx context.Context, owner, repo, originalName string, opts UpdateLabelOptions) (*Label, error)

func (*Client) UpdateKanbanBoardItem added in v0.5.0

func (c *Client) UpdateKanbanBoardItem(ctx context.Context, org string, boardID, itemID int64, opts UpdateKanbanBoardItemOptions) (*KanbanBoardItem, error)

UpdateKanbanBoardItem updates an item on a kanban board.

PUT /orgs/{org}/kanban/boards/{id}/items/{item_id}

func (*Client) UpdateKanbanBoardStatus added in v0.5.0

func (c *Client) UpdateKanbanBoardStatus(ctx context.Context, org string, boardID int64, opts UpdateKanbanBoardStatusOptions) error

UpdateKanbanBoardStatus updates the statuses of a kanban board.

PUT /orgs/{org}/kanban/boards/{id}/status

func (*Client) UpdateMilestone

func (c *Client) UpdateMilestone(ctx context.Context, owner, repo string, number int, opts UpdateMilestoneOptions) (*Milestone, error)

func (*Client) UpdateOrgLabel added in v0.4.0

func (c *Client) UpdateOrgLabel(ctx context.Context, org string, labelID int64, opts UpdateOrgLabelOptions) (*OrgLabel, error)

UpdateOrgLabel updates an organization label.

PATCH /orgs/{org}/labels/{id}

func (*Client) UpdateOrgRepoStatus

func (c *Client) UpdateOrgRepoStatus(ctx context.Context, org, repo, status string) error

func (*Client) UpdateOrgWebhook added in v0.4.0

func (c *Client) UpdateOrgWebhook(ctx context.Context, org string, hookID int64, opts UpdateOrgWebhookOptions) (*OrgWebhook, error)

UpdateOrgWebhook updates an organization webhook.

PATCH /orgs/{org}/hooks/{id}

func (*Client) UpdateOrganization

func (c *Client) UpdateOrganization(ctx context.Context, org string, opts UpdateOrgOptions) (*Organization, error)

func (*Client) UpdatePRSettings

func (c *Client) UpdatePRSettings(ctx context.Context, owner, repo string, settings *PRSettings) error

func (*Client) UpdateProtectedTag added in v0.5.0

func (c *Client) UpdateProtectedTag(ctx context.Context, owner, repo, tag string, opts UpdateProtectedTagOptions) (*ProtectedTag, error)

UpdateProtectedTag updates a protected tag rule.

PUT /repos/{owner}/{repo}/protected-tags/{tag}

func (*Client) UpdatePullRequest

func (c *Client) UpdatePullRequest(ctx context.Context, owner, repo string, number int, opts UpdatePullRequestOptions) (*PullRequest, error)

func (*Client) UpdatePullRequestComment

func (c *Client) UpdatePullRequestComment(ctx context.Context, owner, repo string, commentID string, body string) (*PullRequestComment, error)

func (*Client) UpdatePushConfig

func (c *Client) UpdatePushConfig(ctx context.Context, owner, repo string, config *PushConfig) error

func (*Client) UpdateRelease added in v0.4.0

func (c *Client) UpdateRelease(ctx context.Context, owner, repo string, releaseID int64, opts UpdateReleaseOptions) (*Release, error)

UpdateRelease updates a release.

PATCH /repos/{owner}/{repo}/releases/{id}

func (*Client) UpdateRepoMember

func (c *Client) UpdateRepoMember(ctx context.Context, owner, repo, username string, opts UpdateMemberOptions) error

func (*Client) UpdateRepoSettings

func (c *Client) UpdateRepoSettings(ctx context.Context, owner, repo string, opts *RepoSettings) (*RepoSettings, error)

func (*Client) UpdateRepository

func (c *Client) UpdateRepository(ctx context.Context, owner, repo string, opts UpdateRepositoryOptions) (*Repository, error)

func (*Client) UpdateRepositoryTopics added in v0.4.0

func (c *Client) UpdateRepositoryTopics(ctx context.Context, owner, repo string, topics []string) ([]string, error)

UpdateRepositoryTopics replaces all topics of a repository.

PUT /repos/{owner}/{repo}/topics

func (*Client) UpdateReviewerConfig

func (c *Client) UpdateReviewerConfig(ctx context.Context, owner, repo string, config ReviewerConfig) error

func (*Client) UpdateTeam added in v0.4.0

func (c *Client) UpdateTeam(ctx context.Context, teamID int64, opts UpdateTeamOptions) (*Team, error)

UpdateTeam updates a team.

PATCH /teams/{team_id}

func (*Client) UpdateWebhook

func (c *Client) UpdateWebhook(ctx context.Context, owner, repo string, hookID int64, opts UpdateWebhookOptions) (*Webhook, error)

func (*Client) UpdateWikiPage added in v0.4.0

func (c *Client) UpdateWikiPage(ctx context.Context, owner, repo, pageName string, opts UpdateWikiPageOptions) (*WikiPage, error)

UpdateWikiPage updates an existing wiki page.

PATCH /repos/{owner}/{repo}/wiki/page/{pageName}

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, owner, repo string, filePath string) (*FileUploadResult, error)

func (*Client) UploadFileBytes added in v0.6.0

func (c *Client) UploadFileBytes(ctx context.Context, owner, repo, filename string, data []byte) (*FileUploadResult, error)

UploadFileBytes uploads file bytes using multipart form data.

func (*Client) UploadFileReader added in v0.6.0

func (c *Client) UploadFileReader(ctx context.Context, owner, repo, filename string, reader io.Reader) (*FileUploadResult, error)

UploadFileReader uploads a file using multipart form data. This is the proper way to upload file contents (as opposed to UploadFile which takes a path).

POST /repos/{owner}/{repo}/file/upload

func (*Client) UploadFileWithPath added in v0.6.0

func (c *Client) UploadFileWithPath(ctx context.Context, owner, repo, localPath string) (*FileUploadResult, error)

UploadFileWithPath uploads a file from a local path using multipart form data.

func (*Client) UploadImage

func (c *Client) UploadImage(ctx context.Context, owner, repo string, filePath string) (*FileUploadResult, error)

func (*Client) UploadImageReader added in v0.6.0

func (c *Client) UploadImageReader(ctx context.Context, owner, repo, filename string, reader io.Reader) (*FileUploadResult, error)

UploadImageReader uploads an image using multipart form data.

POST /repos/{owner}/{repo}/img/upload

func (*Client) ValidateWorkflowYAML added in v0.5.0

func (c *Client) ValidateWorkflowYAML(ctx context.Context, owner, repo string, yamlContent string) error

ValidateWorkflowYAML validates a workflow YAML file.

POST /repos/{owner}/{repo}/actions/validate

type CodeFrequencyEntry added in v0.4.0

type CodeFrequencyEntry []int

CodeFrequencyEntry represents a [additions, deletions, timestamp] tuple.

type Collaborator added in v0.4.0

type Collaborator struct {
	ID         int64  `json:"id"`
	Login      string `json:"login"`
	Name       string `json:"name"`
	AvatarURL  string `json:"avatar_url"`
	HTMLURL    string `json:"html_url"`
	Permission string `json:"permission,omitempty"`
}

Collaborator represents a repository collaborator.

type CollaboratorPermission added in v0.4.0

type CollaboratorPermission struct {
	Permission string `json:"permission"`
	RoleName   string `json:"role_name"`
}

CollaboratorPermission represents a collaborator's permission level.

type CombinedStatus added in v0.4.0

type CombinedStatus struct {
	SHA        string          `json:"sha"`
	TotalCount int             `json:"total_count"`
	Statuses   []*CommitStatus `json:"statuses"`
	Repository *Repository     `json:"repository"`
	CommitURL  string          `json:"commit_url"`
	URL        string          `json:"url"`
}

CombinedStatus represents the combined status for a commit.

type Commit

type Commit struct {
	SHA       string    `json:"sha"`
	Message   string    `json:"message"`
	Author    *User     `json:"author"`
	Committer *User     `json:"committer"`
	CreatedAt time.Time `json:"created_at"`
	URL       string    `json:"url,omitempty"`
}

type CommitActivity added in v0.4.0

type CommitActivity struct {
	Days  []int `json:"days"` // Sun-Sat
	Total int   `json:"total"`
	Week  int64 `json:"week"` // Unix timestamp
}

CommitActivity represents weekly commit activity.

type CommitAuthor

type CommitAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

type CommitComment added in v0.4.0

type CommitComment struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	Path      string    `json:"path,omitempty"`
	Position  int       `json:"position,omitempty"`
	Line      int       `json:"line,omitempty"`
	CommitID  string    `json:"commit_id"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	HTMLURL   string    `json:"html_url,omitempty"`
}

CommitComment represents a comment on a commit.

type CommitComparison

type CommitComparison struct {
	TotalCommits int                `json:"total_commits"`
	AheadBy      int                `json:"ahead_by"`
	BehindBy     int                `json:"behind_by"`
	Commits      []*Commit          `json:"commits"`
	Files        []*PullRequestFile `json:"files"`
}

type CommitStatus added in v0.4.0

type CommitStatus struct {
	ID          int64     `json:"id"`
	SHA         string    `json:"sha"`
	State       string    `json:"state"` // pending, success, error, failure
	TargetURL   string    `json:"target_url"`
	Description string    `json:"description"`
	Context     string    `json:"context"`
	Creator     *User     `json:"creator"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

CommitStatus represents a commit status.

type ConflictError added in v0.6.0

type ConflictError struct {
	*APIError
}

ConflictError represents a 409 Conflict error.

func (*ConflictError) Error added in v0.6.0

func (e *ConflictError) Error() string

type Contributor

type Contributor struct {
	ID            string `json:"id"`
	Login         string `json:"login"`
	AvatarURL     string `json:"avatar_url"`
	Contributions int    `json:"contributions"`
}

type ContributorStatistic

type ContributorStatistic struct {
	Author *User `json:"author"`
	Total  int   `json:"total"`
	Weeks  []*struct {
		W string `json:"w"`
		A int    `json:"a"`
		D int    `json:"d"`
		C int    `json:"c"`
	} `json:"weeks"`
}

type CreateAnnotatedTagOptions added in v0.4.0

type CreateAnnotatedTagOptions struct {
	Tag     string `json:"tag"`
	Message string `json:"message"`
	Object  string `json:"object"` // SHA of the object to tag
	Type    string `json:"type"`   // commit, tree, blob
	Tagger  *struct {
		Name  string `json:"name"`
		Email string `json:"email"`
		Date  string `json:"date"`
	} `json:"tagger,omitempty"`
}

CreateAnnotatedTagOptions specifies options for creating an annotated tag.

type CreateBranchOptions

type CreateBranchOptions struct {
	BranchName string `json:"branch_name"`
	Refs       string `json:"refs"`
	Ref        string `json:"ref,omitempty"`
}

type CreateBranchProtectionOptions

type CreateBranchProtectionOptions struct {
	Name                     string `json:"name"`
	RequiredStatusChecks     bool   `json:"required_status_checks"`
	RequiredApprovingReviews int    `json:"required_approving_reviews"`
	AllowForcePushes         bool   `json:"allow_force_pushes"`
	AllowDeletions           bool   `json:"allow_deletions"`
}

type CreateCommitCommentOptions added in v0.4.0

type CreateCommitCommentOptions struct {
	Body     string `json:"body"`
	Path     string `json:"path,omitempty"`
	Position int    `json:"position,omitempty"`
	Line     int    `json:"line,omitempty"`
}

CreateCommitCommentOptions specifies options for creating a commit comment.

type CreateCommitStatusOptions added in v0.4.0

type CreateCommitStatusOptions struct {
	State       string `json:"state"` // pending, success, error, failure
	TargetURL   string `json:"target_url,omitempty"`
	Description string `json:"description,omitempty"`
	Context     string `json:"context,omitempty"`
}

CreateCommitStatusOptions specifies options for creating a commit status.

type CreateDeployKeyOptions added in v0.4.0

type CreateDeployKeyOptions struct {
	Title    string `json:"title"`
	Key      string `json:"key"`
	ReadOnly *bool  `json:"read_only,omitempty"`
}

CreateDeployKeyOptions specifies options for creating a deploy key.

type CreateEnterpriseLabelOptions added in v0.5.0

type CreateEnterpriseLabelOptions struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

CreateEnterpriseLabelOptions specifies options for creating an enterprise label.

type CreateEnterpriseMilestoneOptions added in v0.5.0

type CreateEnterpriseMilestoneOptions struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	DueOn       string `json:"due_on,omitempty"`
}

CreateEnterpriseMilestoneOptions specifies options for creating an enterprise milestone.

type CreateFileOptions

type CreateFileOptions struct {
	Message string `json:"message"`
	Content string `json:"content"`
	Branch  string `json:"branch,omitempty"`
}

type CreateIssueOptions

type CreateIssueOptions struct {
	Title     string   `json:"title"`
	Body      string   `json:"body,omitempty"`
	Assignee  string   `json:"assignee,omitempty"`
	Assignees []string `json:"assignees,omitempty"`
	Milestone int64    `json:"milestone,omitempty"`
	Labels    []string `json:"labels,omitempty"`
}

func (CreateIssueOptions) MarshalJSON

func (o CreateIssueOptions) MarshalJSON() ([]byte, error)

type CreateMilestoneOptions

type CreateMilestoneOptions struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	DueOn       string `json:"due_on"`
}

type CreateOrgLabelOptions added in v0.4.0

type CreateOrgLabelOptions struct {
	Name      string `json:"name"`
	Color     string `json:"color"`
	Exclusive *bool  `json:"exclusive,omitempty"`
	Template  *bool  `json:"template,omitempty"`
}

CreateOrgLabelOptions specifies options for creating an organization label.

type CreateOrgOptions added in v0.4.0

type CreateOrgOptions struct {
	Username    string `json:"username"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Email       string `json:"email,omitempty"`
	Location    string `json:"location,omitempty"`
	Website     string `json:"website,omitempty"`
	Visibility  string `json:"visibility,omitempty"` // public, limited, private
}

CreateOrgOptions specifies options for creating an organization.

type CreateOrgRepoOptions

type CreateOrgRepoOptions struct {
	Name              string `json:"name"`
	Description       string `json:"description,omitempty"`
	Homepage          string `json:"homepage,omitempty"`
	HasIssues         *bool  `json:"has_issues,omitempty"`
	HasWiki           *bool  `json:"has_wiki,omitempty"`
	CanComment        *bool  `json:"can_comment,omitempty"`
	Public            *int   `json:"public,omitempty"`
	Private           *bool  `json:"private,omitempty"`
	AutoInit          *bool  `json:"auto_init,omitempty"`
	GitignoreTemplate string `json:"gitignore_template,omitempty"`
	LicenseTemplate   string `json:"license_template,omitempty"`
	Path              string `json:"path,omitempty"`
	DefaultBranch     string `json:"default_branch,omitempty"`
}

type CreateOrgWebhookOptions added in v0.4.0

type CreateOrgWebhookOptions struct {
	URL    string         `json:"url"`
	Secret string         `json:"secret,omitempty"`
	Events []string       `json:"events,omitempty"`
	Active *bool          `json:"active,omitempty"`
	Config *WebhookConfig `json:"config,omitempty"`
}

CreateOrgWebhookOptions specifies options for creating an organization webhook.

type CreateProtectedTagOptions added in v0.5.0

type CreateProtectedTagOptions struct {
	NamePattern string   `json:"name_pattern"`
	Owners      []string `json:"owners,omitempty"`
}

CreateProtectedTagOptions specifies options for creating a protected tag.

type CreatePullRequestInlineCommentOptions

type CreatePullRequestInlineCommentOptions struct {
	Body     string `json:"body"`
	Path     string `json:"path"`
	Line     int    `json:"line"`
	Side     string `json:"side"`
	CommitID string `json:"commit_id,omitempty"`
}

type CreatePullRequestOptions

type CreatePullRequestOptions struct {
	Title string `json:"title"`
	Body  string `json:"body,omitempty"`
	Head  string `json:"head"`
	Base  string `json:"base"`
	Draft bool   `json:"draft,omitempty"`
}

type CreateReactionOptions added in v0.4.0

type CreateReactionOptions struct {
	Content string `json:"content"`
}

CreateReactionOptions specifies options for creating a reaction.

type CreateReferenceOptions added in v0.4.0

type CreateReferenceOptions struct {
	Ref string `json:"ref"` // e.g. "refs/heads/feature" or "refs/tags/v1.0"
	SHA string `json:"sha"` // The SHA of the object to point to
}

CreateReferenceOptions specifies options for creating a reference.

type CreateReleaseOptions

type CreateReleaseOptions struct {
	TagName    string `json:"tag_name"`
	Target     string `json:"target_commitish,omitempty"`
	Title      string `json:"name"`
	Body       string `json:"body,omitempty"`
	Draft      bool   `json:"draft"`
	Prerelease bool   `json:"prerelease"`
}

type CreateRepositoryOptions

type CreateRepositoryOptions struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Private     *bool  `json:"private,omitempty"`
	AutoInit    *bool  `json:"auto_init,omitempty"`
}

type CreateSSHKeyOptions

type CreateSSHKeyOptions struct {
	Title string `json:"title"`
	Key   string `json:"key"`
}

type CreateTagOptions added in v0.4.0

type CreateTagOptions struct {
	TagName string `json:"tag_name"`
	Target  string `json:"target"` // SHA
	Message string `json:"message,omitempty"`
}

CreateTagOptions specifies options for creating a lightweight tag.

type CreateTeamOptions added in v0.4.0

type CreateTeamOptions struct {
	Name             string `json:"name"`
	Description      string `json:"description,omitempty"`
	Permission       string `json:"permission,omitempty"` // none, read, write, admin
	Privacy          string `json:"privacy,omitempty"`    // closed, secret
	CanCreateOrgRepo *bool  `json:"can_create_org_repo,omitempty"`
	ParentTeamID     int64  `json:"parent_team_id,omitempty"`
}

CreateTeamOptions specifies options for creating a team.

type CreateWebhookOptions

type CreateWebhookOptions struct {
	URL    string   `json:"url"`
	Secret string   `json:"secret,omitempty"`
	Events []string `json:"events,omitempty"`
	Active *bool    `json:"active,omitempty"`
}

type CreateWikiPageOptions added in v0.4.0

type CreateWikiPageOptions struct {
	Title         string `json:"title"`
	ContentBase64 string `json:"content_base64,omitempty"` // base64 encoded content
	Message       string `json:"message,omitempty"`
}

CreateWikiPageOptions specifies options for creating a wiki page.

type CustomizedRole

type CustomizedRole struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type DeleteFileOptions

type DeleteFileOptions struct {
	Message string `json:"message"`
	SHA     string `json:"sha"`
	Branch  string `json:"branch,omitempty"`
}

type DeployKey added in v0.4.0

type DeployKey struct {
	ID        int64     `json:"id"`
	Key       string    `json:"key"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
	ReadOnly  bool      `json:"read_only"`
	URL       string    `json:"url,omitempty"`
}

DeployKey represents a repository deploy key.

type Discussion added in v0.4.0

type Discussion struct {
	ID        int64     `json:"id"`
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	State     string    `json:"state"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	Labels    []*Label  `json:"labels"`
	HTMLURL   string    `json:"html_url,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Discussion represents a repository discussion.

type DiscussionComment added in v0.4.0

type DiscussionComment struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

DiscussionComment represents a comment on a discussion.

type DiscussionCommentReply added in v0.4.0

type DiscussionCommentReply struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	ReplyToID int64     `json:"reply_to_id,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

DiscussionCommentReply represents a reply to a discussion comment.

type DownloadStatistic

type DownloadStatistic struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

type Email

type Email struct {
	Email string `json:"email"`
	State string `json:"state"`
}

type EnterpriseCustomizedRole added in v0.5.0

type EnterpriseCustomizedRole struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Permission  string `json:"permission,omitempty"`
}

EnterpriseCustomizedRole represents a customized role in an enterprise.

type EnterpriseIssueStatus added in v0.4.0

type EnterpriseIssueStatus struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Color     string `json:"color,omitempty"`
	Sort      int    `json:"sort,omitempty"`
	IsDefault bool   `json:"is_default,omitempty"`
}

EnterpriseIssueStatus represents an enterprise-level issue status.

type EnterpriseLabel

type EnterpriseLabel struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Color     string `json:"color"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type EnterpriseMember

type EnterpriseMember struct {
	User       *User  `json:"user"`
	URL        string `json:"url"`
	Active     bool   `json:"active"`
	Role       string `json:"role"`
	Enterprise *struct {
		ID  int64  `json:"id"`
		URL string `json:"url"`
	} `json:"enterprise"`
}

type EnterpriseMilestone added in v0.5.0

type EnterpriseMilestone struct {
	ID          int64      `json:"id"`
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	State       string     `json:"state"`
	DueDate     *time.Time `json:"due_date,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

EnterpriseMilestone represents an enterprise milestone.

type Error

type Error struct {
	Message string `json:"message"`
	Errors  []struct {
		Resource string `json:"resource"`
		Field    string `json:"field"`
		Code     string `json:"code"`
	} `json:"errors"`
}

func (*Error) Error

func (e *Error) Error() string

type ExtendedUser added in v0.4.0

type ExtendedUser struct {
	ID                int64  `json:"id"`
	Login             string `json:"login"`
	Name              string `json:"name"`
	Email             string `json:"email"`
	AvatarURL         string `json:"avatar_url"`
	HTMLURL           string `json:"html_url"`
	Type              string `json:"type"`
	Bio               string `json:"bio,omitempty"`
	Location          string `json:"location,omitempty"`
	Website           string `json:"website,omitempty"`
	FullName          string `json:"full_name,omitempty"`
	FollowersCount    int    `json:"followers_count,omitempty"`
	FollowingCount    int    `json:"following_count,omitempty"`
	StarredReposCount int    `json:"starred_repos_count,omitempty"`
	Username          string `json:"username,omitempty"`
}

ExtendedUser represents extended user information.

type FieldError added in v0.6.0

type FieldError struct {
	Resource string `json:"resource"`
	Field    string `json:"field"`
	Code     string `json:"code"`
	Message  string `json:"message,omitempty"`
}

FieldError represents a field-level validation error.

type FileListEntry

type FileListEntry struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Type string `json:"type"`
}

type FileResult

type FileResult struct {
	Content *RepositoryContent `json:"content"`
	Commit  *Commit            `json:"commit"`
}

type FileUploadResult

type FileUploadResult struct {
	FilePath string `json:"file_path"`
}

type FlexInt

type FlexInt int

func (*FlexInt) UnmarshalJSON

func (fi *FlexInt) UnmarshalJSON(data []byte) error

type FlexString

type FlexString string

func (*FlexString) UnmarshalJSON

func (fs *FlexString) UnmarshalJSON(data []byte) error

type ForbiddenError added in v0.6.0

type ForbiddenError struct {
	*APIError
}

ForbiddenError represents a 403 Forbidden error.

func (*ForbiddenError) Error added in v0.6.0

func (e *ForbiddenError) Error() string

type ForkSyncStatus added in v0.4.0

type ForkSyncStatus struct {
	Synced    bool   `json:"synced"`
	BehindBy  int    `json:"behind_by"`
	AheadBy   int    `json:"ahead_by"`
	MergeBase string `json:"merge_base,omitempty"`
}

ForkSyncStatus represents the sync status of a forked repository.

type GitBlob

type GitBlob struct {
	SHA      string `json:"sha"`
	Size     int64  `json:"size"`
	URL      string `json:"url"`
	Content  string `json:"content"`
	Encoding string `json:"encoding"`
}

type GitObject added in v0.4.0

type GitObject struct {
	SHA  string `json:"sha"`
	Type string `json:"type"`
	URL  string `json:"url"`
}

GitObject represents a git object (commit, tree, blob, tag).

type GitReference added in v0.4.0

type GitReference struct {
	Ref    string     `json:"ref"`
	URL    string     `json:"url"`
	Object *GitObject `json:"object"`
}

GitReference represents a git reference.

type GitTree

type GitTree struct {
	SHA       string          `json:"sha"`
	URL       string          `json:"url"`
	Truncated bool            `json:"truncated"`
	Tree      []*GitTreeEntry `json:"tree"`
}

type GitTreeEntry

type GitTreeEntry struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
	Type string `json:"type"`
	SHA  string `json:"sha"`
	Size int64  `json:"size"`
	URL  string `json:"url"`
}

type GitignoreTemplate added in v0.4.0

type GitignoreTemplate struct {
	Name   string `json:"name"`
	Source string `json:"source"`
}

GitignoreTemplate represents a gitignore template.

type InviteMemberOptions

type InviteMemberOptions struct {
	Permission string `json:"permission,omitempty"`
	RoleID     string `json:"role_id,omitempty"`
}

type Issue

type Issue struct {
	ID        int64      `json:"id"`
	Number    FlexInt    `json:"number"`
	Title     string     `json:"title"`
	Body      string     `json:"body"`
	State     IssueState `json:"state"`
	User      *User      `json:"user"`
	Author    *User      `json:"author"`
	Assignees []*User    `json:"assignees"`
	Labels    []*Label   `json:"labels"`
	Milestone *Milestone `json:"milestone"`
	HTMLURL   string     `json:"html_url"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	ClosedAt  *time.Time `json:"closed_at"`
}

type IssueAssigneeResult added in v0.4.0

type IssueAssigneeResult struct {
	Assignees []*User `json:"assignees"`
}

IssueAssignee represents an issue assignee operation result.

type IssueComment

type IssueComment struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type IssueCustomField added in v0.5.0

type IssueCustomField struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	Required bool   `json:"required"`
	Options  []struct {
		ID   int64  `json:"id"`
		Name string `json:"name"`
	} `json:"options,omitempty"`
}

IssueCustomField represents a custom field for enterprise issues.

type IssueDependency added in v0.4.0

type IssueDependency struct {
	ID    int64  `json:"id"`
	Issue *Issue `json:"issue"`
}

IssueDependency represents a dependency between issues.

type IssueExtendSetting

type IssueExtendSetting struct {
	TypeName string `json:"type_name"`
	TypeID   int    `json:"type_id"`
	TypeDesc string `json:"type_desc"`
	Status   []*struct {
		StatusName         string `json:"status_name"`
		StatusID           int    `json:"status_id"`
		StatusDesc         string `json:"status_desc"`
		GitcodeIssueStatus int    `json:"gitcode_issue_status"`
	} `json:"status"`
}

type IssueOperateLog

type IssueOperateLog struct {
	ID        int64  `json:"id"`
	Action    string `json:"action"`
	CreatedAt string `json:"created_at"`
	User      *User  `json:"user"`
}

type IssueRelatedBranch added in v0.4.0

type IssueRelatedBranch struct {
	BranchName string `json:"branch_name"`
	RepoName   string `json:"repo_name,omitempty"`
}

IssueRelatedBranch represents a branch related to an issue.

type IssueState

type IssueState string
const (
	IssueStateOpen   IssueState = "open"
	IssueStateClosed IssueState = "closed"
)

type IssueSubscriber added in v0.4.0

type IssueSubscriber struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

IssueSubscriber represents a user subscribed to an issue.

type IssueTemplate added in v0.4.0

type IssueTemplate struct {
	Name        string   `json:"name"`
	FileName    string   `json:"file_name,omitempty"`
	Title       string   `json:"title"`
	Body        string   `json:"body"`
	Labels      []string `json:"labels,omitempty"`
	Assignees   []string `json:"assignees,omitempty"`
	Description string   `json:"description,omitempty"`
}

IssueTemplate represents a repository issue template.

type IssueTimelineEvent added in v0.4.0

type IssueTimelineEvent struct {
	ID        int64      `json:"id"`
	Action    string     `json:"action"`
	Body      string     `json:"body,omitempty"`
	User      *User      `json:"user"`
	Author    *User      `json:"author"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	CommitID  string     `json:"commit_id,omitempty"`
	EventType string     `json:"event,omitempty"`
	Label     *Label     `json:"label,omitempty"`
	Milestone *Milestone `json:"milestone,omitempty"`
	Rename    *struct {
		From string `json:"from"`
		To   string `json:"to"`
	} `json:"rename,omitempty"`
}

IssueTimelineEvent represents an event in an issue's timeline.

type IssueUserReaction added in v0.4.0

type IssueUserReaction struct {
	ID        int64     `json:"id"`
	Content   string    `json:"content"`
	User      *User     `json:"user"`
	CreatedAt time.Time `json:"created_at"`
}

IssueUserReaction represents a user's reaction to an issue.

type IssueWebhookEvent

type IssueWebhookEvent struct {
	Action     string      `json:"action"`
	Issue      *Issue      `json:"issue"`
	Repository *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

type KanbanBoard added in v0.5.0

type KanbanBoard struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

KanbanBoard represents a kanban board.

type KanbanBoardItem added in v0.5.0

type KanbanBoardItem struct {
	ID          int64  `json:"id"`
	BoardID     int64  `json:"board_id"`
	IssueNumber int    `json:"issue_number,omitempty"`
	PRNumber    int    `json:"pr_number,omitempty"`
	Status      string `json:"status"`
	Sort        int    `json:"sort,omitempty"`
}

KanbanBoardItem represents an item on a kanban board.

type KanbanBoardStatus added in v0.5.0

type KanbanBoardStatus struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Color     string `json:"color,omitempty"`
	Sort      int    `json:"sort,omitempty"`
	IsDefault bool   `json:"is_default,omitempty"`
}

KanbanBoardStatus represents a kanban board status.

type KanbanValue added in v0.4.0

type KanbanValue struct {
	FieldID   int64  `json:"field_id"`
	FieldName string `json:"field_name"`
	ValueID   int64  `json:"value_id"`
	ValueName string `json:"value_name"`
}

KanbanValue represents a kanban field value for an issue.

type Label

type Label struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
}

type Language

type Language map[string]int

type LicenseTemplate added in v0.4.0

type LicenseTemplate struct {
	Key         string   `json:"key"`
	Name        string   `json:"name"`
	URL         string   `json:"url,omitempty"`
	HTMLURL     string   `json:"html_url,omitempty"`
	HTMLContent string   `json:"html_content,omitempty"`
	Body        string   `json:"body,omitempty"`
	Featured    bool     `json:"featured,omitempty"`
	Conditions  []string `json:"conditions,omitempty"`
	Permissions []string `json:"permissions,omitempty"`
	Limitations []string `json:"limitations,omitempty"`
}

LicenseTemplate represents a license template.

type ListActionRunsOptions added in v0.5.0

type ListActionRunsOptions struct {
	ListOptions
	Status string `json:"status,omitempty"` // queued, in_progress, completed
	Branch string `json:"branch,omitempty"`
	Event  string `json:"event,omitempty"`
}

ListActionRunsOptions specifies options for listing action runs.

type ListBranchProtectionOptions

type ListBranchProtectionOptions struct {
	ListOptions
}

type ListCommitsOptions

type ListCommitsOptions struct {
	ListOptions
	Branch string `json:"branch,omitempty"`
	Since  string `json:"since,omitempty"`
	Until  string `json:"until,omitempty"`
}

type ListEnterprisePRsOptions

type ListEnterprisePRsOptions struct {
	ListOptions
	State       string `json:"state,omitempty"`
	IssueNumber int    `json:"issue_number,omitempty"`
	Sort        string `json:"sort,omitempty"`
	Direction   string `json:"direction,omitempty"`
}

type ListIssuesOptions

type ListIssuesOptions struct {
	ListOptions
	State     IssueState `json:"state,omitempty"`
	Assignee  string     `json:"assignee,omitempty"`
	Creator   string     `json:"creator,omitempty"`
	Milestone string     `json:"milestone,omitempty"`
	Labels    string     `json:"labels,omitempty"`
	Sort      string     `json:"sort,omitempty"`
	Direction string     `json:"direction,omitempty"`
	Since     string     `json:"since,omitempty"`
}

type ListMilestonesOptions

type ListMilestonesOptions struct {
	ListOptions
	State     string `json:"state,omitempty"`
	Sort      string `json:"sort,omitempty"`
	Direction string `json:"direction,omitempty"`
}

type ListNotificationsOptions added in v0.4.0

type ListNotificationsOptions struct {
	ListOptions
	All    bool   `json:"all,omitempty"`    // Include read notifications
	Since  string `json:"since,omitempty"`  // Only notifications updated after this time
	Before string `json:"before,omitempty"` // Only notifications updated before this time
	Status string `json:"status,omitempty"` // unread, read, pinned
}

ListNotificationsOptions specifies options for listing notifications.

type ListOptions

type ListOptions struct {
	Page    int `json:"page"`
	PerPage int `json:"per_page"`
}

ListOptions contains pagination parameters for list requests.

type ListPullRequestsOptions

type ListPullRequestsOptions struct {
	ListOptions
	State     PullRequestState `json:"state,omitempty"`
	Sort      string           `json:"sort,omitempty"`
	Direction string           `json:"direction,omitempty"`
	Head      string           `json:"head,omitempty"`
	Base      string           `json:"base,omitempty"`
}

type ListRepositoriesOptions

type ListRepositoriesOptions struct {
	ListOptions
	Owner string `json:"owner,omitempty"`
	Type  string `json:"type,omitempty"`
	Sort  string `json:"sort,omitempty"`
}

type ListStarredReposOptions

type ListStarredReposOptions struct {
	ListOptions
	Sort      string `json:"sort,omitempty"`
	Direction string `json:"direction,omitempty"`
}

type ListUserIssuesOptions

type ListUserIssuesOptions struct {
	ListOptions
	Filter    string `json:"filter,omitempty"`
	State     string `json:"state,omitempty"`
	Labels    string `json:"labels,omitempty"`
	Sort      string `json:"sort,omitempty"`
	Direction string `json:"direction,omitempty"`
	Since     string `json:"since,omitempty"`
}

type MarkNotificationsOptions added in v0.4.0

type MarkNotificationsOptions struct {
	LastReadAt string `json:"last_read_at,omitempty"` // ISO 8601 timestamp
	All        bool   `json:"all,omitempty"`
}

MarkNotificationsOptions specifies options for marking notifications.

type Member

type Member struct {
	ID    string `json:"id"`
	Login string `json:"login"`
	Role  string `json:"role"`
}

type MergePullRequestOptions

type MergePullRequestOptions struct {
	CommitMessage string `json:"commit_message,omitempty"`
	Squash        bool   `json:"squash,omitempty"`
}

type Milestone

type Milestone struct {
	ID          int64      `json:"id"`
	Title       string     `json:"title"`
	Description string     `json:"description"`
	State       string     `json:"state"`
	DueDate     *time.Time `json:"due_date"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

type ModifyHistoryEntry added in v0.4.0

type ModifyHistoryEntry struct {
	ID        int64     `json:"id"`
	Action    string    `json:"action"`
	Field     string    `json:"field,omitempty"`
	OldValue  string    `json:"old_value,omitempty"`
	NewValue  string    `json:"new_value,omitempty"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CreatedAt time.Time `json:"created_at"`
}

ModifyHistoryEntry represents a modification history entry.

type ModuleSetting

type ModuleSetting struct {
	Issues   bool `json:"issues"`
	Wiki     bool `json:"wiki"`
	Releases bool `json:"releases"`
}

type Namespace

type Namespace struct {
	ID      int64  `json:"id"`
	Path    string `json:"path"`
	Name    string `json:"name"`
	HTMLURL string `json:"html_url"`
	Type    string `json:"type"`
}

type NotFoundError added in v0.6.0

type NotFoundError struct {
	*APIError
	Resource string `json:"resource,omitempty"` // e.g. "repository", "issue", "user"
}

NotFoundError represents a 404 Not Found error.

func (*NotFoundError) Error added in v0.6.0

func (e *NotFoundError) Error() string

type NoteWebhookEvent

type NoteWebhookEvent struct {
	NoteType   string      `json:"noteable_type"`
	NoteID     int64       `json:"id"`
	Body       string      `json:"body"`
	Author     *User       `json:"author"`
	Repository *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

type Notification

type Notification struct {
	ID      string `json:"id"`
	Reason  string `json:"reason"`
	Unread  bool   `json:"unread"`
	Subject struct {
		Title string `json:"title"`
		URL   string `json:"url"`
		Type  string `json:"type"`
	} `json:"subject"`
	CreatedAt time.Time `json:"created_at"`
}

type NotificationSubject added in v0.4.0

type NotificationSubject struct {
	Title            string `json:"title"`
	URL              string `json:"url"`
	LatestCommentURL string `json:"latest_comment_url"`
	Type             string `json:"type"` // Issue, PullRequest, Commit, Repository
}

NotificationSubject represents the subject of a notification.

type NotificationThread added in v0.4.0

type NotificationThread struct {
	ID         int64                `json:"id"`
	Unread     bool                 `json:"unread"`
	Pinned     bool                 `json:"pinned,omitempty"`
	UpdatedAt  time.Time            `json:"updated_at"`
	Subject    *NotificationSubject `json:"subject"`
	Repository *Repository          `json:"repository"`
	URL        string               `json:"url"`
}

NotificationThread represents a detailed notification thread.

type NullableTime

type NullableTime struct {
	time.Time
	Valid bool
}

func (*NullableTime) UnmarshalJSON

func (nt *NullableTime) UnmarshalJSON(data []byte) error

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

func NewOAuthClient

func NewOAuthClient(clientID, clientSecret, redirectURI string) *OAuthClient

func (*OAuthClient) AuthorizeURL

func (o *OAuthClient) AuthorizeURL(scope, state string) string

func (*OAuthClient) ExchangeToken

func (o *OAuthClient) ExchangeToken(ctx context.Context, code string) (*OAuthToken, error)

func (*OAuthClient) RefreshToken

func (o *OAuthClient) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error)

func (*OAuthClient) SetBaseURL

func (o *OAuthClient) SetBaseURL(baseURL string)

type OAuthToken

type OAuthToken struct {
	AccessToken  string    `json:"access_token"`
	ExpiresIn    int       `json:"expires_in"`
	RefreshToken string    `json:"refresh_token"`
	Scope        string    `json:"scope"`
	CreatedAt    time.Time `json:"created_at"`
}

type OrgCustomizedRole added in v0.4.0

type OrgCustomizedRole struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Permission  string `json:"permission,omitempty"`
}

OrgCustomizedRole represents a customized role in an organization.

type OrgDiscussion added in v0.4.0

type OrgDiscussion struct {
	ID        int64     `json:"id"`
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	State     string    `json:"state"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	Labels    []*Label  `json:"labels"`
	HTMLURL   string    `json:"html_url,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

OrgDiscussion represents a discussion in an organization.

type OrgDiscussionComment added in v0.4.0

type OrgDiscussionComment struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

OrgDiscussionComment represents a comment on an organization discussion.

type OrgDiscussionCommentReply added in v0.4.0

type OrgDiscussionCommentReply struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	ReplyToID int64     `json:"reply_to_id,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

OrgDiscussionCommentReply represents a reply to an organization discussion comment.

type OrgEnterprise added in v0.5.0

type OrgEnterprise struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	URL  string `json:"url"`
}

OrgEnterprise represents the enterprise associated with an organization.

type OrgFollowers

type OrgFollowers struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar_url"`
	WatchAt   string `json:"watch_at"`
}

type OrgLabel added in v0.4.0

type OrgLabel struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Color     string    `json:"color"`
	Exclusive bool      `json:"exclusive,omitempty"`
	Template  bool      `json:"template,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

OrgLabel represents an organization-level label.

type OrgMember

type OrgMember struct {
	AvatarURL  string `json:"avatar_url"`
	HTMLURL    string `json:"html_url"`
	ID         string `json:"id"`
	Login      string `json:"login"`
	MemberRole string `json:"member_role"`
	Name       string `json:"name"`
	Type       string `json:"type"`
}

type OrgMemberDetail

type OrgMemberDetail struct {
	ID        int64  `json:"id"`
	Path      string `json:"path"`
	Name      string `json:"name"`
	URL       string `json:"url"`
	AvatarURL string `json:"avatar_url"`
	User      *User  `json:"user"`
}

type OrgWebhook added in v0.4.0

type OrgWebhook struct {
	ID                  int64          `json:"id"`
	URL                 string         `json:"url"`
	Events              []string       `json:"events"`
	Active              bool           `json:"active"`
	Config              *WebhookConfig `json:"config,omitempty"`
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	PushEvents          bool           `json:"push_events"`
	TagPushEvents       bool           `json:"tag_push_events"`
	IssuesEvents        bool           `json:"issues_events"`
	NoteEvents          bool           `json:"note_events"`
	MergeRequestsEvents bool           `json:"merge_requests_events"`
}

OrgWebhook represents an organization webhook.

type Organization

type Organization struct {
	ID          int64  `json:"id"`
	Login       string `json:"login"`
	Name        string `json:"name"`
	Description string `json:"description"`
	AvatarURL   string `json:"avatar_url"`
}

type PRDiscussionComment added in v0.4.0

type PRDiscussionComment struct {
	ID           int64     `json:"id"`
	Body         string    `json:"body"`
	User         *User     `json:"user"`
	Author       *User     `json:"author"`
	DiscussionID string    `json:"discussion_id,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

PRDiscussionComment represents a reply to a PR review comment.

type PRMergeTemplate added in v0.4.0

type PRMergeTemplate struct {
	Name string `json:"name"`
	Body string `json:"body"`
}

PRMergeTemplate represents a pull request merge template.

type PROperateLog

type PROperateLog struct {
	ID        int64  `json:"id"`
	Action    string `json:"action"`
	CreatedAt string `json:"created_at"`
	User      *User  `json:"user"`
}

type PRSettings

type PRSettings struct {
	DefaultMergeMethod string `json:"default_merge_method"`
	AutoCloseIssues    bool   `json:"auto_close_issues"`
}

type PageResult added in v0.6.0

type PageResult[T any] struct {
	Items []T
	Page  int
}

PageResult represents a single page of results.

type ParticipationStats added in v0.4.0

type ParticipationStats struct {
	All   []int `json:"all"`
	Owner []int `json:"owner"`
}

ParticipationStats represents participation statistics (weekly commits).

type ProtectedTag added in v0.5.0

type ProtectedTag struct {
	ID          int64     `json:"id"`
	NamePattern string    `json:"name_pattern"`
	Owners      []*User   `json:"owners,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

ProtectedTag represents a protected tag rule.

type PullRequest

type PullRequest struct {
	ID          int64              `json:"id"`
	Number      int                `json:"number"`
	IID         int                `json:"iid,omitempty"`
	Title       string             `json:"title"`
	Body        string             `json:"body"`
	Description string             `json:"description,omitempty"`
	State       PullRequestState   `json:"state"`
	User        *User              `json:"user"`
	Author      *User              `json:"author"`
	Head        *PullRequestBranch `json:"head"`
	Base        *PullRequestBranch `json:"base"`
	Merged      bool               `json:"merged"`
	Mergeable   *bool              `json:"mergeable"`
	HTMLURL     string             `json:"html_url"`
	DiffURL     string             `json:"diff_url,omitempty"`
	PatchURL    string             `json:"patch_url,omitempty"`
	Draft       bool               `json:"draft,omitempty"`
	CreatedAt   time.Time          `json:"created_at"`
	UpdatedAt   time.Time          `json:"updated_at"`
	ClosedAt    NullableTime       `json:"closed_at,omitempty"`
	MergedAt    NullableTime       `json:"merged_at,omitempty"`
}

type PullRequestBranch

type PullRequestBranch struct {
	Ref  string `json:"ref"`
	SHA  string `json:"sha"`
	Repo *struct {
		FullName string `json:"full_name"`
		Name     string `json:"name"`
		Path     string `json:"path"`
		HTMLURL  string `json:"html_url"`
	} `json:"repo"`
}

type PullRequestComment

type PullRequestComment struct {
	ID        FlexString `json:"id"`
	Body      string     `json:"body"`
	User      *User      `json:"user"`
	Author    *User      `json:"author"`
	Path      string     `json:"path"`
	Position  int        `json:"position"`
	Line      int        `json:"line"`
	Side      string     `json:"side"`
	CommitID  string     `json:"commit_id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

type PullRequestDiff added in v0.4.0

type PullRequestDiff struct {
	Content string `json:"content"`
}

PullRequestDiff represents the diff of a pull request.

type PullRequestFile

type PullRequestFile struct {
	Filename         string      `json:"filename"`
	PreviousFilename string      `json:"previous_filename,omitempty"`
	Status           string      `json:"status"`
	Additions        int         `json:"additions"`
	Deletions        int         `json:"deletions"`
	Changes          int         `json:"changes"`
	Patch            interface{} `json:"patch,omitempty"`
}

type PullRequestFileChange added in v0.4.0

type PullRequestFileChange struct {
	Filename         string `json:"filename"`
	PreviousFilename string `json:"previous_filename,omitempty"`
	Status           string `json:"status"`
	Additions        int    `json:"additions"`
	Deletions        int    `json:"deletions"`
	Changes          int    `json:"changes"`
	BlobURL          string `json:"blob_url,omitempty"`
	RawURL           string `json:"raw_url,omitempty"`
	ContentsURL      string `json:"contents_url,omitempty"`
	Patch            string `json:"patch,omitempty"`
}

PullRequestFileChange represents a file change in a pull request (JSON format).

type PullRequestReview

type PullRequestReview struct {
	ID        int64     `json:"id"`
	Body      string    `json:"body"`
	State     string    `json:"state"`
	User      *User     `json:"user"`
	Author    *User     `json:"author"`
	CommitID  string    `json:"commit_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type PullRequestReviewRequest added in v0.4.0

type PullRequestReviewRequest struct {
	Reviewers     []string `json:"reviewers,omitempty"`
	TeamReviewers []string `json:"team_reviewers,omitempty"`
}

PullRequestReviewRequest represents a review request.

type PullRequestState

type PullRequestState string
const (
	PullRequestStateOpen   PullRequestState = "open"
	PullRequestStateOpened PullRequestState = "opened"
	PullRequestStateClosed PullRequestState = "closed"
	PullRequestStateMerged PullRequestState = "merged"
)

type PullRequestWebhookEvent

type PullRequestWebhookEvent struct {
	Action      string       `json:"action"`
	Number      int          `json:"number"`
	PullRequest *PullRequest `json:"pull_request"`
	Repository  *Repository  `json:"repository"`
	Sender      *User        `json:"sender"`
}

type PunchCardEntry added in v0.4.0

type PunchCardEntry []int

PunchCardEntry represents a [day, hour, commits] tuple.

type PushConfig

type PushConfig struct {
	MaxFileSize        int      `json:"max_file_size"`
	ProhibitedFiles    []string `json:"prohibited_files"`
	CommitMessageRegex string   `json:"commit_message_regex"`
}

type PushEvent

type PushEvent struct {
	Ref        string      `json:"ref"`
	Before     string      `json:"before"`
	After      string      `json:"after"`
	Repository *Repository `json:"repository"`
	Commits    []*Commit   `json:"commits"`
	Sender     *User       `json:"sender"`
}

type RateLimit

type RateLimit struct {
	Limit     int       `json:"limit"`
	Remaining int       `json:"remaining"`
	Reset     time.Time `json:"reset"`
}

RateLimit contains rate limit information.

type RateLimitError added in v0.6.0

type RateLimitError struct {
	*APIError
	RetryAfter int `json:"retry_after,omitempty"` // seconds to wait
}

RateLimitError represents a 429 Too Many Requests error.

func (*RateLimitError) Error added in v0.6.0

func (e *RateLimitError) Error() string

type Reaction added in v0.4.0

type Reaction struct {
	ID        int64     `json:"id"`
	User      *User     `json:"user"`
	Content   string    `json:"content"` // +1, -1, laugh, confused, heart, hooray, rocket, eyes
	CreatedAt time.Time `json:"created_at"`
}

Reaction represents an emoji reaction.

type Release

type Release struct {
	ID              int64     `json:"id"`
	TagName         string    `json:"tag_name"`
	TargetCommitish string    `json:"target_commitish,omitempty"`
	Name            string    `json:"name"`
	Body            string    `json:"body"`
	HTMLURL         string    `json:"html_url,omitempty"`
	Draft           bool      `json:"draft"`
	Prerelease      bool      `json:"prerelease"`
	CreatedAt       time.Time `json:"created_at"`
	PublishedAt     time.Time `json:"published_at,omitempty"`
}

type ReleaseAsset added in v0.4.0

type ReleaseAsset struct {
	ID                 int64     `json:"id"`
	Name               string    `json:"name"`
	ContentType        string    `json:"content_type"`
	Size               int64     `json:"size"`
	DownloadCount      int       `json:"download_count"`
	BrowserDownloadURL string    `json:"browser_download_url"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

ReleaseAsset represents a release asset.

type ReleaseUploadURL added in v0.5.0

type ReleaseUploadURL struct {
	UploadURL string `json:"upload_url"`
	AssetID   int64  `json:"asset_id,omitempty"`
}

ReleaseUploadURL represents the upload URL for a release asset.

type RemoteMirror added in v0.4.0

type RemoteMirror struct {
	ID            int64  `json:"id"`
	RemoteURL     string `json:"remote_url"`
	Enabled       bool   `json:"enabled"`
	OnlyProtected bool   `json:"only_protected"`
	LastError     string `json:"last_error,omitempty"`
	LastUpdateAt  string `json:"last_update_at,omitempty"`
}

RemoteMirror represents a remote mirror configuration.

type RepoBranchInfo added in v0.4.0

type RepoBranchInfo struct {
	Name   string `json:"name"`
	Commit *struct {
		SHA string `json:"sha"`
		URL string `json:"url"`
	} `json:"commit"`
	Protected bool `json:"protected"`
}

RepoBranchInfo represents branch information for listing.

type RepoCLA added in v0.4.0

type RepoCLA struct {
	ID      int64  `json:"id"`
	Name    string `json:"name"`
	Content string `json:"content,omitempty"`
	Enabled bool   `json:"enabled"`
}

RepoCLA represents a repository CLA (Contributor License Agreement).

type RepoEvent

type RepoEvent struct {
	ID        int64  `json:"id"`
	Type      string `json:"type"`
	CreatedAt string `json:"created_at"`
	PushData  *struct {
		Ref string `json:"ref"`
	} `json:"push_data"`
}

type RepoInvitation added in v0.4.0

type RepoInvitation struct {
	ID         int64       `json:"id"`
	Repo       *Repository `json:"repo"`
	Invitee    *User       `json:"invitee"`
	Inviter    *User       `json:"inviter"`
	Permission string      `json:"permission"`
	CreatedAt  time.Time   `json:"created_at"`
	URL        string      `json:"url"`
	HTMLURL    string      `json:"html_url,omitempty"`
}

RepoInvitation represents a repository invitation.

type RepoLicense added in v0.4.0

type RepoLicense struct {
	Key     string `json:"key"`
	Name    string `json:"name"`
	URL     string `json:"url,omitempty"`
	HTMLURL string `json:"html_url,omitempty"`
	Body    string `json:"body,omitempty"`
}

RepoLicense represents a repository license.

type RepoSettings

type RepoSettings struct {
	ID            int64  `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	DefaultBranch string `json:"default_branch"`
	HasIssues     bool   `json:"has_issues"`
	HasWiki       bool   `json:"has_wiki"`
	CanComment    bool   `json:"can_comment"`
	Private       bool   `json:"private"`
}

type RepoStats added in v0.4.0

type RepoStats struct {
	Participation *ParticipationStats `json:"participation,omitempty"`
}

RepoStats represents repository statistics.

type Repository

type Repository struct {
	ID        int64  `json:"id"`
	FullName  string `json:"full_name"`
	Name      string `json:"name"`
	Path      string `json:"path,omitempty"`
	Owner     *User  `json:"owner"`
	Namespace *struct {
		ID   int64  `json:"id"`
		Name string `json:"name"`
		Path string `json:"path"`
	} `json:"namespace,omitempty"`
	Description     string     `json:"description"`
	CloneURL        string     `json:"http_url_to_repo"`
	SSHURL          string     `json:"ssh_url_to_repo"`
	HTMLURL         string     `json:"web_url"`
	DefaultBranch   string     `json:"default_branch"`
	Private         bool       `json:"private"`
	Public          bool       `json:"public,omitempty"`
	Fork            bool       `json:"fork"`
	StarsCount      int        `json:"stargazers_count"`
	ForksCount      int        `json:"forks_count"`
	WatchersCount   int        `json:"watchers_count"`
	OpenIssuesCount int        `json:"open_issues_count"`
	Language        string     `json:"language,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
	UpdatedAt       time.Time  `json:"updated_at"`
	PushedAt        *time.Time `json:"pushed_at,omitempty"`
}

type RepositoryContent

type RepositoryContent struct {
	Name     string `json:"name"`
	Path     string `json:"path"`
	Size     int64  `json:"size"`
	Type     string `json:"type"`
	Content  string `json:"content,omitempty"`
	Encoding string `json:"encoding,omitempty"`
	SHA      string `json:"sha"`
	Links    struct {
		Self string `json:"self"`
		Git  string `json:"git"`
	} `json:"_links"`
}

type RepositoryTopics added in v0.4.0

type RepositoryTopics struct {
	Topics []string `json:"topics"`
}

RepositoryTopics represents the topics of a repository.

type RequestHook added in v0.6.0

type RequestHook func(req *http.Request) error

RequestHook is a function called before each HTTP request. It can modify the request or return an error to cancel the request.

type ResponseHook added in v0.6.0

type ResponseHook func(resp *http.Response) error

ResponseHook is a function called after each HTTP response.

type RetryPolicy added in v0.6.0

type RetryPolicy struct {
	// MaxRetries is the maximum number of retry attempts. Default: 0 (no retry).
	MaxRetries int
	// InitialBackoff is the initial wait time before the first retry. Default: 1s.
	InitialBackoff time.Duration
	// MaxBackoff is the maximum wait time between retries. Default: 30s.
	MaxBackoff time.Duration
	// Multiplier is the backoff multiplier for exponential backoff. Default: 2.0.
	Multiplier float64
	// RetryableStatusCodes defines which HTTP status codes should trigger a retry.
	// Default: [429, 500, 502, 503, 504]
	RetryableStatusCodes []int
}

RetryPolicy defines the retry behavior for failed requests.

func DefaultRetryPolicy added in v0.6.0

func DefaultRetryPolicy() RetryPolicy

DefaultRetryPolicy returns a sensible default retry policy.

type Reviewer added in v0.4.0

type Reviewer struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

Reviewer represents a potential reviewer for a pull request.

type ReviewerConfig

type ReviewerConfig struct {
	MinApprovingReviews int  `json:"min_approving_reviews"`
	RequireCodeOwner    bool `json:"require_code_owner"`
}

type RunActionWorkflowOptions added in v0.5.0

type RunActionWorkflowOptions struct {
	Ref    string            `json:"ref"`
	Inputs map[string]string `json:"inputs,omitempty"`
}

RunActionWorkflowOptions specifies options for manually running a workflow.

type RunnerGroup added in v0.5.0

type RunnerGroup struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Visibility  string `json:"visibility,omitempty"`
	RunnersURL  string `json:"runners_url,omitempty"`
}

RunnerGroup represents a runner group.

type SSHKey

type SSHKey struct {
	ID        int64     `json:"id"`
	Title     string    `json:"title"`
	Key       string    `json:"key"`
	CreatedAt time.Time `json:"created_at"`
	URL       string    `json:"url"`
}

type SearchIssueResult

type SearchIssueResult struct {
	ID         int64     `json:"id"`
	HTMLURL    string    `json:"html_url"`
	Number     string    `json:"number"`
	State      string    `json:"state"`
	Title      string    `json:"title"`
	Body       string    `json:"body"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	Labels     []*Label  `json:"labels"`
	Priority   int       `json:"priority"`
	Comments   int       `json:"comments"`
	Repository *struct {
		ID        int64  `json:"id"`
		FullName  string `json:"full_name"`
		HumanName string `json:"human_name"`
		Path      string `json:"path"`
		Name      string `json:"name"`
		URL       string `json:"url"`
		Owner     *User  `json:"owner"`
	} `json:"repository"`
}

type SearchIssuesOptions

type SearchIssuesOptions struct {
	ListOptions
	Query string `json:"q"`
	Sort  string `json:"sort,omitempty"`
	Order string `json:"order,omitempty"`
	Repo  string `json:"repo,omitempty"`
	State string `json:"state,omitempty"`
}

type SearchOptions

type SearchOptions struct {
	ListOptions
	Query string `json:"q"`
	Order string `json:"order,omitempty"`
}

type SearchRepositoriesOptions

type SearchRepositoriesOptions struct {
	ListOptions
	Query    string `json:"q"`
	Sort     string `json:"sort,omitempty"`
	Order    string `json:"order,omitempty"`
	Owner    string `json:"owner,omitempty"`
	Fork     string `json:"fork,omitempty"`
	Language string `json:"language,omitempty"`
}

type SearchRepositoryResult

type SearchRepositoryResult struct {
	ID              int64     `json:"id"`
	FullName        string    `json:"full_name"`
	HumanName       string    `json:"human_name"`
	Path            string    `json:"path"`
	Name            string    `json:"name"`
	Description     string    `json:"description"`
	SSHURLToRepo    string    `json:"ssh_url_to_repo"`
	HTTPURLToRepo   string    `json:"http_url_to_repo"`
	WebURL          string    `json:"web_url"`
	ForksCount      int       `json:"forks_count"`
	StargazersCount int       `json:"stargazers_count"`
	WatchersCount   int       `json:"watchers_count"`
	DefaultBranch   string    `json:"default_branch"`
	OpenIssuesCount int       `json:"open_issues_count"`
	Private         bool      `json:"private"`
	Public          bool      `json:"public"`
	Fork            bool      `json:"fork"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	PushedAt        string    `json:"pushed_at"`
	Owner           *User     `json:"owner"`
	Namespace       *struct {
		ID      int64  `json:"id"`
		Type    string `json:"type"`
		Name    string `json:"name"`
		Path    string `json:"path"`
		HTMLURL string `json:"html_url"`
	} `json:"namespace"`
}

type SearchResult

type SearchResult struct {
	TotalCount int           `json:"total_count"`
	Items      []*Repository `json:"items"`
}

type SearchUserResult

type SearchUserResult struct {
	ID        string    `json:"id"`
	Login     string    `json:"login"`
	Name      string    `json:"name"`
	AvatarURL string    `json:"avatar_url"`
	HTMLURL   string    `json:"html_url"`
	CreatedAt time.Time `json:"created_at"`
}

type SearchUsersOptions

type SearchUsersOptions struct {
	ListOptions
	Query string `json:"q"`
	Sort  string `json:"sort,omitempty"`
	Order string `json:"order,omitempty"`
}

type Star

type Star struct {
	StarredAt time.Time `json:"starred_at"`
}

type Tag

type Tag struct {
	Name   string `json:"name"`
	Commit struct {
		SHA string `json:"sha"`
	} `json:"commit"`
}

type TagPushEvent

type TagPushEvent struct {
	Ref        string      `json:"ref"`
	Before     string      `json:"before"`
	After      string      `json:"after"`
	Repository *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

type TagWithRelease added in v0.4.0

type TagWithRelease struct {
	Name    string `json:"name"`
	Message string `json:"message,omitempty"`
	Commit  *struct {
		SHA string `json:"sha"`
		URL string `json:"url"`
	} `json:"commit"`
	ZipballURL string    `json:"zipball_url,omitempty"`
	TarballURL string    `json:"tarball_url,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty"`
}

TagWithRelease represents a tag with its associated release info.

type Team added in v0.4.0

type Team struct {
	ID               int64  `json:"id"`
	Name             string `json:"name"`
	Description      string `json:"description,omitempty"`
	Permission       string `json:"permission,omitempty"` // read, write, admin
	Privacy          string `json:"privacy,omitempty"`    // closed, secret
	CanCreateOrgRepo bool   `json:"can_create_org_repo,omitempty"`
	HTMLURL          string `json:"html_url,omitempty"`
	Parent           *Team  `json:"parent,omitempty"`
}

Team represents an organization team.

type TeamMember added in v0.4.0

type TeamMember struct {
	ID        int64     `json:"id"`
	Login     string    `json:"login"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	AvatarURL string    `json:"avatar_url"`
	CreatedAt time.Time `json:"created_at"`
}

TeamMember represents a team member.

type Timestamp

type Timestamp struct {
	time.Time
}

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

type TransferRepoOptions

type TransferRepoOptions struct {
	NewOwner string `json:"new_owner"`
}

type UnauthorizedError added in v0.6.0

type UnauthorizedError struct {
	*APIError
}

UnauthorizedError represents a 401 Unauthorized error.

func (*UnauthorizedError) Error added in v0.6.0

func (e *UnauthorizedError) Error() string

type UpdateBranchProtectionOptions

type UpdateBranchProtectionOptions struct {
	Pusher string `json:"pusher"`
	Merger string `json:"merger"`
}

type UpdateCommitCommentOptions added in v0.4.0

type UpdateCommitCommentOptions struct {
	Body string `json:"body"`
}

UpdateCommitCommentOptions specifies options for updating a commit comment.

type UpdateCurrentUserOptions added in v0.4.0

type UpdateCurrentUserOptions struct {
	Name     string `json:"name,omitempty"`
	Email    string `json:"email,omitempty"`
	Bio      string `json:"bio,omitempty"`
	Location string `json:"location,omitempty"`
	Website  string `json:"website,omitempty"`
}

UpdateCurrentUserOptions specifies options for updating the authenticated user's profile.

type UpdateEnterpriseLabelOptions added in v0.5.0

type UpdateEnterpriseLabelOptions struct {
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
}

UpdateEnterpriseLabelOptions specifies options for updating an enterprise label.

type UpdateEnterpriseMemberOptions

type UpdateEnterpriseMemberOptions struct {
	Role string `json:"role"`
}

type UpdateEnterpriseMilestoneOptions added in v0.5.0

type UpdateEnterpriseMilestoneOptions struct {
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	State       string `json:"state,omitempty"`
	DueOn       string `json:"due_on,omitempty"`
}

UpdateEnterpriseMilestoneOptions specifies options for updating an enterprise milestone.

type UpdateFileOptions

type UpdateFileOptions struct {
	Message string `json:"message"`
	Content string `json:"content"`
	SHA     string `json:"sha"`
	Branch  string `json:"branch,omitempty"`
}

type UpdateIssueOptions

type UpdateIssueOptions struct {
	Title      string     `json:"title,omitempty"`
	Body       string     `json:"body,omitempty"`
	State      IssueState `json:"state,omitempty"`
	StateEvent string     `json:"state_event,omitempty"`
	Assignee   string     `json:"assignee,omitempty"`
	Assignees  []string   `json:"assignees,omitempty"`
	Milestone  int64      `json:"milestone,omitempty"`
	Labels     []string   `json:"labels,omitempty"`
}

type UpdateKanbanBoardItemOptions added in v0.5.0

type UpdateKanbanBoardItemOptions struct {
	Status string `json:"status,omitempty"`
	Sort   int    `json:"sort,omitempty"`
}

UpdateKanbanBoardItemOptions specifies options for updating a kanban board item.

type UpdateKanbanBoardStatusOptions added in v0.5.0

type UpdateKanbanBoardStatusOptions struct {
	Statuses []KanbanBoardStatus `json:"statuses"`
}

UpdateKanbanBoardStatusOptions specifies options for updating a kanban board status.

type UpdateLabelOptions

type UpdateLabelOptions struct {
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
}

type UpdateMemberOptions

type UpdateMemberOptions struct {
	Permission string `json:"permission"`
}

type UpdateMilestoneOptions

type UpdateMilestoneOptions struct {
	Title       string `json:"title"`
	State       string `json:"state,omitempty"`
	Description string `json:"description,omitempty"`
	DueOn       string `json:"due_on"`
}

type UpdateOrgLabelOptions added in v0.4.0

type UpdateOrgLabelOptions struct {
	Name      string `json:"name,omitempty"`
	Color     string `json:"color,omitempty"`
	Exclusive *bool  `json:"exclusive,omitempty"`
	Template  *bool  `json:"template,omitempty"`
}

UpdateOrgLabelOptions specifies options for updating an organization label.

type UpdateOrgOptions

type UpdateOrgOptions struct {
	Name        string `json:"name,omitempty"`
	Email       string `json:"email,omitempty"`
	Location    string `json:"location,omitempty"`
	Description string `json:"description,omitempty"`
	HTMLURL     string `json:"html_url,omitempty"`
}

type UpdateOrgWebhookOptions added in v0.4.0

type UpdateOrgWebhookOptions struct {
	URL    string         `json:"url,omitempty"`
	Secret string         `json:"secret,omitempty"`
	Events []string       `json:"events,omitempty"`
	Active *bool          `json:"active,omitempty"`
	Config *WebhookConfig `json:"config,omitempty"`
}

UpdateOrgWebhookOptions specifies options for updating an organization webhook.

type UpdateProtectedTagOptions added in v0.5.0

type UpdateProtectedTagOptions struct {
	NamePattern string   `json:"name_pattern,omitempty"`
	Owners      []string `json:"owners,omitempty"`
}

UpdateProtectedTagOptions specifies options for updating a protected tag.

type UpdatePullRequestOptions

type UpdatePullRequestOptions struct {
	Title      string           `json:"title,omitempty"`
	Body       string           `json:"body,omitempty"`
	State      PullRequestState `json:"state,omitempty"`
	StateEvent string           `json:"state_event,omitempty"`
	Base       string           `json:"base,omitempty"`
}

type UpdateReferenceOptions added in v0.4.0

type UpdateReferenceOptions struct {
	SHA   string `json:"sha"`
	Force bool   `json:"force,omitempty"`
}

UpdateReferenceOptions specifies options for updating a reference.

type UpdateReleaseOptions added in v0.4.0

type UpdateReleaseOptions struct {
	TagName         string `json:"tag_name,omitempty"`
	TargetCommitish string `json:"target_commitish,omitempty"`
	Name            string `json:"name,omitempty"`
	Body            string `json:"body,omitempty"`
	Draft           *bool  `json:"draft,omitempty"`
	Prerelease      *bool  `json:"prerelease,omitempty"`
}

UpdateReleaseOptions specifies options for updating a release.

type UpdateRepositoryOptions

type UpdateRepositoryOptions struct {
	Name          string `json:"name,omitempty"`
	Description   string `json:"description,omitempty"`
	DefaultBranch string `json:"default_branch,omitempty"`
	Private       *bool  `json:"private,omitempty"`
}

type UpdateTeamOptions added in v0.4.0

type UpdateTeamOptions struct {
	Name             string `json:"name,omitempty"`
	Description      string `json:"description,omitempty"`
	Permission       string `json:"permission,omitempty"`
	Privacy          string `json:"privacy,omitempty"`
	CanCreateOrgRepo *bool  `json:"can_create_org_repo,omitempty"`
	ParentTeamID     int64  `json:"parent_team_id,omitempty"`
}

UpdateTeamOptions specifies options for updating a team.

type UpdateWebhookOptions

type UpdateWebhookOptions struct {
	URL    string   `json:"url,omitempty"`
	Secret string   `json:"secret,omitempty"`
	Events []string `json:"events,omitempty"`
	Active *bool    `json:"active,omitempty"`
}

type UpdateWikiPageOptions added in v0.4.0

type UpdateWikiPageOptions struct {
	ContentBase64 string `json:"content_base64,omitempty"` // base64 encoded content
	Message       string `json:"message,omitempty"`
}

UpdateWikiPageOptions specifies options for updating a wiki page.

type User

type User struct {
	ID        FlexString `json:"id"`
	Login     string     `json:"login"`
	Name      string     `json:"name"`
	Email     string     `json:"email"`
	AvatarURL string     `json:"avatar_url"`
	HTMLURL   string     `json:"html_url,omitempty"`
	Type      string     `json:"type,omitempty"`
}

User represents a GitCode user.

type UserEvent

type UserEvent struct {
	Action         int    `json:"action"`
	ActionName     string `json:"action_name"`
	AuthorID       int64  `json:"author_id"`
	AuthorUsername string `json:"author_username"`
	ProjectID      int64  `json:"project_id"`
	ProjectName    string `json:"project_name"`
	CreatedAt      string `json:"created_at"`
	PushData       *struct {
		CommitCount int    `json:"commit_count"`
		Action      string `json:"action"`
		RefType     string `json:"ref_type"`
		Ref         string `json:"ref"`
		CommitFrom  string `json:"commit_from"`
		CommitTo    string `json:"commit_to"`
		CommitTitle string `json:"commit_title"`
	} `json:"push_data"`
}

type UserEventsResponse

type UserEventsResponse struct {
	Events map[string][]*UserEvent `json:"events"`
	Next   string                  `json:"next"`
}

type UserMembership

type UserMembership struct {
	ID           int64  `json:"id"`
	Path         string `json:"path"`
	Name         string `json:"name"`
	URL          string `json:"url"`
	AvatarURL    string `json:"avatar_url"`
	User         *User  `json:"user"`
	Active       bool   `json:"active"`
	Role         string `json:"role"`
	Organization *struct {
		ID    int64  `json:"id"`
		Login string `json:"login"`
		Name  string `json:"name"`
	} `json:"organization"`
}

type ValidationError added in v0.6.0

type ValidationError struct {
	*APIError
	Errors []FieldError `json:"errors,omitempty"`
}

ValidationError represents a 422 Unprocessable Entity error.

func (*ValidationError) Error added in v0.6.0

func (e *ValidationError) Error() string

type ValidationErrorField added in v0.6.0

type ValidationErrorField struct {
	Field   string
	Message string
}

ValidationErrorField represents a client-side validation error.

func (*ValidationErrorField) Error added in v0.6.0

func (e *ValidationErrorField) Error() string

type Webhook

type Webhook struct {
	ID                  int64     `json:"id"`
	URL                 string    `json:"url"`
	Events              []string  `json:"events"`
	PushEvents          bool      `json:"push_events"`
	TagPushEvents       bool      `json:"tag_push_events"`
	IssuesEvents        bool      `json:"issues_events"`
	MergeRequestsEvents bool      `json:"merge_requests_events"`
	NoteEvents          bool      `json:"note_events"`
	Active              bool      `json:"active"`
	CreatedAt           time.Time `json:"created_at"`
	UpdatedAt           time.Time `json:"updated_at"`
}

type WebhookConfig added in v0.4.0

type WebhookConfig struct {
	URL         string `json:"url"`
	ContentType string `json:"content_type,omitempty"`
	Secret      string `json:"secret,omitempty"`
	InsecureSSL bool   `json:"insecure_ssl,omitempty"`
}

WebhookConfig represents the configuration of a webhook.

type WebhookEvent

type WebhookEvent struct {
	Ref        string      `json:"ref"`
	Before     string      `json:"before"`
	After      string      `json:"after"`
	Repository *Repository `json:"repository"`
	Commits    []*Commit   `json:"commits"`
	Sender     *User       `json:"sender"`
}

type WikiPage added in v0.4.0

type WikiPage struct {
	Title      string `json:"title"`
	Content    string `json:"content,omitempty"`
	HTMLURL    string `json:"html_url,omitempty"`
	CommitSHA  string `json:"commit_sha,omitempty"`
	Sidebar    string `json:"sidebar,omitempty"`
	Footer     string `json:"footer,omitempty"`
	LastCommit *struct {
		SHA     string `json:"sha"`
		Message string `json:"message"`
	} `json:"last_commit,omitempty"`
}

WikiPage represents a wiki page.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL