mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-04-26 21:44:44 +00:00
parent
7f3a6eb17f
commit
a82d569bd1
195 changed files with 48885 additions and 7521 deletions
10
go.mod
10
go.mod
|
@ -26,9 +26,8 @@ require (
|
||||||
github.com/go-sql-driver/mysql v1.6.0
|
github.com/go-sql-driver/mysql v1.6.0
|
||||||
github.com/gogits/go-gogs-client v0.0.0-20160212212711-d584b1e0fb4d
|
github.com/gogits/go-gogs-client v0.0.0-20160212212711-d584b1e0fb4d
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-github v0.0.0-20151120211125-47f2593dad19
|
github.com/google/go-github/v39 v39.1.0
|
||||||
github.com/google/go-querystring v1.0.0 // indirect
|
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
github.com/hashicorp/go-version v1.3.0 // indirect
|
github.com/hashicorp/go-version v1.3.0 // indirect
|
||||||
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1
|
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1
|
||||||
|
@ -39,7 +38,7 @@ require (
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||||
github.com/moby/moby v20.10.8+incompatible
|
github.com/moby/moby v20.10.8+incompatible
|
||||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
||||||
github.com/morikuni/aec v1.0.0 // indirect
|
github.com/morikuni/aec v1.0.0 // indirect
|
||||||
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450
|
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450
|
||||||
github.com/prometheus/client_golang v1.7.1
|
github.com/prometheus/client_golang v1.7.1
|
||||||
|
@ -60,8 +59,7 @@ require (
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||||
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
|
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
google.golang.org/appengine v1.6.6 // indirect
|
|
||||||
google.golang.org/grpc v1.33.2
|
google.golang.org/grpc v1.33.2
|
||||||
google.golang.org/protobuf v1.27.1 // indirect
|
google.golang.org/protobuf v1.27.1
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
)
|
)
|
||||||
|
|
16
go.sum
16
go.sum
|
@ -376,12 +376,13 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-github v0.0.0-20151120211125-47f2593dad19 h1:RNqPPpiIA6KLsN6eqPHdRr/Di6tBROVtTo8GKwvyQ1U=
|
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||||
github.com/google/go-github v0.0.0-20151120211125-47f2593dad19/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
github.com/google/go-github/v39 v39.1.0 h1:1vf4gM0D1e+Df2HMxaYC3+o9+Huj3ywGTtWc3VVYaDA=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-github/v39 v39.1.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE=
|
||||||
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
|
@ -740,6 +741,7 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
@ -973,8 +975,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
||||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk=
|
google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/v39/github"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultBranch = "master"
|
const defaultBranch = "master"
|
||||||
|
@ -109,9 +109,9 @@ func convertRepo(from *github.Repository, private bool) *model.Repo {
|
||||||
// permissions to the common Drone permissions structure.
|
// permissions to the common Drone permissions structure.
|
||||||
func convertPerm(from *github.Repository) *model.Perm {
|
func convertPerm(from *github.Repository) *model.Perm {
|
||||||
return &model.Perm{
|
return &model.Perm{
|
||||||
Admin: (*from.Permissions)["admin"],
|
Admin: from.Permissions["admin"],
|
||||||
Push: (*from.Permissions)["push"],
|
Push: from.Permissions["push"],
|
||||||
Pull: (*from.Permissions)["pull"],
|
Pull: from.Permissions["pull"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,28 +129,17 @@ func convertTeamPerm(from *github.Membership) *model.Perm {
|
||||||
|
|
||||||
// convertRepoList is a helper function used to convert a GitHub repository
|
// convertRepoList is a helper function used to convert a GitHub repository
|
||||||
// list to the common Drone repository structure.
|
// list to the common Drone repository structure.
|
||||||
func convertRepoList(from []github.Repository, private bool) []*model.Repo {
|
func convertRepoList(from []*github.Repository, private bool) []*model.Repo {
|
||||||
var repos []*model.Repo
|
var repos []*model.Repo
|
||||||
for _, repo := range from {
|
for _, repo := range from {
|
||||||
repos = append(repos, convertRepo(&repo, private))
|
repos = append(repos, convertRepo(repo, private))
|
||||||
}
|
}
|
||||||
return repos
|
return repos
|
||||||
}
|
}
|
||||||
|
|
||||||
// // convertRepoLite is a helper function used to convert a GitHub repository
|
|
||||||
// // structure to the common Drone repository structure.
|
|
||||||
// func convertRepoLite(from github.Repository) *model.RepoLite {
|
|
||||||
// return &model.RepoLite{
|
|
||||||
// Owner: *from.Owner.Login,
|
|
||||||
// Name: *from.Name,
|
|
||||||
// FullName: *from.FullName,
|
|
||||||
// Avatar: *from.Owner.AvatarURL,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// convertTeamList is a helper function used to convert a GitHub team list to
|
// convertTeamList is a helper function used to convert a GitHub team list to
|
||||||
// the common Drone repository structure.
|
// the common Drone repository structure.
|
||||||
func convertTeamList(from []github.Organization) []*model.Team {
|
func convertTeamList(from []*github.Organization) []*model.Team {
|
||||||
var teams []*model.Team
|
var teams []*model.Team
|
||||||
for _, team := range from {
|
for _, team := range from {
|
||||||
teams = append(teams, convertTeam(team))
|
teams = append(teams, convertTeam(team))
|
||||||
|
@ -160,7 +149,7 @@ func convertTeamList(from []github.Organization) []*model.Team {
|
||||||
|
|
||||||
// convertTeam is a helper function used to convert a GitHub team structure
|
// convertTeam is a helper function used to convert a GitHub team structure
|
||||||
// to the common Drone repository structure.
|
// to the common Drone repository structure.
|
||||||
func convertTeam(from github.Organization) *model.Team {
|
func convertTeam(from *github.Organization) *model.Team {
|
||||||
return &model.Team{
|
return &model.Team{
|
||||||
Login: *from.Login,
|
Login: *from.Login,
|
||||||
Avatar: *from.AvatarURL,
|
Avatar: *from.AvatarURL,
|
||||||
|
|
|
@ -17,10 +17,10 @@ package github
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||||
|
|
||||||
"github.com/franela/goblin"
|
"github.com/franela/goblin"
|
||||||
|
"github.com/google/go-github/v39/github"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_helper(t *testing.T) {
|
func Test_helper(t *testing.T) {
|
||||||
|
@ -65,7 +65,7 @@ func Test_helper(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("should convert repository list", func() {
|
g.It("should convert repository list", func() {
|
||||||
from := []github.Repository{
|
from := []*github.Repository{
|
||||||
{
|
{
|
||||||
Private: github.Bool(false),
|
Private: github.Bool(false),
|
||||||
FullName: github.String("octocat/hello-world"),
|
FullName: github.String("octocat/hello-world"),
|
||||||
|
@ -76,7 +76,7 @@ func Test_helper(t *testing.T) {
|
||||||
},
|
},
|
||||||
HTMLURL: github.String("https://github.com/octocat/hello-world"),
|
HTMLURL: github.String("https://github.com/octocat/hello-world"),
|
||||||
CloneURL: github.String("https://github.com/octocat/hello-world.git"),
|
CloneURL: github.String("https://github.com/octocat/hello-world.git"),
|
||||||
Permissions: &map[string]bool{
|
Permissions: map[string]bool{
|
||||||
"push": true,
|
"push": true,
|
||||||
"pull": true,
|
"pull": true,
|
||||||
"admin": true,
|
"admin": true,
|
||||||
|
@ -103,7 +103,7 @@ func Test_helper(t *testing.T) {
|
||||||
AvatarURL: github.String("http://..."),
|
AvatarURL: github.String("http://..."),
|
||||||
Login: github.String("octocat"),
|
Login: github.String("octocat"),
|
||||||
},
|
},
|
||||||
Permissions: &map[string]bool{
|
Permissions: map[string]bool{
|
||||||
"push": true,
|
"push": true,
|
||||||
"pull": true,
|
"pull": true,
|
||||||
"admin": true,
|
"admin": true,
|
||||||
|
@ -124,7 +124,7 @@ func Test_helper(t *testing.T) {
|
||||||
|
|
||||||
g.It("should convert repository permissions", func() {
|
g.It("should convert repository permissions", func() {
|
||||||
from := &github.Repository{
|
from := &github.Repository{
|
||||||
Permissions: &map[string]bool{
|
Permissions: map[string]bool{
|
||||||
"admin": true,
|
"admin": true,
|
||||||
"push": true,
|
"push": true,
|
||||||
"pull": true,
|
"pull": true,
|
||||||
|
@ -138,7 +138,7 @@ func Test_helper(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("should convert team", func() {
|
g.It("should convert team", func() {
|
||||||
from := github.Organization{
|
from := &github.Organization{
|
||||||
Login: github.String("octocat"),
|
Login: github.String("octocat"),
|
||||||
AvatarURL: github.String("http://..."),
|
AvatarURL: github.String("http://..."),
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ func Test_helper(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("should convert team list", func() {
|
g.It("should convert team list", func() {
|
||||||
from := []github.Organization{
|
from := []*github.Organization{
|
||||||
{
|
{
|
||||||
Login: github.String("octocat"),
|
Login: github.String("octocat"),
|
||||||
AvatarURL: github.String("http://..."),
|
AvatarURL: github.String("http://..."),
|
||||||
|
|
|
@ -29,8 +29,7 @@ import (
|
||||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||||
"github.com/woodpecker-ci/woodpecker/server/remote"
|
"github.com/woodpecker-ci/woodpecker/server/remote"
|
||||||
|
|
||||||
// TODO upgrade to v39 to pass context down
|
"github.com/google/go-github/v39/github"
|
||||||
"github.com/google/go-github/github"
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,12 +129,12 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
||||||
}
|
}
|
||||||
|
|
||||||
client := c.newClientToken(ctx, token.AccessToken)
|
client := c.newClientToken(ctx, token.AccessToken)
|
||||||
user, _, err := client.Users.Get("")
|
user, _, err := client.Users.Get(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
emails, _, err := client.Users.ListEmails(nil)
|
emails, _, err := client.Users.ListEmails(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -155,7 +154,7 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
||||||
// Auth returns the GitHub user login for the given access token.
|
// Auth returns the GitHub user login for the given access token.
|
||||||
func (c *client) Auth(ctx context.Context, token, secret string) (string, error) {
|
func (c *client) Auth(ctx context.Context, token, secret string) (string, error) {
|
||||||
client := c.newClientToken(ctx, token)
|
client := c.newClientToken(ctx, token)
|
||||||
user, _, err := client.Users.Get("")
|
user, _, err := client.Users.Get(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ func (c *client) Teams(ctx context.Context, u *model.User) ([]*model.Team, error
|
||||||
|
|
||||||
var teams []*model.Team
|
var teams []*model.Team
|
||||||
for opts.Page > 0 {
|
for opts.Page > 0 {
|
||||||
list, resp, err := client.Organizations.List("", opts)
|
list, resp, err := client.Organizations.List(ctx, "", opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -184,7 +183,7 @@ func (c *client) Teams(ctx context.Context, u *model.User) ([]*model.Team, error
|
||||||
// Repo returns the named GitHub repository.
|
// Repo returns the named GitHub repository.
|
||||||
func (c *client) Repo(ctx context.Context, u *model.User, owner, name string) (*model.Repo, error) {
|
func (c *client) Repo(ctx context.Context, u *model.User, owner, name string) (*model.Repo, error) {
|
||||||
client := c.newClientToken(ctx, u.Token)
|
client := c.newClientToken(ctx, u.Token)
|
||||||
repo, _, err := client.Repositories.Get(owner, name)
|
repo, _, err := client.Repositories.Get(ctx, owner, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ func (c *client) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
|
||||||
|
|
||||||
var repos []*model.Repo
|
var repos []*model.Repo
|
||||||
for opts.Page > 0 {
|
for opts.Page > 0 {
|
||||||
list, resp, err := client.Repositories.List("", opts)
|
list, resp, err := client.Repositories.List(ctx, "", opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -215,7 +214,7 @@ func (c *client) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
|
||||||
// Perm returns the user permissions for the named GitHub repository.
|
// Perm returns the user permissions for the named GitHub repository.
|
||||||
func (c *client) Perm(ctx context.Context, u *model.User, owner, name string) (*model.Perm, error) {
|
func (c *client) Perm(ctx context.Context, u *model.User, owner, name string) (*model.Perm, error) {
|
||||||
client := c.newClientToken(ctx, u.Token)
|
client := c.newClientToken(ctx, u.Token)
|
||||||
repo, _, err := client.Repositories.Get(owner, name)
|
repo, _, err := client.Repositories.Get(ctx, owner, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -228,14 +227,15 @@ func (c *client) File(ctx context.Context, u *model.User, r *model.Repo, b *mode
|
||||||
|
|
||||||
opts := new(github.RepositoryContentGetOptions)
|
opts := new(github.RepositoryContentGetOptions)
|
||||||
opts.Ref = b.Commit
|
opts.Ref = b.Commit
|
||||||
data, _, _, err := client.Repositories.GetContents(r.Owner, r.Name, f, opts)
|
content, _, _, err := client.Repositories.GetContents(ctx, r.Owner, r.Name, f, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if data == nil {
|
if content == nil {
|
||||||
return nil, fmt.Errorf("%s is a folder not a file use Dir(..)", f)
|
return nil, fmt.Errorf("%s is a folder not a file use Dir(..)", f)
|
||||||
}
|
}
|
||||||
return data.Decode()
|
data, err := content.GetContent()
|
||||||
|
return []byte(data), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model.Build, f string) ([]*remote.FileMeta, error) {
|
func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model.Build, f string) ([]*remote.FileMeta, error) {
|
||||||
|
@ -243,7 +243,7 @@ func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model
|
||||||
|
|
||||||
opts := new(github.RepositoryContentGetOptions)
|
opts := new(github.RepositoryContentGetOptions)
|
||||||
opts.Ref = b.Commit
|
opts.Ref = b.Commit
|
||||||
_, data, _, err := client.Repositories.GetContents(r.Owner, r.Name, f, opts)
|
_, data, _, err := client.Repositories.GetContents(ctx, r.Owner, r.Name, f, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ func (c *client) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||||
// the GitHub repository.
|
// the GitHub repository.
|
||||||
func (c *client) Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error {
|
func (c *client) Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error {
|
||||||
client := c.newClientToken(ctx, u.Token)
|
client := c.newClientToken(ctx, u.Token)
|
||||||
hooks, _, err := client.Repositories.ListHooks(r.Owner, r.Name, nil)
|
hooks, _, err := client.Repositories.ListHooks(ctx, r.Owner, r.Name, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ func (c *client) Deactivate(ctx context.Context, u *model.User, r *model.Repo, l
|
||||||
if match == nil {
|
if match == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err = client.Repositories.DeleteHook(r.Owner, r.Name, *match.ID)
|
_, err = client.Repositories.DeleteHook(ctx, r.Owner, r.Name, *match.ID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,25 +376,25 @@ func (c *client) newClientToken(ctx context.Context, token string) *github.Clien
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to return matching user email.
|
// helper function to return matching user email.
|
||||||
func matchingEmail(emails []github.UserEmail, rawurl string) *github.UserEmail {
|
func matchingEmail(emails []*github.UserEmail, rawURL string) *github.UserEmail {
|
||||||
for _, email := range emails {
|
for _, email := range emails {
|
||||||
if email.Email == nil || email.Primary == nil || email.Verified == nil {
|
if email.Email == nil || email.Primary == nil || email.Verified == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if *email.Primary && *email.Verified {
|
if *email.Primary && *email.Verified {
|
||||||
return &email
|
return email
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// github enterprise does not support verified email addresses so instead
|
// github enterprise does not support verified email addresses so instead
|
||||||
// we'll return the first email address in the list.
|
// we'll return the first email address in the list.
|
||||||
if len(emails) != 0 && rawurl != defaultAPI {
|
if len(emails) != 0 && rawURL != defaultAPI {
|
||||||
return &emails[0]
|
return emails[0]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to return matching hook.
|
// helper function to return matching hook.
|
||||||
func matchingHooks(hooks []github.Hook, rawurl string) *github.Hook {
|
func matchingHooks(hooks []*github.Hook, rawurl string) *github.Hook {
|
||||||
link, err := url.Parse(rawurl)
|
link, err := url.Parse(rawurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -411,9 +411,9 @@ func matchingHooks(hooks []github.Hook, rawurl string) *github.Hook {
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
hookurl, err := url.Parse(s)
|
hookURL, err := url.Parse(s)
|
||||||
if err == nil && hookurl.Host == link.Host {
|
if err == nil && hookURL.Host == link.Host {
|
||||||
return &hook
|
return hook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -429,13 +429,13 @@ func (c *client) Status(ctx context.Context, u *model.User, r *model.Repo, b *mo
|
||||||
client := c.newClientToken(ctx, u.Token)
|
client := c.newClientToken(ctx, u.Token)
|
||||||
switch b.Event {
|
switch b.Event {
|
||||||
case "deployment":
|
case "deployment":
|
||||||
return deploymentStatus(client, r, b, link)
|
return deploymentStatus(ctx, client, r, b, link)
|
||||||
default:
|
default:
|
||||||
return repoStatus(client, r, b, link, c.Context, proc)
|
return repoStatus(ctx, client, r, b, link, c.Context, proc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoStatus(client *github.Client, r *model.Repo, b *model.Build, link, ctx string, proc *model.Proc) error {
|
func repoStatus(c context.Context, client *github.Client, r *model.Repo, b *model.Build, link, ctx string, proc *model.Proc) error {
|
||||||
switch b.Event {
|
switch b.Event {
|
||||||
case model.EventPull:
|
case model.EventPull:
|
||||||
ctx += "/pr"
|
ctx += "/pr"
|
||||||
|
@ -460,13 +460,13 @@ func repoStatus(client *github.Client, r *model.Repo, b *model.Build, link, ctx
|
||||||
Description: desc,
|
Description: desc,
|
||||||
TargetURL: github.String(link),
|
TargetURL: github.String(link),
|
||||||
}
|
}
|
||||||
_, _, err := client.Repositories.CreateStatus(r.Owner, r.Name, b.Commit, &data)
|
_, _, err := client.Repositories.CreateStatus(c, r.Owner, r.Name, b.Commit, &data)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var reDeploy = regexp.MustCompile(".+/deployments/(\\d+)")
|
var reDeploy = regexp.MustCompile(".+/deployments/(\\d+)")
|
||||||
|
|
||||||
func deploymentStatus(client *github.Client, r *model.Repo, b *model.Build, link string) error {
|
func deploymentStatus(ctx context.Context, client *github.Client, r *model.Repo, b *model.Build, link string) error {
|
||||||
matches := reDeploy.FindStringSubmatch(b.Link)
|
matches := reDeploy.FindStringSubmatch(b.Link)
|
||||||
if len(matches) != 2 {
|
if len(matches) != 2 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -476,9 +476,9 @@ func deploymentStatus(client *github.Client, r *model.Repo, b *model.Build, link
|
||||||
data := github.DeploymentStatusRequest{
|
data := github.DeploymentStatusRequest{
|
||||||
State: github.String(convertStatus(b.Status)),
|
State: github.String(convertStatus(b.Status)),
|
||||||
Description: github.String(convertDesc(b.Status)),
|
Description: github.String(convertDesc(b.Status)),
|
||||||
TargetURL: github.String(link),
|
LogURL: github.String(link),
|
||||||
}
|
}
|
||||||
_, _, err := client.Repositories.CreateDeploymentStatus(r.Owner, r.Name, id, &data)
|
_, _, err := client.Repositories.CreateDeploymentStatus(ctx, r.Owner, r.Name, int64(id), &data)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin
|
||||||
"content_type": "form",
|
"content_type": "form",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, _, err := client.Repositories.CreateHook(r.Owner, r.Name, hook)
|
_, _, err := client.Repositories.CreateHook(ctx, r.Owner, r.Name, hook)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
64
vendor/github.com/google/go-github/AUTHORS
generated
vendored
64
vendor/github.com/google/go-github/AUTHORS
generated
vendored
|
@ -1,64 +0,0 @@
|
||||||
# This is the official list of go-github authors for copyright purposes.
|
|
||||||
# This file is distinct from the CONTRIBUTORS files.
|
|
||||||
# See the latter for an explanation.
|
|
||||||
|
|
||||||
Akeda Bagus <akeda@x-team.com>
|
|
||||||
Alec Thomas <alec@swapoff.org>
|
|
||||||
Alexander Harkness <me@bearbin.net>
|
|
||||||
Amey Sakhadeo <me@ameyms.com>
|
|
||||||
Andreas Garnæs <https://github.com/andreas>
|
|
||||||
Arıl Bozoluk <arilbozoluk@hotmail.com>
|
|
||||||
Austin Dizzy <dizzy@wow.com>
|
|
||||||
Beyang Liu <beyang.liu@gmail.com>
|
|
||||||
Brian Egizi <brian@mojotech.com>
|
|
||||||
Cami Diez <diezcami@gmail.com>
|
|
||||||
Charlie Yan <charlieyan08@gmail.com>
|
|
||||||
Chris Schaefer <chris@dtzq.com>
|
|
||||||
Colin Misare <github.com/cmisare>
|
|
||||||
Craig Peterson <cpeterson@stackoverflow.com>
|
|
||||||
Cristian Maglie <c.maglie@bug.st>
|
|
||||||
Daniel Leavitt <daniel.leavitt@gmail.com>
|
|
||||||
Diego Lapiduz <diego.lapiduz@cfpb.gov>
|
|
||||||
Dmitri Shuralyov <shurcooL@gmail.com>
|
|
||||||
dmnlk <seikima2demon@gmail.com>
|
|
||||||
Doug Turner <doug.turner@gmail.com>
|
|
||||||
erwinvaneyk <erwinvaneyk@gmail.com>
|
|
||||||
Francis <hello@francismakes.com>
|
|
||||||
Fredrik Jönsson <fredrik.jonsson@izettle.com>
|
|
||||||
Google Inc.
|
|
||||||
Guz Alexander <kalimatas@gmail.com>
|
|
||||||
Hari haran <hariharan.uno@gmail.com>
|
|
||||||
i2bskn <i2bskn@gmail.com>
|
|
||||||
Jameel Haffejee <RC1140@republiccommandos.co.za>
|
|
||||||
Jihoon Chung <j.c@navercorp.com>
|
|
||||||
Justin Abrahms <justin@abrah.ms>
|
|
||||||
Konrad Malawski <konrad.malawski@project13.pl>
|
|
||||||
Krzysztof Kowalczyk <kkowalczyk@gmail.com>
|
|
||||||
kyokomi <kyoko1220adword@gmail.com>
|
|
||||||
Maksim Zhylinski <uzzable@gmail.com>
|
|
||||||
Martin-Louis Bright <mlbright@gmail.com>
|
|
||||||
Mat Geist <matgeist@gmail.com>
|
|
||||||
Matt Landis <landis.matt@gmail.com>
|
|
||||||
Maxime Bury <maxime.bury@gmail.com>
|
|
||||||
Michael Tiller <michael.tiller@gmail.com>
|
|
||||||
Ondrej Kupka <ondra.cap@gmail.com>
|
|
||||||
Panagiotis Moustafellos <pmoust@gmail.com>
|
|
||||||
Parker Moore <parkrmoore@gmail.com>
|
|
||||||
Piotr Zurek <p.zurek@gmail.com>
|
|
||||||
Quinn Slack <qslack@qslack.com>
|
|
||||||
Rackspace US, Inc.
|
|
||||||
Rob Figueiredo <robfig@yext.com>
|
|
||||||
Ruben Vereecken <rubenvereecken@gmail.com>
|
|
||||||
Ryan Lower <rpjlower@gmail.com>
|
|
||||||
Sander van Harmelen <svanharmelen@schubergphilis.com>
|
|
||||||
Sean Wang <sean@decrypted.org>
|
|
||||||
Shawn Smith <shawnpsmith@gmail.com>
|
|
||||||
SoundCloud, Ltd.
|
|
||||||
Stian Eikeland <stian@eikeland.se>
|
|
||||||
Thomas Bruyelle <thomas.bruyelle@gmail.com>
|
|
||||||
Trey Tacon <ttacon@gmail.com>
|
|
||||||
Victor Castell <victor@victorcastell.com>
|
|
||||||
William Bailey <mail@williambailey.org.uk>
|
|
||||||
Yann Malet <yann.malet@gmail.com>
|
|
||||||
Yicheng Qin <qycqycqycqycqyc@gmail.com>
|
|
||||||
Zach Latta <zach@zachlatta.com>
|
|
82
vendor/github.com/google/go-github/CONTRIBUTORS
generated
vendored
82
vendor/github.com/google/go-github/CONTRIBUTORS
generated
vendored
|
@ -1,82 +0,0 @@
|
||||||
# People who have agreed to one of the CLAs and can contribute patches.
|
|
||||||
# The AUTHORS file lists the copyright holders; this file
|
|
||||||
# lists people. For example, Google employees are listed here
|
|
||||||
# but not in AUTHORS, because Google holds the copyright.
|
|
||||||
#
|
|
||||||
# https://developers.google.com/open-source/cla/individual
|
|
||||||
# https://developers.google.com/open-source/cla/corporate
|
|
||||||
#
|
|
||||||
# Note that the CLA isn't a copyright _assigment_ but rather a
|
|
||||||
# copyright _license_. You retain the copyright on your
|
|
||||||
# contributions.
|
|
||||||
|
|
||||||
Akeda Bagus <akeda@x-team.com>
|
|
||||||
Alec Thomas <alec@swapoff.org>
|
|
||||||
Alex Bramley <a.bramley@gmail.com>
|
|
||||||
Alexander Harkness <me@bearbin.net>
|
|
||||||
Ali Afshar <afshar@google.com>
|
|
||||||
Amey Sakhadeo <me@ameyms.com>
|
|
||||||
Andreas Garnæs <https://github.com/andreas>
|
|
||||||
Arıl Bozoluk <arilbozoluk@hotmail.com>
|
|
||||||
Austin Dizzy <dizzy@wow.com>
|
|
||||||
Beyang Liu <beyang.liu@gmail.com>
|
|
||||||
Billy Lynch <wlynch@google.com> <wlynch92@gmail.com>
|
|
||||||
Brendan Burns <bburns@google.com>
|
|
||||||
Brian Egizi <brian@mojotech.com>
|
|
||||||
Cami Diez <diezcami@gmail.com>
|
|
||||||
Charlie Yan <charlieyan08@gmail.com>
|
|
||||||
Chris Broadfoot <cbro@google.com>
|
|
||||||
Chris Schaefer <chris@dtzq.com>
|
|
||||||
Colin Misare <github.com/cmisare>
|
|
||||||
Craig Peterson <cpeterson@stackoverflow.com>
|
|
||||||
Cristian Maglie <c.maglie@bug.st>
|
|
||||||
Daniel Leavitt <daniel.leavitt@gmail.com>
|
|
||||||
Diego Lapiduz <diego.lapiduz@cfpb.gov>
|
|
||||||
Dmitri Shuralyov <shurcooL@gmail.com>
|
|
||||||
dmnlk <seikima2demon@gmail.com>
|
|
||||||
Doug Turner <doug.turner@gmail.com>
|
|
||||||
erwinvaneyk <erwinvaneyk@gmail.com>
|
|
||||||
Francis <hello@francismakes.com>
|
|
||||||
Fredrik Jönsson <fredrik.jonsson@izettle.com>
|
|
||||||
Guz Alexander <kalimatas@gmail.com>
|
|
||||||
Hari haran <hariharan.uno@gmail.com>
|
|
||||||
i2bskn <i2bskn@gmail.com>
|
|
||||||
Jameel Haffejee <RC1140@republiccommandos.co.za>
|
|
||||||
Jason Hall <jasonhall@google.com>
|
|
||||||
Jihoon Chung <j.c@navercorp.com>
|
|
||||||
Justin Abrahms <justin@abrah.ms>
|
|
||||||
Konrad Malawski <konrad.malawski@project13.pl>
|
|
||||||
Krzysztof Kowalczyk <kkowalczyk@gmail.com>
|
|
||||||
Kyle Kelley <kyle.kelley@rackspace.com>
|
|
||||||
kyokomi <kyoko1220adword@gmail.com>
|
|
||||||
Maksim Zhylinski <uzzable@gmail.com>
|
|
||||||
Mark McDonald <macd@google.com>
|
|
||||||
Martin-Louis Bright <mlbright@gmail.com>
|
|
||||||
Mat Geist <matgeist@gmail.com>
|
|
||||||
Matt Landis <landis.matt@gmail.com>
|
|
||||||
Maxime Bury <maxime.bury@gmail.com>
|
|
||||||
Michael Tiller <michael.tiller@gmail.com>
|
|
||||||
Nathan VanBenschoten <nvanbenschoten@gmail.com>
|
|
||||||
Omar Jarjur <ojarjur@google.com>
|
|
||||||
Ondrej Kupka <ondra.cap@gmail.com>
|
|
||||||
Panagiotis Moustafellos <pmoust@gmail.com>
|
|
||||||
Parker Moore <parkrmoore@gmail.com>
|
|
||||||
Piotr Zurek <p.zurek@gmail.com>
|
|
||||||
Quinn Slack <qslack@qslack.com>
|
|
||||||
Rob Figueiredo <robfig@yext.com>
|
|
||||||
Russ Cox <rsc@golang.org>
|
|
||||||
Ruben Vereecken <rubenvereecken@gmail.com>
|
|
||||||
Ryan Lower <rpjlower@gmail.com>
|
|
||||||
Sander van Harmelen <svanharmelen@schubergphilis.com>
|
|
||||||
Sean Wang <sean@decrypted.org>
|
|
||||||
Shawn Smith <shawnpsmith@gmail.com>
|
|
||||||
Stian Eikeland <stian@eikeland.se>
|
|
||||||
Thomas Bruyelle <thomas.bruyelle@gmail.com>
|
|
||||||
Tobias Schmidt <ts@soundcloud.com>
|
|
||||||
Trey Tacon <ttacon@gmail.com>
|
|
||||||
Victor Castell <victor@victorcastell.com>
|
|
||||||
Will Norris <willnorris@google.com> <will@willnorris.com>
|
|
||||||
William Bailey <mail@williambailey.org.uk>
|
|
||||||
Yann Malet <yann.malet@gmail.com>
|
|
||||||
Yicheng Qin <qycqycqycqycqyc@gmail.com>
|
|
||||||
Zach Latta <zach@zachlatta.com>
|
|
340
vendor/github.com/google/go-github/LICENSE
generated
vendored
340
vendor/github.com/google/go-github/LICENSE
generated
vendored
|
@ -1,340 +0,0 @@
|
||||||
Copyright (c) 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
----------
|
|
||||||
|
|
||||||
Some documentation is taken from the GitHub Developer site
|
|
||||||
<http://developer.github.com/>, which is available under a Creative Commons
|
|
||||||
Attribution 3.0 License:
|
|
||||||
|
|
||||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
|
||||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
|
||||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
|
||||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
|
||||||
|
|
||||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
|
||||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
|
||||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
|
||||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
|
||||||
CONDITIONS.
|
|
||||||
|
|
||||||
1. Definitions
|
|
||||||
|
|
||||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
|
||||||
other pre-existing works, such as a translation, adaptation,
|
|
||||||
derivative work, arrangement of music or other alterations of a
|
|
||||||
literary or artistic work, or phonogram or performance and includes
|
|
||||||
cinematographic adaptations or any other form in which the Work may be
|
|
||||||
recast, transformed, or adapted including in any form recognizably
|
|
||||||
derived from the original, except that a work that constitutes a
|
|
||||||
Collection will not be considered an Adaptation for the purpose of
|
|
||||||
this License. For the avoidance of doubt, where the Work is a musical
|
|
||||||
work, performance or phonogram, the synchronization of the Work in
|
|
||||||
timed-relation with a moving image ("synching") will be considered an
|
|
||||||
Adaptation for the purpose of this License.
|
|
||||||
b. "Collection" means a collection of literary or artistic works, such as
|
|
||||||
encyclopedias and anthologies, or performances, phonograms or
|
|
||||||
broadcasts, or other works or subject matter other than works listed
|
|
||||||
in Section 1(f) below, which, by reason of the selection and
|
|
||||||
arrangement of their contents, constitute intellectual creations, in
|
|
||||||
which the Work is included in its entirety in unmodified form along
|
|
||||||
with one or more other contributions, each constituting separate and
|
|
||||||
independent works in themselves, which together are assembled into a
|
|
||||||
collective whole. A work that constitutes a Collection will not be
|
|
||||||
considered an Adaptation (as defined above) for the purposes of this
|
|
||||||
License.
|
|
||||||
c. "Distribute" means to make available to the public the original and
|
|
||||||
copies of the Work or Adaptation, as appropriate, through sale or
|
|
||||||
other transfer of ownership.
|
|
||||||
d. "Licensor" means the individual, individuals, entity or entities that
|
|
||||||
offer(s) the Work under the terms of this License.
|
|
||||||
e. "Original Author" means, in the case of a literary or artistic work,
|
|
||||||
the individual, individuals, entity or entities who created the Work
|
|
||||||
or if no individual or entity can be identified, the publisher; and in
|
|
||||||
addition (i) in the case of a performance the actors, singers,
|
|
||||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
|
||||||
play in, interpret or otherwise perform literary or artistic works or
|
|
||||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
|
||||||
being the person or legal entity who first fixes the sounds of a
|
|
||||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
|
||||||
organization that transmits the broadcast.
|
|
||||||
f. "Work" means the literary and/or artistic work offered under the terms
|
|
||||||
of this License including without limitation any production in the
|
|
||||||
literary, scientific and artistic domain, whatever may be the mode or
|
|
||||||
form of its expression including digital form, such as a book,
|
|
||||||
pamphlet and other writing; a lecture, address, sermon or other work
|
|
||||||
of the same nature; a dramatic or dramatico-musical work; a
|
|
||||||
choreographic work or entertainment in dumb show; a musical
|
|
||||||
composition with or without words; a cinematographic work to which are
|
|
||||||
assimilated works expressed by a process analogous to cinematography;
|
|
||||||
a work of drawing, painting, architecture, sculpture, engraving or
|
|
||||||
lithography; a photographic work to which are assimilated works
|
|
||||||
expressed by a process analogous to photography; a work of applied
|
|
||||||
art; an illustration, map, plan, sketch or three-dimensional work
|
|
||||||
relative to geography, topography, architecture or science; a
|
|
||||||
performance; a broadcast; a phonogram; a compilation of data to the
|
|
||||||
extent it is protected as a copyrightable work; or a work performed by
|
|
||||||
a variety or circus performer to the extent it is not otherwise
|
|
||||||
considered a literary or artistic work.
|
|
||||||
g. "You" means an individual or entity exercising rights under this
|
|
||||||
License who has not previously violated the terms of this License with
|
|
||||||
respect to the Work, or who has received express permission from the
|
|
||||||
Licensor to exercise rights under this License despite a previous
|
|
||||||
violation.
|
|
||||||
h. "Publicly Perform" means to perform public recitations of the Work and
|
|
||||||
to communicate to the public those public recitations, by any means or
|
|
||||||
process, including by wire or wireless means or public digital
|
|
||||||
performances; to make available to the public Works in such a way that
|
|
||||||
members of the public may access these Works from a place and at a
|
|
||||||
place individually chosen by them; to perform the Work to the public
|
|
||||||
by any means or process and the communication to the public of the
|
|
||||||
performances of the Work, including by public digital performance; to
|
|
||||||
broadcast and rebroadcast the Work by any means including signs,
|
|
||||||
sounds or images.
|
|
||||||
i. "Reproduce" means to make copies of the Work by any means including
|
|
||||||
without limitation by sound or visual recordings and the right of
|
|
||||||
fixation and reproducing fixations of the Work, including storage of a
|
|
||||||
protected performance or phonogram in digital form or other electronic
|
|
||||||
medium.
|
|
||||||
|
|
||||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
|
||||||
limit, or restrict any uses free from copyright or rights arising from
|
|
||||||
limitations or exceptions that are provided for in connection with the
|
|
||||||
copyright protection under copyright law or other applicable laws.
|
|
||||||
|
|
||||||
3. License Grant. Subject to the terms and conditions of this License,
|
|
||||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
|
||||||
perpetual (for the duration of the applicable copyright) license to
|
|
||||||
exercise the rights in the Work as stated below:
|
|
||||||
|
|
||||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
|
||||||
Collections, and to Reproduce the Work as incorporated in the
|
|
||||||
Collections;
|
|
||||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
|
||||||
including any translation in any medium, takes reasonable steps to
|
|
||||||
clearly label, demarcate or otherwise identify that changes were made
|
|
||||||
to the original Work. For example, a translation could be marked "The
|
|
||||||
original work was translated from English to Spanish," or a
|
|
||||||
modification could indicate "The original work has been modified.";
|
|
||||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
|
||||||
in Collections; and,
|
|
||||||
d. to Distribute and Publicly Perform Adaptations.
|
|
||||||
e. For the avoidance of doubt:
|
|
||||||
|
|
||||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
|
||||||
which the right to collect royalties through any statutory or
|
|
||||||
compulsory licensing scheme cannot be waived, the Licensor
|
|
||||||
reserves the exclusive right to collect such royalties for any
|
|
||||||
exercise by You of the rights granted under this License;
|
|
||||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
|
||||||
which the right to collect royalties through any statutory or
|
|
||||||
compulsory licensing scheme can be waived, the Licensor waives the
|
|
||||||
exclusive right to collect such royalties for any exercise by You
|
|
||||||
of the rights granted under this License; and,
|
|
||||||
iii. Voluntary License Schemes. The Licensor waives the right to
|
|
||||||
collect royalties, whether individually or, in the event that the
|
|
||||||
Licensor is a member of a collecting society that administers
|
|
||||||
voluntary licensing schemes, via that society, from any exercise
|
|
||||||
by You of the rights granted under this License.
|
|
||||||
|
|
||||||
The above rights may be exercised in all media and formats whether now
|
|
||||||
known or hereafter devised. The above rights include the right to make
|
|
||||||
such modifications as are technically necessary to exercise the rights in
|
|
||||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
|
||||||
granted by Licensor are hereby reserved.
|
|
||||||
|
|
||||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
|
||||||
subject to and limited by the following restrictions:
|
|
||||||
|
|
||||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
|
||||||
of this License. You must include a copy of, or the Uniform Resource
|
|
||||||
Identifier (URI) for, this License with every copy of the Work You
|
|
||||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
|
||||||
on the Work that restrict the terms of this License or the ability of
|
|
||||||
the recipient of the Work to exercise the rights granted to that
|
|
||||||
recipient under the terms of the License. You may not sublicense the
|
|
||||||
Work. You must keep intact all notices that refer to this License and
|
|
||||||
to the disclaimer of warranties with every copy of the Work You
|
|
||||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
|
||||||
Perform the Work, You may not impose any effective technological
|
|
||||||
measures on the Work that restrict the ability of a recipient of the
|
|
||||||
Work from You to exercise the rights granted to that recipient under
|
|
||||||
the terms of the License. This Section 4(a) applies to the Work as
|
|
||||||
incorporated in a Collection, but this does not require the Collection
|
|
||||||
apart from the Work itself to be made subject to the terms of this
|
|
||||||
License. If You create a Collection, upon notice from any Licensor You
|
|
||||||
must, to the extent practicable, remove from the Collection any credit
|
|
||||||
as required by Section 4(b), as requested. If You create an
|
|
||||||
Adaptation, upon notice from any Licensor You must, to the extent
|
|
||||||
practicable, remove from the Adaptation any credit as required by
|
|
||||||
Section 4(b), as requested.
|
|
||||||
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
|
||||||
Collections, You must, unless a request has been made pursuant to
|
|
||||||
Section 4(a), keep intact all copyright notices for the Work and
|
|
||||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
|
||||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
|
||||||
and/or if the Original Author and/or Licensor designate another party
|
|
||||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
|
||||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
|
||||||
terms of service or by other reasonable means, the name of such party
|
|
||||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
|
||||||
extent reasonably practicable, the URI, if any, that Licensor
|
|
||||||
specifies to be associated with the Work, unless such URI does not
|
|
||||||
refer to the copyright notice or licensing information for the Work;
|
|
||||||
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
|
|
||||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
|
||||||
"French translation of the Work by Original Author," or "Screenplay
|
|
||||||
based on original Work by Original Author"). The credit required by
|
|
||||||
this Section 4 (b) may be implemented in any reasonable manner;
|
|
||||||
provided, however, that in the case of a Adaptation or Collection, at
|
|
||||||
a minimum such credit will appear, if a credit for all contributing
|
|
||||||
authors of the Adaptation or Collection appears, then as part of these
|
|
||||||
credits and in a manner at least as prominent as the credits for the
|
|
||||||
other contributing authors. For the avoidance of doubt, You may only
|
|
||||||
use the credit required by this Section for the purpose of attribution
|
|
||||||
in the manner set out above and, by exercising Your rights under this
|
|
||||||
License, You may not implicitly or explicitly assert or imply any
|
|
||||||
connection with, sponsorship or endorsement by the Original Author,
|
|
||||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
|
||||||
use of the Work, without the separate, express prior written
|
|
||||||
permission of the Original Author, Licensor and/or Attribution
|
|
||||||
Parties.
|
|
||||||
c. Except as otherwise agreed in writing by the Licensor or as may be
|
|
||||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
|
||||||
Publicly Perform the Work either by itself or as part of any
|
|
||||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
|
||||||
take other derogatory action in relation to the Work which would be
|
|
||||||
prejudicial to the Original Author's honor or reputation. Licensor
|
|
||||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
|
||||||
of the right granted in Section 3(b) of this License (the right to
|
|
||||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
|
||||||
modification or other derogatory action prejudicial to the Original
|
|
||||||
Author's honor and reputation, the Licensor will waive or not assert,
|
|
||||||
as appropriate, this Section, to the fullest extent permitted by the
|
|
||||||
applicable national law, to enable You to reasonably exercise Your
|
|
||||||
right under Section 3(b) of this License (right to make Adaptations)
|
|
||||||
but not otherwise.
|
|
||||||
|
|
||||||
5. Representations, Warranties and Disclaimer
|
|
||||||
|
|
||||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
|
||||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
|
||||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
|
||||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
|
||||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
|
||||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
|
||||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
|
||||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
|
||||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
|
||||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
|
||||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
7. Termination
|
|
||||||
|
|
||||||
a. This License and the rights granted hereunder will terminate
|
|
||||||
automatically upon any breach by You of the terms of this License.
|
|
||||||
Individuals or entities who have received Adaptations or Collections
|
|
||||||
from You under this License, however, will not have their licenses
|
|
||||||
terminated provided such individuals or entities remain in full
|
|
||||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
|
||||||
survive any termination of this License.
|
|
||||||
b. Subject to the above terms and conditions, the license granted here is
|
|
||||||
perpetual (for the duration of the applicable copyright in the Work).
|
|
||||||
Notwithstanding the above, Licensor reserves the right to release the
|
|
||||||
Work under different license terms or to stop distributing the Work at
|
|
||||||
any time; provided, however that any such election will not serve to
|
|
||||||
withdraw this License (or any other license that has been, or is
|
|
||||||
required to be, granted under the terms of this License), and this
|
|
||||||
License will continue in full force and effect unless terminated as
|
|
||||||
stated above.
|
|
||||||
|
|
||||||
8. Miscellaneous
|
|
||||||
|
|
||||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
|
||||||
the Licensor offers to the recipient a license to the Work on the same
|
|
||||||
terms and conditions as the license granted to You under this License.
|
|
||||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
|
||||||
offers to the recipient a license to the original Work on the same
|
|
||||||
terms and conditions as the license granted to You under this License.
|
|
||||||
c. If any provision of this License is invalid or unenforceable under
|
|
||||||
applicable law, it shall not affect the validity or enforceability of
|
|
||||||
the remainder of the terms of this License, and without further action
|
|
||||||
by the parties to this agreement, such provision shall be reformed to
|
|
||||||
the minimum extent necessary to make such provision valid and
|
|
||||||
enforceable.
|
|
||||||
d. No term or provision of this License shall be deemed waived and no
|
|
||||||
breach consented to unless such waiver or consent shall be in writing
|
|
||||||
and signed by the party to be charged with such waiver or consent.
|
|
||||||
e. This License constitutes the entire agreement between the parties with
|
|
||||||
respect to the Work licensed here. There are no understandings,
|
|
||||||
agreements or representations with respect to the Work not specified
|
|
||||||
here. Licensor shall not be bound by any additional provisions that
|
|
||||||
may appear in any communication from You. This License may not be
|
|
||||||
modified without the mutual written agreement of the Licensor and You.
|
|
||||||
f. The rights granted under, and the subject matter referenced, in this
|
|
||||||
License were drafted utilizing the terminology of the Berne Convention
|
|
||||||
for the Protection of Literary and Artistic Works (as amended on
|
|
||||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
|
||||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
|
||||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
|
||||||
These rights and subject matter take effect in the relevant
|
|
||||||
jurisdiction in which the License terms are sought to be enforced
|
|
||||||
according to the corresponding provisions of the implementation of
|
|
||||||
those treaty provisions in the applicable national law. If the
|
|
||||||
standard suite of rights granted under applicable copyright law
|
|
||||||
includes additional rights not granted under this License, such
|
|
||||||
additional rights are deemed to be included in the License; this
|
|
||||||
License is not intended to restrict the license of any rights under
|
|
||||||
applicable law.
|
|
||||||
|
|
||||||
|
|
||||||
Creative Commons Notice
|
|
||||||
|
|
||||||
Creative Commons is not a party to this License, and makes no warranty
|
|
||||||
whatsoever in connection with the Work. Creative Commons will not be
|
|
||||||
liable to You or any party on any legal theory for any damages
|
|
||||||
whatsoever, including without limitation any general, special,
|
|
||||||
incidental or consequential damages arising in connection to this
|
|
||||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
|
||||||
Commons has expressly identified itself as the Licensor hereunder, it
|
|
||||||
shall have all rights and obligations of Licensor.
|
|
||||||
|
|
||||||
Except for the limited purpose of indicating to the public that the
|
|
||||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
|
||||||
the use by either party of the trademark "Creative Commons" or any
|
|
||||||
related trademark or logo of Creative Commons without the prior
|
|
||||||
written consent of Creative Commons. Any permitted use will be in
|
|
||||||
compliance with Creative Commons' then-current trademark usage
|
|
||||||
guidelines, as may be published on its website or otherwise made
|
|
||||||
available upon request from time to time. For the avoidance of doubt,
|
|
||||||
this trademark restriction does not form part of this License.
|
|
||||||
|
|
||||||
Creative Commons may be contacted at http://creativecommons.org/.
|
|
14
vendor/github.com/google/go-github/github/activity.go
generated
vendored
14
vendor/github.com/google/go-github/github/activity.go
generated
vendored
|
@ -1,14 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
// ActivityService handles communication with the activity related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/
|
|
||||||
type ActivityService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
305
vendor/github.com/google/go-github/github/activity_events.go
generated
vendored
305
vendor/github.com/google/go-github/github/activity_events.go
generated
vendored
|
@ -1,305 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Event represents a GitHub event.
|
|
||||||
type Event struct {
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
Public *bool `json:"public"`
|
|
||||||
RawPayload *json.RawMessage `json:"payload,omitempty"`
|
|
||||||
Repo *Repository `json:"repo,omitempty"`
|
|
||||||
Actor *User `json:"actor,omitempty"`
|
|
||||||
Org *Organization `json:"org,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
ID *string `json:"id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e Event) String() string {
|
|
||||||
return Stringify(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Payload returns the parsed event payload. For recognized event types
|
|
||||||
// (PushEvent), a value of the corresponding struct type will be returned.
|
|
||||||
func (e *Event) Payload() (payload interface{}) {
|
|
||||||
switch *e.Type {
|
|
||||||
case "PushEvent":
|
|
||||||
payload = &PushEvent{}
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(*e.RawPayload, &payload); err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
return payload
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushEvent represents a git push to a GitHub repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/types/#pushevent
|
|
||||||
type PushEvent struct {
|
|
||||||
PushID *int `json:"push_id,omitempty"`
|
|
||||||
Head *string `json:"head,omitempty"`
|
|
||||||
Ref *string `json:"ref,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
Commits []PushEventCommit `json:"commits,omitempty"`
|
|
||||||
Repo *Repository `json:"repository,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PushEvent) String() string {
|
|
||||||
return Stringify(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushEventCommit represents a git commit in a GitHub PushEvent.
|
|
||||||
type PushEventCommit struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
Author *CommitAuthor `json:"author,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Distinct *bool `json:"distinct,omitempty"`
|
|
||||||
Added []string `json:"added,omitempty"`
|
|
||||||
Removed []string `json:"removed,omitempty"`
|
|
||||||
Modified []string `json:"modified,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PushEventCommit) String() string {
|
|
||||||
return Stringify(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
//PullRequestEvent represents the payload delivered by PullRequestEvent webhook
|
|
||||||
type PullRequestEvent struct {
|
|
||||||
Action *string `json:"action,omitempty"`
|
|
||||||
Number *int `json:"number,omitempty"`
|
|
||||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
|
||||||
Repo *Repository `json:"repository,omitempty"`
|
|
||||||
Sender *User `json:"sender,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueActivityEvent represents the payload delivered by Issue webhook
|
|
||||||
type IssueActivityEvent struct {
|
|
||||||
Action *string `json:"action,omitempty"`
|
|
||||||
Issue *Issue `json:"issue,omitempty"`
|
|
||||||
Repo *Repository `json:"repository,omitempty"`
|
|
||||||
Sender *User `json:"sender,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueCommentEvent represents the payload delivered by IssueComment webhook
|
|
||||||
//
|
|
||||||
// This webhook also gets fired for comments on pull requests
|
|
||||||
type IssueCommentEvent struct {
|
|
||||||
Action *string `json:"action,omitempty"`
|
|
||||||
Issue *Issue `json:"issue,omitempty"`
|
|
||||||
Comment *IssueComment `json:"comment,omitempty"`
|
|
||||||
Repo *Repository `json:"repository,omitempty"`
|
|
||||||
Sender *User `json:"sender,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEvents drinks from the firehose of all public events across GitHub.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events
|
|
||||||
func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u, err := addOptions("events", opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRepositoryEvents lists events for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-repository-events
|
|
||||||
func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListIssueEventsForRepository lists issue events for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
|
|
||||||
func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEventsForRepoNetwork lists public events for a network of repositories.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
|
|
||||||
func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEventsForOrganization lists public events for an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
|
|
||||||
func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/events", org)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
|
|
||||||
// true, only public events will be returned.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
|
|
||||||
func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if publicOnly {
|
|
||||||
u = fmt.Sprintf("users/%v/events/public", user)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("users/%v/events", user)
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is
|
|
||||||
// true, only public events will be returned.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received
|
|
||||||
func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if publicOnly {
|
|
||||||
u = fmt.Sprintf("users/%v/received_events/public", user)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("users/%v/received_events", user)
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListUserEventsForOrganization provides the user’s organization dashboard. You
|
|
||||||
// must be authenticated as the user to view this.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-for-an-organization
|
|
||||||
func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *ListOptions) ([]Event, *Response, error) {
|
|
||||||
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
events := new([]Event)
|
|
||||||
resp, err := s.client.Do(req, events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *events, resp, err
|
|
||||||
}
|
|
123
vendor/github.com/google/go-github/github/activity_star.go
generated
vendored
123
vendor/github.com/google/go-github/github/activity_star.go
generated
vendored
|
@ -1,123 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// StarredRepository is returned by ListStarred.
|
|
||||||
type StarredRepository struct {
|
|
||||||
StarredAt *Timestamp `json:"starred_at,omitempty"`
|
|
||||||
Repository *Repository `json:"repo,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListStargazers lists people who have starred the specified repo.
|
|
||||||
//
|
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/starring/#list-stargazers
|
|
||||||
func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ([]User, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
stargazers := new([]User)
|
|
||||||
resp, err := s.client.Do(req, stargazers)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *stargazers, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActivityListStarredOptions specifies the optional parameters to the
|
|
||||||
// ActivityService.ListStarred method.
|
|
||||||
type ActivityListStarredOptions struct {
|
|
||||||
// How to sort the repository list. Possible values are: created, updated,
|
|
||||||
// pushed, full_name. Default is "full_name".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort repositories. Possible values are: asc, desc.
|
|
||||||
// Default is "asc" when sort is "full_name", otherwise default is "desc".
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListStarred lists all the repos starred by a user. Passing the empty string
|
|
||||||
// will list the starred repositories for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred
|
|
||||||
func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptions) ([]StarredRepository, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/starred", user)
|
|
||||||
} else {
|
|
||||||
u = "user/starred"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when this API fully launches
|
|
||||||
req.Header.Set("Accept", mediaTypeStarringPreview)
|
|
||||||
|
|
||||||
repos := new([]StarredRepository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsStarred checks if a repository is starred by authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository
|
|
||||||
func (s *ActivityService) IsStarred(owner, repo string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
starred, err := parseBoolResponse(err)
|
|
||||||
return starred, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Star a repository as the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/activity/starring/#star-a-repository
|
|
||||||
func (s *ActivityService) Star(owner, repo string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unstar a repository as the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/activity/starring/#unstar-a-repository
|
|
||||||
func (s *ActivityService) Unstar(owner, repo string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
126
vendor/github.com/google/go-github/github/doc.go
generated
vendored
126
vendor/github.com/google/go-github/github/doc.go
generated
vendored
|
@ -1,126 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package github provides a client for using the GitHub API.
|
|
||||||
|
|
||||||
Construct a new GitHub client, then use the various services on the client to
|
|
||||||
access different parts of the GitHub API. For example:
|
|
||||||
|
|
||||||
client := github.NewClient(nil)
|
|
||||||
|
|
||||||
// list all organizations for user "willnorris"
|
|
||||||
orgs, _, err := client.Organizations.List("willnorris", nil)
|
|
||||||
|
|
||||||
Set optional parameters for an API method by passing an Options object.
|
|
||||||
|
|
||||||
// list recently updated repositories for org "github"
|
|
||||||
opt := &github.RepositoryListByOrgOptions{Sort: "updated"}
|
|
||||||
repos, _, err := client.Repositories.ListByOrg("github", opt)
|
|
||||||
|
|
||||||
The services of a client divide the API into logical chunks and correspond to
|
|
||||||
the structure of the GitHub API documentation at
|
|
||||||
http://developer.github.com/v3/.
|
|
||||||
|
|
||||||
Authentication
|
|
||||||
|
|
||||||
The go-github library does not directly handle authentication. Instead, when
|
|
||||||
creating a new client, pass an http.Client that can handle authentication for
|
|
||||||
you. The easiest and recommended way to do this is using the golang.org/x/oauth2
|
|
||||||
library, but you can always use any other library that provides an http.Client.
|
|
||||||
If you have an OAuth2 access token (for example, a personal API token), you can
|
|
||||||
use it with the oauth2 library using:
|
|
||||||
|
|
||||||
import "golang.org/x/oauth2"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ts := oauth2.StaticTokenSource(
|
|
||||||
&oauth2.Token{AccessToken: "... your access token ..."},
|
|
||||||
)
|
|
||||||
tc := oauth2.NewClient(oauth2.NoContext, ts)
|
|
||||||
|
|
||||||
client := github.NewClient(tc)
|
|
||||||
|
|
||||||
// list all repositories for the authenticated user
|
|
||||||
repos, _, err := client.Repositories.List("", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
Note that when using an authenticated Client, all calls made by the client will
|
|
||||||
include the specified OAuth token. Therefore, authenticated clients should
|
|
||||||
almost never be shared between different users.
|
|
||||||
|
|
||||||
Rate Limiting
|
|
||||||
|
|
||||||
GitHub imposes a rate limit on all API clients. Unauthenticated clients are
|
|
||||||
limited to 60 requests per hour, while authenticated clients can make up to
|
|
||||||
5,000 requests per hour. To receive the higher rate limit when making calls
|
|
||||||
that are not issued on behalf of a user, use the
|
|
||||||
UnauthenticatedRateLimitedTransport.
|
|
||||||
|
|
||||||
The Rate field on a client tracks the rate limit information based on the most
|
|
||||||
recent API call. This is updated on every call, but may be out of date if it's
|
|
||||||
been some time since the last API call and other clients have made subsequent
|
|
||||||
requests since then. You can always call RateLimit() directly to get the most
|
|
||||||
up-to-date rate limit data for the client.
|
|
||||||
|
|
||||||
Learn more about GitHub rate limiting at
|
|
||||||
http://developer.github.com/v3/#rate-limiting.
|
|
||||||
|
|
||||||
Conditional Requests
|
|
||||||
|
|
||||||
The GitHub API has good support for conditional requests which will help
|
|
||||||
prevent you from burning through your rate limit, as well as help speed up your
|
|
||||||
application. go-github does not handle conditional requests directly, but is
|
|
||||||
instead designed to work with a caching http.Transport. We recommend using
|
|
||||||
https://github.com/gregjones/httpcache, which can be used in conjuction with
|
|
||||||
https://github.com/sourcegraph/apiproxy to provide additional flexibility and
|
|
||||||
control of caching rules.
|
|
||||||
|
|
||||||
Learn more about GitHub conditional requests at
|
|
||||||
https://developer.github.com/v3/#conditional-requests.
|
|
||||||
|
|
||||||
Creating and Updating Resources
|
|
||||||
|
|
||||||
All structs for GitHub resources use pointer values for all non-repeated fields.
|
|
||||||
This allows distinguishing between unset fields and those set to a zero-value.
|
|
||||||
Helper functions have been provided to easily create these pointers for string,
|
|
||||||
bool, and int values. For example:
|
|
||||||
|
|
||||||
// create a new private repository named "foo"
|
|
||||||
repo := &github.Repository{
|
|
||||||
Name: github.String("foo"),
|
|
||||||
Private: github.Bool(true),
|
|
||||||
}
|
|
||||||
client.Repositories.Create("", repo)
|
|
||||||
|
|
||||||
Users who have worked with protocol buffers should find this pattern familiar.
|
|
||||||
|
|
||||||
Pagination
|
|
||||||
|
|
||||||
All requests for resource collections (repos, pull requests, issues, etc)
|
|
||||||
support pagination. Pagination options are described in the
|
|
||||||
ListOptions struct and passed to the list methods directly or as an
|
|
||||||
embedded type of a more specific list options struct (for example
|
|
||||||
PullRequestListOptions). Pages information is available via Response struct.
|
|
||||||
|
|
||||||
opt := &github.RepositoryListByOrgOptions{
|
|
||||||
ListOptions: github.ListOptions{PerPage: 10},
|
|
||||||
}
|
|
||||||
// get all pages of results
|
|
||||||
var allRepos []github.Repository
|
|
||||||
for {
|
|
||||||
repos, resp, err := client.Repositories.ListByOrg("github", opt)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
allRepos = append(allRepos, repos...)
|
|
||||||
if resp.NextPage == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
opt.ListOptions.Page = resp.NextPage
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
package github
|
|
281
vendor/github.com/google/go-github/github/gists.go
generated
vendored
281
vendor/github.com/google/go-github/github/gists.go
generated
vendored
|
@ -1,281 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GistsService handles communication with the Gist related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/
|
|
||||||
type GistsService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gist represents a GitHub's gist.
|
|
||||||
type Gist struct {
|
|
||||||
ID *string `json:"id,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Public *bool `json:"public,omitempty"`
|
|
||||||
Owner *User `json:"owner,omitempty"`
|
|
||||||
Files map[GistFilename]GistFile `json:"files,omitempty"`
|
|
||||||
Comments *int `json:"comments,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
GitPullURL *string `json:"git_pull_url,omitempty"`
|
|
||||||
GitPushURL *string `json:"git_push_url,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g Gist) String() string {
|
|
||||||
return Stringify(g)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GistFilename represents filename on a gist.
|
|
||||||
type GistFilename string
|
|
||||||
|
|
||||||
// GistFile represents a file on a gist.
|
|
||||||
type GistFile struct {
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
Filename *string `json:"filename,omitempty"`
|
|
||||||
RawURL *string `json:"raw_url,omitempty"`
|
|
||||||
Content *string `json:"content,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g GistFile) String() string {
|
|
||||||
return Stringify(g)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GistListOptions specifies the optional parameters to the
|
|
||||||
// GistsService.List, GistsService.ListAll, and GistsService.ListStarred methods.
|
|
||||||
type GistListOptions struct {
|
|
||||||
// Since filters Gists by time.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// List gists for a user. Passing the empty string will list
|
|
||||||
// all public gists if called anonymously. However, if the call
|
|
||||||
// is authenticated, it will returns all gists for the authenticated
|
|
||||||
// user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
|
|
||||||
func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/gists", user)
|
|
||||||
} else {
|
|
||||||
u = "gists"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
gists := new([]Gist)
|
|
||||||
resp, err := s.client.Do(req, gists)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *gists, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListAll lists all public gists.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
|
|
||||||
func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error) {
|
|
||||||
u, err := addOptions("gists/public", opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
gists := new([]Gist)
|
|
||||||
resp, err := s.client.Do(req, gists)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *gists, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListStarred lists starred gists of authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
|
|
||||||
func (s *GistsService) ListStarred(opt *GistListOptions) ([]Gist, *Response, error) {
|
|
||||||
u, err := addOptions("gists/starred", opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
gists := new([]Gist)
|
|
||||||
resp, err := s.client.Do(req, gists)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *gists, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a single gist.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#get-a-single-gist
|
|
||||||
func (s *GistsService) Get(id string) (*Gist, *Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v", id)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
gist := new(Gist)
|
|
||||||
resp, err := s.client.Do(req, gist)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gist, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRevision gets a specific revision of a gist.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
|
|
||||||
func (s *GistsService) GetRevision(id, sha string) (*Gist, *Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v/%v", id, sha)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
gist := new(Gist)
|
|
||||||
resp, err := s.client.Do(req, gist)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gist, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a gist for authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#create-a-gist
|
|
||||||
func (s *GistsService) Create(gist *Gist) (*Gist, *Response, error) {
|
|
||||||
u := "gists"
|
|
||||||
req, err := s.client.NewRequest("POST", u, gist)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
g := new(Gist)
|
|
||||||
resp, err := s.client.Do(req, g)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return g, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit a gist.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#edit-a-gist
|
|
||||||
func (s *GistsService) Edit(id string, gist *Gist) (*Gist, *Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v", id)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, gist)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
g := new(Gist)
|
|
||||||
resp, err := s.client.Do(req, g)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return g, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a gist.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#delete-a-gist
|
|
||||||
func (s *GistsService) Delete(id string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v", id)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Star a gist on behalf of authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#star-a-gist
|
|
||||||
func (s *GistsService) Star(id string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v/star", id)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unstar a gist on a behalf of authenticated user.
|
|
||||||
//
|
|
||||||
// Github API docs: http://developer.github.com/v3/gists/#unstar-a-gist
|
|
||||||
func (s *GistsService) Unstar(id string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v/star", id)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsStarred checks if a gist is starred by authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
|
|
||||||
func (s *GistsService) IsStarred(id string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v/star", id)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
starred, err := parseBoolResponse(err)
|
|
||||||
return starred, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fork a gist.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/#fork-a-gist
|
|
||||||
func (s *GistsService) Fork(id string) (*Gist, *Response, error) {
|
|
||||||
u := fmt.Sprintf("gists/%v/forks", id)
|
|
||||||
req, err := s.client.NewRequest("POST", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
g := new(Gist)
|
|
||||||
resp, err := s.client.Do(req, g)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return g, resp, err
|
|
||||||
}
|
|
47
vendor/github.com/google/go-github/github/git_blobs.go
generated
vendored
47
vendor/github.com/google/go-github/github/git_blobs.go
generated
vendored
|
@ -1,47 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Blob represents a blob object.
|
|
||||||
type Blob struct {
|
|
||||||
Content *string `json:"content,omitempty"`
|
|
||||||
Encoding *string `json:"encoding,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBlob fetchs a blob from a repo given a SHA.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/blobs/#get-a-blob
|
|
||||||
func (s *GitService) GetBlob(owner string, repo string, sha string) (*Blob, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
blob := new(Blob)
|
|
||||||
resp, err := s.client.Do(req, blob)
|
|
||||||
return blob, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateBlob creates a blob object.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/blobs/#create-a-blob
|
|
||||||
func (s *GitService) CreateBlob(owner string, repo string, blob *Blob) (*Blob, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("POST", u, blob)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Blob)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
112
vendor/github.com/google/go-github/github/git_commits.go
generated
vendored
112
vendor/github.com/google/go-github/github/git_commits.go
generated
vendored
|
@ -1,112 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Commit represents a GitHub commit.
|
|
||||||
type Commit struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Author *CommitAuthor `json:"author,omitempty"`
|
|
||||||
Committer *CommitAuthor `json:"committer,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
Tree *Tree `json:"tree,omitempty"`
|
|
||||||
Parents []Commit `json:"parents,omitempty"`
|
|
||||||
Stats *CommitStats `json:"stats,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
|
|
||||||
// CommentCount is the number of GitHub comments on the commit. This
|
|
||||||
// is only populated for requests that fetch GitHub data like
|
|
||||||
// Pulls.ListCommits, Repositories.ListCommits, etc.
|
|
||||||
CommentCount *int `json:"comment_count,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Commit) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommitAuthor represents the author or committer of a commit. The commit
|
|
||||||
// author may not correspond to a GitHub User.
|
|
||||||
type CommitAuthor struct {
|
|
||||||
Date *time.Time `json:"date,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Email *string `json:"email,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CommitAuthor) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCommit fetchs the Commit object for a given SHA.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/commits/#get-a-commit
|
|
||||||
func (s *GitService) GetCommit(owner string, repo string, sha string) (*Commit, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/commits/%v", owner, repo, sha)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := new(Commit)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// createCommit represents the body of a CreateCommit request.
|
|
||||||
type createCommit struct {
|
|
||||||
Author *CommitAuthor `json:"author,omitempty"`
|
|
||||||
Committer *CommitAuthor `json:"committer,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
Tree *string `json:"tree,omitempty"`
|
|
||||||
Parents []string `json:"parents,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateCommit creates a new commit in a repository.
|
|
||||||
//
|
|
||||||
// The commit.Committer is optional and will be filled with the commit.Author
|
|
||||||
// data if omitted. If the commit.Author is omitted, it will be filled in with
|
|
||||||
// the authenticated user’s information and the current date.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/commits/#create-a-commit
|
|
||||||
func (s *GitService) CreateCommit(owner string, repo string, commit *Commit) (*Commit, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/commits", owner, repo)
|
|
||||||
|
|
||||||
body := &createCommit{}
|
|
||||||
if commit != nil {
|
|
||||||
parents := make([]string, len(commit.Parents))
|
|
||||||
for i, parent := range commit.Parents {
|
|
||||||
parents[i] = *parent.SHA
|
|
||||||
}
|
|
||||||
|
|
||||||
body = &createCommit{
|
|
||||||
Author: commit.Author,
|
|
||||||
Committer: commit.Committer,
|
|
||||||
Message: commit.Message,
|
|
||||||
Tree: commit.Tree.SHA,
|
|
||||||
Parents: parents,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := new(Commit)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
89
vendor/github.com/google/go-github/github/git_trees.go
generated
vendored
89
vendor/github.com/google/go-github/github/git_trees.go
generated
vendored
|
@ -1,89 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Tree represents a GitHub tree.
|
|
||||||
type Tree struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Entries []TreeEntry `json:"tree,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t Tree) String() string {
|
|
||||||
return Stringify(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TreeEntry represents the contents of a tree structure. TreeEntry can
|
|
||||||
// represent either a blob, a commit (in the case of a submodule), or another
|
|
||||||
// tree.
|
|
||||||
type TreeEntry struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Path *string `json:"path,omitempty"`
|
|
||||||
Mode *string `json:"mode,omitempty"`
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
Content *string `json:"content,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TreeEntry) String() string {
|
|
||||||
return Stringify(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTree fetches the Tree object for a given sha hash from a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/trees/#get-a-tree
|
|
||||||
func (s *GitService) GetTree(owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha)
|
|
||||||
if recursive {
|
|
||||||
u += "?recursive=1"
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Tree)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// createTree represents the body of a CreateTree request.
|
|
||||||
type createTree struct {
|
|
||||||
BaseTree string `json:"base_tree,omitempty"`
|
|
||||||
Entries []TreeEntry `json:"tree"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateTree creates a new tree in a repository. If both a tree and a nested
|
|
||||||
// path modifying that tree are specified, it will overwrite the contents of
|
|
||||||
// that tree with the new path contents and write a new tree out.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/trees/#create-a-tree
|
|
||||||
func (s *GitService) CreateTree(owner string, repo string, baseTree string, entries []TreeEntry) (*Tree, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo)
|
|
||||||
|
|
||||||
body := &createTree{
|
|
||||||
BaseTree: baseTree,
|
|
||||||
Entries: entries,
|
|
||||||
}
|
|
||||||
req, err := s.client.NewRequest("POST", u, body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Tree)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
588
vendor/github.com/google/go-github/github/github.go
generated
vendored
588
vendor/github.com/google/go-github/github/github.go
generated
vendored
|
@ -1,588 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"reflect"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
libraryVersion = "0.1"
|
|
||||||
defaultBaseURL = "https://api.github.com/"
|
|
||||||
uploadBaseURL = "https://uploads.github.com/"
|
|
||||||
userAgent = "go-github/" + libraryVersion
|
|
||||||
|
|
||||||
headerRateLimit = "X-RateLimit-Limit"
|
|
||||||
headerRateRemaining = "X-RateLimit-Remaining"
|
|
||||||
headerRateReset = "X-RateLimit-Reset"
|
|
||||||
|
|
||||||
mediaTypeV3 = "application/vnd.github.v3+json"
|
|
||||||
defaultMediaType = "application/octet-stream"
|
|
||||||
|
|
||||||
// Media Type values to access preview APIs
|
|
||||||
|
|
||||||
// https://developer.github.com/changes/2015-03-09-licenses-api/
|
|
||||||
mediaTypeLicensesPreview = "application/vnd.github.drax-preview+json"
|
|
||||||
|
|
||||||
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
|
|
||||||
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"
|
|
||||||
|
|
||||||
// https://developer.github.com/changes/2015-06-24-api-enhancements-for-working-with-organization-permissions/
|
|
||||||
mediaTypeOrgPermissionPreview = "application/vnd.github.ironman-preview+json"
|
|
||||||
mediaTypeOrgPermissionRepoPreview = "application/vnd.github.ironman-preview.repository+json"
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Client manages communication with the GitHub API.
|
|
||||||
type Client struct {
|
|
||||||
// HTTP client used to communicate with the API.
|
|
||||||
client *http.Client
|
|
||||||
|
|
||||||
// Base URL for API requests. Defaults to the public GitHub API, but can be
|
|
||||||
// set to a domain endpoint to use with GitHub Enterprise. BaseURL should
|
|
||||||
// always be specified with a trailing slash.
|
|
||||||
BaseURL *url.URL
|
|
||||||
|
|
||||||
// Base URL for uploading files.
|
|
||||||
UploadURL *url.URL
|
|
||||||
|
|
||||||
// User agent used when communicating with the GitHub API.
|
|
||||||
UserAgent string
|
|
||||||
|
|
||||||
// Rate specifies the current rate limit for the client as determined by the
|
|
||||||
// most recent API call. If the client is used in a multi-user application,
|
|
||||||
// this rate may not always be up-to-date. Call RateLimits() to check the
|
|
||||||
// current rate.
|
|
||||||
Rate Rate
|
|
||||||
|
|
||||||
// Services used for talking to different parts of the GitHub API.
|
|
||||||
Activity *ActivityService
|
|
||||||
Gists *GistsService
|
|
||||||
Git *GitService
|
|
||||||
Gitignores *GitignoresService
|
|
||||||
Issues *IssuesService
|
|
||||||
Organizations *OrganizationsService
|
|
||||||
PullRequests *PullRequestsService
|
|
||||||
Repositories *RepositoriesService
|
|
||||||
Search *SearchService
|
|
||||||
Users *UsersService
|
|
||||||
Licenses *LicensesService
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListOptions specifies the optional parameters to various List methods that
|
|
||||||
// support pagination.
|
|
||||||
type ListOptions struct {
|
|
||||||
// For paginated result sets, page of results to retrieve.
|
|
||||||
Page int `url:"page,omitempty"`
|
|
||||||
|
|
||||||
// For paginated result sets, the number of results to include per page.
|
|
||||||
PerPage int `url:"per_page,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UploadOptions specifies the parameters to methods that support uploads.
|
|
||||||
type UploadOptions struct {
|
|
||||||
Name string `url:"name,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// addOptions adds the parameters in opt as URL query parameters to s. opt
|
|
||||||
// must be a struct whose fields may contain "url" tags.
|
|
||||||
func addOptions(s string, opt interface{}) (string, error) {
|
|
||||||
v := reflect.ValueOf(opt)
|
|
||||||
if v.Kind() == reflect.Ptr && v.IsNil() {
|
|
||||||
return s, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
u, err := url.Parse(s)
|
|
||||||
if err != nil {
|
|
||||||
return s, err
|
|
||||||
}
|
|
||||||
|
|
||||||
qs, err := query.Values(opt)
|
|
||||||
if err != nil {
|
|
||||||
return s, err
|
|
||||||
}
|
|
||||||
|
|
||||||
u.RawQuery = qs.Encode()
|
|
||||||
return u.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewClient returns a new GitHub API client. If a nil httpClient is
|
|
||||||
// provided, http.DefaultClient will be used. To use API methods which require
|
|
||||||
// authentication, provide an http.Client that will perform the authentication
|
|
||||||
// for you (such as that provided by the golang.org/x/oauth2 library).
|
|
||||||
func NewClient(httpClient *http.Client) *Client {
|
|
||||||
if httpClient == nil {
|
|
||||||
httpClient = http.DefaultClient
|
|
||||||
}
|
|
||||||
baseURL, _ := url.Parse(defaultBaseURL)
|
|
||||||
uploadURL, _ := url.Parse(uploadBaseURL)
|
|
||||||
|
|
||||||
c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL}
|
|
||||||
c.Activity = &ActivityService{client: c}
|
|
||||||
c.Gists = &GistsService{client: c}
|
|
||||||
c.Git = &GitService{client: c}
|
|
||||||
c.Gitignores = &GitignoresService{client: c}
|
|
||||||
c.Issues = &IssuesService{client: c}
|
|
||||||
c.Organizations = &OrganizationsService{client: c}
|
|
||||||
c.PullRequests = &PullRequestsService{client: c}
|
|
||||||
c.Repositories = &RepositoriesService{client: c}
|
|
||||||
c.Search = &SearchService{client: c}
|
|
||||||
c.Users = &UsersService{client: c}
|
|
||||||
c.Licenses = &LicensesService{client: c}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRequest creates an API request. A relative URL can be provided in urlStr,
|
|
||||||
// in which case it is resolved relative to the BaseURL of the Client.
|
|
||||||
// Relative URLs should always be specified without a preceding slash. If
|
|
||||||
// specified, the value pointed to by body is JSON encoded and included as the
|
|
||||||
// request body.
|
|
||||||
func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) {
|
|
||||||
rel, err := url.Parse(urlStr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
u := c.BaseURL.ResolveReference(rel)
|
|
||||||
|
|
||||||
var buf io.ReadWriter
|
|
||||||
if body != nil {
|
|
||||||
buf = new(bytes.Buffer)
|
|
||||||
err := json.NewEncoder(buf).Encode(body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest(method, u.String(), buf)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Add("Accept", mediaTypeV3)
|
|
||||||
if c.UserAgent != "" {
|
|
||||||
req.Header.Add("User-Agent", c.UserAgent)
|
|
||||||
}
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewUploadRequest creates an upload request. A relative URL can be provided in
|
|
||||||
// urlStr, in which case it is resolved relative to the UploadURL of the Client.
|
|
||||||
// Relative URLs should always be specified without a preceding slash.
|
|
||||||
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error) {
|
|
||||||
rel, err := url.Parse(urlStr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
u := c.UploadURL.ResolveReference(rel)
|
|
||||||
req, err := http.NewRequest("POST", u.String(), reader)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req.ContentLength = size
|
|
||||||
|
|
||||||
if len(mediaType) == 0 {
|
|
||||||
mediaType = defaultMediaType
|
|
||||||
}
|
|
||||||
req.Header.Add("Content-Type", mediaType)
|
|
||||||
req.Header.Add("Accept", mediaTypeV3)
|
|
||||||
req.Header.Add("User-Agent", c.UserAgent)
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response is a GitHub API response. This wraps the standard http.Response
|
|
||||||
// returned from GitHub and provides convenient access to things like
|
|
||||||
// pagination links.
|
|
||||||
type Response struct {
|
|
||||||
*http.Response
|
|
||||||
|
|
||||||
// These fields provide the page values for paginating through a set of
|
|
||||||
// results. Any or all of these may be set to the zero value for
|
|
||||||
// responses that are not part of a paginated set, or for which there
|
|
||||||
// are no additional pages.
|
|
||||||
|
|
||||||
NextPage int
|
|
||||||
PrevPage int
|
|
||||||
FirstPage int
|
|
||||||
LastPage int
|
|
||||||
|
|
||||||
Rate
|
|
||||||
}
|
|
||||||
|
|
||||||
// newResponse creates a new Response for the provided http.Response.
|
|
||||||
func newResponse(r *http.Response) *Response {
|
|
||||||
response := &Response{Response: r}
|
|
||||||
response.populatePageValues()
|
|
||||||
response.populateRate()
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
// populatePageValues parses the HTTP Link response headers and populates the
|
|
||||||
// various pagination link values in the Reponse.
|
|
||||||
func (r *Response) populatePageValues() {
|
|
||||||
if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 {
|
|
||||||
for _, link := range strings.Split(links[0], ",") {
|
|
||||||
segments := strings.Split(strings.TrimSpace(link), ";")
|
|
||||||
|
|
||||||
// link must at least have href and rel
|
|
||||||
if len(segments) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure href is properly formatted
|
|
||||||
if !strings.HasPrefix(segments[0], "<") || !strings.HasSuffix(segments[0], ">") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to pull out page parameter
|
|
||||||
url, err := url.Parse(segments[0][1 : len(segments[0])-1])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
page := url.Query().Get("page")
|
|
||||||
if page == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, segment := range segments[1:] {
|
|
||||||
switch strings.TrimSpace(segment) {
|
|
||||||
case `rel="next"`:
|
|
||||||
r.NextPage, _ = strconv.Atoi(page)
|
|
||||||
case `rel="prev"`:
|
|
||||||
r.PrevPage, _ = strconv.Atoi(page)
|
|
||||||
case `rel="first"`:
|
|
||||||
r.FirstPage, _ = strconv.Atoi(page)
|
|
||||||
case `rel="last"`:
|
|
||||||
r.LastPage, _ = strconv.Atoi(page)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// populateRate parses the rate related headers and populates the response Rate.
|
|
||||||
func (r *Response) populateRate() {
|
|
||||||
if limit := r.Header.Get(headerRateLimit); limit != "" {
|
|
||||||
r.Rate.Limit, _ = strconv.Atoi(limit)
|
|
||||||
}
|
|
||||||
if remaining := r.Header.Get(headerRateRemaining); remaining != "" {
|
|
||||||
r.Rate.Remaining, _ = strconv.Atoi(remaining)
|
|
||||||
}
|
|
||||||
if reset := r.Header.Get(headerRateReset); reset != "" {
|
|
||||||
if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 {
|
|
||||||
r.Rate.Reset = Timestamp{time.Unix(v, 0)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do sends an API request and returns the API response. The API response is
|
|
||||||
// JSON decoded and stored in the value pointed to by v, or returned as an
|
|
||||||
// error if an API error has occurred. If v implements the io.Writer
|
|
||||||
// interface, the raw response body will be written to v, without attempting to
|
|
||||||
// first decode it.
|
|
||||||
func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
|
|
||||||
resp, err := c.client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
response := newResponse(resp)
|
|
||||||
|
|
||||||
c.Rate = response.Rate
|
|
||||||
|
|
||||||
err = CheckResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
// even though there was an error, we still return the response
|
|
||||||
// in case the caller wants to inspect it further
|
|
||||||
return response, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if v != nil {
|
|
||||||
if w, ok := v.(io.Writer); ok {
|
|
||||||
io.Copy(w, resp.Body)
|
|
||||||
} else {
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return response, err
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
An ErrorResponse reports one or more errors caused by an API request.
|
|
||||||
|
|
||||||
GitHub API docs: http://developer.github.com/v3/#client-errors
|
|
||||||
*/
|
|
||||||
type ErrorResponse struct {
|
|
||||||
Response *http.Response // HTTP response that caused this error
|
|
||||||
Message string `json:"message"` // error message
|
|
||||||
Errors []Error `json:"errors"` // more detail on individual errors
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *ErrorResponse) Error() string {
|
|
||||||
return fmt.Sprintf("%v %v: %d %v %+v",
|
|
||||||
r.Response.Request.Method, sanitizeURL(r.Response.Request.URL),
|
|
||||||
r.Response.StatusCode, r.Message, r.Errors)
|
|
||||||
}
|
|
||||||
|
|
||||||
// sanitizeURL redacts the client_id and client_secret tokens from the URL which
|
|
||||||
// may be exposed to the user, specifically in the ErrorResponse error message.
|
|
||||||
func sanitizeURL(uri *url.URL) *url.URL {
|
|
||||||
if uri == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
params := uri.Query()
|
|
||||||
if len(params.Get("client_secret")) > 0 {
|
|
||||||
params.Set("client_secret", "REDACTED")
|
|
||||||
uri.RawQuery = params.Encode()
|
|
||||||
}
|
|
||||||
return uri
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
An Error reports more details on an individual error in an ErrorResponse.
|
|
||||||
These are the possible validation error codes:
|
|
||||||
|
|
||||||
missing:
|
|
||||||
resource does not exist
|
|
||||||
missing_field:
|
|
||||||
a required field on a resource has not been set
|
|
||||||
invalid:
|
|
||||||
the formatting of a field is invalid
|
|
||||||
already_exists:
|
|
||||||
another resource has the same valid as this field
|
|
||||||
|
|
||||||
GitHub API docs: http://developer.github.com/v3/#client-errors
|
|
||||||
*/
|
|
||||||
type Error struct {
|
|
||||||
Resource string `json:"resource"` // resource on which the error occurred
|
|
||||||
Field string `json:"field"` // field on which the error occurred
|
|
||||||
Code string `json:"code"` // validation error code
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Error) Error() string {
|
|
||||||
return fmt.Sprintf("%v error caused by %v field on %v resource",
|
|
||||||
e.Code, e.Field, e.Resource)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckResponse checks the API response for errors, and returns them if
|
|
||||||
// present. A response is considered an error if it has a status code outside
|
|
||||||
// the 200 range. API error responses are expected to have either no response
|
|
||||||
// body, or a JSON response body that maps to ErrorResponse. Any other
|
|
||||||
// response body will be silently ignored.
|
|
||||||
func CheckResponse(r *http.Response) error {
|
|
||||||
if c := r.StatusCode; 200 <= c && c <= 299 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
errorResponse := &ErrorResponse{Response: r}
|
|
||||||
data, err := ioutil.ReadAll(r.Body)
|
|
||||||
if err == nil && data != nil {
|
|
||||||
json.Unmarshal(data, errorResponse)
|
|
||||||
}
|
|
||||||
return errorResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseBoolResponse determines the boolean result from a GitHub API response.
|
|
||||||
// Several GitHub API methods return boolean responses indicated by the HTTP
|
|
||||||
// status code in the response (true indicated by a 204, false indicated by a
|
|
||||||
// 404). This helper function will determine that result and hide the 404
|
|
||||||
// error if present. Any other error will be returned through as-is.
|
|
||||||
func parseBoolResponse(err error) (bool, error) {
|
|
||||||
if err == nil {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err, ok := err.(*ErrorResponse); ok && err.Response.StatusCode == http.StatusNotFound {
|
|
||||||
// Simply false. In this one case, we do not pass the error through.
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// some other real error occurred
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rate represents the rate limit for the current client.
|
|
||||||
type Rate struct {
|
|
||||||
// The number of requests per hour the client is currently limited to.
|
|
||||||
Limit int `json:"limit"`
|
|
||||||
|
|
||||||
// The number of remaining requests the client can make this hour.
|
|
||||||
Remaining int `json:"remaining"`
|
|
||||||
|
|
||||||
// The time at which the current rate limit will reset.
|
|
||||||
Reset Timestamp `json:"reset"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Rate) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RateLimits represents the rate limits for the current client.
|
|
||||||
type RateLimits struct {
|
|
||||||
// The rate limit for non-search API requests. Unauthenticated
|
|
||||||
// requests are limited to 60 per hour. Authenticated requests are
|
|
||||||
// limited to 5,000 per hour.
|
|
||||||
Core *Rate `json:"core"`
|
|
||||||
|
|
||||||
// The rate limit for search API requests. Unauthenticated requests
|
|
||||||
// are limited to 5 requests per minutes. Authenticated requests are
|
|
||||||
// limited to 20 per minute.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/search/#rate-limit
|
|
||||||
Search *Rate `json:"search"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RateLimits) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RateLimit is deprecated. Use RateLimits instead.
|
|
||||||
func (c *Client) RateLimit() (*Rate, *Response, error) {
|
|
||||||
limits, resp, err := c.RateLimits()
|
|
||||||
if limits == nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return limits.Core, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RateLimits returns the rate limits for the current client.
|
|
||||||
func (c *Client) RateLimits() (*RateLimits, *Response, error) {
|
|
||||||
req, err := c.NewRequest("GET", "rate_limit", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response := new(struct {
|
|
||||||
Resources *RateLimits `json:"resources"`
|
|
||||||
})
|
|
||||||
resp, err := c.Do(req, response)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.Resources, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
UnauthenticatedRateLimitedTransport allows you to make unauthenticated calls
|
|
||||||
that need to use a higher rate limit associated with your OAuth application.
|
|
||||||
|
|
||||||
t := &github.UnauthenticatedRateLimitedTransport{
|
|
||||||
ClientID: "your app's client ID",
|
|
||||||
ClientSecret: "your app's client secret",
|
|
||||||
}
|
|
||||||
client := github.NewClient(t.Client())
|
|
||||||
|
|
||||||
This will append the querystring params client_id=xxx&client_secret=yyy to all
|
|
||||||
requests.
|
|
||||||
|
|
||||||
See http://developer.github.com/v3/#unauthenticated-rate-limited-requests for
|
|
||||||
more information.
|
|
||||||
*/
|
|
||||||
type UnauthenticatedRateLimitedTransport struct {
|
|
||||||
// ClientID is the GitHub OAuth client ID of the current application, which
|
|
||||||
// can be found by selecting its entry in the list at
|
|
||||||
// https://github.com/settings/applications.
|
|
||||||
ClientID string
|
|
||||||
|
|
||||||
// ClientSecret is the GitHub OAuth client secret of the current
|
|
||||||
// application.
|
|
||||||
ClientSecret string
|
|
||||||
|
|
||||||
// Transport is the underlying HTTP transport to use when making requests.
|
|
||||||
// It will default to http.DefaultTransport if nil.
|
|
||||||
Transport http.RoundTripper
|
|
||||||
}
|
|
||||||
|
|
||||||
// RoundTrip implements the RoundTripper interface.
|
|
||||||
func (t *UnauthenticatedRateLimitedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
||||||
if t.ClientID == "" {
|
|
||||||
return nil, errors.New("t.ClientID is empty")
|
|
||||||
}
|
|
||||||
if t.ClientSecret == "" {
|
|
||||||
return nil, errors.New("t.ClientSecret is empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
// To set extra querystring params, we must make a copy of the Request so
|
|
||||||
// that we don't modify the Request we were given. This is required by the
|
|
||||||
// specification of http.RoundTripper.
|
|
||||||
req = cloneRequest(req)
|
|
||||||
q := req.URL.Query()
|
|
||||||
q.Set("client_id", t.ClientID)
|
|
||||||
q.Set("client_secret", t.ClientSecret)
|
|
||||||
req.URL.RawQuery = q.Encode()
|
|
||||||
|
|
||||||
// Make the HTTP request.
|
|
||||||
return t.transport().RoundTrip(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client returns an *http.Client that makes requests which are subject to the
|
|
||||||
// rate limit of your OAuth application.
|
|
||||||
func (t *UnauthenticatedRateLimitedTransport) Client() *http.Client {
|
|
||||||
return &http.Client{Transport: t}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *UnauthenticatedRateLimitedTransport) transport() http.RoundTripper {
|
|
||||||
if t.Transport != nil {
|
|
||||||
return t.Transport
|
|
||||||
}
|
|
||||||
return http.DefaultTransport
|
|
||||||
}
|
|
||||||
|
|
||||||
// cloneRequest returns a clone of the provided *http.Request. The clone is a
|
|
||||||
// shallow copy of the struct and its Header map.
|
|
||||||
func cloneRequest(r *http.Request) *http.Request {
|
|
||||||
// shallow copy of the struct
|
|
||||||
r2 := new(http.Request)
|
|
||||||
*r2 = *r
|
|
||||||
// deep copy of the Header
|
|
||||||
r2.Header = make(http.Header)
|
|
||||||
for k, s := range r.Header {
|
|
||||||
r2.Header[k] = s
|
|
||||||
}
|
|
||||||
return r2
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool is a helper routine that allocates a new bool value
|
|
||||||
// to store v and returns a pointer to it.
|
|
||||||
func Bool(v bool) *bool {
|
|
||||||
p := new(bool)
|
|
||||||
*p = v
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int is a helper routine that allocates a new int32 value
|
|
||||||
// to store v and returns a pointer to it, but unlike Int32
|
|
||||||
// its argument value is an int.
|
|
||||||
func Int(v int) *int {
|
|
||||||
p := new(int)
|
|
||||||
*p = v
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
// String is a helper routine that allocates a new string value
|
|
||||||
// to store v and returns a pointer to it.
|
|
||||||
func String(v string) *string {
|
|
||||||
p := new(string)
|
|
||||||
*p = v
|
|
||||||
return p
|
|
||||||
}
|
|
261
vendor/github.com/google/go-github/github/issues.go
generated
vendored
261
vendor/github.com/google/go-github/github/issues.go
generated
vendored
|
@ -1,261 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IssuesService handles communication with the issue related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/
|
|
||||||
type IssuesService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Issue represents a GitHub issue on a repository.
|
|
||||||
type Issue struct {
|
|
||||||
Number *int `json:"number,omitempty"`
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
Labels []Label `json:"labels,omitempty"`
|
|
||||||
Assignee *User `json:"assignee,omitempty"`
|
|
||||||
Comments *int `json:"comments,omitempty"`
|
|
||||||
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
Milestone *Milestone `json:"milestone,omitempty"`
|
|
||||||
PullRequestLinks *PullRequestLinks `json:"pull_request,omitempty"`
|
|
||||||
|
|
||||||
// TextMatches is only populated from search results that request text matches
|
|
||||||
// See: search.go and https://developer.github.com/v3/search/#text-match-metadata
|
|
||||||
TextMatches []TextMatch `json:"text_matches,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i Issue) String() string {
|
|
||||||
return Stringify(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueRequest represents a request to create/edit an issue.
|
|
||||||
// It is separate from Issue above because otherwise Labels
|
|
||||||
// and Assignee fail to serialize to the correct JSON.
|
|
||||||
type IssueRequest struct {
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
Labels *[]string `json:"labels,omitempty"`
|
|
||||||
Assignee *string `json:"assignee,omitempty"`
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
Milestone *int `json:"milestone,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueListOptions specifies the optional parameters to the IssuesService.List
|
|
||||||
// and IssuesService.ListByOrg methods.
|
|
||||||
type IssueListOptions struct {
|
|
||||||
// Filter specifies which issues to list. Possible values are: assigned,
|
|
||||||
// created, mentioned, subscribed, all. Default is "assigned".
|
|
||||||
Filter string `url:"filter,omitempty"`
|
|
||||||
|
|
||||||
// State filters issues based on their state. Possible values are: open,
|
|
||||||
// closed. Default is "open".
|
|
||||||
State string `url:"state,omitempty"`
|
|
||||||
|
|
||||||
// Labels filters issues based on their label.
|
|
||||||
Labels []string `url:"labels,comma,omitempty"`
|
|
||||||
|
|
||||||
// Sort specifies how to sort issues. Possible values are: created, updated,
|
|
||||||
// and comments. Default value is "created".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort issues. Possible values are: asc, desc.
|
|
||||||
// Default is "asc".
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
// Since filters issues by time.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequestLinks object is added to the Issue object when it's an issue included
|
|
||||||
// in the IssueCommentEvent webhook payload, if the webhooks is fired by a comment on a PR
|
|
||||||
type PullRequestLinks struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
DiffURL *string `json:"diff_url,omitempty"`
|
|
||||||
PatchURL *string `json:"patch_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// List the issues for the authenticated user. If all is true, list issues
|
|
||||||
// across all the user's visible repositories including owned, member, and
|
|
||||||
// organization repositories; if false, list only owned and member
|
|
||||||
// repositories.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#list-issues
|
|
||||||
func (s *IssuesService) List(all bool, opt *IssueListOptions) ([]Issue, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if all {
|
|
||||||
u = "issues"
|
|
||||||
} else {
|
|
||||||
u = "user/issues"
|
|
||||||
}
|
|
||||||
return s.listIssues(u, opt)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByOrg fetches the issues in the specified organization for the
|
|
||||||
// authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#list-issues
|
|
||||||
func (s *IssuesService) ListByOrg(org string, opt *IssueListOptions) ([]Issue, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/issues", org)
|
|
||||||
return s.listIssues(u, opt)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *IssuesService) listIssues(u string, opt *IssueListOptions) ([]Issue, *Response, error) {
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
issues := new([]Issue)
|
|
||||||
resp, err := s.client.Do(req, issues)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *issues, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueListByRepoOptions specifies the optional parameters to the
|
|
||||||
// IssuesService.ListByRepo method.
|
|
||||||
type IssueListByRepoOptions struct {
|
|
||||||
// Milestone limits issues for the specified milestone. Possible values are
|
|
||||||
// a milestone number, "none" for issues with no milestone, "*" for issues
|
|
||||||
// with any milestone.
|
|
||||||
Milestone string `url:"milestone,omitempty"`
|
|
||||||
|
|
||||||
// State filters issues based on their state. Possible values are: open,
|
|
||||||
// closed. Default is "open".
|
|
||||||
State string `url:"state,omitempty"`
|
|
||||||
|
|
||||||
// Assignee filters issues based on their assignee. Possible values are a
|
|
||||||
// user name, "none" for issues that are not assigned, "*" for issues with
|
|
||||||
// any assigned user.
|
|
||||||
Assignee string `url:"assignee,omitempty"`
|
|
||||||
|
|
||||||
// Creator filters issues based on their creator.
|
|
||||||
Creator string `url:"creator,omitempty"`
|
|
||||||
|
|
||||||
// Mentioned filters issues to those mentioned a specific user.
|
|
||||||
Mentioned string `url:"mentioned,omitempty"`
|
|
||||||
|
|
||||||
// Labels filters issues based on their label.
|
|
||||||
Labels []string `url:"labels,omitempty,comma"`
|
|
||||||
|
|
||||||
// Sort specifies how to sort issues. Possible values are: created, updated,
|
|
||||||
// and comments. Default value is "created".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort issues. Possible values are: asc, desc.
|
|
||||||
// Default is "asc".
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
// Since filters issues by time.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByRepo lists the issues for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#list-issues-for-a-repository
|
|
||||||
func (s *IssuesService) ListByRepo(owner string, repo string, opt *IssueListByRepoOptions) ([]Issue, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
issues := new([]Issue)
|
|
||||||
resp, err := s.client.Do(req, issues)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *issues, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a single issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#get-a-single-issue
|
|
||||||
func (s *IssuesService) Get(owner string, repo string, number int) (*Issue, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
issue := new(Issue)
|
|
||||||
resp, err := s.client.Do(req, issue)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return issue, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new issue on the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#create-an-issue
|
|
||||||
func (s *IssuesService) Create(owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("POST", u, issue)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
i := new(Issue)
|
|
||||||
resp, err := s.client.Do(req, i)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return i, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/#edit-an-issue
|
|
||||||
func (s *IssuesService) Edit(owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, issue)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
i := new(Issue)
|
|
||||||
resp, err := s.client.Do(req, i)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return i, resp, err
|
|
||||||
}
|
|
46
vendor/github.com/google/go-github/github/issues_assignees.go
generated
vendored
46
vendor/github.com/google/go-github/github/issues_assignees.go
generated
vendored
|
@ -1,46 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// ListAssignees fetches all available assignees (owners and collaborators) to
|
|
||||||
// which issues may be assigned.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#list-assignees
|
|
||||||
func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOptions) ([]User, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
assignees := new([]User)
|
|
||||||
resp, err := s.client.Do(req, assignees)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *assignees, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsAssignee checks if a user is an assignee for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#check-assignee
|
|
||||||
func (s *IssuesService) IsAssignee(owner string, repo string, user string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
assignee, err := parseBoolResponse(err)
|
|
||||||
return assignee, resp, err
|
|
||||||
}
|
|
138
vendor/github.com/google/go-github/github/issues_comments.go
generated
vendored
138
vendor/github.com/google/go-github/github/issues_comments.go
generated
vendored
|
@ -1,138 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IssueComment represents a comment left on an issue.
|
|
||||||
type IssueComment struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
IssueURL *string `json:"issue_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i IssueComment) String() string {
|
|
||||||
return Stringify(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssueListCommentsOptions specifies the optional parameters to the
|
|
||||||
// IssuesService.ListComments method.
|
|
||||||
type IssueListCommentsOptions struct {
|
|
||||||
// Sort specifies how to sort comments. Possible values are: created, updated.
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort comments. Possible values are: asc, desc.
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
// Since filters comments by time.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListComments lists all comments on the specified issue. Specifying an issue
|
|
||||||
// number of 0 will return all comments on all issues for the repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
|
||||||
func (s *IssuesService) ListComments(owner string, repo string, number int, opt *IssueListCommentsOptions) ([]IssueComment, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if number == 0 {
|
|
||||||
u = fmt.Sprintf("repos/%v/%v/issues/comments", owner, repo)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
comments := new([]IssueComment)
|
|
||||||
resp, err := s.client.Do(req, comments)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *comments, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetComment fetches the specified issue comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/comments/#get-a-single-comment
|
|
||||||
func (s *IssuesService) GetComment(owner string, repo string, id int) (*IssueComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
comment := new(IssueComment)
|
|
||||||
resp, err := s.client.Do(req, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return comment, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateComment creates a new comment on the specified issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/comments/#create-a-comment
|
|
||||||
func (s *IssuesService) CreateComment(owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("POST", u, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
c := new(IssueComment)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditComment updates an issue comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/comments/#edit-a-comment
|
|
||||||
func (s *IssuesService) EditComment(owner string, repo string, id int, comment *IssueComment) (*IssueComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
c := new(IssueComment)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteComment deletes an issue comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/comments/#delete-a-comment
|
|
||||||
func (s *IssuesService) DeleteComment(owner string, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
149
vendor/github.com/google/go-github/github/issues_events.go
generated
vendored
149
vendor/github.com/google/go-github/github/issues_events.go
generated
vendored
|
@ -1,149 +0,0 @@
|
||||||
// Copyright 2014 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IssueEvent represents an event that occurred around an Issue or Pull Request.
|
|
||||||
type IssueEvent struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
|
|
||||||
// The User that generated this event.
|
|
||||||
Actor *User `json:"actor,omitempty"`
|
|
||||||
|
|
||||||
// Event identifies the actual type of Event that occurred. Possible
|
|
||||||
// values are:
|
|
||||||
//
|
|
||||||
// closed
|
|
||||||
// The Actor closed the issue.
|
|
||||||
// If the issue was closed by commit message, CommitID holds the SHA1 hash of the commit.
|
|
||||||
//
|
|
||||||
// merged
|
|
||||||
// The Actor merged into master a branch containing a commit mentioning the issue.
|
|
||||||
// CommitID holds the SHA1 of the merge commit.
|
|
||||||
//
|
|
||||||
// referenced
|
|
||||||
// The Actor committed to master a commit mentioning the issue in its commit message.
|
|
||||||
// CommitID holds the SHA1 of the commit.
|
|
||||||
//
|
|
||||||
// reopened, locked, unlocked
|
|
||||||
// The Actor did that to the issue.
|
|
||||||
//
|
|
||||||
// renamed
|
|
||||||
// The Actor changed the issue title from Rename.From to Rename.To.
|
|
||||||
//
|
|
||||||
// mentioned
|
|
||||||
// Someone unspecified @mentioned the Actor [sic] in an issue comment body.
|
|
||||||
//
|
|
||||||
// assigned, unassigned
|
|
||||||
// The Actor assigned the issue to or removed the assignment from the Assignee.
|
|
||||||
//
|
|
||||||
// labeled, unlabeled
|
|
||||||
// The Actor added or removed the Label from the issue.
|
|
||||||
//
|
|
||||||
// milestoned, demilestoned
|
|
||||||
// The Actor added or removed the issue from the Milestone.
|
|
||||||
//
|
|
||||||
// subscribed, unsubscribed
|
|
||||||
// The Actor subscribed to or unsubscribed from notifications for an issue.
|
|
||||||
//
|
|
||||||
// head_ref_deleted, head_ref_restored
|
|
||||||
// The pull request’s branch was deleted or restored.
|
|
||||||
//
|
|
||||||
Event *string `json:"event,omitempty"`
|
|
||||||
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
Issue *Issue `json:"issue,omitempty"`
|
|
||||||
|
|
||||||
// Only present on certain events; see above.
|
|
||||||
Assignee *User `json:"assignee,omitempty"`
|
|
||||||
CommitID *string `json:"commit_id,omitempty"`
|
|
||||||
Milestone *Milestone `json:"milestone,omitempty"`
|
|
||||||
Label *Label `json:"label,omitempty"`
|
|
||||||
Rename *Rename `json:"rename,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListIssueEvents lists events for the specified issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/events/#list-events-for-an-issue
|
|
||||||
func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *ListOptions) ([]IssueEvent, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var events []IssueEvent
|
|
||||||
resp, err := s.client.Do(req, &events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListRepositoryEvents lists events for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/events/#list-events-for-a-repository
|
|
||||||
func (s *IssuesService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]IssueEvent, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var events []IssueEvent
|
|
||||||
resp, err := s.client.Do(req, &events)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return events, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetEvent returns the specified issue event.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/events/#get-a-single-event
|
|
||||||
func (s *IssuesService) GetEvent(owner, repo string, id int) (*IssueEvent, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
event := new(IssueEvent)
|
|
||||||
resp, err := s.client.Do(req, event)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return event, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename contains details for 'renamed' events.
|
|
||||||
type Rename struct {
|
|
||||||
From *string `json:"from,omitempty"`
|
|
||||||
To *string `json:"to,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Rename) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
222
vendor/github.com/google/go-github/github/issues_labels.go
generated
vendored
222
vendor/github.com/google/go-github/github/issues_labels.go
generated
vendored
|
@ -1,222 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Label represents a GitHub label on an Issue
|
|
||||||
type Label struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Color *string `json:"color,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l Label) String() string {
|
|
||||||
return fmt.Sprint(*l.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListLabels lists all labels for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
|
|
||||||
func (s *IssuesService) ListLabels(owner string, repo string, opt *ListOptions) ([]Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
labels := new([]Label)
|
|
||||||
resp, err := s.client.Do(req, labels)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *labels, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLabel gets a single label.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#get-a-single-label
|
|
||||||
func (s *IssuesService) GetLabel(owner string, repo string, name string) (*Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label := new(Label)
|
|
||||||
resp, err := s.client.Do(req, label)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return label, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateLabel creates a new label on the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#create-a-label
|
|
||||||
func (s *IssuesService) CreateLabel(owner string, repo string, label *Label) (*Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("POST", u, label)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
l := new(Label)
|
|
||||||
resp, err := s.client.Do(req, l)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return l, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditLabel edits a label.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#update-a-label
|
|
||||||
func (s *IssuesService) EditLabel(owner string, repo string, name string, label *Label) (*Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, label)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
l := new(Label)
|
|
||||||
resp, err := s.client.Do(req, l)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return l, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteLabel deletes a label.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#delete-a-label
|
|
||||||
func (s *IssuesService) DeleteLabel(owner string, repo string, name string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListLabelsByIssue lists all labels for an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
|
|
||||||
func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, opt *ListOptions) ([]Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
labels := new([]Label)
|
|
||||||
resp, err := s.client.Do(req, labels)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *labels, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddLabelsToIssue adds labels to an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
|
|
||||||
func (s *IssuesService) AddLabelsToIssue(owner string, repo string, number int, labels []string) ([]Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("POST", u, labels)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
l := new([]Label)
|
|
||||||
resp, err := s.client.Do(req, l)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *l, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveLabelForIssue removes a label for an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
|
|
||||||
func (s *IssuesService) RemoveLabelForIssue(owner string, repo string, number int, label string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReplaceLabelsForIssue replaces all labels for an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue
|
|
||||||
func (s *IssuesService) ReplaceLabelsForIssue(owner string, repo string, number int, labels []string) ([]Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, labels)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
l := new([]Label)
|
|
||||||
resp, err := s.client.Do(req, l)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *l, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveLabelsForIssue removes all labels for an issue.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
|
|
||||||
func (s *IssuesService) RemoveLabelsForIssue(owner string, repo string, number int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListLabelsForMilestone lists labels for every issue in a milestone.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
|
|
||||||
func (s *IssuesService) ListLabelsForMilestone(owner string, repo string, number int, opt *ListOptions) ([]Label, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
labels := new([]Label)
|
|
||||||
resp, err := s.client.Do(req, labels)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *labels, resp, err
|
|
||||||
}
|
|
81
vendor/github.com/google/go-github/github/licenses.go
generated
vendored
81
vendor/github.com/google/go-github/github/licenses.go
generated
vendored
|
@ -1,81 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// LicensesService handles communication with the license related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/pulls/
|
|
||||||
type LicensesService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// License represents an open source license.
|
|
||||||
type License struct {
|
|
||||||
Key *string `json:"key,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
Featured *bool `json:"featured,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Category *string `json:"category,omitempty"`
|
|
||||||
Implementation *string `json:"implementation,omitempty"`
|
|
||||||
Required *[]string `json:"required,omitempty"`
|
|
||||||
Permitted *[]string `json:"permitted,omitempty"`
|
|
||||||
Forbidden *[]string `json:"forbidden,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l License) String() string {
|
|
||||||
return Stringify(l)
|
|
||||||
}
|
|
||||||
|
|
||||||
// List popular open source licenses.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/licenses/#list-all-licenses
|
|
||||||
func (s *LicensesService) List() ([]License, *Response, error) {
|
|
||||||
req, err := s.client.NewRequest("GET", "licenses", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when this API fully launches
|
|
||||||
req.Header.Set("Accept", mediaTypeLicensesPreview)
|
|
||||||
|
|
||||||
licenses := new([]License)
|
|
||||||
resp, err := s.client.Do(req, licenses)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *licenses, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get extended metadata for one license.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/licenses/#get-an-individual-license
|
|
||||||
func (s *LicensesService) Get(licenseName string) (*License, *Response, error) {
|
|
||||||
u := fmt.Sprintf("licenses/%s", licenseName)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when this API fully launches
|
|
||||||
req.Header.Set("Accept", mediaTypeLicensesPreview)
|
|
||||||
|
|
||||||
license := new(License)
|
|
||||||
resp, err := s.client.Do(req, license)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return license, resp, err
|
|
||||||
}
|
|
137
vendor/github.com/google/go-github/github/orgs.go
generated
vendored
137
vendor/github.com/google/go-github/github/orgs.go
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// OrganizationsService provides access to the organization related functions
|
|
||||||
// in the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/
|
|
||||||
type OrganizationsService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Organization represents a GitHub organization account.
|
|
||||||
type Organization struct {
|
|
||||||
Login *string `json:"login,omitempty"`
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
AvatarURL *string `json:"avatar_url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Company *string `json:"company,omitempty"`
|
|
||||||
Blog *string `json:"blog,omitempty"`
|
|
||||||
Location *string `json:"location,omitempty"`
|
|
||||||
Email *string `json:"email,omitempty"`
|
|
||||||
PublicRepos *int `json:"public_repos,omitempty"`
|
|
||||||
PublicGists *int `json:"public_gists,omitempty"`
|
|
||||||
Followers *int `json:"followers,omitempty"`
|
|
||||||
Following *int `json:"following,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
|
|
||||||
OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
|
|
||||||
PrivateGists *int `json:"private_gists,omitempty"`
|
|
||||||
DiskUsage *int `json:"disk_usage,omitempty"`
|
|
||||||
Collaborators *int `json:"collaborators,omitempty"`
|
|
||||||
BillingEmail *string `json:"billing_email,omitempty"`
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
Plan *Plan `json:"plan,omitempty"`
|
|
||||||
|
|
||||||
// API URLs
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
EventsURL *string `json:"events_url,omitempty"`
|
|
||||||
MembersURL *string `json:"members_url,omitempty"`
|
|
||||||
PublicMembersURL *string `json:"public_members_url,omitempty"`
|
|
||||||
ReposURL *string `json:"repos_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o Organization) String() string {
|
|
||||||
return Stringify(o)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
|
|
||||||
type Plan struct {
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Space *int `json:"space,omitempty"`
|
|
||||||
Collaborators *int `json:"collaborators,omitempty"`
|
|
||||||
PrivateRepos *int `json:"private_repos,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Plan) String() string {
|
|
||||||
return Stringify(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// List the organizations for a user. Passing the empty string will list
|
|
||||||
// organizations for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/#list-user-organizations
|
|
||||||
func (s *OrganizationsService) List(user string, opt *ListOptions) ([]Organization, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/orgs", user)
|
|
||||||
} else {
|
|
||||||
u = "user/orgs"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
orgs := new([]Organization)
|
|
||||||
resp, err := s.client.Do(req, orgs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *orgs, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get fetches an organization by name.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/#get-an-organization
|
|
||||||
func (s *OrganizationsService) Get(org string) (*Organization, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v", org)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
organization := new(Organization)
|
|
||||||
resp, err := s.client.Do(req, organization)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return organization, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/#edit-an-organization
|
|
||||||
func (s *OrganizationsService) Edit(name string, org *Organization) (*Organization, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v", name)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, org)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
o := new(Organization)
|
|
||||||
resp, err := s.client.Do(req, o)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return o, resp, err
|
|
||||||
}
|
|
104
vendor/github.com/google/go-github/github/orgs_hooks.go
generated
vendored
104
vendor/github.com/google/go-github/github/orgs_hooks.go
generated
vendored
|
@ -1,104 +0,0 @@
|
||||||
// Copyright 2015 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// ListHooks lists all Hooks for the specified organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#list-hooks
|
|
||||||
func (s *OrganizationsService) ListHooks(org string, opt *ListOptions) ([]Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks", org)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
hooks := new([]Hook)
|
|
||||||
resp, err := s.client.Do(req, hooks)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *hooks, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHook returns a single specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#get-single-hook
|
|
||||||
func (s *OrganizationsService) GetHook(org string, id int) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
hook := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, hook)
|
|
||||||
return hook, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateHook creates a Hook for the specified org.
|
|
||||||
// Name and Config are required fields.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#create-a-hook
|
|
||||||
func (s *OrganizationsService) CreateHook(org string, hook *Hook) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks", org)
|
|
||||||
req, err := s.client.NewRequest("POST", u, hook)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
h := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, h)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return h, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditHook updates a specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#edit-a-hook
|
|
||||||
func (s *OrganizationsService) EditHook(org string, id int, hook *Hook) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, hook)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
h := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, h)
|
|
||||||
return h, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// PingHook triggers a 'ping' event to be sent to the Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#ping-a-hook
|
|
||||||
func (s *OrganizationsService) PingHook(org string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks/%d/pings", org, id)
|
|
||||||
req, err := s.client.NewRequest("POST", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteHook deletes a specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#delete-a-hook
|
|
||||||
func (s *OrganizationsService) DeleteHook(org string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/hooks/%d", org, id)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
276
vendor/github.com/google/go-github/github/orgs_members.go
generated
vendored
276
vendor/github.com/google/go-github/github/orgs_members.go
generated
vendored
|
@ -1,276 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Membership represents the status of a user's membership in an organization or team.
|
|
||||||
type Membership struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
|
|
||||||
// State is the user's status within the organization or team.
|
|
||||||
// Possible values are: "active", "pending"
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
|
|
||||||
// Role identifies the user's role within the organization or team.
|
|
||||||
// Possible values for organization membership:
|
|
||||||
// member - non-owner organization member
|
|
||||||
// admin - organization owner
|
|
||||||
//
|
|
||||||
// Possible values for team membership are:
|
|
||||||
// member - a normal member of the team
|
|
||||||
// maintainer - a team maintainer. Able to add/remove other team
|
|
||||||
// members, promote other team members to team
|
|
||||||
// maintainer, and edit the team’s name and description
|
|
||||||
Role *string `json:"role,omitempty"`
|
|
||||||
|
|
||||||
// For organization membership, the API URL of the organization.
|
|
||||||
OrganizationURL *string `json:"organization_url,omitempty"`
|
|
||||||
|
|
||||||
// For organization membership, the organization the membership is for.
|
|
||||||
Organization *Organization `json:"organization,omitempty"`
|
|
||||||
|
|
||||||
// For organization membership, the user the membership is for.
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Membership) String() string {
|
|
||||||
return Stringify(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListMembersOptions specifies optional parameters to the
|
|
||||||
// OrganizationsService.ListMembers method.
|
|
||||||
type ListMembersOptions struct {
|
|
||||||
// If true (or if the authenticated user is not an owner of the
|
|
||||||
// organization), list only publicly visible members.
|
|
||||||
PublicOnly bool `url:"-"`
|
|
||||||
|
|
||||||
// Filter members returned in the list. Possible values are:
|
|
||||||
// 2fa_disabled, all. Default is "all".
|
|
||||||
Filter string `url:"filter,omitempty"`
|
|
||||||
|
|
||||||
// Role filters memebers returned by their role in the organization.
|
|
||||||
// Possible values are:
|
|
||||||
// all - all members of the organization, regardless of role
|
|
||||||
// admin - organization owners
|
|
||||||
// member - non-organization members
|
|
||||||
//
|
|
||||||
// Default is "all".
|
|
||||||
Role string `url:"role,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListMembers lists the members for an organization. If the authenticated
|
|
||||||
// user is an owner of the organization, this will return both concealed and
|
|
||||||
// public members, otherwise it will only return public members.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#members-list
|
|
||||||
func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions) ([]User, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if opt != nil && opt.PublicOnly {
|
|
||||||
u = fmt.Sprintf("orgs/%v/public_members", org)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("orgs/%v/members", org)
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt != nil && opt.Role != "" {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
members := new([]User)
|
|
||||||
resp, err := s.client.Do(req, members)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *members, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMember checks if a user is a member of an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#check-membership
|
|
||||||
func (s *OrganizationsService) IsMember(org, user string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/members/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
member, err := parseBoolResponse(err)
|
|
||||||
return member, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsPublicMember checks if a user is a public member of an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#check-public-membership
|
|
||||||
func (s *OrganizationsService) IsPublicMember(org, user string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
member, err := parseBoolResponse(err)
|
|
||||||
return member, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveMember removes a user from all teams of an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#remove-a-member
|
|
||||||
func (s *OrganizationsService) RemoveMember(org, user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/members/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PublicizeMembership publicizes a user's membership in an organization. (A
|
|
||||||
// user cannot publicize the membership for another user.)
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#publicize-a-users-membership
|
|
||||||
func (s *OrganizationsService) PublicizeMembership(org, user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConcealMembership conceals a user's membership in an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/members/#conceal-a-users-membership
|
|
||||||
func (s *OrganizationsService) ConcealMembership(org, user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListOrgMembershipsOptions specifies optional parameters to the
|
|
||||||
// OrganizationsService.ListOrgMemberships method.
|
|
||||||
type ListOrgMembershipsOptions struct {
|
|
||||||
// Filter memberships to include only those with the specified state.
|
|
||||||
// Possible values are: "active", "pending".
|
|
||||||
State string `url:"state,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListOrgMemberships lists the organization memberships for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#list-your-organization-memberships
|
|
||||||
func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions) ([]Membership, *Response, error) {
|
|
||||||
u := "user/memberships/orgs"
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var memberships []Membership
|
|
||||||
resp, err := s.client.Do(req, &memberships)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return memberships, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOrgMembership gets the membership for a user in a specified organization.
|
|
||||||
// Passing an empty string for user will get the membership for the
|
|
||||||
// authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#get-organization-membership
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#get-your-organization-membership
|
|
||||||
func (s *OrganizationsService) GetOrgMembership(user, org string) (*Membership, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("orgs/%v/memberships/%v", org, user)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("user/memberships/orgs/%v", org)
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
membership := new(Membership)
|
|
||||||
resp, err := s.client.Do(req, membership)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return membership, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditOrgMembership edits the membership for user in specified organization.
|
|
||||||
// Passing an empty string for user will edit the membership for the
|
|
||||||
// authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
|
|
||||||
func (s *OrganizationsService) EditOrgMembership(user, org string, membership *Membership) (*Membership, *Response, error) {
|
|
||||||
var u, method string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("orgs/%v/memberships/%v", org, user)
|
|
||||||
method = "PUT"
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("user/memberships/orgs/%v", org)
|
|
||||||
method = "PATCH"
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest(method, u, membership)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
m := new(Membership)
|
|
||||||
resp, err := s.client.Do(req, m)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveOrgMembership removes user from the specified organization. If the
|
|
||||||
// user has been invited to the organization, this will cancel their invitation.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
|
||||||
func (s *OrganizationsService) RemoveOrgMembership(user, org string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/memberships/%v", org, user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
396
vendor/github.com/google/go-github/github/orgs_teams.go
generated
vendored
396
vendor/github.com/google/go-github/github/orgs_teams.go
generated
vendored
|
@ -1,396 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Team represents a team within a GitHub organization. Teams are used to
|
|
||||||
// manage access to an organization's repositories.
|
|
||||||
type Team struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Slug *string `json:"slug,omitempty"`
|
|
||||||
|
|
||||||
// Permission is deprecated when creating or editing a team in an org
|
|
||||||
// using the new GitHub permission model. It no longer identifies the
|
|
||||||
// permission a team has on its repos, but only specifies the default
|
|
||||||
// permission a repo is initially added with. Avoid confusion by
|
|
||||||
// specifying a permission value when calling AddTeamRepo.
|
|
||||||
Permission *string `json:"permission,omitempty"`
|
|
||||||
|
|
||||||
// Privacy identifies the level of privacy this team should have.
|
|
||||||
// Possible values are:
|
|
||||||
// secret - only visible to organization owners and members of this team
|
|
||||||
// closed - visible to all members of this organization
|
|
||||||
// Default is "secret".
|
|
||||||
Privacy *string `json:"privacy,omitempty"`
|
|
||||||
|
|
||||||
MembersCount *int `json:"members_count,omitempty"`
|
|
||||||
ReposCount *int `json:"repos_count,omitempty"`
|
|
||||||
Organization *Organization `json:"organization,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t Team) String() string {
|
|
||||||
return Stringify(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTeams lists all of the teams for an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-teams
|
|
||||||
func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]Team, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/teams", org)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
teams := new([]Team)
|
|
||||||
resp, err := s.client.Do(req, teams)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *teams, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTeam fetches a team by ID.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team
|
|
||||||
func (s *OrganizationsService) GetTeam(team int) (*Team, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v", team)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Team)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateTeam creates a new team within an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#create-team
|
|
||||||
func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/teams", org)
|
|
||||||
req, err := s.client.NewRequest("POST", u, team)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if team.Privacy != nil {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Team)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditTeam edits a team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#edit-team
|
|
||||||
func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v", id)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, team)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if team.Privacy != nil {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Team)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteTeam deletes a team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#delete-team
|
|
||||||
func (s *OrganizationsService) DeleteTeam(team int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v", team)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrganizationListTeamMembersOptions specifies the optional parameters to the
|
|
||||||
// OrganizationsService.ListTeamMembers method.
|
|
||||||
type OrganizationListTeamMembersOptions struct {
|
|
||||||
// Role filters members returned by their role in the team. Possible
|
|
||||||
// values are "all", "member", "maintainer". Default is "all".
|
|
||||||
Role string `url:"role,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTeamMembers lists all of the users who are members of the specified
|
|
||||||
// team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-members
|
|
||||||
func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTeamMembersOptions) ([]User, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/members", team)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt != nil && opt.Role != "" {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
members := new([]User)
|
|
||||||
resp, err := s.client.Do(req, members)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *members, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsTeamMember checks if a user is a member of the specified team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-member
|
|
||||||
func (s *OrganizationsService) IsTeamMember(team int, user string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/members/%v", team, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
member, err := parseBoolResponse(err)
|
|
||||||
return member, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTeamRepos lists the repositories that the specified team has access to.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-repos
|
|
||||||
func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/repos", team)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
repos := new([]Repository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsTeamRepo checks if a team manages the specified repository. If the
|
|
||||||
// repository is managed by team, a Repository is returned which includes the
|
|
||||||
// permissions team has for that repo.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-repo
|
|
||||||
func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (*Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionRepoPreview)
|
|
||||||
|
|
||||||
repository := new(Repository)
|
|
||||||
resp, err := s.client.Do(req, repository)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrganizationAddTeamRepoOptions specifies the optional parameters to the
|
|
||||||
// OrganizationsService.AddTeamRepo method.
|
|
||||||
type OrganizationAddTeamRepoOptions struct {
|
|
||||||
// Permission specifies the permission to grant the team on this repository.
|
|
||||||
// Possible values are:
|
|
||||||
// pull - team members can pull, but not push to or administer this repository
|
|
||||||
// push - team members can pull and push, but not administer this repository
|
|
||||||
// admin - team members can pull, push and administer this repository
|
|
||||||
//
|
|
||||||
// If not specified, the team's permission attribute will be used.
|
|
||||||
Permission string `json:"permission,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddTeamRepo adds a repository to be managed by the specified team. The
|
|
||||||
// specified repository must be owned by the organization to which the team
|
|
||||||
// belongs, or a direct fork of a repository owned by the organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#add-team-repo
|
|
||||||
func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string, opt *OrganizationAddTeamRepoOptions) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt != nil {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveTeamRepo removes a repository from being managed by the specified
|
|
||||||
// team. Note that this does not delete the repository, it just removes it
|
|
||||||
// from the team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#remove-team-repo
|
|
||||||
func (s *OrganizationsService) RemoveTeamRepo(team int, owner string, repo string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListUserTeams lists a user's teams
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-user-teams
|
|
||||||
func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]Team, *Response, error) {
|
|
||||||
u := "user/teams"
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
teams := new([]Team)
|
|
||||||
resp, err := s.client.Do(req, teams)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *teams, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTeamMembership returns the membership status for a user in a team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team-membership
|
|
||||||
func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Membership, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Membership)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// OrganizationAddTeamMembershipOptions does stuff specifies the optional
|
|
||||||
// parameters to the OrganizationsService.AddTeamMembership method.
|
|
||||||
type OrganizationAddTeamMembershipOptions struct {
|
|
||||||
// Role specifies the role the user should have in the team. Possible
|
|
||||||
// values are:
|
|
||||||
// member - a normal member of the team
|
|
||||||
// maintainer - a team maintainer. Able to add/remove other team
|
|
||||||
// members, promote other team members to team
|
|
||||||
// maintainer, and edit the team’s name and description
|
|
||||||
//
|
|
||||||
// Default value is "member".
|
|
||||||
Role string `json:"role,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddTeamMembership adds or invites a user to a team.
|
|
||||||
//
|
|
||||||
// In order to add a membership between a user and a team, the authenticated
|
|
||||||
// user must have 'admin' permissions to the team or be an owner of the
|
|
||||||
// organization that the team is associated with.
|
|
||||||
//
|
|
||||||
// If the user is already a part of the team's organization (meaning they're on
|
|
||||||
// at least one other team in the organization), this endpoint will add the
|
|
||||||
// user to the team.
|
|
||||||
//
|
|
||||||
// If the user is completely unaffiliated with the team's organization (meaning
|
|
||||||
// they're on none of the organization's teams), this endpoint will send an
|
|
||||||
// invitation to the user via email. This newly-created membership will be in
|
|
||||||
// the "pending" state until the user accepts the invitation, at which point
|
|
||||||
// the membership will transition to the "active" state and the user will be
|
|
||||||
// added as a member of the team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-membership
|
|
||||||
func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *OrganizationAddTeamMembershipOptions) (*Membership, *Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt != nil {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
t := new(Membership)
|
|
||||||
resp, err := s.client.Do(req, t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveTeamMembership removes a user from a team.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#remove-team-membership
|
|
||||||
func (s *OrganizationsService) RemoveTeamMembership(team int, user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
275
vendor/github.com/google/go-github/github/pulls.go
generated
vendored
275
vendor/github.com/google/go-github/github/pulls.go
generated
vendored
|
@ -1,275 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PullRequestsService handles communication with the pull request related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/pulls/
|
|
||||||
type PullRequestsService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequest represents a GitHub pull request on a repository.
|
|
||||||
type PullRequest struct {
|
|
||||||
Number *int `json:"number,omitempty"`
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
|
||||||
MergedAt *time.Time `json:"merged_at,omitempty"`
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
Merged *bool `json:"merged,omitempty"`
|
|
||||||
Mergeable *bool `json:"mergeable,omitempty"`
|
|
||||||
MergedBy *User `json:"merged_by,omitempty"`
|
|
||||||
Comments *int `json:"comments,omitempty"`
|
|
||||||
Commits *int `json:"commits,omitempty"`
|
|
||||||
Additions *int `json:"additions,omitempty"`
|
|
||||||
Deletions *int `json:"deletions,omitempty"`
|
|
||||||
ChangedFiles *int `json:"changed_files,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
IssueURL *string `json:"issue_url,omitempty"`
|
|
||||||
StatusesURL *string `json:"statuses_url,omitempty"`
|
|
||||||
DiffURL *string `json:"diff_url,omitempty"`
|
|
||||||
PatchURL *string `json:"patch_url,omitempty"`
|
|
||||||
|
|
||||||
Head *PullRequestBranch `json:"head,omitempty"`
|
|
||||||
Base *PullRequestBranch `json:"base,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PullRequest) String() string {
|
|
||||||
return Stringify(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequestBranch represents a base or head branch in a GitHub pull request.
|
|
||||||
type PullRequestBranch struct {
|
|
||||||
Label *string `json:"label,omitempty"`
|
|
||||||
Ref *string `json:"ref,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Repo *Repository `json:"repo,omitempty"`
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequestListOptions specifies the optional parameters to the
|
|
||||||
// PullRequestsService.List method.
|
|
||||||
type PullRequestListOptions struct {
|
|
||||||
// State filters pull requests based on their state. Possible values are:
|
|
||||||
// open, closed. Default is "open".
|
|
||||||
State string `url:"state,omitempty"`
|
|
||||||
|
|
||||||
// Head filters pull requests by head user and branch name in the format of:
|
|
||||||
// "user:ref-name".
|
|
||||||
Head string `url:"head,omitempty"`
|
|
||||||
|
|
||||||
// Base filters pull requests by base branch name.
|
|
||||||
Base string `url:"base,omitempty"`
|
|
||||||
|
|
||||||
// Sort specifies how to sort pull requests. Possible values are: created,
|
|
||||||
// updated, popularity, long-running. Default is "created".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort pull requests. Possible values are: asc, desc.
|
|
||||||
// If Sort is "created" or not specified, Default is "desc", otherwise Default
|
|
||||||
// is "asc"
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// List the pull requests for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/pulls/#list-pull-requests
|
|
||||||
func (s *PullRequestsService) List(owner string, repo string, opt *PullRequestListOptions) ([]PullRequest, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
pulls := new([]PullRequest)
|
|
||||||
resp, err := s.client.Do(req, pulls)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *pulls, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a single pull request.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#get-a-single-pull-request
|
|
||||||
func (s *PullRequestsService) Get(owner string, repo string, number int) (*PullRequest, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
pull := new(PullRequest)
|
|
||||||
resp, err := s.client.Do(req, pull)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return pull, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPullRequest represents a new pull request to be created.
|
|
||||||
type NewPullRequest struct {
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
Head *string `json:"head,omitempty"`
|
|
||||||
Base *string `json:"base,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
Issue *int `json:"issue,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new pull request on the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#create-a-pull-request
|
|
||||||
func (s *PullRequestsService) Create(owner string, repo string, pull *NewPullRequest) (*PullRequest, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("POST", u, pull)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
p := new(PullRequest)
|
|
||||||
resp, err := s.client.Do(req, p)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return p, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit a pull request.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#update-a-pull-request
|
|
||||||
func (s *PullRequestsService) Edit(owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, pull)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
p := new(PullRequest)
|
|
||||||
resp, err := s.client.Do(req, p)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return p, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListCommits lists the commits in a pull request.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
|
|
||||||
func (s *PullRequestsService) ListCommits(owner string, repo string, number int, opt *ListOptions) ([]RepositoryCommit, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
commits := new([]RepositoryCommit)
|
|
||||||
resp, err := s.client.Do(req, commits)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *commits, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListFiles lists the files in a pull request.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#list-pull-requests-files
|
|
||||||
func (s *PullRequestsService) ListFiles(owner string, repo string, number int, opt *ListOptions) ([]CommitFile, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/files", owner, repo, number)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
commitFiles := new([]CommitFile)
|
|
||||||
resp, err := s.client.Do(req, commitFiles)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *commitFiles, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMerged checks if a pull request has been merged.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged
|
|
||||||
func (s *PullRequestsService) IsMerged(owner string, repo string, number int) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
merged, err := parseBoolResponse(err)
|
|
||||||
return merged, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequestMergeResult represents the result of merging a pull request.
|
|
||||||
type PullRequestMergeResult struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Merged *bool `json:"merged,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type pullRequestMergeRequest struct {
|
|
||||||
CommitMessage *string `json:"commit_message"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge a pull request (Merge Button™).
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade
|
|
||||||
func (s *PullRequestsService) Merge(owner string, repo string, number int, commitMessage string) (*PullRequestMergeResult, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, &pullRequestMergeRequest{
|
|
||||||
CommitMessage: &commitMessage,
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mergeResult := new(PullRequestMergeResult)
|
|
||||||
resp, err := s.client.Do(req, mergeResult)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergeResult, resp, err
|
|
||||||
}
|
|
145
vendor/github.com/google/go-github/github/pulls_comments.go
generated
vendored
145
vendor/github.com/google/go-github/github/pulls_comments.go
generated
vendored
|
@ -1,145 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PullRequestComment represents a comment left on a pull request.
|
|
||||||
type PullRequestComment struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
Body *string `json:"body,omitempty"`
|
|
||||||
Path *string `json:"path,omitempty"`
|
|
||||||
DiffHunk *string `json:"diff_hunk,omitempty"`
|
|
||||||
Position *int `json:"position,omitempty"`
|
|
||||||
OriginalPosition *int `json:"original_position,omitempty"`
|
|
||||||
CommitID *string `json:"commit_id,omitempty"`
|
|
||||||
OriginalCommitID *string `json:"original_commit_id,omitempty"`
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p PullRequestComment) String() string {
|
|
||||||
return Stringify(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PullRequestListCommentsOptions specifies the optional parameters to the
|
|
||||||
// PullRequestsService.ListComments method.
|
|
||||||
type PullRequestListCommentsOptions struct {
|
|
||||||
// Sort specifies how to sort comments. Possible values are: created, updated.
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort comments. Possible values are: asc, desc.
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
// Since filters comments by time.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListComments lists all comments on the specified pull request. Specifying a
|
|
||||||
// pull request number of 0 will return all comments on all pull requests for
|
|
||||||
// the repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
|
|
||||||
func (s *PullRequestsService) ListComments(owner string, repo string, number int, opt *PullRequestListCommentsOptions) ([]PullRequestComment, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if number == 0 {
|
|
||||||
u = fmt.Sprintf("repos/%v/%v/pulls/comments", owner, repo)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number)
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
comments := new([]PullRequestComment)
|
|
||||||
resp, err := s.client.Do(req, comments)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *comments, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetComment fetches the specified pull request comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#get-a-single-comment
|
|
||||||
func (s *PullRequestsService) GetComment(owner string, repo string, number int) (*PullRequestComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
comment := new(PullRequestComment)
|
|
||||||
resp, err := s.client.Do(req, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return comment, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateComment creates a new comment on the specified pull request.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#create-a-comment
|
|
||||||
func (s *PullRequestsService) CreateComment(owner string, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("POST", u, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := new(PullRequestComment)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditComment updates a pull request comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#edit-a-comment
|
|
||||||
func (s *PullRequestsService) EditComment(owner string, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := new(PullRequestComment)
|
|
||||||
resp, err := s.client.Do(req, c)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteComment deletes a pull request comment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#delete-a-comment
|
|
||||||
func (s *PullRequestsService) DeleteComment(owner string, repo string, number int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
496
vendor/github.com/google/go-github/github/repos.go
generated
vendored
496
vendor/github.com/google/go-github/github/repos.go
generated
vendored
|
@ -1,496 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// RepositoriesService handles communication with the repository related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/
|
|
||||||
type RepositoriesService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repository represents a GitHub repository.
|
|
||||||
type Repository struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
Owner *User `json:"owner,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
FullName *string `json:"full_name,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Homepage *string `json:"homepage,omitempty"`
|
|
||||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
|
||||||
MasterBranch *string `json:"master_branch,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
PushedAt *Timestamp `json:"pushed_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
CloneURL *string `json:"clone_url,omitempty"`
|
|
||||||
GitURL *string `json:"git_url,omitempty"`
|
|
||||||
MirrorURL *string `json:"mirror_url,omitempty"`
|
|
||||||
SSHURL *string `json:"ssh_url,omitempty"`
|
|
||||||
SVNURL *string `json:"svn_url,omitempty"`
|
|
||||||
Language *string `json:"language,omitempty"`
|
|
||||||
Fork *bool `json:"fork"`
|
|
||||||
ForksCount *int `json:"forks_count,omitempty"`
|
|
||||||
NetworkCount *int `json:"network_count,omitempty"`
|
|
||||||
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
|
|
||||||
StargazersCount *int `json:"stargazers_count,omitempty"`
|
|
||||||
SubscribersCount *int `json:"subscribers_count,omitempty"`
|
|
||||||
WatchersCount *int `json:"watchers_count,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
AutoInit *bool `json:"auto_init,omitempty"`
|
|
||||||
Parent *Repository `json:"parent,omitempty"`
|
|
||||||
Source *Repository `json:"source,omitempty"`
|
|
||||||
Organization *Organization `json:"organization,omitempty"`
|
|
||||||
Permissions *map[string]bool `json:"permissions,omitempty"`
|
|
||||||
|
|
||||||
// Only provided when using RepositoriesService.Get while in preview
|
|
||||||
License *License `json:"license,omitempty"`
|
|
||||||
|
|
||||||
// Additional mutable fields when creating and editing a repository
|
|
||||||
Private *bool `json:"private"`
|
|
||||||
HasIssues *bool `json:"has_issues"`
|
|
||||||
HasWiki *bool `json:"has_wiki"`
|
|
||||||
HasDownloads *bool `json:"has_downloads"`
|
|
||||||
// Creating an organization repository. Required for non-owners.
|
|
||||||
TeamID *int `json:"team_id"`
|
|
||||||
|
|
||||||
// API URLs
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
ArchiveURL *string `json:"archive_url,omitempty"`
|
|
||||||
AssigneesURL *string `json:"assignees_url,omitempty"`
|
|
||||||
BlobsURL *string `json:"blobs_url,omitempty"`
|
|
||||||
BranchesURL *string `json:"branches_url,omitempty"`
|
|
||||||
CollaboratorsURL *string `json:"collaborators_url,omitempty"`
|
|
||||||
CommentsURL *string `json:"comments_url,omitempty"`
|
|
||||||
CommitsURL *string `json:"commits_url,omitempty"`
|
|
||||||
CompareURL *string `json:"compare_url,omitempty"`
|
|
||||||
ContentsURL *string `json:"contents_url,omitempty"`
|
|
||||||
ContributorsURL *string `json:"contributors_url,omitempty"`
|
|
||||||
DownloadsURL *string `json:"downloads_url,omitempty"`
|
|
||||||
EventsURL *string `json:"events_url,omitempty"`
|
|
||||||
ForksURL *string `json:"forks_url,omitempty"`
|
|
||||||
GitCommitsURL *string `json:"git_commits_url,omitempty"`
|
|
||||||
GitRefsURL *string `json:"git_refs_url,omitempty"`
|
|
||||||
GitTagsURL *string `json:"git_tags_url,omitempty"`
|
|
||||||
HooksURL *string `json:"hooks_url,omitempty"`
|
|
||||||
IssueCommentURL *string `json:"issue_comment_url,omitempty"`
|
|
||||||
IssueEventsURL *string `json:"issue_events_url,omitempty"`
|
|
||||||
IssuesURL *string `json:"issues_url,omitempty"`
|
|
||||||
KeysURL *string `json:"keys_url,omitempty"`
|
|
||||||
LabelsURL *string `json:"labels_url,omitempty"`
|
|
||||||
LanguagesURL *string `json:"languages_url,omitempty"`
|
|
||||||
MergesURL *string `json:"merges_url,omitempty"`
|
|
||||||
MilestonesURL *string `json:"milestones_url,omitempty"`
|
|
||||||
NotificationsURL *string `json:"notifications_url,omitempty"`
|
|
||||||
PullsURL *string `json:"pulls_url,omitempty"`
|
|
||||||
ReleasesURL *string `json:"releases_url,omitempty"`
|
|
||||||
StargazersURL *string `json:"stargazers_url,omitempty"`
|
|
||||||
StatusesURL *string `json:"statuses_url,omitempty"`
|
|
||||||
SubscribersURL *string `json:"subscribers_url,omitempty"`
|
|
||||||
SubscriptionURL *string `json:"subscription_url,omitempty"`
|
|
||||||
TagsURL *string `json:"tags_url,omitempty"`
|
|
||||||
TreesURL *string `json:"trees_url,omitempty"`
|
|
||||||
TeamsURL *string `json:"teams_url,omitempty"`
|
|
||||||
|
|
||||||
// TextMatches is only populated from search results that request text matches
|
|
||||||
// See: search.go and https://developer.github.com/v3/search/#text-match-metadata
|
|
||||||
TextMatches []TextMatch `json:"text_matches,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Repository) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryListOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.List method.
|
|
||||||
type RepositoryListOptions struct {
|
|
||||||
// Type of repositories to list. Possible values are: all, owner, public,
|
|
||||||
// private, member. Default is "all".
|
|
||||||
Type string `url:"type,omitempty"`
|
|
||||||
|
|
||||||
// How to sort the repository list. Possible values are: created, updated,
|
|
||||||
// pushed, full_name. Default is "full_name".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Direction in which to sort repositories. Possible values are: asc, desc.
|
|
||||||
// Default is "asc" when sort is "full_name", otherwise default is "desc".
|
|
||||||
Direction string `url:"direction,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// List the repositories for a user. Passing the empty string will list
|
|
||||||
// repositories for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#list-user-repositories
|
|
||||||
func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]Repository, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/repos", user)
|
|
||||||
} else {
|
|
||||||
u = "user/repos"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when license support fully launches
|
|
||||||
req.Header.Set("Accept", mediaTypeLicensesPreview)
|
|
||||||
|
|
||||||
repos := new([]Repository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryListByOrgOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListByOrg method.
|
|
||||||
type RepositoryListByOrgOptions struct {
|
|
||||||
// Type of repositories to list. Possible values are: all, public, private,
|
|
||||||
// forks, sources, member. Default is "all".
|
|
||||||
Type string `url:"type,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByOrg lists the repositories for an organization.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#list-organization-repositories
|
|
||||||
func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOptions) ([]Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("orgs/%v/repos", org)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when license support fully launches
|
|
||||||
req.Header.Set("Accept", mediaTypeLicensesPreview)
|
|
||||||
|
|
||||||
repos := new([]Repository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryListAllOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListAll method.
|
|
||||||
type RepositoryListAllOptions struct {
|
|
||||||
// ID of the last repository seen
|
|
||||||
Since int `url:"since,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListAll lists all GitHub repositories in the order that they were created.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#list-all-public-repositories
|
|
||||||
func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]Repository, *Response, error) {
|
|
||||||
u, err := addOptions("repositories", opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
repos := new([]Repository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new repository. If an organization is specified, the new
|
|
||||||
// repository will be created under that org. If the empty string is
|
|
||||||
// specified, it will be created for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#create
|
|
||||||
func (s *RepositoriesService) Create(org string, repo *Repository) (*Repository, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if org != "" {
|
|
||||||
u = fmt.Sprintf("orgs/%v/repos", org)
|
|
||||||
} else {
|
|
||||||
u = "user/repos"
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, repo)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r := new(Repository)
|
|
||||||
resp, err := s.client.Do(req, r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return r, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get fetches a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#get
|
|
||||||
func (s *RepositoriesService) Get(owner, repo string) (*Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove custom Accept header when the license support fully launches
|
|
||||||
// https://developer.github.com/v3/licenses/#get-a-repositorys-license
|
|
||||||
req.Header.Set("Accept", mediaTypeLicensesPreview)
|
|
||||||
|
|
||||||
repository := new(Repository)
|
|
||||||
resp, err := s.client.Do(req, repository)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit updates a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#edit
|
|
||||||
func (s *RepositoriesService) Edit(owner, repo string, repository *Repository) (*Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, repository)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r := new(Repository)
|
|
||||||
resp, err := s.client.Do(req, r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return r, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/#delete-a-repository
|
|
||||||
func (s *RepositoriesService) Delete(owner, repo string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contributor represents a repository contributor
|
|
||||||
type Contributor struct {
|
|
||||||
Login *string `json:"login,omitempty"`
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
AvatarURL *string `json:"avatar_url,omitempty"`
|
|
||||||
GravatarID *string `json:"gravatar_id,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
FollowersURL *string `json:"followers_url,omitempty"`
|
|
||||||
FollowingURL *string `json:"following_url,omitempty"`
|
|
||||||
GistsURL *string `json:"gists_url,omitempty"`
|
|
||||||
StarredURL *string `json:"starred_url,omitempty"`
|
|
||||||
SubscriptionsURL *string `json:"subscriptions_url,omitempty"`
|
|
||||||
OrganizationsURL *string `json:"organizations_url,omitempty"`
|
|
||||||
ReposURL *string `json:"repos_url,omitempty"`
|
|
||||||
EventsURL *string `json:"events_url,omitempty"`
|
|
||||||
ReceivedEventsURL *string `json:"received_events_url,omitempty"`
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
SiteAdmin *bool `json:"site_admin"`
|
|
||||||
Contributions *int `json:"contributions,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListContributorsOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListContributors method.
|
|
||||||
type ListContributorsOptions struct {
|
|
||||||
// Include anonymous contributors in results or not
|
|
||||||
Anon string `url:"anon,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListContributors lists contributors for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#list-contributors
|
|
||||||
func (s *RepositoriesService) ListContributors(owner string, repository string, opt *ListContributorsOptions) ([]Contributor, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/contributors", owner, repository)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
contributor := new([]Contributor)
|
|
||||||
resp, err := s.client.Do(req, contributor)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *contributor, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListLanguages lists languages for the specified repository. The returned map
|
|
||||||
// specifies the languages and the number of bytes of code written in that
|
|
||||||
// language. For example:
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// "C": 78769,
|
|
||||||
// "Python": 7769
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// GitHub API Docs: http://developer.github.com/v3/repos/#list-languages
|
|
||||||
func (s *RepositoriesService) ListLanguages(owner string, repo string) (map[string]int, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/languages", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
languages := make(map[string]int)
|
|
||||||
resp, err := s.client.Do(req, &languages)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return languages, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTeams lists the teams for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/#list-teams
|
|
||||||
func (s *RepositoriesService) ListTeams(owner string, repo string, opt *ListOptions) ([]Team, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/teams", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
teams := new([]Team)
|
|
||||||
resp, err := s.client.Do(req, teams)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *teams, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryTag represents a repository tag.
|
|
||||||
type RepositoryTag struct {
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Commit *Commit `json:"commit,omitempty"`
|
|
||||||
ZipballURL *string `json:"zipball_url,omitempty"`
|
|
||||||
TarballURL *string `json:"tarball_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListTags lists tags for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/#list-tags
|
|
||||||
func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptions) ([]RepositoryTag, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/tags", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
tags := new([]RepositoryTag)
|
|
||||||
resp, err := s.client.Do(req, tags)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *tags, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Branch represents a repository branch
|
|
||||||
type Branch struct {
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Commit *Commit `json:"commit,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListBranches lists branches for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/#list-branches
|
|
||||||
func (s *RepositoriesService) ListBranches(owner string, repo string, opt *ListOptions) ([]Branch, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/branches", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
branches := new([]Branch)
|
|
||||||
resp, err := s.client.Do(req, branches)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *branches, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBranch gets the specified branch for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/#get-branch
|
|
||||||
func (s *RepositoriesService) GetBranch(owner, repo, branch string) (*Branch, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, branch)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
b := new(Branch)
|
|
||||||
resp, err := s.client.Do(req, b)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return b, resp, err
|
|
||||||
}
|
|
95
vendor/github.com/google/go-github/github/repos_collaborators.go
generated
vendored
95
vendor/github.com/google/go-github/github/repos_collaborators.go
generated
vendored
|
@ -1,95 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// ListCollaborators lists the Github users that have access to the repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#list
|
|
||||||
func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOptions) ([]User, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
|
|
||||||
users := new([]User)
|
|
||||||
resp, err := s.client.Do(req, users)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *users, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsCollaborator checks whether the specified Github user has collaborator
|
|
||||||
// access to the given repo.
|
|
||||||
// Note: This will return false if the user is not a collaborator OR the user
|
|
||||||
// is not a GitHub user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#get
|
|
||||||
func (s *RepositoriesService) IsCollaborator(owner, repo, user string) (bool, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
isCollab, err := parseBoolResponse(err)
|
|
||||||
return isCollab, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryAddCollaboratorOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.AddCollaborator method.
|
|
||||||
type RepositoryAddCollaboratorOptions struct {
|
|
||||||
// Permission specifies the permission to grant the user on this repository.
|
|
||||||
// Possible values are:
|
|
||||||
// pull - team members can pull, but not push to or administer this repository
|
|
||||||
// push - team members can pull and push, but not administer this repository
|
|
||||||
// admin - team members can pull, push and administer this repository
|
|
||||||
//
|
|
||||||
// Default value is "pull". This option is only valid for organization-owned repositories.
|
|
||||||
Permission string `json:"permission,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddCollaborator adds the specified Github user as collaborator to the given repo.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#add-collaborator
|
|
||||||
func (s *RepositoriesService) AddCollaborator(owner, repo, user string, opt *RepositoryAddCollaboratorOptions) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt != nil {
|
|
||||||
req.Header.Set("Accept", mediaTypeOrgPermissionPreview)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveCollaborator removes the specified Github user as collaborator from the given repo.
|
|
||||||
// Note: Does not return error if a valid user that is not a collaborator is removed.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#remove-collaborator
|
|
||||||
func (s *RepositoriesService) RemoveCollaborator(owner, repo, user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
168
vendor/github.com/google/go-github/github/repos_commits.go
generated
vendored
168
vendor/github.com/google/go-github/github/repos_commits.go
generated
vendored
|
@ -1,168 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RepositoryCommit represents a commit in a repo.
|
|
||||||
// Note that it's wrapping a Commit, so author/committer information is in two places,
|
|
||||||
// but contain different details about them: in RepositoryCommit "github details", in Commit - "git details".
|
|
||||||
type RepositoryCommit struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Commit *Commit `json:"commit,omitempty"`
|
|
||||||
Author *User `json:"author,omitempty"`
|
|
||||||
Committer *User `json:"committer,omitempty"`
|
|
||||||
Parents []Commit `json:"parents,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
|
|
||||||
// Details about how many changes were made in this commit. Only filled in during GetCommit!
|
|
||||||
Stats *CommitStats `json:"stats,omitempty"`
|
|
||||||
// Details about which files, and how this commit touched. Only filled in during GetCommit!
|
|
||||||
Files []CommitFile `json:"files,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RepositoryCommit) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommitStats represents the number of additions / deletions from a file in a given RepositoryCommit.
|
|
||||||
type CommitStats struct {
|
|
||||||
Additions *int `json:"additions,omitempty"`
|
|
||||||
Deletions *int `json:"deletions,omitempty"`
|
|
||||||
Total *int `json:"total,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CommitStats) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommitFile represents a file modified in a commit.
|
|
||||||
type CommitFile struct {
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Filename *string `json:"filename,omitempty"`
|
|
||||||
Additions *int `json:"additions,omitempty"`
|
|
||||||
Deletions *int `json:"deletions,omitempty"`
|
|
||||||
Changes *int `json:"changes,omitempty"`
|
|
||||||
Status *string `json:"status,omitempty"`
|
|
||||||
Patch *string `json:"patch,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CommitFile) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommitsComparison is the result of comparing two commits.
|
|
||||||
// See CompareCommits() for details.
|
|
||||||
type CommitsComparison struct {
|
|
||||||
BaseCommit *RepositoryCommit `json:"base_commit,omitempty"`
|
|
||||||
MergeBaseCommit *RepositoryCommit `json:"merge_base_commit,omitempty"`
|
|
||||||
|
|
||||||
// Head can be 'behind' or 'ahead'
|
|
||||||
Status *string `json:"status,omitempty"`
|
|
||||||
AheadBy *int `json:"ahead_by,omitempty"`
|
|
||||||
BehindBy *int `json:"behind_by,omitempty"`
|
|
||||||
TotalCommits *int `json:"total_commits,omitempty"`
|
|
||||||
|
|
||||||
Commits []RepositoryCommit `json:"commits,omitempty"`
|
|
||||||
|
|
||||||
Files []CommitFile `json:"files,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CommitsComparison) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommitsListOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListCommits method.
|
|
||||||
type CommitsListOptions struct {
|
|
||||||
// SHA or branch to start listing Commits from.
|
|
||||||
SHA string `url:"sha,omitempty"`
|
|
||||||
|
|
||||||
// Path that should be touched by the returned Commits.
|
|
||||||
Path string `url:"path,omitempty"`
|
|
||||||
|
|
||||||
// Author of by which to filter Commits.
|
|
||||||
Author string `url:"author,omitempty"`
|
|
||||||
|
|
||||||
// Since when should Commits be included in the response.
|
|
||||||
Since time.Time `url:"since,omitempty"`
|
|
||||||
|
|
||||||
// Until when should Commits be included in the response.
|
|
||||||
Until time.Time `url:"until,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListCommits lists the commits of a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/commits/#list
|
|
||||||
func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOptions) ([]RepositoryCommit, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/commits", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
commits := new([]RepositoryCommit)
|
|
||||||
resp, err := s.client.Do(req, commits)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *commits, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCommit fetches the specified commit, including all details about it.
|
|
||||||
// todo: support media formats - https://github.com/google/go-github/issues/6
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/commits/#get-a-single-commit
|
|
||||||
// See also: http://developer.github.com//v3/git/commits/#get-a-single-commit provides the same functionality
|
|
||||||
func (s *RepositoriesService) GetCommit(owner, repo, sha string) (*RepositoryCommit, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
commit := new(RepositoryCommit)
|
|
||||||
resp, err := s.client.Do(req, commit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return commit, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CompareCommits compares a range of commits with each other.
|
|
||||||
// todo: support media formats - https://github.com/google/go-github/issues/6
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/commits/index.html#compare-two-commits
|
|
||||||
func (s *RepositoriesService) CompareCommits(owner, repo string, base, head string) (*CommitsComparison, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/compare/%v...%v", owner, repo, base, head)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
comp := new(CommitsComparison)
|
|
||||||
resp, err := s.client.Do(req, comp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return comp, resp, err
|
|
||||||
}
|
|
248
vendor/github.com/google/go-github/github/repos_contents.go
generated
vendored
248
vendor/github.com/google/go-github/github/repos_contents.go
generated
vendored
|
@ -1,248 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Repository contents API methods.
|
|
||||||
// http://developer.github.com/v3/repos/contents/
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"path"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RepositoryContent represents a file or directory in a github repository.
|
|
||||||
type RepositoryContent struct {
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
Encoding *string `json:"encoding,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Path *string `json:"path,omitempty"`
|
|
||||||
Content *string `json:"content,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
GitURL *string `json:"git_url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
DownloadURL *string `json:"download_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryContentResponse holds the parsed response from CreateFile, UpdateFile, and DeleteFile.
|
|
||||||
type RepositoryContentResponse struct {
|
|
||||||
Content *RepositoryContent `json:"content,omitempty"`
|
|
||||||
Commit `json:"commit,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryContentFileOptions specifies optional parameters for CreateFile, UpdateFile, and DeleteFile.
|
|
||||||
type RepositoryContentFileOptions struct {
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
Content []byte `json:"content,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Branch *string `json:"branch,omitempty"`
|
|
||||||
Author *CommitAuthor `json:"author,omitempty"`
|
|
||||||
Committer *CommitAuthor `json:"committer,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryContentGetOptions represents an optional ref parameter, which can be a SHA,
|
|
||||||
// branch, or tag
|
|
||||||
type RepositoryContentGetOptions struct {
|
|
||||||
Ref string `url:"ref,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RepositoryContent) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes the file content if it is base64 encoded.
|
|
||||||
func (r *RepositoryContent) Decode() ([]byte, error) {
|
|
||||||
if *r.Encoding != "base64" {
|
|
||||||
return nil, errors.New("cannot decode non-base64")
|
|
||||||
}
|
|
||||||
o, err := base64.StdEncoding.DecodeString(*r.Content)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return o, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetReadme gets the Readme file for the repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-the-readme
|
|
||||||
func (s *RepositoriesService) GetReadme(owner, repo string, opt *RepositoryContentGetOptions) (*RepositoryContent, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/readme", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
readme := new(RepositoryContent)
|
|
||||||
resp, err := s.client.Do(req, readme)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return readme, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DownloadContents returns an io.ReadCloser that reads the contents of the
|
|
||||||
// specified file. This function will work with files of any size, as opposed
|
|
||||||
// to GetContents which is limited to 1 Mb files. It is the caller's
|
|
||||||
// responsibility to close the ReadCloser.
|
|
||||||
func (s *RepositoriesService) DownloadContents(owner, repo, filepath string, opt *RepositoryContentGetOptions) (io.ReadCloser, error) {
|
|
||||||
dir := path.Dir(filepath)
|
|
||||||
filename := path.Base(filepath)
|
|
||||||
_, dirContents, _, err := s.GetContents(owner, repo, dir, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, contents := range dirContents {
|
|
||||||
if *contents.Name == filename {
|
|
||||||
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
|
|
||||||
return nil, fmt.Errorf("No download link found for %s", filepath)
|
|
||||||
}
|
|
||||||
resp, err := s.client.client.Get(*contents.DownloadURL)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp.Body, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("No file named %s found in %s", filename, dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetContents can return either the metadata and content of a single file
|
|
||||||
// (when path references a file) or the metadata of all the files and/or
|
|
||||||
// subdirectories of a directory (when path references a directory). To make it
|
|
||||||
// easy to distinguish between both result types and to mimic the API as much
|
|
||||||
// as possible, both result types will be returned but only one will contain a
|
|
||||||
// value and the other will be nil.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-contents
|
|
||||||
func (s *RepositoriesService) GetContents(owner, repo, path string, opt *RepositoryContentGetOptions) (fileContent *RepositoryContent,
|
|
||||||
directoryContent []*RepositoryContent, resp *Response, err error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
|
||||||
u, err = addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
|
||||||
var rawJSON json.RawMessage
|
|
||||||
resp, err = s.client.Do(req, &rawJSON)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, resp, err
|
|
||||||
}
|
|
||||||
fileUnmarshalError := json.Unmarshal(rawJSON, &fileContent)
|
|
||||||
if fileUnmarshalError == nil {
|
|
||||||
return fileContent, nil, resp, fileUnmarshalError
|
|
||||||
}
|
|
||||||
directoryUnmarshalError := json.Unmarshal(rawJSON, &directoryContent)
|
|
||||||
if directoryUnmarshalError == nil {
|
|
||||||
return nil, directoryContent, resp, directoryUnmarshalError
|
|
||||||
}
|
|
||||||
return nil, nil, resp, fmt.Errorf("unmarshalling failed for both file and directory content: %s and %s ", fileUnmarshalError, directoryUnmarshalError)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateFile creates a new file in a repository at the given path and returns
|
|
||||||
// the commit and file metadata.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#create-a-file
|
|
||||||
func (s *RepositoriesService) CreateFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
createResponse := new(RepositoryContentResponse)
|
|
||||||
resp, err := s.client.Do(req, createResponse)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return createResponse, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateFile updates a file in a repository at the given path and returns the
|
|
||||||
// commit and file metadata. Requires the blob SHA of the file being updated.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#update-a-file
|
|
||||||
func (s *RepositoriesService) UpdateFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
updateResponse := new(RepositoryContentResponse)
|
|
||||||
resp, err := s.client.Do(req, updateResponse)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return updateResponse, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteFile deletes a file from a repository and returns the commit.
|
|
||||||
// Requires the blob SHA of the file to be deleted.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#delete-a-file
|
|
||||||
func (s *RepositoriesService) DeleteFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
deleteResponse := new(RepositoryContentResponse)
|
|
||||||
resp, err := s.client.Do(req, deleteResponse)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return deleteResponse, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// archiveFormat is used to define the archive type when calling GetArchiveLink.
|
|
||||||
type archiveFormat string
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Tarball specifies an archive in gzipped tar format.
|
|
||||||
Tarball archiveFormat = "tarball"
|
|
||||||
|
|
||||||
// Zipball specifies an archive in zip format.
|
|
||||||
Zipball archiveFormat = "zipball"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetArchiveLink returns an URL to download a tarball or zipball archive for a
|
|
||||||
// repository. The archiveFormat can be specified by either the github.Tarball
|
|
||||||
// or github.Zipball constant.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-archive-link
|
|
||||||
func (s *RepositoriesService) GetArchiveLink(owner, repo string, archiveformat archiveFormat, opt *RepositoryContentGetOptions) (*url.URL, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat)
|
|
||||||
if opt != nil && opt.Ref != "" {
|
|
||||||
u += fmt.Sprintf("/%s", opt.Ref)
|
|
||||||
}
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
var resp *http.Response
|
|
||||||
// Use http.DefaultTransport if no custom Transport is configured
|
|
||||||
if s.client.client.Transport == nil {
|
|
||||||
resp, err = http.DefaultTransport.RoundTrip(req)
|
|
||||||
} else {
|
|
||||||
resp, err = s.client.client.Transport.RoundTrip(req)
|
|
||||||
}
|
|
||||||
if err != nil || resp.StatusCode != http.StatusFound {
|
|
||||||
return nil, newResponse(resp), err
|
|
||||||
}
|
|
||||||
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
|
||||||
return parsedURL, newResponse(resp), err
|
|
||||||
}
|
|
162
vendor/github.com/google/go-github/github/repos_deployments.go
generated
vendored
162
vendor/github.com/google/go-github/github/repos_deployments.go
generated
vendored
|
@ -1,162 +0,0 @@
|
||||||
// Copyright 2014 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Deployment represents a deployment in a repo
|
|
||||||
type Deployment struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
Ref *string `json:"ref,omitempty"`
|
|
||||||
Task *string `json:"task,omitempty"`
|
|
||||||
Payload json.RawMessage `json:"payload,omitempty"`
|
|
||||||
Environment *string `json:"environment,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
Creator *User `json:"creator,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"pushed_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeploymentRequest represents a deployment request
|
|
||||||
type DeploymentRequest struct {
|
|
||||||
Ref *string `json:"ref,omitempty"`
|
|
||||||
Task *string `json:"task,omitempty"`
|
|
||||||
AutoMerge *bool `json:"auto_merge,omitempty"`
|
|
||||||
RequiredContexts *[]string `json:"required_contexts,omitempty"`
|
|
||||||
Payload *string `json:"payload,omitempty"`
|
|
||||||
Environment *string `json:"environment,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeploymentsListOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListDeployments method.
|
|
||||||
type DeploymentsListOptions struct {
|
|
||||||
// SHA of the Deployment.
|
|
||||||
SHA string `url:"sha,omitempty"`
|
|
||||||
|
|
||||||
// List deployments for a given ref.
|
|
||||||
Ref string `url:"ref,omitempty"`
|
|
||||||
|
|
||||||
// List deployments for a given task.
|
|
||||||
Task string `url:"task,omitempty"`
|
|
||||||
|
|
||||||
// List deployments for a given environment.
|
|
||||||
Environment string `url:"environment,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListDeployments lists the deployments of a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/deployments/#list-deployments
|
|
||||||
func (s *RepositoriesService) ListDeployments(owner, repo string, opt *DeploymentsListOptions) ([]Deployment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
deployments := new([]Deployment)
|
|
||||||
resp, err := s.client.Do(req, deployments)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *deployments, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateDeployment creates a new deployment for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/deployments/#create-a-deployment
|
|
||||||
func (s *RepositoriesService) CreateDeployment(owner, repo string, request *DeploymentRequest) (*Deployment, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
d := new(Deployment)
|
|
||||||
resp, err := s.client.Do(req, d)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return d, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeploymentStatus represents the status of a
|
|
||||||
// particular deployment.
|
|
||||||
type DeploymentStatus struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
Creator *User `json:"creator,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
TargetURL *string `json:"target_url,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"pushed_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeploymentStatusRequest represents a deployment request
|
|
||||||
type DeploymentStatusRequest struct {
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
TargetURL *string `json:"target_url,omitempty"`
|
|
||||||
Description *string `json:"description,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListDeploymentStatuses lists the statuses of a given deployment of a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
|
||||||
func (s *RepositoriesService) ListDeploymentStatuses(owner, repo string, deployment int, opt *ListOptions) ([]DeploymentStatus, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
statuses := new([]DeploymentStatus)
|
|
||||||
resp, err := s.client.Do(req, statuses)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *statuses, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateDeploymentStatus creates a new status for a deployment.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
|
|
||||||
func (s *RepositoriesService) CreateDeploymentStatus(owner, repo string, deployment int, request *DeploymentStatusRequest) (*DeploymentStatus, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
d := new(DeploymentStatus)
|
|
||||||
resp, err := s.client.Do(req, d)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return d, resp, err
|
|
||||||
}
|
|
73
vendor/github.com/google/go-github/github/repos_forks.go
generated
vendored
73
vendor/github.com/google/go-github/github/repos_forks.go
generated
vendored
|
@ -1,73 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// RepositoryListForksOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.ListForks method.
|
|
||||||
type RepositoryListForksOptions struct {
|
|
||||||
// How to sort the forks list. Possible values are: newest, oldest,
|
|
||||||
// watchers. Default is "newest".
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListForks lists the forks of the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/forks/#list-forks
|
|
||||||
func (s *RepositoriesService) ListForks(owner, repo string, opt *RepositoryListForksOptions) ([]Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/forks", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
repos := new([]Repository)
|
|
||||||
resp, err := s.client.Do(req, repos)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *repos, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoryCreateForkOptions specifies the optional parameters to the
|
|
||||||
// RepositoriesService.CreateFork method.
|
|
||||||
type RepositoryCreateForkOptions struct {
|
|
||||||
// The organization to fork the repository into.
|
|
||||||
Organization string `url:"organization,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateFork creates a fork of the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/forks/#list-forks
|
|
||||||
func (s *RepositoriesService) CreateFork(owner, repo string, opt *RepositoryCreateForkOptions) (*Repository, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/forks", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
fork := new(Repository)
|
|
||||||
resp, err := s.client.Do(req, fork)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return fork, resp, err
|
|
||||||
}
|
|
194
vendor/github.com/google/go-github/github/repos_hooks.go
generated
vendored
194
vendor/github.com/google/go-github/github/repos_hooks.go
generated
vendored
|
@ -1,194 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WebHookPayload represents the data that is received from GitHub when a push
|
|
||||||
// event hook is triggered. The format of these payloads pre-date most of the
|
|
||||||
// GitHub v3 API, so there are lots of minor incompatibilities with the types
|
|
||||||
// defined in the rest of the API. Therefore, several types are duplicated
|
|
||||||
// here to account for these differences.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://help.github.com/articles/post-receive-hooks
|
|
||||||
type WebHookPayload struct {
|
|
||||||
After *string `json:"after,omitempty"`
|
|
||||||
Before *string `json:"before,omitempty"`
|
|
||||||
Commits []WebHookCommit `json:"commits,omitempty"`
|
|
||||||
Compare *string `json:"compare,omitempty"`
|
|
||||||
Created *bool `json:"created,omitempty"`
|
|
||||||
Deleted *bool `json:"deleted,omitempty"`
|
|
||||||
Forced *bool `json:"forced,omitempty"`
|
|
||||||
HeadCommit *WebHookCommit `json:"head_commit,omitempty"`
|
|
||||||
Pusher *User `json:"pusher,omitempty"`
|
|
||||||
Ref *string `json:"ref,omitempty"`
|
|
||||||
Repo *Repository `json:"repository,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w WebHookPayload) String() string {
|
|
||||||
return Stringify(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebHookCommit represents the commit variant we receive from GitHub in a
|
|
||||||
// WebHookPayload.
|
|
||||||
type WebHookCommit struct {
|
|
||||||
Added []string `json:"added,omitempty"`
|
|
||||||
Author *WebHookAuthor `json:"author,omitempty"`
|
|
||||||
Committer *WebHookAuthor `json:"committer,omitempty"`
|
|
||||||
Distinct *bool `json:"distinct,omitempty"`
|
|
||||||
ID *string `json:"id,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
Modified []string `json:"modified,omitempty"`
|
|
||||||
Removed []string `json:"removed,omitempty"`
|
|
||||||
Timestamp *time.Time `json:"timestamp,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w WebHookCommit) String() string {
|
|
||||||
return Stringify(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebHookAuthor represents the author or committer of a commit, as specified
|
|
||||||
// in a WebHookCommit. The commit author may not correspond to a GitHub User.
|
|
||||||
type WebHookAuthor struct {
|
|
||||||
Email *string `json:"email,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Username *string `json:"username,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w WebHookAuthor) String() string {
|
|
||||||
return Stringify(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook represents a GitHub (web and service) hook for a repository.
|
|
||||||
type Hook struct {
|
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Events []string `json:"events,omitempty"`
|
|
||||||
Active *bool `json:"active,omitempty"`
|
|
||||||
Config map[string]interface{} `json:"config,omitempty"`
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h Hook) String() string {
|
|
||||||
return Stringify(h)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateHook creates a Hook for the specified repository.
|
|
||||||
// Name and Config are required fields.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#create-a-hook
|
|
||||||
func (s *RepositoriesService) CreateHook(owner, repo string, hook *Hook) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("POST", u, hook)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
h := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, h)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return h, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListHooks lists all Hooks for the specified repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#list
|
|
||||||
func (s *RepositoriesService) ListHooks(owner, repo string, opt *ListOptions) ([]Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
hooks := new([]Hook)
|
|
||||||
resp, err := s.client.Do(req, hooks)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *hooks, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHook returns a single specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#get-single-hook
|
|
||||||
func (s *RepositoriesService) GetHook(owner, repo string, id int) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
hook := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, hook)
|
|
||||||
return hook, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditHook updates a specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#edit-a-hook
|
|
||||||
func (s *RepositoriesService) EditHook(owner, repo string, id int, hook *Hook) (*Hook, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, hook)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
h := new(Hook)
|
|
||||||
resp, err := s.client.Do(req, h)
|
|
||||||
return h, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteHook deletes a specified Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#delete-a-hook
|
|
||||||
func (s *RepositoriesService) DeleteHook(owner, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PingHook triggers a 'ping' event to be sent to the Hook.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#ping-a-hook
|
|
||||||
func (s *RepositoriesService) PingHook(owner, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d/pings", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("POST", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestHook triggers a test Hook by github.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/hooks/#test-a-push-hook
|
|
||||||
func (s *RepositoriesService) TestHook(owner, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d/tests", owner, repo, id)
|
|
||||||
req, err := s.client.NewRequest("POST", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListServiceHooks is deprecated. Use Client.ListServiceHooks instead.
|
|
||||||
func (s *RepositoriesService) ListServiceHooks() ([]ServiceHook, *Response, error) {
|
|
||||||
return s.client.ListServiceHooks()
|
|
||||||
}
|
|
108
vendor/github.com/google/go-github/github/repos_keys.go
generated
vendored
108
vendor/github.com/google/go-github/github/repos_keys.go
generated
vendored
|
@ -1,108 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// The Key type is defined in users_keys.go
|
|
||||||
|
|
||||||
// ListKeys lists the deploy keys for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/keys/#list
|
|
||||||
func (s *RepositoriesService) ListKeys(owner string, repo string, opt *ListOptions) ([]Key, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/keys", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
keys := new([]Key)
|
|
||||||
resp, err := s.client.Do(req, keys)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *keys, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKey fetches a single deploy key.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/keys/#get
|
|
||||||
func (s *RepositoriesService) GetKey(owner string, repo string, id int) (*Key, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
key := new(Key)
|
|
||||||
resp, err := s.client.Do(req, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return key, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateKey adds a deploy key for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/keys/#create
|
|
||||||
func (s *RepositoriesService) CreateKey(owner string, repo string, key *Key) (*Key, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/keys", owner, repo)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
k := new(Key)
|
|
||||||
resp, err := s.client.Do(req, k)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return k, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditKey edits a deploy key.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/keys/#edit
|
|
||||||
func (s *RepositoriesService) EditKey(owner string, repo string, id int, key *Key) (*Key, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
k := new(Key)
|
|
||||||
resp, err := s.client.Do(req, k)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return k, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteKey deletes a deploy key.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/keys/#delete
|
|
||||||
func (s *RepositoriesService) DeleteKey(owner string, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
90
vendor/github.com/google/go-github/github/repos_pages.go
generated
vendored
90
vendor/github.com/google/go-github/github/repos_pages.go
generated
vendored
|
@ -1,90 +0,0 @@
|
||||||
// Copyright 2014 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Pages represents a GitHub Pages site configuration.
|
|
||||||
type Pages struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Status *string `json:"status,omitempty"`
|
|
||||||
CNAME *string `json:"cname,omitempty"`
|
|
||||||
Custom404 *bool `json:"custom_404,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PagesError represents a build error for a GitHub Pages site.
|
|
||||||
type PagesError struct {
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PagesBuild represents the build information for a GitHub Pages site.
|
|
||||||
type PagesBuild struct {
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Status *string `json:"status,omitempty"`
|
|
||||||
Error *PagesError `json:"error,omitempty"`
|
|
||||||
Pusher *User `json:"pusher,omitempty"`
|
|
||||||
Commit *string `json:"commit,omitempty"`
|
|
||||||
Duration *int `json:"duration,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPagesInfo fetches information about a GitHub Pages site.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site
|
|
||||||
func (s *RepositoriesService) GetPagesInfo(owner string, repo string) (*Pages, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pages", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
site := new(Pages)
|
|
||||||
resp, err := s.client.Do(req, site)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return site, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListPagesBuilds lists the builds for a GitHub Pages site.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/pages/#list-pages-builds
|
|
||||||
func (s *RepositoriesService) ListPagesBuilds(owner string, repo string) ([]PagesBuild, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var pages []PagesBuild
|
|
||||||
resp, err := s.client.Do(req, &pages)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return pages, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLatestPagesBuild fetches the latest build information for a GitHub pages site.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/pages/#list-latest-pages-build
|
|
||||||
func (s *RepositoriesService) GetLatestPagesBuild(owner string, repo string) (*PagesBuild, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%v/%v/pages/builds/latest", owner, repo)
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
build := new(PagesBuild)
|
|
||||||
resp, err := s.client.Do(req, build)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return build, resp, err
|
|
||||||
}
|
|
301
vendor/github.com/google/go-github/github/repos_releases.go
generated
vendored
301
vendor/github.com/google/go-github/github/repos_releases.go
generated
vendored
|
@ -1,301 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"mime"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RepositoryRelease represents a GitHub release in a repository.
|
|
||||||
type RepositoryRelease struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
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"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
PublishedAt *Timestamp `json:"published_at,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
AssetsURL *string `json:"assets_url,omitempty"`
|
|
||||||
Assets []ReleaseAsset `json:"assets,omitempty"`
|
|
||||||
UploadURL *string `json:"upload_url,omitempty"`
|
|
||||||
ZipballURL *string `json:"zipball_url,omitempty"`
|
|
||||||
TarballURL *string `json:"tarball_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RepositoryRelease) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReleaseAsset represents a Github release asset in a repository.
|
|
||||||
type ReleaseAsset struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Label *string `json:"label,omitempty"`
|
|
||||||
State *string `json:"state,omitempty"`
|
|
||||||
ContentType *string `json:"content_type,omitempty"`
|
|
||||||
Size *int `json:"size,omitempty"`
|
|
||||||
DownloadCount *int `json:"download_count,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
|
||||||
BrowserDownloadURL *string `json:"browser_download_url,omitempty"`
|
|
||||||
Uploader *User `json:"uploader,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r ReleaseAsset) String() string {
|
|
||||||
return Stringify(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListReleases lists the releases for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
|
|
||||||
func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions) ([]RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases", owner, repo)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
releases := new([]RepositoryRelease)
|
|
||||||
resp, err := s.client.Do(req, releases)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return *releases, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRelease fetches a single release.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/repos/releases/#get-a-single-release
|
|
||||||
func (s *RepositoriesService) GetRelease(owner, repo string, id int) (*RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id)
|
|
||||||
return s.getSingleRelease(u)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLatestRelease fetches the latest published release for the repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/releases/#get-the-latest-release
|
|
||||||
func (s *RepositoriesService) GetLatestRelease(owner, repo string) (*RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/latest", owner, repo)
|
|
||||||
return s.getSingleRelease(u)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetReleaseByTag fetches a release with the specified tag.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
|
|
||||||
func (s *RepositoriesService) GetReleaseByTag(owner, repo, tag string) (*RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/tags/%s", owner, repo, tag)
|
|
||||||
return s.getSingleRelease(u)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *RepositoriesService) getSingleRelease(url string) (*RepositoryRelease, *Response, error) {
|
|
||||||
req, err := s.client.NewRequest("GET", url, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
release := new(RepositoryRelease)
|
|
||||||
resp, err := s.client.Do(req, release)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return release, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateRelease adds a new release for a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#create-a-release
|
|
||||||
func (s *RepositoriesService) CreateRelease(owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases", owner, repo)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, release)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r := new(RepositoryRelease)
|
|
||||||
resp, err := s.client.Do(req, r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return r, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditRelease edits a repository release.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#edit-a-release
|
|
||||||
func (s *RepositoriesService) EditRelease(owner, repo string, id int, release *RepositoryRelease) (*RepositoryRelease, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, release)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r := new(RepositoryRelease)
|
|
||||||
resp, err := s.client.Do(req, r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return r, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteRelease delete a single release from a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#delete-a-release
|
|
||||||
func (s *RepositoriesService) DeleteRelease(owner, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListReleaseAssets lists the release's assets.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#list-assets-for-a-release
|
|
||||||
func (s *RepositoriesService) ListReleaseAssets(owner, repo string, id int, opt *ListOptions) ([]ReleaseAsset, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
assets := new([]ReleaseAsset)
|
|
||||||
resp, err := s.client.Do(req, assets)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, nil
|
|
||||||
}
|
|
||||||
return *assets, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetReleaseAsset fetches a single release asset.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#get-a-single-release-asset
|
|
||||||
func (s *RepositoriesService) GetReleaseAsset(owner, repo string, id int) (*ReleaseAsset, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
asset := new(ReleaseAsset)
|
|
||||||
resp, err := s.client.Do(req, asset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, nil
|
|
||||||
}
|
|
||||||
return asset, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DownloadReleaseAsset downloads a release asset.
|
|
||||||
//
|
|
||||||
// DownloadReleaseAsset returns an io.ReadCloser that reads the contents of the
|
|
||||||
// specified release asset. It is the caller's responsibility to close the ReadCloser.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#get-a-single-release-asset
|
|
||||||
func (s *RepositoriesService) DownloadReleaseAsset(owner, repo string, id int) (io.ReadCloser, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req.Header.Set("Accept", defaultMediaType)
|
|
||||||
|
|
||||||
resp, err := s.client.client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.Body, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditReleaseAsset edits a repository release asset.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#edit-a-release-asset
|
|
||||||
func (s *RepositoriesService) EditReleaseAsset(owner, repo string, id int, release *ReleaseAsset) (*ReleaseAsset, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, release)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
asset := new(ReleaseAsset)
|
|
||||||
resp, err := s.client.Do(req, asset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return asset, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteReleaseAsset delete a single release asset from a repository.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#delete-a-release-asset
|
|
||||||
func (s *RepositoriesService) DeleteReleaseAsset(owner, repo string, id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UploadReleaseAsset creates an asset by uploading a file into a release repository.
|
|
||||||
// To upload assets that cannot be represented by an os.File, call NewUploadRequest directly.
|
|
||||||
//
|
|
||||||
// GitHub API docs : http://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
|
||||||
func (s *RepositoriesService) UploadReleaseAsset(owner, repo string, id int, opt *UploadOptions, file *os.File) (*ReleaseAsset, *Response, error) {
|
|
||||||
u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id)
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
stat, err := file.Stat()
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
if stat.IsDir() {
|
|
||||||
return nil, nil, errors.New("the asset to upload can't be a directory")
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaType := mime.TypeByExtension(filepath.Ext(file.Name()))
|
|
||||||
req, err := s.client.NewUploadRequest(u, file, stat.Size(), mediaType)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
asset := new(ReleaseAsset)
|
|
||||||
resp, err := s.client.Do(req, asset)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
return asset, resp, err
|
|
||||||
}
|
|
158
vendor/github.com/google/go-github/github/search.go
generated
vendored
158
vendor/github.com/google/go-github/github/search.go
generated
vendored
|
@ -1,158 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
qs "github.com/google/go-querystring/query"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SearchService provides access to the search related functions
|
|
||||||
// in the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/search/
|
|
||||||
type SearchService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// SearchOptions specifies optional parameters to the SearchService methods.
|
|
||||||
type SearchOptions struct {
|
|
||||||
// How to sort the search results. Possible values are:
|
|
||||||
// - for repositories: stars, fork, updated
|
|
||||||
// - for code: indexed
|
|
||||||
// - for issues: comments, created, updated
|
|
||||||
// - for users: followers, repositories, joined
|
|
||||||
//
|
|
||||||
// Default is to sort by best match.
|
|
||||||
Sort string `url:"sort,omitempty"`
|
|
||||||
|
|
||||||
// Sort order if sort parameter is provided. Possible values are: asc,
|
|
||||||
// desc. Default is desc.
|
|
||||||
Order string `url:"order,omitempty"`
|
|
||||||
|
|
||||||
// Whether to retrieve text match metadata with a query
|
|
||||||
TextMatch bool `url:"-"`
|
|
||||||
|
|
||||||
ListOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// RepositoriesSearchResult represents the result of a repositories search.
|
|
||||||
type RepositoriesSearchResult struct {
|
|
||||||
Total *int `json:"total_count,omitempty"`
|
|
||||||
Repositories []Repository `json:"items,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repositories searches repositories via various criteria.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/search/#search-repositories
|
|
||||||
func (s *SearchService) Repositories(query string, opt *SearchOptions) (*RepositoriesSearchResult, *Response, error) {
|
|
||||||
result := new(RepositoriesSearchResult)
|
|
||||||
resp, err := s.search("repositories", query, opt, result)
|
|
||||||
return result, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IssuesSearchResult represents the result of an issues search.
|
|
||||||
type IssuesSearchResult struct {
|
|
||||||
Total *int `json:"total_count,omitempty"`
|
|
||||||
Issues []Issue `json:"items,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Issues searches issues via various criteria.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/search/#search-issues
|
|
||||||
func (s *SearchService) Issues(query string, opt *SearchOptions) (*IssuesSearchResult, *Response, error) {
|
|
||||||
result := new(IssuesSearchResult)
|
|
||||||
resp, err := s.search("issues", query, opt, result)
|
|
||||||
return result, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UsersSearchResult represents the result of an issues search.
|
|
||||||
type UsersSearchResult struct {
|
|
||||||
Total *int `json:"total_count,omitempty"`
|
|
||||||
Users []User `json:"items,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Users searches users via various criteria.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/search/#search-users
|
|
||||||
func (s *SearchService) Users(query string, opt *SearchOptions) (*UsersSearchResult, *Response, error) {
|
|
||||||
result := new(UsersSearchResult)
|
|
||||||
resp, err := s.search("users", query, opt, result)
|
|
||||||
return result, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match represents a single text match.
|
|
||||||
type Match struct {
|
|
||||||
Text *string `json:"text,omitempty"`
|
|
||||||
Indices []int `json:"indices,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TextMatch represents a text match for a SearchResult
|
|
||||||
type TextMatch struct {
|
|
||||||
ObjectURL *string `json:"object_url,omitempty"`
|
|
||||||
ObjectType *string `json:"object_type,omitempty"`
|
|
||||||
Property *string `json:"property,omitempty"`
|
|
||||||
Fragment *string `json:"fragment,omitempty"`
|
|
||||||
Matches []Match `json:"matches,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tm TextMatch) String() string {
|
|
||||||
return Stringify(tm)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CodeSearchResult represents the result of an code search.
|
|
||||||
type CodeSearchResult struct {
|
|
||||||
Total *int `json:"total_count,omitempty"`
|
|
||||||
CodeResults []CodeResult `json:"items,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CodeResult represents a single search result.
|
|
||||||
type CodeResult struct {
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Path *string `json:"path,omitempty"`
|
|
||||||
SHA *string `json:"sha,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
Repository *Repository `json:"repository,omitempty"`
|
|
||||||
TextMatches []TextMatch `json:"text_matches,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CodeResult) String() string {
|
|
||||||
return Stringify(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code searches code via various criteria.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/search/#search-code
|
|
||||||
func (s *SearchService) Code(query string, opt *SearchOptions) (*CodeSearchResult, *Response, error) {
|
|
||||||
result := new(CodeSearchResult)
|
|
||||||
resp, err := s.search("code", query, opt, result)
|
|
||||||
return result, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function that executes search queries against different
|
|
||||||
// GitHub search types (repositories, code, issues, users)
|
|
||||||
func (s *SearchService) search(searchType string, query string, opt *SearchOptions, result interface{}) (*Response, error) {
|
|
||||||
params, err := qs.Values(opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
params.Add("q", query)
|
|
||||||
u := fmt.Sprintf("search/%s?%s", searchType, params.Encode())
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt.TextMatch {
|
|
||||||
// Accept header defaults to "application/vnd.github.v3+json"
|
|
||||||
// We change it here to fetch back text-match metadata
|
|
||||||
req.Header.Set("Accept", "application/vnd.github.v3.text-match+json")
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, result)
|
|
||||||
}
|
|
144
vendor/github.com/google/go-github/github/users.go
generated
vendored
144
vendor/github.com/google/go-github/github/users.go
generated
vendored
|
@ -1,144 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// UsersService handles communication with the user related
|
|
||||||
// methods of the GitHub API.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/
|
|
||||||
type UsersService struct {
|
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// User represents a GitHub user.
|
|
||||||
type User struct {
|
|
||||||
Login *string `json:"login,omitempty"`
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
AvatarURL *string `json:"avatar_url,omitempty"`
|
|
||||||
HTMLURL *string `json:"html_url,omitempty"`
|
|
||||||
GravatarID *string `json:"gravatar_id,omitempty"`
|
|
||||||
Name *string `json:"name,omitempty"`
|
|
||||||
Company *string `json:"company,omitempty"`
|
|
||||||
Blog *string `json:"blog,omitempty"`
|
|
||||||
Location *string `json:"location,omitempty"`
|
|
||||||
Email *string `json:"email,omitempty"`
|
|
||||||
Hireable *bool `json:"hireable,omitempty"`
|
|
||||||
Bio *string `json:"bio,omitempty"`
|
|
||||||
PublicRepos *int `json:"public_repos,omitempty"`
|
|
||||||
PublicGists *int `json:"public_gists,omitempty"`
|
|
||||||
Followers *int `json:"followers,omitempty"`
|
|
||||||
Following *int `json:"following,omitempty"`
|
|
||||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
SiteAdmin *bool `json:"site_admin,omitempty"`
|
|
||||||
TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
|
|
||||||
OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
|
|
||||||
PrivateGists *int `json:"private_gists,omitempty"`
|
|
||||||
DiskUsage *int `json:"disk_usage,omitempty"`
|
|
||||||
Collaborators *int `json:"collaborators,omitempty"`
|
|
||||||
Plan *Plan `json:"plan,omitempty"`
|
|
||||||
|
|
||||||
// API URLs
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
EventsURL *string `json:"events_url,omitempty"`
|
|
||||||
FollowingURL *string `json:"following_url,omitempty"`
|
|
||||||
FollowersURL *string `json:"followers_url,omitempty"`
|
|
||||||
GistsURL *string `json:"gists_url,omitempty"`
|
|
||||||
OrganizationsURL *string `json:"organizations_url,omitempty"`
|
|
||||||
ReceivedEventsURL *string `json:"received_events_url,omitempty"`
|
|
||||||
ReposURL *string `json:"repos_url,omitempty"`
|
|
||||||
StarredURL *string `json:"starred_url,omitempty"`
|
|
||||||
SubscriptionsURL *string `json:"subscriptions_url,omitempty"`
|
|
||||||
|
|
||||||
// TextMatches is only populated from search results that request text matches
|
|
||||||
// See: search.go and https://developer.github.com/v3/search/#text-match-metadata
|
|
||||||
TextMatches []TextMatch `json:"text_matches,omitempty"`
|
|
||||||
|
|
||||||
// Permissions identifies the permissions that a user has on a given
|
|
||||||
// repository. This is only populated when calling Repositories.ListCollaborators.
|
|
||||||
Permissions *map[string]bool `json:"permissions,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u User) String() string {
|
|
||||||
return Stringify(u)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get fetches a user. Passing the empty string will fetch the authenticated
|
|
||||||
// user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/#get-a-single-user
|
|
||||||
func (s *UsersService) Get(user string) (*User, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v", user)
|
|
||||||
} else {
|
|
||||||
u = "user"
|
|
||||||
}
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
uResp := new(User)
|
|
||||||
resp, err := s.client.Do(req, uResp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return uResp, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/#update-the-authenticated-user
|
|
||||||
func (s *UsersService) Edit(user *User) (*User, *Response, error) {
|
|
||||||
u := "user"
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, user)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
uResp := new(User)
|
|
||||||
resp, err := s.client.Do(req, uResp)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return uResp, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserListOptions specifies optional parameters to the UsersService.ListAll
|
|
||||||
// method.
|
|
||||||
type UserListOptions struct {
|
|
||||||
// ID of the last user seen
|
|
||||||
Since int `url:"since,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListAll lists all GitHub users.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/#get-all-users
|
|
||||||
func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) {
|
|
||||||
u, err := addOptions("users", opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
users := new([]User)
|
|
||||||
resp, err := s.client.Do(req, users)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *users, resp, err
|
|
||||||
}
|
|
64
vendor/github.com/google/go-github/github/users_administration.go
generated
vendored
64
vendor/github.com/google/go-github/github/users_administration.go
generated
vendored
|
@ -1,64 +0,0 @@
|
||||||
// Copyright 2014 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// PromoteSiteAdmin promotes a user to a site administrator of a GitHub Enterprise instance.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/users/administration/#promote-an-ordinary-user-to-a-site-administrator
|
|
||||||
func (s *UsersService) PromoteSiteAdmin(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("users/%v/site_admin", user)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DemoteSiteAdmin demotes a user from site administrator of a GitHub Enterprise instance.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/users/administration/#demote-a-site-administrator-to-an-ordinary-user
|
|
||||||
func (s *UsersService) DemoteSiteAdmin(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("users/%v/site_admin", user)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Suspend a user on a GitHub Enterprise instance.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/users/administration/#suspend-a-user
|
|
||||||
func (s *UsersService) Suspend(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("users/%v/suspended", user)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unsuspend a user on a GitHub Enterprise instance.
|
|
||||||
//
|
|
||||||
// GitHub API docs: https://developer.github.com/v3/users/administration/#unsuspend-a-user
|
|
||||||
func (s *UsersService) Unsuspend(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("users/%v/suspended", user)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
69
vendor/github.com/google/go-github/github/users_emails.go
generated
vendored
69
vendor/github.com/google/go-github/github/users_emails.go
generated
vendored
|
@ -1,69 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
// UserEmail represents user's email address
|
|
||||||
type UserEmail struct {
|
|
||||||
Email *string `json:"email,omitempty"`
|
|
||||||
Primary *bool `json:"primary,omitempty"`
|
|
||||||
Verified *bool `json:"verified,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListEmails lists all email addresses for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
|
|
||||||
func (s *UsersService) ListEmails(opt *ListOptions) ([]UserEmail, *Response, error) {
|
|
||||||
u := "user/emails"
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
emails := new([]UserEmail)
|
|
||||||
resp, err := s.client.Do(req, emails)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *emails, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddEmails adds email addresses of the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/emails/#add-email-addresses
|
|
||||||
func (s *UsersService) AddEmails(emails []string) ([]UserEmail, *Response, error) {
|
|
||||||
u := "user/emails"
|
|
||||||
req, err := s.client.NewRequest("POST", u, emails)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
e := new([]UserEmail)
|
|
||||||
resp, err := s.client.Do(req, e)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *e, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteEmails deletes email addresses from authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/emails/#delete-email-addresses
|
|
||||||
func (s *UsersService) DeleteEmails(emails []string) (*Response, error) {
|
|
||||||
u := "user/emails"
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, emails)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
116
vendor/github.com/google/go-github/github/users_followers.go
generated
vendored
116
vendor/github.com/google/go-github/github/users_followers.go
generated
vendored
|
@ -1,116 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// ListFollowers lists the followers for a user. Passing the empty string will
|
|
||||||
// fetch followers for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/followers/#list-followers-of-a-user
|
|
||||||
func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]User, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/followers", user)
|
|
||||||
} else {
|
|
||||||
u = "user/followers"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
users := new([]User)
|
|
||||||
resp, err := s.client.Do(req, users)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *users, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListFollowing lists the people that a user is following. Passing the empty
|
|
||||||
// string will list people the authenticated user is following.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
|
|
||||||
func (s *UsersService) ListFollowing(user string, opt *ListOptions) ([]User, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/following", user)
|
|
||||||
} else {
|
|
||||||
u = "user/following"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
users := new([]User)
|
|
||||||
resp, err := s.client.Do(req, users)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *users, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsFollowing checks if "user" is following "target". Passing the empty
|
|
||||||
// string for "user" will check if the authenticated user is following "target".
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user
|
|
||||||
func (s *UsersService) IsFollowing(user, target string) (bool, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/following/%v", user, target)
|
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("user/following/%v", target)
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := s.client.Do(req, nil)
|
|
||||||
following, err := parseBoolResponse(err)
|
|
||||||
return following, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Follow will cause the authenticated user to follow the specified user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/followers/#follow-a-user
|
|
||||||
func (s *UsersService) Follow(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("user/following/%v", user)
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unfollow will cause the authenticated user to unfollow the specified user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/followers/#unfollow-a-user
|
|
||||||
func (s *UsersService) Unfollow(user string) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("user/following/%v", user)
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
104
vendor/github.com/google/go-github/github/users_keys.go
generated
vendored
104
vendor/github.com/google/go-github/github/users_keys.go
generated
vendored
|
@ -1,104 +0,0 @@
|
||||||
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package github
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Key represents a public SSH key used to authenticate a user or deploy script.
|
|
||||||
type Key struct {
|
|
||||||
ID *int `json:"id,omitempty"`
|
|
||||||
Key *string `json:"key,omitempty"`
|
|
||||||
URL *string `json:"url,omitempty"`
|
|
||||||
Title *string `json:"title,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k Key) String() string {
|
|
||||||
return Stringify(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListKeys lists the verified public keys for a user. Passing the empty
|
|
||||||
// string will fetch keys for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
|
|
||||||
func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]Key, *Response, error) {
|
|
||||||
var u string
|
|
||||||
if user != "" {
|
|
||||||
u = fmt.Sprintf("users/%v/keys", user)
|
|
||||||
} else {
|
|
||||||
u = "user/keys"
|
|
||||||
}
|
|
||||||
u, err := addOptions(u, opt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
keys := new([]Key)
|
|
||||||
resp, err := s.client.Do(req, keys)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *keys, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKey fetches a single public key.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/keys/#get-a-single-public-key
|
|
||||||
func (s *UsersService) GetKey(id int) (*Key, *Response, error) {
|
|
||||||
u := fmt.Sprintf("user/keys/%v", id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
key := new(Key)
|
|
||||||
resp, err := s.client.Do(req, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return key, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateKey adds a public key for the authenticated user.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/keys/#create-a-public-key
|
|
||||||
func (s *UsersService) CreateKey(key *Key) (*Key, *Response, error) {
|
|
||||||
u := "user/keys"
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("POST", u, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
k := new(Key)
|
|
||||||
resp, err := s.client.Do(req, k)
|
|
||||||
if err != nil {
|
|
||||||
return nil, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return k, resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteKey deletes a public key.
|
|
||||||
//
|
|
||||||
// GitHub API docs: http://developer.github.com/v3/users/keys/#delete-a-public-key
|
|
||||||
func (s *UsersService) DeleteKey(id int) (*Response, error) {
|
|
||||||
u := fmt.Sprintf("user/keys/%v", id)
|
|
||||||
|
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
|
356
vendor/github.com/google/go-github/v39/AUTHORS
generated
vendored
Normal file
356
vendor/github.com/google/go-github/v39/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,356 @@
|
||||||
|
# This is the official list of go-github authors for copyright purposes.
|
||||||
|
#
|
||||||
|
# This does not necessarily list everyone who has contributed code, since in
|
||||||
|
# some cases, their employer may be the copyright holder. To see the full list
|
||||||
|
# of contributors, see the revision history in source control or
|
||||||
|
# https://github.com/google/go-github/graphs/contributors.
|
||||||
|
#
|
||||||
|
# Authors who wish to be recognized in this file should add themselves (or
|
||||||
|
# their employer, as appropriate).
|
||||||
|
|
||||||
|
178inaba <masahiro.furudate@gmail.com>
|
||||||
|
2BFL <imqksl@gmail.com>
|
||||||
|
413x <dedifferentiator@gmail.com>
|
||||||
|
Abhinav Gupta <mail@abhinavg.net>
|
||||||
|
adrienzieba <adrien.zieba@appdirect.com>
|
||||||
|
afdesk <work@afdesk.com>
|
||||||
|
Ahmed Hagy <a.akram93@gmail.com>
|
||||||
|
Aidan Steele <aidan.steele@glassechidna.com.au>
|
||||||
|
Ainsley Chong <ainsley.chong@gmail.com>
|
||||||
|
ajz01 <azdenek@yahoo.com>
|
||||||
|
Akeda Bagus <akeda@x-team.com>
|
||||||
|
Akhil Mohan <akhilerm@gmail.com>
|
||||||
|
Alec Thomas <alec@swapoff.org>
|
||||||
|
Aleks Clark <aleks.clark@gmail.com>
|
||||||
|
Alex Bramley <a.bramley@gmail.com>
|
||||||
|
Alex Orr <Alexorr.CSE@gmail.com>
|
||||||
|
Alex Unger <zyxancf@gmail.com>
|
||||||
|
Alexander Harkness <me@bearbin.net>
|
||||||
|
Alexis Gauthiez <alexis.gauthiez@gmail.com>
|
||||||
|
Ali Farooq <ali.farooq0@pm.me>
|
||||||
|
Allen Sun <shlallen1990@gmail.com>
|
||||||
|
Amey Sakhadeo <me@ameyms.com>
|
||||||
|
Anders Janmyr <anders@janmyr.com>
|
||||||
|
Andreas Garnæs <https://github.com/andreas>
|
||||||
|
Andrew Ryabchun <aryabchun@mail.ua>
|
||||||
|
Andy Grunwald <andygrunwald@gmail.com>
|
||||||
|
Andy Hume <andyhume@gmail.com>
|
||||||
|
Andy Lindeman <andy@lindeman.io>
|
||||||
|
angie pinilla <angelinepinilla@gmail.com>
|
||||||
|
anjanashenoy <anjanashenoy1@gmail.com>
|
||||||
|
Anshuman Bhartiya <anshuman.bhartiya@gmail.com>
|
||||||
|
Antoine <antoine.tu@mail.mcgill.ca>
|
||||||
|
Antoine Pelisse <apelisse@gmail.com>
|
||||||
|
Anton Nguyen <afnguyen85@gmail.com>
|
||||||
|
Anubha Kushwaha <anubha_bt2k14@dtu.ac.in>
|
||||||
|
appilon <apilon@hashicorp.com>
|
||||||
|
aprp <doelaudi@gmail.com>
|
||||||
|
Aravind <aravindkp@outlook.in>
|
||||||
|
Arda Kuyumcu <kuyumcuarda@gmail.com>
|
||||||
|
Arıl Bozoluk <arilbozoluk@hotmail.com>
|
||||||
|
Asier Marruedo <asiermarruedo@gmail.com>
|
||||||
|
Austin Burdine <acburdine@gmail.com>
|
||||||
|
Austin Dizzy <dizzy@wow.com>
|
||||||
|
Azuka Okuleye <azuka@zatechcorp.com>
|
||||||
|
Ben Batha <bhbatha@gmail.com>
|
||||||
|
Benjamen Keroack <benjamen@dollarshaveclub.com>
|
||||||
|
Beshr Kayali <beshrkayali@gmail.com>
|
||||||
|
Beyang Liu <beyang.liu@gmail.com>
|
||||||
|
Billy Keyes <bluekeyes@gmail.com>
|
||||||
|
Billy Lynch <wlynch92@gmail.com>
|
||||||
|
Björn Häuser <b.haeuser@rebuy.de>
|
||||||
|
boljen <bol.christophe@gmail.com>
|
||||||
|
Brad Harris <bmharris@gmail.com>
|
||||||
|
Brad Moylan <moylan.brad@gmail.com>
|
||||||
|
Bradley Falzon <brad@teambrad.net>
|
||||||
|
Bradley McAllister <brad.mcallister@hotmail.com>
|
||||||
|
Brandon Cook <phylake@gmail.com>
|
||||||
|
Brett Logan <lindluni@github.com>
|
||||||
|
Brian Egizi <brian@mojotech.com>
|
||||||
|
Bryan Boreham <bryan@weave.works>
|
||||||
|
Cami Diez <diezcami@gmail.com>
|
||||||
|
Carl Johnson <me@carlmjohnson.net>
|
||||||
|
Carlos Alexandro Becker <caarlos0@gmail.com>
|
||||||
|
Carlos Tadeu Panato Junior <ctadeu@gmail.com>
|
||||||
|
chandresh-pancholi <chandreshpancholi007@gmail.com>
|
||||||
|
Charles Fenwick Elliott <Charles@FenwickElliott.io>
|
||||||
|
Charlie Yan <charlieyan08@gmail.com>
|
||||||
|
Chmouel Boudjnah <chmouel@chmouel.com>
|
||||||
|
Chris King <chriskingnet@gmail.com>
|
||||||
|
Chris Mc <prince.chrismc@gmail.com>
|
||||||
|
Chris Raborg <craborg57@gmail.com>
|
||||||
|
Chris Roche <chris@vsco.co>
|
||||||
|
Chris Schaefer <chris@dtzq.com>
|
||||||
|
chrisforrette <chris@chrisforrette.com>
|
||||||
|
Christian Muehlhaeuser <muesli@gmail.com>
|
||||||
|
Christoph Sassenberg <defsprite@gmail.com>
|
||||||
|
Colin Misare <github.com/cmisare>
|
||||||
|
Craig Peterson <cpeterson@stackoverflow.com>
|
||||||
|
Cristian Maglie <c.maglie@bug.st>
|
||||||
|
Daehyeok Mun <daehyeok@gmail.com>
|
||||||
|
Daniel Lanner <lanner.dan@gmail.com>
|
||||||
|
Daniel Leavitt <daniel.leavitt@gmail.com>
|
||||||
|
Daniel Nilsson <daniel.nilsson1989@gmail.com>
|
||||||
|
Daoq <masseto2002@gmail.com>
|
||||||
|
Dave Du Cros <davidducros@gmail.com>
|
||||||
|
Dave Henderson <dhenderson@gmail.com>
|
||||||
|
Dave Perrett <hello@daveperrett.com>
|
||||||
|
Dave Protasowski <dprotaso@gmail.com>
|
||||||
|
David Deng <daviddengcn@gmail.com>
|
||||||
|
David J. M. Karlsen <david@davidkarlsen.com>
|
||||||
|
David Jannotta <djannotta@gmail.com>
|
||||||
|
David Ji <github.com/davidji99>
|
||||||
|
David Lopez Reyes <davidlopezre@gmail.com>
|
||||||
|
Davide Zipeto <dawez1@gmail.com>
|
||||||
|
Dennis Webb <dennis@bluesentryit.com>
|
||||||
|
Derek Jobst <derekjobst@gmail.com>
|
||||||
|
Dhi Aurrahman <diorahman@rockybars.com>
|
||||||
|
Diego Lapiduz <diego.lapiduz@cfpb.gov>
|
||||||
|
Dmitri Shuralyov <shurcooL@gmail.com>
|
||||||
|
dmnlk <seikima2demon@gmail.com>
|
||||||
|
Don Petersen <don@donpetersen.net>
|
||||||
|
Doug Turner <doug.turner@gmail.com>
|
||||||
|
Drew Fradette <drew.fradette@gmail.com>
|
||||||
|
Dustin Deus <deusdustin@gmail.com>
|
||||||
|
Eivind <eivindkn@gmail.com>
|
||||||
|
Eli Uriegas <seemethere101@gmail.com>
|
||||||
|
Elliott Beach <elliott2.71828@gmail.com>
|
||||||
|
Emerson Wood <emersonwood94@gmail.com>
|
||||||
|
eperm <staffordworrell@gmail.com>
|
||||||
|
Erick Fejta <erick@fejta.com>
|
||||||
|
Erik Nobel <hendrik.nobel@transferwise.com>
|
||||||
|
erwinvaneyk <erwinvaneyk@gmail.com>
|
||||||
|
Evan Elias <evanjelias@gmail.com>
|
||||||
|
Fabian Holler <fabian.holler@simplesurance.de>
|
||||||
|
Fabrice <fabrice.vaillant@student.ecp.fr>
|
||||||
|
Felix Geisendörfer <felix@debuggable.com>
|
||||||
|
Filippo Valsorda <hi@filippo.io>
|
||||||
|
Florian Forster <ff@octo.it>
|
||||||
|
Francesc Gil <xescugil@gmail.com>
|
||||||
|
Francis <hello@francismakes.com>
|
||||||
|
Francisco Guimarães <francisco.cpg@gmail.com>
|
||||||
|
Fredrik Jönsson <fredrik.jonsson@izettle.com>
|
||||||
|
Garrett Squire <garrettsquire@gmail.com>
|
||||||
|
George Kontridze <george.kontridze@gmail.com>
|
||||||
|
Georgy Buranov <gburanov@gmail.com>
|
||||||
|
Glen Mailer <glenjamin@gmail.com>
|
||||||
|
Gnahz <p@oath.pl>
|
||||||
|
Google Inc.
|
||||||
|
Grachev Mikhail <work@mgrachev.com>
|
||||||
|
griffin_stewie <panterathefamilyguy@gmail.com>
|
||||||
|
Guillaume Jacquet <guillaume.jacquet@gmail.com>
|
||||||
|
Guz Alexander <kalimatas@gmail.com>
|
||||||
|
Guðmundur Bjarni Ólafsson <gudmundur@github.com>
|
||||||
|
Hanno Hecker <hanno.hecker@zalando.de>
|
||||||
|
Hari haran <hariharan.uno@gmail.com>
|
||||||
|
haya14busa <haya14busa@gmail.com>
|
||||||
|
haya14busa <hayabusa1419@gmail.com>
|
||||||
|
Huy Tr <kingbazoka@gmail.com>
|
||||||
|
huydx <doxuanhuy@gmail.com>
|
||||||
|
i2bskn <i2bskn@gmail.com>
|
||||||
|
Ikko Ashimine <eltociear@gmail.com>
|
||||||
|
Ioannis Georgoulas <igeorgoulas21@gmail.com>
|
||||||
|
Isao Jonas <isao.jonas@gmail.com>
|
||||||
|
ishan upadhyay <ishanupadhyay412@gmail.com>
|
||||||
|
isqua <isqua@isqua.ru>
|
||||||
|
Jacob Valdemar <jan@lunar.app>
|
||||||
|
Jake Krammer <jake.krammer1@gmail.com>
|
||||||
|
Jameel Haffejee <RC1140@republiccommandos.co.za>
|
||||||
|
James Cockbain <james.cockbain@ibm.com>
|
||||||
|
James Loh <github@jloh.co>
|
||||||
|
Jan Kosecki <jan.kosecki91@gmail.com>
|
||||||
|
Jan Švábík <jansvabik@jansvabik.cz>
|
||||||
|
Javier Campanini <jcampanini@palantir.com>
|
||||||
|
Jef LeCompte <jeffreylec@gmail.com>
|
||||||
|
Jens Rantil <jens.rantil@gmail.com>
|
||||||
|
Jeremy Morris <jeremylevanmorris@gmail.com>
|
||||||
|
Jesse Haka <haka.jesse@gmail.com>
|
||||||
|
Jesse Newland <jesse@jnewland.com>
|
||||||
|
Jihoon Chung <j.c@navercorp.com>
|
||||||
|
Jimmi Dyson <jimmidyson@gmail.com>
|
||||||
|
Joan Saum <joan.saum@epitech.eu>
|
||||||
|
Joe Tsai <joetsai@digital-static.net>
|
||||||
|
John Barton <jrbarton@gmail.com>
|
||||||
|
John Engelman <john.r.engelman@gmail.com>
|
||||||
|
John Liu <john.liu@mongodb.com>
|
||||||
|
Jordan Brockopp <jdbro94@gmail.com>
|
||||||
|
Jordan Sussman <jordansail22@gmail.com>
|
||||||
|
Joshua Bezaleel Abednego <joshua.bezaleel@gmail.com>
|
||||||
|
JP Phillips <jonphill9@gmail.com>
|
||||||
|
jpbelanger-mtl <jp.belanger@gmail.com>
|
||||||
|
Juan <juan.rios.28@gmail.com>
|
||||||
|
Juan Basso <jrbasso@gmail.com>
|
||||||
|
Julien Garcia Gonzalez <garciagonzalez.julien@gmail.com>
|
||||||
|
Julien Rostand <jrostand@users.noreply.github.com>
|
||||||
|
Junya Kono <junya03dance@gmail.com>
|
||||||
|
Justin Abrahms <justin@abrah.ms>
|
||||||
|
Jusung Lee <e.jusunglee@gmail.com>
|
||||||
|
jzhoucliqr <jzhou@cliqr.com>
|
||||||
|
kadern0 <kaderno@gmail.com>
|
||||||
|
Katrina Owen <kytrinyx@github.com>
|
||||||
|
Kautilya Tripathi <tripathi.kautilya@gmail.com>
|
||||||
|
Keita Urashima <ursm@ursm.jp>
|
||||||
|
Kevin Burke <kev@inburke.com>
|
||||||
|
Kirill <g4s8.public@gmail.com>
|
||||||
|
Konrad Malawski <konrad.malawski@project13.pl>
|
||||||
|
Kookheon Kwon <kucuny@gmail.com>
|
||||||
|
Krzysztof Kowalczyk <kkowalczyk@gmail.com>
|
||||||
|
Kshitij Saraogi <KshitijSaraogi@gmail.com>
|
||||||
|
Kumar Saurabh <itsksaurabh@gmail.com>
|
||||||
|
kyokomi <kyoko1220adword@gmail.com>
|
||||||
|
Laurent Verdoïa <verdoialaurent@gmail.com>
|
||||||
|
Liam Galvin <liam@liam-galvin.co.uk>
|
||||||
|
Lovro Mažgon <lovro.mazgon@gmail.com>
|
||||||
|
Luca Campese <me@campesel.net>
|
||||||
|
Lucas Alcantara <lucasalcantaraf@gmail.com>
|
||||||
|
Luke Evers <me@lukevers.com>
|
||||||
|
Luke Kysow <lkysow@gmail.com>
|
||||||
|
Luke Roberts <email@luke-roberts.co.uk>
|
||||||
|
Luke Young <luke@hydrantlabs.org>
|
||||||
|
lynn [they] <lynncyrin@gmail.com>
|
||||||
|
Maksim Zhylinski <uzzable@gmail.com>
|
||||||
|
Marc Binder <marcandrebinder@gmail.com>
|
||||||
|
Marcelo Carlos <marcelo@permutive.com>
|
||||||
|
Mark Tareshawty <tarebyte@github.com>
|
||||||
|
Martin Holman <me@martinholman.co.nz>
|
||||||
|
Martin-Louis Bright <mlbright@gmail.com>
|
||||||
|
Martins Sipenko <martins.sipenko@gmail.com>
|
||||||
|
Marwan Sulaiman <marwan.sameer@gmail.com>
|
||||||
|
Masayuki Izumi <m@izum.in>
|
||||||
|
Mat Geist <matgeist@gmail.com>
|
||||||
|
Matin Rahmanian <itsmatinx@gmail.com>
|
||||||
|
Matt <alpmatthew@gmail.com>
|
||||||
|
Matt Brender <mjbrender@gmail.com>
|
||||||
|
Matt Gaunt <matt@gauntface.co.uk>
|
||||||
|
Matt Landis <landis.matt@gmail.com>
|
||||||
|
Matt Moore <mattmoor@vmware.com>
|
||||||
|
Maxime Bury <maxime.bury@gmail.com>
|
||||||
|
Michael Spiegel <michael.m.spiegel@gmail.com>
|
||||||
|
Michael Tiller <michael.tiller@gmail.com>
|
||||||
|
Michał Glapa <michal.glapa@gmail.com>
|
||||||
|
Michelangelo Morrillo <michelangelo@morrillo.it>
|
||||||
|
Mukundan Senthil <mukundan314@gmail.com>
|
||||||
|
Munia Balayil <munia.247@gmail.com>
|
||||||
|
Nadav Kaner <nadavkaner1@gmail.com>
|
||||||
|
Nathan VanBenschoten <nvanbenschoten@gmail.com>
|
||||||
|
Navaneeth Suresh <navaneeths1998@gmail.com>
|
||||||
|
Neil O'Toole <neilotoole@apache.org>
|
||||||
|
Nick Miyake <nmiyake@palantir.com>
|
||||||
|
Nick Platt <hello@nickplatt.co.uk>
|
||||||
|
Nick Spragg <nick.spragg@bbc.co.uk>
|
||||||
|
Nikhita Raghunath <nikitaraghunath@gmail.com>
|
||||||
|
Nilesh Singh <nilesh.singh24@outlook.com>
|
||||||
|
Noah Zoschke <noah+sso2@convox.com>
|
||||||
|
ns-cweber <cweber@narrativescience.com>
|
||||||
|
Ole Orhagen <ole.orhagen@northern.tech>
|
||||||
|
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||||
|
Ondřej Kupka <ondra.cap@gmail.com>
|
||||||
|
Ori Talmor <talmorori@gmail.com>
|
||||||
|
Pablo Pérez Schröder <pablo.perezschroder@wetransfer.com>
|
||||||
|
Palash Nigam <npalash25@gmail.com>
|
||||||
|
Panagiotis Moustafellos <pmoust@gmail.com>
|
||||||
|
Parham Alvani <parham.alvani@gmail.com>
|
||||||
|
Parker Moore <parkrmoore@gmail.com>
|
||||||
|
parkhyukjun89 <park.hyukjun89@gmail.com>
|
||||||
|
Patrick DeVivo <patrick.devivo@gmail.com>
|
||||||
|
Patrick Marabeas <patrick@marabeas.io>
|
||||||
|
Pavel Shtanko <pavel.shtanko@gmail.com>
|
||||||
|
Pete Wagner <thepwagner@github.com>
|
||||||
|
Petr Shevtsov <petr.shevtsov@gmail.com>
|
||||||
|
Pierre Carrier <pierre@meteor.com>
|
||||||
|
Piotr Zurek <p.zurek@gmail.com>
|
||||||
|
Piyush Chugh <piyushchugh1993@gmail.com>
|
||||||
|
Pratik Mallya <pratik.mallya@gmail.com>
|
||||||
|
Qais Patankar <qaisjp@gmail.com>
|
||||||
|
Quang Le Hong <iamquang95@gmail.com>
|
||||||
|
Quentin Leffray <fiahil@gmail.com>
|
||||||
|
Quinn Slack <qslack@qslack.com>
|
||||||
|
Rackspace US, Inc.
|
||||||
|
Radek Simko <radek.simko@gmail.com>
|
||||||
|
Radliński Ignacy <radlinsk@student.agh.edu.pl>
|
||||||
|
Rajat Jindal <rajatjindal83@gmail.com>
|
||||||
|
Rajendra arora <rajendraarora16@yahoo.com>
|
||||||
|
Ranbir Singh <binkkatal.r@gmail.com>
|
||||||
|
Ravi Shekhar Jethani <rsjethani@gmail.com>
|
||||||
|
RaviTeja Pothana <ravi-teja@live.com>
|
||||||
|
rc1140 <jameel@republiccommandos.co.za>
|
||||||
|
Red Hat, Inc.
|
||||||
|
Reetuparna Mukherjee <reetuparna.1988@gmail.com>
|
||||||
|
Reinier Timmer <reinier.timmer@ah.nl>
|
||||||
|
Renjith R <renjithr201097@gmail.com>
|
||||||
|
Ricco Førgaard <ricco@fiskeben.dk>
|
||||||
|
Rob Figueiredo <robfig@yext.com>
|
||||||
|
Rohit Upadhyay <urohit011@gmail.com>
|
||||||
|
Ronak Jain <ronakjain@outlook.in>
|
||||||
|
Ross Gustafson <srgustafson8@icloud.com>
|
||||||
|
Ruben Vereecken <rubenvereecken@gmail.com>
|
||||||
|
Russell Boley <raboley@gmail.com>
|
||||||
|
Ryan Leung <rleungx@gmail.com>
|
||||||
|
Ryan Lower <rpjlower@gmail.com>
|
||||||
|
Ryo Nakao <nakabonne@gmail.com>
|
||||||
|
Saaarah <sarah.liusy@gmail.com>
|
||||||
|
Safwan Olaimat <safwan.olaimat@gmail.com>
|
||||||
|
Sahil Dua <sahildua2305@gmail.com>
|
||||||
|
saisi <saisi@users.noreply.github.com>
|
||||||
|
Sam Minnée <sam@silverstripe.com>
|
||||||
|
Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
|
||||||
|
Sander Knape <s.knape88@gmail.com>
|
||||||
|
Sander van Harmelen <svanharmelen@schubergphilis.com>
|
||||||
|
Sanket Payghan <sanket.payghan8@gmail.com>
|
||||||
|
Sarasa Kisaragi <lingsamuelgrace@gmail.com>
|
||||||
|
Sean Wang <sean@decrypted.org>
|
||||||
|
Sebastian Mandrean <sebastian.mandrean@gmail.com>
|
||||||
|
Sebastian Mæland Pedersen <sem.pedersen@stud.uis.no>
|
||||||
|
Sergey Romanov <xxsmotur@gmail.com>
|
||||||
|
Sergio Garcia <sergio.garcia@gmail.com>
|
||||||
|
Seth Vargo <seth@sethvargo.com>
|
||||||
|
Sevki <s@sevki.org>
|
||||||
|
Shagun Khemka <shagun.khemka60@gmail.com>
|
||||||
|
shakeelrao <shakeelrao79@gmail.com>
|
||||||
|
Shawn Catanzarite <me@shawncatz.com>
|
||||||
|
Shawn Smith <shawnpsmith@gmail.com>
|
||||||
|
Shibasis Patel <patelshibasis@gmail.com>
|
||||||
|
Shrikrishna Singh <krishnasingh.ss30@gmail.com>
|
||||||
|
Simon Davis <sdavis@hashicorp.com>
|
||||||
|
sona-tar <sona.zip@gmail.com>
|
||||||
|
SoundCloud, Ltd.
|
||||||
|
Sridhar Mocherla <srmocher@microsoft.com>
|
||||||
|
SriVignessh Pss <sriknowledge@gmail.com>
|
||||||
|
Stefan Sedich <stefan.sedich@gmail.com>
|
||||||
|
Steve Teuber <github@steveteuber.com>
|
||||||
|
Stian Eikeland <stian@eikeland.se>
|
||||||
|
Suhaib Mujahid <suhaibmujahid@gmail.com>
|
||||||
|
Szymon Kodrebski <simonkey007@gmail.com>
|
||||||
|
Søren Hansen <soren@dinero.dk>
|
||||||
|
Takayuki Watanabe <takanabe.w@gmail.com>
|
||||||
|
Taketoshi Fujiwara <fujiwara@leapmind.io>
|
||||||
|
Taketoshi Fujiwara <taketoshi.fujiwara@gmail.com>
|
||||||
|
Tasya Aditya Rukmana <tadityar@gmail.com>
|
||||||
|
Theo Henson <theodorehenson@protonmail.com>
|
||||||
|
Thomas Aidan Curran <thomas@ory.sh>
|
||||||
|
Thomas Bruyelle <thomas.bruyelle@gmail.com>
|
||||||
|
Timothée Peignier <timothee.peignier@tryphon.org>
|
||||||
|
tkhandel <tarunkhandelwal.iitr@gmail.com>
|
||||||
|
Trey Tacon <ttacon@gmail.com>
|
||||||
|
ttacon <ttacon@gmail.com>
|
||||||
|
Vaibhav Singh <vaibhav.singh.14cse@bml.edu.in>
|
||||||
|
Varadarajan Aravamudhan <varadaraajan@gmail.com>
|
||||||
|
Victor Castell <victor@victorcastell.com>
|
||||||
|
Victor Vrantchan <vrancean+github@gmail.com>
|
||||||
|
vikkyomkar <vikky.omkar@samsung.com>
|
||||||
|
Vlad Ungureanu <vladu@palantir.com>
|
||||||
|
Wasim Thabraze <wasim@thabraze.me>
|
||||||
|
Weslei Juan Moser Pereira <wesleimsr@gmail.com>
|
||||||
|
Will Maier <wcmaier@gmail.com>
|
||||||
|
Willem D'Haeseleer <dhwillem@gmail.com>
|
||||||
|
William Bailey <mail@williambailey.org.uk>
|
||||||
|
William Cooke <pipeston@gmail.com>
|
||||||
|
xibz <impactbchang@gmail.com>
|
||||||
|
Yann Malet <yann.malet@gmail.com>
|
||||||
|
Yannick Utard <yannickutard@gmail.com>
|
||||||
|
Yicheng Qin <qycqycqycqycqyc@gmail.com>
|
||||||
|
Yosuke Akatsuka <yosuke.akatsuka@access-company.com>
|
||||||
|
Yumikiyo Osanai <yumios.art@gmail.com>
|
||||||
|
Yusuke Kuoka <ykuoka@gmail.com>
|
||||||
|
Zach Latta <zach@zachlatta.com>
|
||||||
|
zhouhaibing089 <zhouhaibing089@gmail.com>
|
27
vendor/github.com/google/go-github/v39/LICENSE
generated
vendored
Normal file
27
vendor/github.com/google/go-github/v39/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
12
vendor/github.com/google/go-github/v39/github/actions.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v39/github/actions.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// ActionsService handles communication with the actions related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/
|
||||||
|
type ActionsService service
|
164
vendor/github.com/google/go-github/v39/github/actions_artifacts.go
generated
vendored
Normal file
164
vendor/github.com/google/go-github/v39/github/actions_artifacts.go
generated
vendored
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Artifact reprents a GitHub artifact. Artifacts allow sharing
|
||||||
|
// data between jobs in a workflow and provide storage for data
|
||||||
|
// once a workflow is complete.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/artifacts/
|
||||||
|
type Artifact struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
|
||||||
|
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
|
||||||
|
Expired *bool `json:"expired,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ArtifactList represents a list of GitHub artifacts.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/artifacts/
|
||||||
|
type ArtifactList struct {
|
||||||
|
TotalCount *int64 `json:"total_count,omitempty"`
|
||||||
|
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListArtifacts lists all artifacts that belong to a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-artifacts-for-a-repository
|
||||||
|
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactList := new(ArtifactList)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifactList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifactList, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-run-artifacts
|
||||||
|
func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", owner, repo, runID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactList := new(ArtifactList)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifactList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifactList, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArtifact gets a specific artifact for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-artifact
|
||||||
|
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact := new(Artifact)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifact)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifact, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DownloadArtifact gets a redirect URL to download an archive for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/artifacts/#download-an-artifact
|
||||||
|
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID)
|
||||||
|
|
||||||
|
resp, err := s.getDownloadArtifactFromURL(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
return parsedURL, newResponse(resp), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getDownloadArtifactFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp *http.Response
|
||||||
|
// Use http.DefaultTransport if no custom Transport is configured
|
||||||
|
req = withContext(ctx, req)
|
||||||
|
if s.client.client.Transport == nil {
|
||||||
|
resp, err = http.DefaultTransport.RoundTrip(req)
|
||||||
|
} else {
|
||||||
|
resp, err = s.client.client.Transport.RoundTrip(req)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
|
// If redirect response is returned, follow it
|
||||||
|
if followRedirects && resp.StatusCode == http.StatusMovedPermanently {
|
||||||
|
u = resp.Header.Get("Location")
|
||||||
|
resp, err = s.getDownloadArtifactFromURL(ctx, u, false)
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteArtifact deletes a workflow run artifact.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-an-artifact
|
||||||
|
func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
294
vendor/github.com/google/go-github/v39/github/actions_runner_groups.go
generated
vendored
Normal file
294
vendor/github.com/google/go-github/v39/github/actions_runner_groups.go
generated
vendored
Normal file
|
@ -0,0 +1,294 @@
|
||||||
|
// Copyright 2021 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunnerGroup represents a self-hosted runner group configured in an organization.
|
||||||
|
type RunnerGroup struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
Default *bool `json:"default,omitempty"`
|
||||||
|
SelectedRepositoriesURL *string `json:"selected_repositories_url,omitempty"`
|
||||||
|
RunnersURL *string `json:"runners_url,omitempty"`
|
||||||
|
Inherited *bool `json:"inherited,omitempty"`
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunnerGroups represents a collection of self-hosted runner groups configured for an organization.
|
||||||
|
type RunnerGroups struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
RunnerGroups []*RunnerGroup `json:"runner_groups"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRunnerGroupRequest represents a request to create a Runner group for an organization.
|
||||||
|
type CreateRunnerGroupRequest struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
// List of repository IDs that can access the runner group.
|
||||||
|
SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
|
||||||
|
// Runners represent a list of runner IDs to add to the runner group.
|
||||||
|
Runners []int64 `json:"runners,omitempty"`
|
||||||
|
// If set to True, public repos can use this runner group
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRunnerGroupRequest represents a request to update a Runner group for an organization.
|
||||||
|
type UpdateRunnerGroupRequest struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRepoAccessRunnerGroupRequest represents a request to replace the list of repositories
|
||||||
|
// that can access a self-hosted runner group configured in an organization.
|
||||||
|
type SetRepoAccessRunnerGroupRequest struct {
|
||||||
|
// Updated list of repository IDs that should be given access to the runner group.
|
||||||
|
SelectedRepositoryIDs []int64 `json:"selected_repository_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRunnerGroupRunnersRequest represents a request to replace the list of
|
||||||
|
// self-hosted runners that are part of an organization runner group.
|
||||||
|
type SetRunnerGroupRunnersRequest struct {
|
||||||
|
// Updated list of runner IDs that should be given access to the runner group.
|
||||||
|
Runners []int64 `json:"runners"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunnerGroups lists all self-hosted runner groups configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-self-hosted-runner-groups-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOptions) (*RunnerGroups, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
groups := &RunnerGroups{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &groups)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrganizationRunnerGroup deletes a self-hosted runner group from an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-a-self-hosted-runner-group-from-an-organization
|
||||||
|
func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRunnerGroup creates a new self-hosted runner group for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#create-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
|
||||||
|
req, err := s.client.NewRequest("POST", u, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOrganizationRunnerGroup updates a self-hosted runner group for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#update-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org string, groupID int64, updateReq UpdateRunnerGroupRequest) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos := &ListRepositories{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRepositoryAccessRunnerGroup replaces the list of repositories that have access to a self-hosted runner group configured in an organization
|
||||||
|
// with a new List of repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-repository-access-for-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, ids SetRepoAccessRunnerGroupRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRepositoryAccessRunnerGroup adds a repository to the list of selected repositories that can access a self-hosted runner group.
|
||||||
|
// The runner group must have visibility set to 'selected'.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#add-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRepositoryAccessRunnerGroup removes a repository from the list of selected repositories that can access a self-hosted runner group.
|
||||||
|
// The runner group must have visibility set to 'selected'.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-self-hosted-runners-in-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string, groupID int64, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an organization runner group
|
||||||
|
// with a new list of runners.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-self-hosted-runners-in-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization.
|
||||||
|
// The runner is then returned to the default group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) RemoveRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
377
vendor/github.com/google/go-github/v39/github/actions_runners.go
generated
vendored
Normal file
377
vendor/github.com/google/go-github/v39/github/actions_runners.go
generated
vendored
Normal file
|
@ -0,0 +1,377 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunnerApplicationDownload represents a binary for the self-hosted runner application that can be downloaded.
|
||||||
|
type RunnerApplicationDownload struct {
|
||||||
|
OS *string `json:"os,omitempty"`
|
||||||
|
Architecture *string `json:"architecture,omitempty"`
|
||||||
|
DownloadURL *string `json:"download_url,omitempty"`
|
||||||
|
Filename *string `json:"filename,omitempty"`
|
||||||
|
TempDownloadToken *string `json:"temp_download_token,omitempty"`
|
||||||
|
SHA256Checksum *string `json:"sha256_checksum,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActionsEnabledOnOrgRepos represents all the repositories in an organization for which Actions is enabled.
|
||||||
|
type ActionsEnabledOnOrgRepos struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Repositories []*Repository `json:"repositories"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-runner-applications-for-a-repository
|
||||||
|
func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/downloads", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rads []*RunnerApplicationDownload
|
||||||
|
resp, err := s.client.Do(ctx, req, &rads)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rads, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegistrationToken represents a token that can be used to add a self-hosted runner to a repository.
|
||||||
|
type RegistrationToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-registration-token-for-a-repository
|
||||||
|
func (s *ActionsService) CreateRegistrationToken(ctx context.Context, owner, repo string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/registration-token", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runner represents a self-hosted runner registered with a repository.
|
||||||
|
type Runner struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
OS *string `json:"os,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Busy *bool `json:"busy,omitempty"`
|
||||||
|
Labels []*RunnerLabels `json:"labels,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunnerLabels represents a collection of labels attached to each runner.
|
||||||
|
type RunnerLabels struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runners represents a collection of self-hosted runners for a repository.
|
||||||
|
type Runners struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Runners []*Runner `json:"runners"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunners lists all the self-hosted runners for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-self-hosted-runners-for-a-repository
|
||||||
|
func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRunner gets a specific self-hosted runner for a repository using its runner ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-self-hosted-runner-for-a-repository
|
||||||
|
func (s *ActionsService) GetRunner(ctx context.Context, owner, repo string, runnerID int64) (*Runner, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := new(Runner)
|
||||||
|
resp, err := s.client.Do(ctx, req, runner)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runner, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveToken represents a token that can be used to remove a self-hosted runner from a repository.
|
||||||
|
type RemoveToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRemoveToken creates a token that can be used to remove a self-hosted runner from a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-remove-token-for-a-repository
|
||||||
|
func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo string) (*RemoveToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/remove-token", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken := new(RemoveToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, removeToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return removeToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunner forces the removal of a self-hosted runner in a repository using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-self-hosted-runner-from-a-repository
|
||||||
|
func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-runner-applications-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/downloads", owner)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rads []*RunnerApplicationDownload
|
||||||
|
resp, err := s.client.Do(ctx, req, &rads)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rads, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRegistrationToken creates a token that can be used to add a self-hosted runner to an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-registration-token-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/registration-token", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunners lists all the self-hosted runners for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-self-hosted-runners-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners", owner)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEnabledReposInOrg lists the selected repositories that are enabled for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-selected-repositories-enabled-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnOrgRepos, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos := &ActionsEnabledOnOrgRepos{}
|
||||||
|
resp, err := s.client.Do(ctx, req, repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEnabledReposInOrg replaces the list of selected repositories that are enabled for GitHub Actions in an organization..
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-selected-repositories-enabled-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string, repositoryIDs []int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, struct {
|
||||||
|
IDs []int64 `json:"selected_repository_ids"`
|
||||||
|
}{IDs: repositoryIDs})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEnabledReposInOrg adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#enable-a-selected-repository-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveEnabledRepoInOrg removes a single repository from the list of enabled repos for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#disable-a-selected-repository-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) RemoveEnabledRepoInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-self-hosted-runner-for-an-organization
|
||||||
|
func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := new(Runner)
|
||||||
|
resp, err := s.client.Do(ctx, req, runner)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runner, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRemoveToken creates a token that can be used to remove a self-hosted runner from an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-remove-token-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/remove-token", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken := new(RemoveToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, removeToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return removeToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveOrganizationRunner forces the removal of a self-hosted runner from an organization using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-self-hosted-runner-from-an-organization
|
||||||
|
func (s *ActionsService) RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
425
vendor/github.com/google/go-github/v39/github/actions_secrets.go
generated
vendored
Normal file
425
vendor/github.com/google/go-github/v39/github/actions_secrets.go
generated
vendored
Normal file
|
@ -0,0 +1,425 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PublicKey represents the public key that should be used to encrypt secrets.
|
||||||
|
type PublicKey struct {
|
||||||
|
KeyID *string `json:"key_id"`
|
||||||
|
Key *string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||||
|
// This ensures GitHub Enterprise versions which return a numeric key id
|
||||||
|
// do not error out when unmarshaling.
|
||||||
|
func (p *PublicKey) UnmarshalJSON(data []byte) error {
|
||||||
|
var pk struct {
|
||||||
|
KeyID interface{} `json:"key_id,string"`
|
||||||
|
Key *string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := json.Unmarshal(data, &pk); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Key = pk.Key
|
||||||
|
|
||||||
|
switch v := pk.KeyID.(type) {
|
||||||
|
case nil:
|
||||||
|
return nil
|
||||||
|
case string:
|
||||||
|
p.KeyID = &v
|
||||||
|
case float64:
|
||||||
|
p.KeyID = String(strconv.FormatFloat(v, 'f', -1, 64))
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unable to unmarshal %T as a string", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-repository-public-key
|
||||||
|
func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/secrets/public-key", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubKey := new(PublicKey)
|
||||||
|
resp, err := s.client.Do(ctx, req, pubKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubKey, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-organization-public-key
|
||||||
|
func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubKey := new(PublicKey)
|
||||||
|
resp, err := s.client.Do(ctx, req, pubKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubKey, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnvPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-an-environment-public-key
|
||||||
|
func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repositories/%v/environments/%v/secrets/public-key", repoID, env)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubKey := new(PublicKey)
|
||||||
|
resp, err := s.client.Do(ctx, req, pubKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubKey, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secret represents a repository action secret.
|
||||||
|
type Secret struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
CreatedAt Timestamp `json:"created_at"`
|
||||||
|
UpdatedAt Timestamp `json:"updated_at"`
|
||||||
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
SelectedRepositoriesURL string `json:"selected_repositories_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secrets represents one item from the ListSecrets response.
|
||||||
|
type Secrets struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Secrets []*Secret `json:"secrets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepoSecrets lists all secrets available in a repository
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-repository-secrets
|
||||||
|
func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/secrets", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets := new(Secrets)
|
||||||
|
resp, err := s.client.Do(ctx, req, &secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secrets, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoSecret gets a single repository secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-repository-secret
|
||||||
|
func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := new(Secret)
|
||||||
|
resp, err := s.client.Do(ctx, req, secret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secret, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectedRepoIDs are the repository IDs that have access to the secret.
|
||||||
|
type SelectedRepoIDs []int64
|
||||||
|
|
||||||
|
// EncryptedSecret represents a secret that is encrypted using a public key.
|
||||||
|
//
|
||||||
|
// The value of EncryptedValue must be your secret, encrypted with
|
||||||
|
// LibSodium (see documentation here: https://libsodium.gitbook.io/doc/bindings_for_other_languages)
|
||||||
|
// using the public key retrieved using the GetPublicKey method.
|
||||||
|
type EncryptedSecret struct {
|
||||||
|
Name string `json:"-"`
|
||||||
|
KeyID string `json:"key_id"`
|
||||||
|
EncryptedValue string `json:"encrypted_value"`
|
||||||
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
SelectedRepositoryIDs SelectedRepoIDs `json:"selected_repository_ids,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateRepoSecret creates or updates a repository secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-or-update-a-repository-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, eSecret.Name)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, eSecret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRepoSecret deletes a secret in a repository using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-repository-secret
|
||||||
|
func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgSecrets lists all secrets available in an organization
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-organization-secrets
|
||||||
|
func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets := new(Secrets)
|
||||||
|
resp, err := s.client.Do(ctx, req, &secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secrets, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgSecret gets a single organization secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-organization-secret
|
||||||
|
func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := new(Secret)
|
||||||
|
resp, err := s.client.Do(ctx, req, secret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secret, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateOrgSecret creates or updates an organization secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-or-update-an-organization-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, eSecret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectedReposList represents the list of repositories selected for an organization secret.
|
||||||
|
type SelectedReposList struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSelectedReposForOrgSecret lists all repositories that have access to a secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := new(SelectedReposList)
|
||||||
|
resp, err := s.client.Do(ctx, req, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSelectedReposForOrgSecret sets the repositories that have access to a secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#set-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *ActionsService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||||
|
|
||||||
|
type repoIDs struct {
|
||||||
|
SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, repoIDs{SelectedIDs: ids})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSelectedRepoToOrgSecret adds a repository to an organization secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#add-selected-repository-to-an-organization-secret
|
||||||
|
func (s *ActionsService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#remove-selected-repository-from-an-organization-secret
|
||||||
|
func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrgSecret deletes a secret in an organization using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-an-organization-secret
|
||||||
|
func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEnvSecrets lists all secrets available in an environment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-environment-secrets
|
||||||
|
func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repositories/%v/environments/%v/secrets", repoID, env)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets := new(Secrets)
|
||||||
|
resp, err := s.client.Do(ctx, req, &secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secrets, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnvSecret gets a single environment secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-environment-secrets
|
||||||
|
func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := new(Secret)
|
||||||
|
resp, err := s.client.Do(ctx, req, secret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secret, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateEnvSecret creates or updates a repository secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#create-or-update-an-environment-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, eSecret.Name)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, eSecret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteEnvSecret deletes a secret in an environment using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-an-environment-secret
|
||||||
|
func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
149
vendor/github.com/google/go-github/v39/github/actions_workflow_jobs.go
generated
vendored
Normal file
149
vendor/github.com/google/go-github/v39/github/actions_workflow_jobs.go
generated
vendored
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TaskStep represents a single task step from a sequence of tasks of a job.
|
||||||
|
type TaskStep struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
Number *int64 `json:"number,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowJob represents a repository action workflow job.
|
||||||
|
type WorkflowJob struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
RunID *int64 `json:"run_id,omitempty"`
|
||||||
|
RunURL *string `json:"run_url,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Steps []*TaskStep `json:"steps,omitempty"`
|
||||||
|
CheckRunURL *string `json:"check_run_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jobs represents a slice of repository action workflow job.
|
||||||
|
type Jobs struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Jobs []*WorkflowJob `json:"jobs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowJobsOptions specifies optional parameters to ListWorkflowJobs.
|
||||||
|
type ListWorkflowJobsOptions struct {
|
||||||
|
// Filter specifies how jobs should be filtered by their completed_at timestamp.
|
||||||
|
// Possible values are:
|
||||||
|
// latest - Returns jobs from the most recent execution of the workflow run
|
||||||
|
// all - Returns all jobs for a workflow run, including from old executions of the workflow run
|
||||||
|
//
|
||||||
|
// Default value is "latest".
|
||||||
|
Filter string `url:"filter,omitempty"`
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowJobs lists all jobs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-jobs-for-a-workflow-run
|
||||||
|
func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jobs := new(Jobs)
|
||||||
|
resp, err := s.client.Do(ctx, req, &jobs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return jobs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowJobByID gets a specific job in a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-job-for-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
job := new(WorkflowJob)
|
||||||
|
resp, err := s.client.Do(ctx, req, job)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return job, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowJobLogs gets a redirect URL to download a plain text file of logs for a workflow job.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#download-job-logs-for-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID)
|
||||||
|
|
||||||
|
resp, err := s.getWorkflowLogsFromURL(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
return parsedURL, newResponse(resp), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp *http.Response
|
||||||
|
// Use http.DefaultTransport if no custom Transport is configured
|
||||||
|
req = withContext(ctx, req)
|
||||||
|
if s.client.client.Transport == nil {
|
||||||
|
resp, err = http.DefaultTransport.RoundTrip(req)
|
||||||
|
} else {
|
||||||
|
resp, err = s.client.client.Transport.RoundTrip(req)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
|
// If redirect response is returned, follow it
|
||||||
|
if followRedirects && resp.StatusCode == http.StatusMovedPermanently {
|
||||||
|
u = resp.Header.Get("Location")
|
||||||
|
resp, err = s.getWorkflowLogsFromURL(ctx, u, false)
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
|
||||||
|
}
|
239
vendor/github.com/google/go-github/v39/github/actions_workflow_runs.go
generated
vendored
Normal file
239
vendor/github.com/google/go-github/v39/github/actions_workflow_runs.go
generated
vendored
Normal file
|
@ -0,0 +1,239 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WorkflowRun represents a repository action workflow run.
|
||||||
|
type WorkflowRun struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
RunNumber *int `json:"run_number,omitempty"`
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
WorkflowID *int64 `json:"workflow_id,omitempty"`
|
||||||
|
CheckSuiteID *int64 `json:"check_suite_id,omitempty"`
|
||||||
|
CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
JobsURL *string `json:"jobs_url,omitempty"`
|
||||||
|
LogsURL *string `json:"logs_url,omitempty"`
|
||||||
|
CheckSuiteURL *string `json:"check_suite_url,omitempty"`
|
||||||
|
ArtifactsURL *string `json:"artifacts_url,omitempty"`
|
||||||
|
CancelURL *string `json:"cancel_url,omitempty"`
|
||||||
|
RerunURL *string `json:"rerun_url,omitempty"`
|
||||||
|
HeadCommit *HeadCommit `json:"head_commit,omitempty"`
|
||||||
|
WorkflowURL *string `json:"workflow_url,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
HeadRepository *Repository `json:"head_repository,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRuns represents a slice of repository action workflow run.
|
||||||
|
type WorkflowRuns struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
WorkflowRuns []*WorkflowRun `json:"workflow_runs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsOptions specifies optional parameters to ListWorkflowRuns.
|
||||||
|
type ListWorkflowRunsOptions struct {
|
||||||
|
Actor string `url:"actor,omitempty"`
|
||||||
|
Branch string `url:"branch,omitempty"`
|
||||||
|
Event string `url:"event,omitempty"`
|
||||||
|
Status string `url:"status,omitempty"`
|
||||||
|
Created string `url:"created,omitempty"`
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunUsage represents a usage of a specific workflow run.
|
||||||
|
type WorkflowRunUsage struct {
|
||||||
|
Billable *WorkflowRunEnvironment `json:"billable,omitempty"`
|
||||||
|
RunDurationMS *int64 `json:"run_duration_ms,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunEnvironment represents different runner environments available for a workflow run.
|
||||||
|
type WorkflowRunEnvironment struct {
|
||||||
|
Ubuntu *WorkflowRunBill `json:"UBUNTU,omitempty"`
|
||||||
|
MacOS *WorkflowRunBill `json:"MACOS,omitempty"`
|
||||||
|
Windows *WorkflowRunBill `json:"WINDOWS,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunBill specifies billable time for a specific environment in a workflow run.
|
||||||
|
type WorkflowRunBill struct {
|
||||||
|
TotalMS *int64 `json:"total_ms,omitempty"`
|
||||||
|
Jobs *int `json:"jobs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u, err := addOptions(endpoint, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runs := new(WorkflowRuns)
|
||||||
|
resp, err := s.client.Do(ctx, req, &runs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsByID lists all workflow runs by workflow ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs
|
||||||
|
func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowID)
|
||||||
|
return s.listWorkflowRuns(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsByFileName lists all workflow runs by workflow file name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs
|
||||||
|
func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowFileName)
|
||||||
|
return s.listWorkflowRuns(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryWorkflowRuns lists all workflow runs for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs-for-a-repository
|
||||||
|
func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/runs", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runs := new(WorkflowRuns)
|
||||||
|
resp, err := s.client.Do(ctx, req, &runs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunByID gets a specific workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
run := new(WorkflowRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, run)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return run, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RerunWorkflowByID re-runs a workflow by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#re-run-a-workflow
|
||||||
|
func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelWorkflowRunByID cancels a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#cancel-a-workflow-run
|
||||||
|
func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/cancel", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunLogs gets a redirect URL to download a plain text file of logs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#download-workflow-run-logs
|
||||||
|
func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
|
||||||
|
|
||||||
|
resp, err := s.getWorkflowLogsFromURL(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
return parsedURL, newResponse(resp), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteWorkflowRunLogs deletes all logs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-workflow-run-logs
|
||||||
|
func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunUsageByID gets a specific workflow usage run by run ID in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-run-usage
|
||||||
|
func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRunUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/timing", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowRunUsage := new(WorkflowRunUsage)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflowRunUsage)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflowRunUsage, resp, nil
|
||||||
|
}
|
218
vendor/github.com/google/go-github/v39/github/actions_workflows.go
generated
vendored
Normal file
218
vendor/github.com/google/go-github/v39/github/actions_workflows.go
generated
vendored
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Workflow represents a repository action workflow.
|
||||||
|
type Workflow struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
BadgeURL *string `json:"badge_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workflows represents a slice of repository action workflows.
|
||||||
|
type Workflows struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Workflows []*Workflow `json:"workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowUsage represents a usage of a specific workflow.
|
||||||
|
type WorkflowUsage struct {
|
||||||
|
Billable *WorkflowEnvironment `json:"billable,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowEnvironment represents different runner environments available for a workflow.
|
||||||
|
type WorkflowEnvironment struct {
|
||||||
|
Ubuntu *WorkflowBill `json:"UBUNTU,omitempty"`
|
||||||
|
MacOS *WorkflowBill `json:"MACOS,omitempty"`
|
||||||
|
Windows *WorkflowBill `json:"WINDOWS,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowBill specifies billable time for a specific environment in a workflow.
|
||||||
|
type WorkflowBill struct {
|
||||||
|
TotalMS *int64 `json:"total_ms,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventRequest represents a request to create a workflow dispatch event.
|
||||||
|
type CreateWorkflowDispatchEventRequest struct {
|
||||||
|
// Ref represents the reference of the workflow run.
|
||||||
|
// The reference can be a branch, tag, or a commit SHA.
|
||||||
|
// Ref is required when creating a workflow dispatch event.
|
||||||
|
Ref string `json:"ref"`
|
||||||
|
// Inputs represents input keys and values configured in the workflow file.
|
||||||
|
// The maximum number of properties is 10.
|
||||||
|
// Default: Any default properties configured in the workflow file will be used when `inputs` are omitted.
|
||||||
|
Inputs map[string]interface{} `json:"inputs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflows lists all workflows in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-repository-workflows
|
||||||
|
func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflows := new(Workflows)
|
||||||
|
resp, err := s.client.Do(ctx, req, &workflows)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflows, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowByID gets a specific workflow by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow
|
||||||
|
func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.getWorkflow(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowByFileName gets a specific workflow by file name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow
|
||||||
|
func (s *ActionsService) GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.getWorkflow(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow := new(Workflow)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflow)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflow, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowUsageByID gets a specific workflow usage by ID in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-usage
|
||||||
|
func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo string, workflowID int64) (*WorkflowUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.getWorkflowUsage(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowUsageByFileName gets a specific workflow usage by file name in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-usage
|
||||||
|
func (s *ActionsService) GetWorkflowUsageByFileName(ctx context.Context, owner, repo, workflowFileName string) (*WorkflowUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.getWorkflowUsage(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getWorkflowUsage(ctx context.Context, url string) (*WorkflowUsage, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowUsage := new(WorkflowUsage)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflowUsage)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflowUsage, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventByID manually triggers a GitHub Actions workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-workflow-dispatch-event
|
||||||
|
func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.createWorkflowDispatchEvent(ctx, u, &event)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventByFileName manually triggers a GitHub Actions workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-workflow-dispatch-event
|
||||||
|
func (s *ActionsService) CreateWorkflowDispatchEventByFileName(ctx context.Context, owner, repo, workflowFileName string, event CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.createWorkflowDispatchEvent(ctx, u, &event)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) createWorkflowDispatchEvent(ctx context.Context, url string, event *CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("POST", url, event)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWorkflowByID enables a workflow and sets the state of the workflow to "active".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#enable-a-workflow
|
||||||
|
func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowID)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWorkflowByFileName enables a workflow and sets the state of the workflow to "active".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#enable-a-workflow
|
||||||
|
func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowFileName)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableWorkflowByID disables a workflow and sets the state of the workflow to "disabled_manually".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#disable-a-workflow
|
||||||
|
func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowID)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableWorkflowByFileName disables a workflow and sets the state of the workflow to "disabled_manually".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#disable-a-workflow
|
||||||
|
func (s *ActionsService) DisableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowFileName)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) doNewPutRequest(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PUT", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
72
vendor/github.com/google/go-github/v39/github/activity.go
generated
vendored
Normal file
72
vendor/github.com/google/go-github/v39/github/activity.go
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// ActivityService handles communication with the activity related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/
|
||||||
|
type ActivityService service
|
||||||
|
|
||||||
|
// FeedLink represents a link to a related resource.
|
||||||
|
type FeedLink struct {
|
||||||
|
HRef *string `json:"href,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feeds represents timeline resources in Atom format.
|
||||||
|
type Feeds struct {
|
||||||
|
TimelineURL *string `json:"timeline_url,omitempty"`
|
||||||
|
UserURL *string `json:"user_url,omitempty"`
|
||||||
|
CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"`
|
||||||
|
CurrentUserURL *string `json:"current_user_url,omitempty"`
|
||||||
|
CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"`
|
||||||
|
CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"`
|
||||||
|
CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"`
|
||||||
|
Links *FeedLinks `json:"_links,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FeedLinks represents the links in a Feed.
|
||||||
|
type FeedLinks struct {
|
||||||
|
Timeline *FeedLink `json:"timeline,omitempty"`
|
||||||
|
User *FeedLink `json:"user,omitempty"`
|
||||||
|
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
|
||||||
|
CurrentUser *FeedLink `json:"current_user,omitempty"`
|
||||||
|
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
|
||||||
|
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
|
||||||
|
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListFeeds lists all the feeds available to the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub provides several timeline resources in Atom format:
|
||||||
|
// Timeline: The GitHub global public timeline
|
||||||
|
// User: The public timeline for any user, using URI template
|
||||||
|
// Current user public: The public timeline for the authenticated user
|
||||||
|
// Current user: The private timeline for the authenticated user
|
||||||
|
// Current user actor: The private timeline for activity created by the
|
||||||
|
// authenticated user
|
||||||
|
// Current user organizations: The private timeline for the organizations
|
||||||
|
// the authenticated user is a member of.
|
||||||
|
//
|
||||||
|
// Note: Private feeds are only returned when authenticating via Basic Auth
|
||||||
|
// since current feed URIs use the older, non revocable auth tokens.
|
||||||
|
func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", "feeds", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
f := &Feeds{}
|
||||||
|
resp, err := s.client.Do(ctx, req, f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return f, resp, nil
|
||||||
|
}
|
217
vendor/github.com/google/go-github/v39/github/activity_events.go
generated
vendored
Normal file
217
vendor/github.com/google/go-github/v39/github/activity_events.go
generated
vendored
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListEvents drinks from the firehose of all public events across GitHub.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events
|
||||||
|
func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u, err := addOptions("events", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryEvents lists events for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-events
|
||||||
|
func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueEventsForRepository lists issue events for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events-for-a-repository
|
||||||
|
func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsForRepoNetwork lists public events for a network of repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-network-of-repositories
|
||||||
|
func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsForOrganization lists public events for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-organization-events
|
||||||
|
func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/events", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
|
||||||
|
// true, only public events will be returned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-for-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-user
|
||||||
|
func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if publicOnly {
|
||||||
|
u = fmt.Sprintf("users/%v/events/public", user)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("users/%v/events", user)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is
|
||||||
|
// true, only public events will be returned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-received-by-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-received-by-a-user
|
||||||
|
func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if publicOnly {
|
||||||
|
u = fmt.Sprintf("users/%v/received_events/public", user)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("users/%v/received_events", user)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserEventsForOrganization provides the user’s organization dashboard. You
|
||||||
|
// must be authenticated as the user to view this.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-organization-events-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -18,7 +19,7 @@ type Notification struct {
|
||||||
|
|
||||||
// Reason identifies the event that triggered the notification.
|
// Reason identifies the event that triggered the notification.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#notification-reasons
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#notification-reasons
|
||||||
Reason *string `json:"reason,omitempty"`
|
Reason *string `json:"reason,omitempty"`
|
||||||
|
|
||||||
Unread *bool `json:"unread,omitempty"`
|
Unread *bool `json:"unread,omitempty"`
|
||||||
|
@ -42,14 +43,16 @@ type NotificationListOptions struct {
|
||||||
Participating bool `url:"participating,omitempty"`
|
Participating bool `url:"participating,omitempty"`
|
||||||
Since time.Time `url:"since,omitempty"`
|
Since time.Time `url:"since,omitempty"`
|
||||||
Before time.Time `url:"before,omitempty"`
|
Before time.Time `url:"before,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListNotifications lists all notifications for the authenticated user.
|
// ListNotifications lists all notifications for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-notifications-for-the-authenticated-user
|
||||||
func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Notification, *Response, error) {
|
func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) {
|
||||||
u := fmt.Sprintf("notifications")
|
u := "notifications"
|
||||||
u, err := addOptions(u, opt)
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -59,22 +62,22 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Not
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifications []Notification
|
var notifications []*Notification
|
||||||
resp, err := s.client.Do(req, ¬ifications)
|
resp, err := s.client.Do(ctx, req, ¬ifications)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifications, resp, err
|
return notifications, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepositoryNotifications lists all notifications in a given repository
|
// ListRepositoryNotifications lists all notifications in a given repository
|
||||||
// for the authenticated user.
|
// for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-notifications-for-the-authenticated-user
|
||||||
func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *NotificationListOptions) ([]Notification, *Response, error) {
|
func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
||||||
u, err := addOptions(u, opt)
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -84,60 +87,55 @@ func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *N
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifications []Notification
|
var notifications []*Notification
|
||||||
resp, err := s.client.Do(req, ¬ifications)
|
resp, err := s.client.Do(ctx, req, ¬ifications)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifications, resp, err
|
return notifications, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type markReadOptions struct {
|
type markReadOptions struct {
|
||||||
LastReadAt time.Time `url:"last_read_at,omitempty"`
|
LastReadAt time.Time `json:"last_read_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkNotificationsRead marks all notifications up to lastRead as read.
|
// MarkNotificationsRead marks all notifications up to lastRead as read.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#mark-as-read
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#mark-as-read
|
||||||
func (s *ActivityService) MarkNotificationsRead(lastRead time.Time) (*Response, error) {
|
func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead time.Time) (*Response, error) {
|
||||||
u := fmt.Sprintf("notifications")
|
opts := &markReadOptions{
|
||||||
u, err := addOptions(u, markReadOptions{lastRead})
|
LastReadAt: lastRead,
|
||||||
|
}
|
||||||
|
req, err := s.client.NewRequest("PUT", "notifications", opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkRepositoryNotificationsRead marks all notifications up to lastRead in
|
// MarkRepositoryNotificationsRead marks all notifications up to lastRead in
|
||||||
// the specified repository as read.
|
// the specified repository as read.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-repository-notifications-as-read
|
||||||
func (s *ActivityService) MarkRepositoryNotificationsRead(owner, repo string, lastRead time.Time) (*Response, error) {
|
func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead time.Time) (*Response, error) {
|
||||||
|
opts := &markReadOptions{
|
||||||
|
LastReadAt: lastRead,
|
||||||
|
}
|
||||||
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
||||||
u, err := addOptions(u, markReadOptions{lastRead})
|
req, err := s.client.NewRequest("PUT", u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetThread gets the specified notification thread.
|
// GetThread gets the specified notification thread.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#view-a-single-thread
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread
|
||||||
func (s *ActivityService) GetThread(id string) (*Notification, *Response, error) {
|
func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) {
|
||||||
u := fmt.Sprintf("notifications/threads/%v", id)
|
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
@ -146,18 +144,18 @@ func (s *ActivityService) GetThread(id string) (*Notification, *Response, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
notification := new(Notification)
|
notification := new(Notification)
|
||||||
resp, err := s.client.Do(req, notification)
|
resp, err := s.client.Do(ctx, req, notification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return notification, resp, err
|
return notification, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkThreadRead marks the specified thread as read.
|
// MarkThreadRead marks the specified thread as read.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-a-thread-as-read
|
||||||
func (s *ActivityService) MarkThreadRead(id string) (*Response, error) {
|
func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) {
|
||||||
u := fmt.Sprintf("notifications/threads/%v", id)
|
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PATCH", u, nil)
|
req, err := s.client.NewRequest("PATCH", u, nil)
|
||||||
|
@ -165,14 +163,14 @@ func (s *ActivityService) MarkThreadRead(id string) (*Response, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetThreadSubscription checks to see if the authenticated user is subscribed
|
// GetThreadSubscription checks to see if the authenticated user is subscribed
|
||||||
// to a thread.
|
// to a thread.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread-subscription-for-the-authenticated-user
|
||||||
func (s *ActivityService) GetThreadSubscription(id string) (*Subscription, *Response, error) {
|
func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) {
|
||||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
@ -181,19 +179,19 @@ func (s *ActivityService) GetThreadSubscription(id string) (*Subscription, *Resp
|
||||||
}
|
}
|
||||||
|
|
||||||
sub := new(Subscription)
|
sub := new(Subscription)
|
||||||
resp, err := s.client.Do(req, sub)
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub, resp, err
|
return sub, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetThreadSubscription sets the subscription for the specified thread for the
|
// SetThreadSubscription sets the subscription for the specified thread for the
|
||||||
// authenticated user.
|
// authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#set-a-thread-subscription
|
||||||
func (s *ActivityService) SetThreadSubscription(id string, subscription *Subscription) (*Subscription, *Response, error) {
|
func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) {
|
||||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, subscription)
|
req, err := s.client.NewRequest("PUT", u, subscription)
|
||||||
|
@ -202,24 +200,24 @@ func (s *ActivityService) SetThreadSubscription(id string, subscription *Subscri
|
||||||
}
|
}
|
||||||
|
|
||||||
sub := new(Subscription)
|
sub := new(Subscription)
|
||||||
resp, err := s.client.Do(req, sub)
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub, resp, err
|
return sub, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteThreadSubscription deletes the subscription for the specified thread
|
// DeleteThreadSubscription deletes the subscription for the specified thread
|
||||||
// for the authenticated user.
|
// for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#delete-a-thread-subscription
|
||||||
func (s *ActivityService) DeleteThreadSubscription(id string) (*Response, error) {
|
func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) {
|
||||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
138
vendor/github.com/google/go-github/v39/github/activity_star.go
generated
vendored
Normal file
138
vendor/github.com/google/go-github/v39/github/activity_star.go
generated
vendored
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StarredRepository is returned by ListStarred.
|
||||||
|
type StarredRepository struct {
|
||||||
|
StarredAt *Timestamp `json:"starred_at,omitempty"`
|
||||||
|
Repository *Repository `json:"repo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stargazer represents a user that has starred a repository.
|
||||||
|
type Stargazer struct {
|
||||||
|
StarredAt *Timestamp `json:"starred_at,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStargazers lists people who have starred the specified repo.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-stargazers
|
||||||
|
func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches
|
||||||
|
req.Header.Set("Accept", mediaTypeStarringPreview)
|
||||||
|
|
||||||
|
var stargazers []*Stargazer
|
||||||
|
resp, err := s.client.Do(ctx, req, &stargazers)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return stargazers, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivityListStarredOptions specifies the optional parameters to the
|
||||||
|
// ActivityService.ListStarred method.
|
||||||
|
type ActivityListStarredOptions struct {
|
||||||
|
// How to sort the repository list. Possible values are: created, updated,
|
||||||
|
// pushed, full_name. Default is "full_name".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort repositories. Possible values are: asc, desc.
|
||||||
|
// Default is "asc" when sort is "full_name", otherwise default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarred lists all the repos starred by a user. Passing the empty string
|
||||||
|
// will list the starred repositories for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-starred-by-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-starred-by-a-user
|
||||||
|
func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/starred", user)
|
||||||
|
} else {
|
||||||
|
u = "user/starred"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when APIs fully launch
|
||||||
|
acceptHeaders := []string{mediaTypeStarringPreview, mediaTypeTopicsPreview}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var repos []*StarredRepository
|
||||||
|
resp, err := s.client.Do(ctx, req, &repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStarred checks if a repository is starred by authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#check-if-a-repository-is-starred-by-the-authenticated-user
|
||||||
|
func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
starred, err := parseBoolResponse(err)
|
||||||
|
return starred, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Star a repository as the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#star-a-repository-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unstar a repository as the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#unstar-a-repository-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) Unstar(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// Subscription identifies a repository or thread subscription.
|
// Subscription identifies a repository or thread subscription.
|
||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
|
@ -24,10 +27,10 @@ type Subscription struct {
|
||||||
|
|
||||||
// ListWatchers lists watchers of a particular repo.
|
// ListWatchers lists watchers of a particular repo.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: http://developer.github.com/v3/activity/watching/#list-watchers
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-watchers
|
||||||
func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]User, *Response, error) {
|
func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
|
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
|
||||||
u, err := addOptions(u, opt)
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -37,46 +40,52 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
watchers := new([]User)
|
var watchers []*User
|
||||||
resp, err := s.client.Do(req, watchers)
|
resp, err := s.client.Do(ctx, req, &watchers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *watchers, resp, err
|
return watchers, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListWatched lists the repositories the specified user is watching. Passing
|
// ListWatched lists the repositories the specified user is watching. Passing
|
||||||
// the empty string will fetch watched repos for the authenticated user.
|
// the empty string will fetch watched repos for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-the-authenticated-user
|
||||||
func (s *ActivityService) ListWatched(user string) ([]Repository, *Response, error) {
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-a-user
|
||||||
|
func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) {
|
||||||
var u string
|
var u string
|
||||||
if user != "" {
|
if user != "" {
|
||||||
u = fmt.Sprintf("users/%v/subscriptions", user)
|
u = fmt.Sprintf("users/%v/subscriptions", user)
|
||||||
} else {
|
} else {
|
||||||
u = "user/subscriptions"
|
u = "user/subscriptions"
|
||||||
}
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
watched := new([]Repository)
|
var watched []*Repository
|
||||||
resp, err := s.client.Do(req, watched)
|
resp, err := s.client.Do(ctx, req, &watched)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *watched, resp, err
|
return watched, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepositorySubscription returns the subscription for the specified
|
// GetRepositorySubscription returns the subscription for the specified
|
||||||
// repository for the authenticated user. If the authenticated user is not
|
// repository for the authenticated user. If the authenticated user is not
|
||||||
// watching the repository, a nil Subscription is returned.
|
// watching the repository, a nil Subscription is returned.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#get-a-repository-subscription
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-repository-subscription
|
||||||
func (s *ActivityService) GetRepositorySubscription(owner, repo string) (*Subscription, *Response, error) {
|
func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
@ -85,21 +94,25 @@ func (s *ActivityService) GetRepositorySubscription(owner, repo string) (*Subscr
|
||||||
}
|
}
|
||||||
|
|
||||||
sub := new(Subscription)
|
sub := new(Subscription)
|
||||||
resp, err := s.client.Do(req, sub)
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// if it's just a 404, don't return that as an error
|
// if it's just a 404, don't return that as an error
|
||||||
_, err = parseBoolResponse(err)
|
_, err = parseBoolResponse(err)
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub, resp, err
|
return sub, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRepositorySubscription sets the subscription for the specified repository
|
// SetRepositorySubscription sets the subscription for the specified repository
|
||||||
// for the authenticated user.
|
// for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#set-a-repository-subscription
|
// To watch a repository, set subscription.Subscribed to true.
|
||||||
func (s *ActivityService) SetRepositorySubscription(owner, repo string, subscription *Subscription) (*Subscription, *Response, error) {
|
// To ignore notifications made within a repository, set subscription.Ignored to true.
|
||||||
|
// To stop watching a repository, use DeleteRepositorySubscription.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#set-a-repository-subscription
|
||||||
|
func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("PUT", u, subscription)
|
req, err := s.client.NewRequest("PUT", u, subscription)
|
||||||
|
@ -108,24 +121,27 @@ func (s *ActivityService) SetRepositorySubscription(owner, repo string, subscrip
|
||||||
}
|
}
|
||||||
|
|
||||||
sub := new(Subscription)
|
sub := new(Subscription)
|
||||||
resp, err := s.client.Do(req, sub)
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return sub, resp, err
|
return sub, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRepositorySubscription deletes the subscription for the specified
|
// DeleteRepositorySubscription deletes the subscription for the specified
|
||||||
// repository for the authenticated user.
|
// repository for the authenticated user.
|
||||||
//
|
//
|
||||||
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#delete-a-repository-subscription
|
// This is used to stop watching a repository. To control whether or not to
|
||||||
func (s *ActivityService) DeleteRepositorySubscription(owner, repo string) (*Response, error) {
|
// receive notifications from a repository, use SetRepositorySubscription.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#delete-a-repository-subscription
|
||||||
|
func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
119
vendor/github.com/google/go-github/v39/github/admin.go
generated
vendored
Normal file
119
vendor/github.com/google/go-github/v39/github/admin.go
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminService handles communication with the admin related methods of the
|
||||||
|
// GitHub API. These API routes are normally only accessible for GitHub
|
||||||
|
// Enterprise installations.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/
|
||||||
|
type AdminService service
|
||||||
|
|
||||||
|
// TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group.
|
||||||
|
type TeamLDAPMapping struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
LDAPDN *string `json:"ldap_dn,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Privacy *string `json:"privacy,omitempty"`
|
||||||
|
Permission *string `json:"permission,omitempty"`
|
||||||
|
|
||||||
|
MembersURL *string `json:"members_url,omitempty"`
|
||||||
|
RepositoriesURL *string `json:"repositories_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m TeamLDAPMapping) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserLDAPMapping represents the mapping between a GitHub user and an LDAP user.
|
||||||
|
type UserLDAPMapping struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
LDAPDN *string `json:"ldap_dn,omitempty"`
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||||
|
GravatarID *string `json:"gravatar_id,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
SiteAdmin *bool `json:"site_admin,omitempty"`
|
||||||
|
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
EventsURL *string `json:"events_url,omitempty"`
|
||||||
|
FollowingURL *string `json:"following_url,omitempty"`
|
||||||
|
FollowersURL *string `json:"followers_url,omitempty"`
|
||||||
|
GistsURL *string `json:"gists_url,omitempty"`
|
||||||
|
OrganizationsURL *string `json:"organizations_url,omitempty"`
|
||||||
|
ReceivedEventsURL *string `json:"received_events_url,omitempty"`
|
||||||
|
ReposURL *string `json:"repos_url,omitempty"`
|
||||||
|
StarredURL *string `json:"starred_url,omitempty"`
|
||||||
|
SubscriptionsURL *string `json:"subscriptions_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m UserLDAPMapping) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enterprise represents the GitHub enterprise profile.
|
||||||
|
type Enterprise struct {
|
||||||
|
ID *int `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
WebsiteURL *string `json:"website_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Enterprise) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/ldap/#update-ldap-mapping-for-a-user
|
||||||
|
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/ldap/users/%v/mapping", user)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, mapping)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(UserLDAPMapping)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/ldap/#update-ldap-mapping-for-a-team
|
||||||
|
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, mapping)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(TeamLDAPMapping)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
89
vendor/github.com/google/go-github/v39/github/admin_orgs.go
generated
vendored
Normal file
89
vendor/github.com/google/go-github/v39/github/admin_orgs.go
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
// Copyright 2019 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// createOrgRequest is a subset of Organization and is used internally
|
||||||
|
// by CreateOrg to pass only the known fields for the endpoint.
|
||||||
|
type createOrgRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
Admin *string `json:"admin,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrg creates a new organization in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// Note that only a subset of the org fields are used and org must
|
||||||
|
// not be nil.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#create-an-organization
|
||||||
|
func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) {
|
||||||
|
u := "admin/organizations"
|
||||||
|
|
||||||
|
orgReq := &createOrgRequest{
|
||||||
|
Login: org.Login,
|
||||||
|
Admin: &admin,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, orgReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
o := new(Organization)
|
||||||
|
resp, err := s.client.Do(ctx, req, o)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return o, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// renameOrgRequest is a subset of Organization and is used internally
|
||||||
|
// by RenameOrg and RenameOrgByName to pass only the known fields for the endpoint.
|
||||||
|
type renameOrgRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrgResponse is the response given when renaming an Organization.
|
||||||
|
type RenameOrgResponse struct {
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrg renames an organization in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization
|
||||||
|
func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) {
|
||||||
|
return s.RenameOrgByName(ctx, *org.Login, newName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrgByName renames an organization in GitHub Enterprise using its current name.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization
|
||||||
|
func (s *AdminService) RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/organizations/%v", org)
|
||||||
|
|
||||||
|
orgReq := &renameOrgRequest{
|
||||||
|
Login: &newName,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, orgReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
o := new(RenameOrgResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, o)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return o, resp, nil
|
||||||
|
}
|
171
vendor/github.com/google/go-github/v39/github/admin_stats.go
generated
vendored
Normal file
171
vendor/github.com/google/go-github/v39/github/admin_stats.go
generated
vendored
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminStats represents a variety of stats of a GitHub Enterprise
|
||||||
|
// installation.
|
||||||
|
type AdminStats struct {
|
||||||
|
Issues *IssueStats `json:"issues,omitempty"`
|
||||||
|
Hooks *HookStats `json:"hooks,omitempty"`
|
||||||
|
Milestones *MilestoneStats `json:"milestones,omitempty"`
|
||||||
|
Orgs *OrgStats `json:"orgs,omitempty"`
|
||||||
|
Comments *CommentStats `json:"comments,omitempty"`
|
||||||
|
Pages *PageStats `json:"pages,omitempty"`
|
||||||
|
Users *UserStats `json:"users,omitempty"`
|
||||||
|
Gists *GistStats `json:"gists,omitempty"`
|
||||||
|
Pulls *PullStats `json:"pulls,omitempty"`
|
||||||
|
Repos *RepoStats `json:"repos,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AdminStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueStats represents the number of total, open and closed issues.
|
||||||
|
type IssueStats struct {
|
||||||
|
TotalIssues *int `json:"total_issues,omitempty"`
|
||||||
|
OpenIssues *int `json:"open_issues,omitempty"`
|
||||||
|
ClosedIssues *int `json:"closed_issues,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s IssueStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HookStats represents the number of total, active and inactive hooks.
|
||||||
|
type HookStats struct {
|
||||||
|
TotalHooks *int `json:"total_hooks,omitempty"`
|
||||||
|
ActiveHooks *int `json:"active_hooks,omitempty"`
|
||||||
|
InactiveHooks *int `json:"inactive_hooks,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s HookStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MilestoneStats represents the number of total, open and close milestones.
|
||||||
|
type MilestoneStats struct {
|
||||||
|
TotalMilestones *int `json:"total_milestones,omitempty"`
|
||||||
|
OpenMilestones *int `json:"open_milestones,omitempty"`
|
||||||
|
ClosedMilestones *int `json:"closed_milestones,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s MilestoneStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrgStats represents the number of total, disabled organizations and the team
|
||||||
|
// and team member count.
|
||||||
|
type OrgStats struct {
|
||||||
|
TotalOrgs *int `json:"total_orgs,omitempty"`
|
||||||
|
DisabledOrgs *int `json:"disabled_orgs,omitempty"`
|
||||||
|
TotalTeams *int `json:"total_teams,omitempty"`
|
||||||
|
TotalTeamMembers *int `json:"total_team_members,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s OrgStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommentStats represents the number of total comments on commits, gists, issues
|
||||||
|
// and pull requests.
|
||||||
|
type CommentStats struct {
|
||||||
|
TotalCommitComments *int `json:"total_commit_comments,omitempty"`
|
||||||
|
TotalGistComments *int `json:"total_gist_comments,omitempty"`
|
||||||
|
TotalIssueComments *int `json:"total_issue_comments,omitempty"`
|
||||||
|
TotalPullRequestComments *int `json:"total_pull_request_comments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s CommentStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PageStats represents the total number of github pages.
|
||||||
|
type PageStats struct {
|
||||||
|
TotalPages *int `json:"total_pages,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s PageStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserStats represents the number of total, admin and suspended users.
|
||||||
|
type UserStats struct {
|
||||||
|
TotalUsers *int `json:"total_users,omitempty"`
|
||||||
|
AdminUsers *int `json:"admin_users,omitempty"`
|
||||||
|
SuspendedUsers *int `json:"suspended_users,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistStats represents the number of total, private and public gists.
|
||||||
|
type GistStats struct {
|
||||||
|
TotalGists *int `json:"total_gists,omitempty"`
|
||||||
|
PrivateGists *int `json:"private_gists,omitempty"`
|
||||||
|
PublicGists *int `json:"public_gists,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s GistStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PullStats represents the number of total, merged, mergable and unmergeable
|
||||||
|
// pull-requests.
|
||||||
|
type PullStats struct {
|
||||||
|
TotalPulls *int `json:"total_pulls,omitempty"`
|
||||||
|
MergedPulls *int `json:"merged_pulls,omitempty"`
|
||||||
|
MergablePulls *int `json:"mergeable_pulls,omitempty"`
|
||||||
|
UnmergablePulls *int `json:"unmergeable_pulls,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s PullStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RepoStats represents the number of total, root, fork, organization repositories
|
||||||
|
// together with the total number of pushes and wikis.
|
||||||
|
type RepoStats struct {
|
||||||
|
TotalRepos *int `json:"total_repos,omitempty"`
|
||||||
|
RootRepos *int `json:"root_repos,omitempty"`
|
||||||
|
ForkRepos *int `json:"fork_repos,omitempty"`
|
||||||
|
OrgRepos *int `json:"org_repos,omitempty"`
|
||||||
|
TotalPushes *int `json:"total_pushes,omitempty"`
|
||||||
|
TotalWikis *int `json:"total_wikis,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s RepoStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAdminStats returns a variety of metrics about a GitHub Enterprise
|
||||||
|
// installation.
|
||||||
|
//
|
||||||
|
// Please note that this is only available to site administrators,
|
||||||
|
// otherwise it will error with a 404 not found (instead of 401 or 403).
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/admin_stats/
|
||||||
|
func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprise/stats/all")
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(AdminStats)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
133
vendor/github.com/google/go-github/v39/github/admin_users.go
generated
vendored
Normal file
133
vendor/github.com/google/go-github/v39/github/admin_users.go
generated
vendored
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
// Copyright 2019 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// createUserRequest is a subset of User and is used internally
|
||||||
|
// by CreateUser to pass only the known fields for the endpoint.
|
||||||
|
type createUserRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateUser creates a new user in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-a-new-user
|
||||||
|
func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*User, *Response, error) {
|
||||||
|
u := "admin/users"
|
||||||
|
|
||||||
|
userReq := &createUserRequest{
|
||||||
|
Login: &login,
|
||||||
|
Email: &email,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, userReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var user User
|
||||||
|
resp, err := s.client.Do(ctx, req, &user)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &user, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUser deletes a user in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-user
|
||||||
|
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := "admin/users/" + username
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImpersonateUserOptions represents the scoping for the OAuth token.
|
||||||
|
type ImpersonateUserOptions struct {
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OAuthAPP represents the GitHub Site Administrator OAuth app.
|
||||||
|
type OAuthAPP struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s OAuthAPP) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAuthorization represents the impersonation response.
|
||||||
|
type UserAuthorization struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
TokenLastEight *string `json:"token_last_eight,omitempty"`
|
||||||
|
HashedToken *string `json:"hashed_token,omitempty"`
|
||||||
|
App *OAuthAPP `json:"app,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateUserImpersonation creates an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
||||||
|
func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%s/authorizations", username)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(UserAuthorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserImpersonation deletes an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
||||||
|
func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%s/authorizations", username)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
352
vendor/github.com/google/go-github/v39/github/apps.go
generated
vendored
Normal file
352
vendor/github.com/google/go-github/v39/github/apps.go
generated
vendored
Normal file
|
@ -0,0 +1,352 @@
|
||||||
|
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppsService provides access to the installation related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/
|
||||||
|
type AppsService service
|
||||||
|
|
||||||
|
// App represents a GitHub App.
|
||||||
|
type App struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
ExternalURL *string `json:"external_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
Events []string `json:"events,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationToken represents an installation token.
|
||||||
|
type InstallationToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationTokenOptions allow restricting a token's access to specific repositories.
|
||||||
|
type InstallationTokenOptions struct {
|
||||||
|
// The IDs of the repositories that the installation token can access.
|
||||||
|
// Providing repository IDs restricts the access of an installation token to specific repositories.
|
||||||
|
RepositoryIDs []int64 `json:"repository_ids,omitempty"`
|
||||||
|
|
||||||
|
// The permissions granted to the access token.
|
||||||
|
// The permissions object includes the permission names and their access type.
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationPermissions lists the repository and organization permissions for an installation.
|
||||||
|
//
|
||||||
|
// Permission names taken from:
|
||||||
|
// https://docs.github.com/en/enterprise-server@3.0/rest/reference/apps#create-an-installation-access-token-for-an-app
|
||||||
|
// https://docs.github.com/en/rest/reference/apps#create-an-installation-access-token-for-an-app
|
||||||
|
type InstallationPermissions struct {
|
||||||
|
Actions *string `json:"actions,omitempty"`
|
||||||
|
Administration *string `json:"administration,omitempty"`
|
||||||
|
Blocking *string `json:"blocking,omitempty"`
|
||||||
|
Checks *string `json:"checks,omitempty"`
|
||||||
|
Contents *string `json:"contents,omitempty"`
|
||||||
|
ContentReferences *string `json:"content_references,omitempty"`
|
||||||
|
Deployments *string `json:"deployments,omitempty"`
|
||||||
|
Emails *string `json:"emails,omitempty"`
|
||||||
|
Environments *string `json:"environments,omitempty"`
|
||||||
|
Followers *string `json:"followers,omitempty"`
|
||||||
|
Issues *string `json:"issues,omitempty"`
|
||||||
|
Metadata *string `json:"metadata,omitempty"`
|
||||||
|
Members *string `json:"members,omitempty"`
|
||||||
|
OrganizationAdministration *string `json:"organization_administration,omitempty"`
|
||||||
|
OrganizationHooks *string `json:"organization_hooks,omitempty"`
|
||||||
|
OrganizationPlan *string `json:"organization_plan,omitempty"`
|
||||||
|
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
|
||||||
|
OrganizationProjects *string `json:"organization_projects,omitempty"`
|
||||||
|
OrganizationSecrets *string `json:"organization_secrets,omitempty"`
|
||||||
|
OrganizationSelfHostedRunners *string `json:"organization_self_hosted_runners,omitempty"`
|
||||||
|
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
|
||||||
|
Packages *string `json:"packages,omitempty"`
|
||||||
|
Pages *string `json:"pages,omitempty"`
|
||||||
|
PullRequests *string `json:"pull_requests,omitempty"`
|
||||||
|
RepositoryHooks *string `json:"repository_hooks,omitempty"`
|
||||||
|
RepositoryProjects *string `json:"repository_projects,omitempty"`
|
||||||
|
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
|
||||||
|
Secrets *string `json:"secrets,omitempty"`
|
||||||
|
SecretScanningAlerts *string `json:"secret_scanning_alerts,omitempty"`
|
||||||
|
SecurityEvents *string `json:"security_events,omitempty"`
|
||||||
|
SingleFile *string `json:"single_file,omitempty"`
|
||||||
|
Statuses *string `json:"statuses,omitempty"`
|
||||||
|
TeamDiscussions *string `json:"team_discussions,omitempty"`
|
||||||
|
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
|
||||||
|
Workflows *string `json:"workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Installation represents a GitHub Apps installation.
|
||||||
|
type Installation struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
AppID *int64 `json:"app_id,omitempty"`
|
||||||
|
AppSlug *string `json:"app_slug,omitempty"`
|
||||||
|
TargetID *int64 `json:"target_id,omitempty"`
|
||||||
|
Account *User `json:"account,omitempty"`
|
||||||
|
AccessTokensURL *string `json:"access_tokens_url,omitempty"`
|
||||||
|
RepositoriesURL *string `json:"repositories_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
TargetType *string `json:"target_type,omitempty"`
|
||||||
|
SingleFileName *string `json:"single_file_name,omitempty"`
|
||||||
|
RepositorySelection *string `json:"repository_selection,omitempty"`
|
||||||
|
Events []string `json:"events,omitempty"`
|
||||||
|
SingleFilePaths []string `json:"single_file_paths,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
HasMultipleSingleFiles *bool `json:"has_multiple_single_files,omitempty"`
|
||||||
|
SuspendedBy *User `json:"suspended_by,omitempty"`
|
||||||
|
SuspendedAt *Timestamp `json:"suspended_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attachment represents a GitHub Apps attachment.
|
||||||
|
type Attachment struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContentReference represents a reference to a URL in an issue or pull request.
|
||||||
|
type ContentReference struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Reference *string `json:"reference,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Installation) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single GitHub App. Passing the empty string will get
|
||||||
|
// the authenticated GitHub App.
|
||||||
|
//
|
||||||
|
// Note: appSlug is just the URL-friendly name of your GitHub App.
|
||||||
|
// You can find this on the settings page for your GitHub App
|
||||||
|
// (e.g., https://github.com/settings/apps/:app_slug).
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-the-authenticated-app
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-app
|
||||||
|
func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if appSlug != "" {
|
||||||
|
u = fmt.Sprintf("apps/%v", appSlug)
|
||||||
|
} else {
|
||||||
|
u = "app"
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
app := new(App)
|
||||||
|
resp, err := s.client.Do(ctx, req, app)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return app, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListInstallations lists the installations that the current GitHub App has.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-installations-for-the-authenticated-app
|
||||||
|
func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
|
||||||
|
u, err := addOptions("app/installations", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i []*Installation
|
||||||
|
resp, err := s.client.Do(ctx, req, &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInstallation returns the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("app/installations/%v", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserInstallations lists installations that are accessible to the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-app-installations-accessible-to-the-user-access-token
|
||||||
|
func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
|
||||||
|
u, err := addOptions("user/installations", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i struct {
|
||||||
|
Installations []*Installation `json:"installations"`
|
||||||
|
}
|
||||||
|
resp, err := s.client.Do(ctx, req, &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i.Installations, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuspendInstallation suspends the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#suspend-an-app-installation
|
||||||
|
func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnsuspendInstallation unsuspends the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#unsuspend-an-app-installation
|
||||||
|
func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteInstallation deletes the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateInstallationToken creates a new installation token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-an-installation-access-token-for-an-app
|
||||||
|
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/access_tokens", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(InstallationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateAttachment creates a new attachment on user comment containing a url.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-a-content-attachment
|
||||||
|
func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
|
||||||
|
payload := &Attachment{Title: String(title), Body: String(body)}
|
||||||
|
req, err := s.client.NewRequest("POST", u, payload)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeContentAttachmentsPreview)
|
||||||
|
|
||||||
|
m := &Attachment{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindOrganizationInstallation finds the organization's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-organization-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("orgs/%v/installation", org))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindRepositoryInstallation finds the repository's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-a-repository-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, repo string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindRepositoryInstallationByID finds the repository's installation information.
|
||||||
|
//
|
||||||
|
// Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint /repositories/:id/installation.
|
||||||
|
func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindUserInstallation finds the user's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-a-user-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("users/%v/installation", user))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AppsService) getInstallation(ctx context.Context, url string) (*Installation, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Installation)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
128
vendor/github.com/google/go-github/v39/github/apps_installation.go
generated
vendored
Normal file
128
vendor/github.com/google/go-github/v39/github/apps_installation.go
generated
vendored
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRepositories represents the response from the list repos endpoints.
|
||||||
|
type ListRepositories struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepos lists the repositories that are accessible to the authenticated installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-repositories-accessible-to-the-app-installation
|
||||||
|
func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u, err := addOptions("installation/repositories", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
acceptHeaders := []string{
|
||||||
|
mediaTypeTopicsPreview,
|
||||||
|
mediaTypeRepositoryVisibilityPreview,
|
||||||
|
mediaTypeRepositoryTemplatePreview,
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var r *ListRepositories
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserRepos lists repositories that are accessible
|
||||||
|
// to the authenticated user for an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-repositories-accessible-to-the-user-access-token
|
||||||
|
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
acceptHeaders := []string{
|
||||||
|
mediaTypeTopicsPreview,
|
||||||
|
mediaTypeRepositoryVisibilityPreview,
|
||||||
|
mediaTypeRepositoryTemplatePreview,
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var r *ListRepositories
|
||||||
|
resp, err := s.client.Do(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRepository adds a single repository to an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#add-a-repository-to-an-app-installation
|
||||||
|
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := new(Repository)
|
||||||
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRepository removes a single repository from an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#remove-a-repository-from-an-app-installation
|
||||||
|
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeInstallationToken revokes an installation token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#revoke-an-installation-access-token
|
||||||
|
func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, error) {
|
||||||
|
u := "installation/token"
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
49
vendor/github.com/google/go-github/v39/github/apps_manifest.go
generated
vendored
Normal file
49
vendor/github.com/google/go-github/v39/github/apps_manifest.go
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
// Copyright 2019 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppConfig describes the configuration of a GitHub App.
|
||||||
|
type AppConfig struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
ExternalURL *string `json:"external_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
ClientSecret *string `json:"client_secret,omitempty"`
|
||||||
|
WebhookSecret *string `json:"webhook_secret,omitempty"`
|
||||||
|
PEM *string `json:"pem,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompleteAppManifest completes the App manifest handshake flow for the given
|
||||||
|
// code.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-a-github-app-from-a-manifest
|
||||||
|
func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app-manifests/%s/conversions", code)
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := new(AppConfig)
|
||||||
|
resp, err := s.client.Do(ctx, req, cfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg, resp, nil
|
||||||
|
}
|
180
vendor/github.com/google/go-github/v39/github/apps_marketplace.go
generated
vendored
Normal file
180
vendor/github.com/google/go-github/v39/github/apps_marketplace.go
generated
vendored
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MarketplaceService handles communication with the marketplace related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#marketplace
|
||||||
|
type MarketplaceService struct {
|
||||||
|
client *Client
|
||||||
|
// Stubbed controls whether endpoints that return stubbed data are used
|
||||||
|
// instead of production endpoints. Stubbed data is fake data that's useful
|
||||||
|
// for testing your GitHub Apps. Stubbed data is hard-coded and will not
|
||||||
|
// change based on actual subscriptions.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#testing-with-stubbed-endpoints
|
||||||
|
Stubbed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePlan represents a GitHub Apps Marketplace Listing Plan.
|
||||||
|
type MarketplacePlan struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
AccountsURL *string `json:"accounts_url,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"`
|
||||||
|
YearlyPriceInCents *int `json:"yearly_price_in_cents,omitempty"`
|
||||||
|
// The pricing model for this listing. Can be one of "flat-rate", "per-unit", or "free".
|
||||||
|
PriceModel *string `json:"price_model,omitempty"`
|
||||||
|
UnitName *string `json:"unit_name,omitempty"`
|
||||||
|
Bullets *[]string `json:"bullets,omitempty"`
|
||||||
|
// State can be one of the values "draft" or "published".
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
HasFreeTrial *bool `json:"has_free_trial,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePurchase represents a GitHub Apps Marketplace Purchase.
|
||||||
|
type MarketplacePurchase struct {
|
||||||
|
// BillingCycle can be one of the values "yearly", "monthly" or nil.
|
||||||
|
BillingCycle *string `json:"billing_cycle,omitempty"`
|
||||||
|
NextBillingDate *Timestamp `json:"next_billing_date,omitempty"`
|
||||||
|
UnitCount *int `json:"unit_count,omitempty"`
|
||||||
|
Plan *MarketplacePlan `json:"plan,omitempty"`
|
||||||
|
OnFreeTrial *bool `json:"on_free_trial,omitempty"`
|
||||||
|
FreeTrialEndsOn *Timestamp `json:"free_trial_ends_on,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePendingChange represents a pending change to a GitHub Apps Marketplace Plan.
|
||||||
|
type MarketplacePendingChange struct {
|
||||||
|
EffectiveDate *Timestamp `json:"effective_date,omitempty"`
|
||||||
|
UnitCount *int `json:"unit_count,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Plan *MarketplacePlan `json:"plan,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePlanAccount represents a GitHub Account (user or organization) on a specific plan.
|
||||||
|
type MarketplacePlanAccount struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"`
|
||||||
|
MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase,omitempty"`
|
||||||
|
MarketplacePendingChange *MarketplacePendingChange `json:"marketplace_pending_change,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPlans lists all plans for your Marketplace listing.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-plans
|
||||||
|
func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) {
|
||||||
|
uri := s.marketplaceURI("plans")
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var plans []*MarketplacePlan
|
||||||
|
resp, err := s.client.Do(ctx, req, &plans)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return plans, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/apps#list-accounts-for-a-plan
|
||||||
|
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
|
||||||
|
uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID))
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var accounts []*MarketplacePlanAccount
|
||||||
|
resp, err := s.client.Do(ctx, req, &accounts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accounts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPlanAccountForAccount get GitHub account (user or organization) associated with an account.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/apps#get-a-subscription-plan-for-an-account
|
||||||
|
func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) {
|
||||||
|
uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID))
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", uri, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var account *MarketplacePlanAccount
|
||||||
|
resp, err := s.client.Do(ctx, req, &account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return account, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-subscriptions-for-the-authenticated-user-stubbed
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-subscriptions-for-the-authenticated-user
|
||||||
|
func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) {
|
||||||
|
uri := "user/marketplace_purchases"
|
||||||
|
if s.Stubbed {
|
||||||
|
uri = "user/marketplace_purchases/stubbed"
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var purchases []*MarketplacePurchase
|
||||||
|
resp, err := s.client.Do(ctx, req, &purchases)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
return purchases, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MarketplaceService) marketplaceURI(endpoint string) string {
|
||||||
|
url := "marketplace_listing"
|
||||||
|
if s.Stubbed {
|
||||||
|
url = "marketplace_listing/stubbed"
|
||||||
|
}
|
||||||
|
return url + "/" + endpoint
|
||||||
|
}
|
281
vendor/github.com/google/go-github/v39/github/authorizations.go
generated
vendored
Normal file
281
vendor/github.com/google/go-github/v39/github/authorizations.go
generated
vendored
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
// Copyright 2015 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Scope models a GitHub authorization scope.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth/#scopes
|
||||||
|
type Scope string
|
||||||
|
|
||||||
|
// This is the set of scopes for GitHub API V3
|
||||||
|
const (
|
||||||
|
ScopeNone Scope = "(no scope)" // REVISIT: is this actually returned, or just a documentation artifact?
|
||||||
|
ScopeUser Scope = "user"
|
||||||
|
ScopeUserEmail Scope = "user:email"
|
||||||
|
ScopeUserFollow Scope = "user:follow"
|
||||||
|
ScopePublicRepo Scope = "public_repo"
|
||||||
|
ScopeRepo Scope = "repo"
|
||||||
|
ScopeRepoDeployment Scope = "repo_deployment"
|
||||||
|
ScopeRepoStatus Scope = "repo:status"
|
||||||
|
ScopeDeleteRepo Scope = "delete_repo"
|
||||||
|
ScopeNotifications Scope = "notifications"
|
||||||
|
ScopeGist Scope = "gist"
|
||||||
|
ScopeReadRepoHook Scope = "read:repo_hook"
|
||||||
|
ScopeWriteRepoHook Scope = "write:repo_hook"
|
||||||
|
ScopeAdminRepoHook Scope = "admin:repo_hook"
|
||||||
|
ScopeAdminOrgHook Scope = "admin:org_hook"
|
||||||
|
ScopeReadOrg Scope = "read:org"
|
||||||
|
ScopeWriteOrg Scope = "write:org"
|
||||||
|
ScopeAdminOrg Scope = "admin:org"
|
||||||
|
ScopeReadPublicKey Scope = "read:public_key"
|
||||||
|
ScopeWritePublicKey Scope = "write:public_key"
|
||||||
|
ScopeAdminPublicKey Scope = "admin:public_key"
|
||||||
|
ScopeReadGPGKey Scope = "read:gpg_key"
|
||||||
|
ScopeWriteGPGKey Scope = "write:gpg_key"
|
||||||
|
ScopeAdminGPGKey Scope = "admin:gpg_key"
|
||||||
|
ScopeSecurityEvents Scope = "security_events"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthorizationsService handles communication with the authorization related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// This service requires HTTP Basic Authentication; it cannot be accessed using
|
||||||
|
// an OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth_authorizations/
|
||||||
|
type AuthorizationsService service
|
||||||
|
|
||||||
|
// Authorization represents an individual GitHub authorization.
|
||||||
|
type Authorization struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Scopes []Scope `json:"scopes,omitempty"`
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
TokenLastEight *string `json:"token_last_eight,omitempty"`
|
||||||
|
HashedToken *string `json:"hashed_token,omitempty"`
|
||||||
|
App *AuthorizationApp `json:"app,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
|
||||||
|
// User is only populated by the Check and Reset methods.
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a Authorization) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationApp represents an individual GitHub app (in the context of authorization).
|
||||||
|
type AuthorizationApp struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationApp) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grant represents an OAuth application that has been granted access to an account.
|
||||||
|
type Grant struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
App *AuthorizationApp `json:"app,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Grant) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationRequest represents a request to create an authorization.
|
||||||
|
type AuthorizationRequest struct {
|
||||||
|
Scopes []Scope `json:"scopes,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
ClientSecret *string `json:"client_secret,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationRequest) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationUpdateRequest represents a request to update an authorization.
|
||||||
|
//
|
||||||
|
// Note that for any one update, you must only provide one of the "scopes"
|
||||||
|
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
|
||||||
|
// "RemoveScopes".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth_authorizations/#update-an-existing-authorization
|
||||||
|
type AuthorizationUpdateRequest struct {
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
AddScopes []string `json:"add_scopes,omitempty"`
|
||||||
|
RemoveScopes []string `json:"remove_scopes,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationUpdateRequest) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if an OAuth token is valid for a specific app.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// The returned Authorization.User field will be populated.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#check-a-token
|
||||||
|
func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset is used to reset a valid OAuth token without end user involvement.
|
||||||
|
// Applications must save the "token" property in the response, because changes
|
||||||
|
// take effect immediately.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// The returned Authorization.User field will be populated.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#reset-a-token
|
||||||
|
func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Revoke an authorization for an application.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-app-token
|
||||||
|
func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGrant deletes an OAuth application grant. Deleting an application's
|
||||||
|
// grant will also delete all OAuth tokens associated with the application for
|
||||||
|
// the user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-app-authorization
|
||||||
|
func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/grant", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateImpersonation creates an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// This requires admin permissions. With the returned Authorization.Token
|
||||||
|
// you can e.g. create or delete a user's public SSH key. NOTE: creating a
|
||||||
|
// new token automatically revokes an existing one.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
||||||
|
func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||||
|
req, err := s.client.NewRequest("POST", u, authReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteImpersonation deletes an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// NOTE: there can be only one at a time.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
||||||
|
func (s *AuthorizationsService) DeleteImpersonation(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
131
vendor/github.com/google/go-github/v39/github/billing.go
generated
vendored
Normal file
131
vendor/github.com/google/go-github/v39/github/billing.go
generated
vendored
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
// Copyright 2021 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BillingService provides access to the billing related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing
|
||||||
|
type BillingService service
|
||||||
|
|
||||||
|
// ActionBilling represents a GitHub Action billing.
|
||||||
|
type ActionBilling struct {
|
||||||
|
TotalMinutesUsed int `json:"total_minutes_used"`
|
||||||
|
TotalPaidMinutesUsed int `json:"total_paid_minutes_used"`
|
||||||
|
IncludedMinutes int `json:"included_minutes"`
|
||||||
|
MinutesUsedBreakdown MinutesUsedBreakdown `json:"minutes_used_breakdown"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MinutesUsedBreakdown struct {
|
||||||
|
Ubuntu int `json:"UBUNTU"`
|
||||||
|
MacOS int `json:"MACOS"`
|
||||||
|
Windows int `json:"WINDOWS"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PackageBilling represents a GitHub Package billing.
|
||||||
|
type PackageBilling struct {
|
||||||
|
TotalGigabytesBandwidthUsed int `json:"total_gigabytes_bandwidth_used"`
|
||||||
|
TotalPaidGigabytesBandwidthUsed int `json:"total_paid_gigabytes_bandwidth_used"`
|
||||||
|
IncludedGigabytesBandwidth int `json:"included_gigabytes_bandwidth"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageBilling represents a GitHub Storage billing.
|
||||||
|
type StorageBilling struct {
|
||||||
|
DaysLeftInBillingCycle int `json:"days_left_in_billing_cycle"`
|
||||||
|
EstimatedPaidStorageForMonth int `json:"estimated_paid_storage_for_month"`
|
||||||
|
EstimatedStorageForMonth int `json:"estimated_storage_for_month"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsBillingOrg returns the summary of the free and paid GitHub Actions minutes used for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/actions", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
actionsOrgBilling := new(ActionBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, actionsOrgBilling)
|
||||||
|
return actionsOrgBilling, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPackagesBillingOrg returns the free and paid storage used for GitHub Packages in gigabytes for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-packages-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/packages", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
packagesOrgBilling := new(PackageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, packagesOrgBilling)
|
||||||
|
return packagesOrgBilling, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStorageBillingOrg returns the estimated paid and estimated total storage used for GitHub Actions
|
||||||
|
// and GitHub Packages in gigabytes for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-shared-storage-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
storageOrgBilling := new(StorageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, storageOrgBilling)
|
||||||
|
return storageOrgBilling, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsBillingUser returns the summary of the free and paid GitHub Actions minutes used for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-a-user
|
||||||
|
func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/actions", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
actionsUserBilling := new(ActionBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, actionsUserBilling)
|
||||||
|
return actionsUserBilling, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPackagesBillingUser returns the free and paid storage used for GitHub Packages in gigabytes for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-packages-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/packages", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
packagesUserBilling := new(PackageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, packagesUserBilling)
|
||||||
|
return packagesUserBilling, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStorageBillingUser returns the estimated paid and estimated total storage used for GitHub Actions
|
||||||
|
// and GitHub Packages in gigabytes for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-shared-storage-billing-for-a-user
|
||||||
|
func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
storageUserBilling := new(StorageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, storageUserBilling)
|
||||||
|
return storageUserBilling, resp, err
|
||||||
|
}
|
412
vendor/github.com/google/go-github/v39/github/checks.go
generated
vendored
Normal file
412
vendor/github.com/google/go-github/v39/github/checks.go
generated
vendored
Normal file
|
@ -0,0 +1,412 @@
|
||||||
|
// Copyright 2018 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChecksService provides access to the Checks API in the
|
||||||
|
// GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/
|
||||||
|
type ChecksService service
|
||||||
|
|
||||||
|
// CheckRun represents a GitHub check run on a repository associated with a GitHub app.
|
||||||
|
type CheckRun struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
ExternalID *string `json:"external_id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
CheckSuite *CheckSuite `json:"check_suite,omitempty"`
|
||||||
|
App *App `json:"app,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunOutput represents the output of a CheckRun.
|
||||||
|
type CheckRunOutput struct {
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Summary *string `json:"summary,omitempty"`
|
||||||
|
Text *string `json:"text,omitempty"`
|
||||||
|
AnnotationsCount *int `json:"annotations_count,omitempty"`
|
||||||
|
AnnotationsURL *string `json:"annotations_url,omitempty"`
|
||||||
|
Annotations []*CheckRunAnnotation `json:"annotations,omitempty"`
|
||||||
|
Images []*CheckRunImage `json:"images,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunAnnotation represents an annotation object for a CheckRun output.
|
||||||
|
type CheckRunAnnotation struct {
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
StartLine *int `json:"start_line,omitempty"`
|
||||||
|
EndLine *int `json:"end_line,omitempty"`
|
||||||
|
StartColumn *int `json:"start_column,omitempty"`
|
||||||
|
EndColumn *int `json:"end_column,omitempty"`
|
||||||
|
AnnotationLevel *string `json:"annotation_level,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
RawDetails *string `json:"raw_details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunImage represents an image object for a CheckRun output.
|
||||||
|
type CheckRunImage struct {
|
||||||
|
Alt *string `json:"alt,omitempty"`
|
||||||
|
ImageURL *string `json:"image_url,omitempty"`
|
||||||
|
Caption *string `json:"caption,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuite represents a suite of check runs.
|
||||||
|
type CheckSuite struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
BeforeSHA *string `json:"before,omitempty"`
|
||||||
|
AfterSHA *string `json:"after,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
App *App `json:"app,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
|
||||||
|
// The following fields are only populated by Webhook events.
|
||||||
|
HeadCommit *Commit `json:"head_commit,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CheckRun) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CheckSuite) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCheckRun gets a check-run for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#get-a-check-run
|
||||||
|
func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCheckSuite gets a single check suite.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#get-a-check-suite
|
||||||
|
func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v", owner, repo, checkSuiteID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSuite := new(CheckSuite)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkSuite)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuite, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckRunOptions sets up parameters needed to create a CheckRun.
|
||||||
|
type CreateCheckRunOptions struct {
|
||||||
|
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
|
||||||
|
HeadSHA string `json:"head_sha"` // The SHA of the commit. (Required.)
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
|
||||||
|
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
|
||||||
|
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "skipped", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"` // The time that the check run began. (Optional.)
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
|
||||||
|
Actions []*CheckRunAction `json:"actions,omitempty"` // Possible further actions the integrator can perform, which a user may trigger. (Optional.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunAction exposes further actions the integrator can perform, which a user may trigger.
|
||||||
|
type CheckRunAction struct {
|
||||||
|
Label string `json:"label"` // The text to be displayed on a button in the web UI. The maximum size is 20 characters. (Required.)
|
||||||
|
Description string `json:"description"` // A short explanation of what this action would do. The maximum size is 40 characters. (Required.)
|
||||||
|
Identifier string `json:"identifier"` // A reference for the action on the integrator's system. The maximum size is 20 characters. (Required.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckRun creates a check run for repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#create-a-check-run
|
||||||
|
func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCheckRunOptions sets up parameters needed to update a CheckRun.
|
||||||
|
type UpdateCheckRunOptions struct {
|
||||||
|
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
|
||||||
|
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
|
||||||
|
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "skipped", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
|
||||||
|
Actions []*CheckRunAction `json:"actions,omitempty"` // Possible further actions the integrator can perform, which a user may trigger. (Optional.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCheckRun updates a check run for a specific commit in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#update-a-check-run
|
||||||
|
func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunAnnotations lists the annotations for a check run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-run-annotations
|
||||||
|
func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/annotations", owner, repo, checkRunID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkRunAnnotations []*CheckRunAnnotation
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunAnnotations)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunAnnotations, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsOptions represents parameters to list check runs.
|
||||||
|
type ListCheckRunsOptions struct {
|
||||||
|
CheckName *string `url:"check_name,omitempty"` // Returns check runs with the specified name.
|
||||||
|
Status *string `url:"status,omitempty"` // Returns check runs with the specified status. Can be one of "queued", "in_progress", or "completed".
|
||||||
|
Filter *string `url:"filter,omitempty"` // Filters check runs by their completed_at timestamp. Can be one of "latest" (returning the most recent check runs) or "all". Default: "latest"
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsResults represents the result of a check run list.
|
||||||
|
type ListCheckRunsResults struct {
|
||||||
|
Total *int `json:"total_count,omitempty"`
|
||||||
|
CheckRuns []*CheckRun `json:"check_runs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsForRef lists check runs for a specific ref.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-runs-for-a-git-reference
|
||||||
|
func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkRunResults *ListCheckRunsResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsCheckSuite lists check runs for a check suite.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-runs-in-a-check-suite
|
||||||
|
func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/check-runs", owner, repo, checkSuiteID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkRunResults *ListCheckRunsResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuiteOptions represents parameters to list check suites.
|
||||||
|
type ListCheckSuiteOptions struct {
|
||||||
|
CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run.
|
||||||
|
AppID *int `url:"app_id,omitempty"` // Filters check suites by GitHub App id.
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuiteResults represents the result of a check run list.
|
||||||
|
type ListCheckSuiteResults struct {
|
||||||
|
Total *int `json:"total_count,omitempty"`
|
||||||
|
CheckSuites []*CheckSuite `json:"check_suites,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuitesForRef lists check suite for a specific ref.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-suites-for-a-git-reference
|
||||||
|
func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkSuiteResults *ListCheckSuiteResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkSuiteResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuiteResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoTriggerCheck enables or disables automatic creation of CheckSuite events upon pushes to the repository.
|
||||||
|
type AutoTriggerCheck struct {
|
||||||
|
AppID *int64 `json:"app_id,omitempty"` // The id of the GitHub App. (Required.)
|
||||||
|
Setting *bool `json:"setting,omitempty"` // Set to "true" to enable automatic creation of CheckSuite events upon pushes to the repository, or "false" to disable them. Default: "true" (Required.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuitePreferenceOptions set options for check suite preferences for a repository.
|
||||||
|
type CheckSuitePreferenceOptions struct {
|
||||||
|
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuitePreferenceResults represents the results of the preference set operation.
|
||||||
|
type CheckSuitePreferenceResults struct {
|
||||||
|
Preferences *PreferenceList `json:"preferences,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferenceList represents a list of auto trigger checks for repository
|
||||||
|
type PreferenceList struct {
|
||||||
|
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCheckSuitePreferences changes the default automatic flow when creating check suites.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#update-repository-preferences-for-check-suites
|
||||||
|
func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, repo string, opts CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/preferences", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkSuitePrefResults *CheckSuitePreferenceResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkSuitePrefResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuitePrefResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckSuiteOptions sets up parameters to manually create a check suites
|
||||||
|
type CreateCheckSuiteOptions struct {
|
||||||
|
HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.)
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"` // The name of the head branch where the code changes are implemented.
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckSuite manually creates a check suite for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#create-a-check-suite
|
||||||
|
func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSuite := new(CheckSuite)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkSuite)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuite, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#rerequest-a-check-suite
|
||||||
|
func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
return resp, err
|
||||||
|
}
|
173
vendor/github.com/google/go-github/v39/github/code-scanning.go
generated
vendored
Normal file
173
vendor/github.com/google/go-github/v39/github/code-scanning.go
generated
vendored
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CodeScanningService handles communication with the code scanning related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/
|
||||||
|
type CodeScanningService service
|
||||||
|
|
||||||
|
// Rule represents the complete details of GitHub Code Scanning alert type.
|
||||||
|
type Rule struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Severity *string `json:"severity,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
SecuritySeverityLevel *string `json:"security_severity_level,omitempty"`
|
||||||
|
FullDescription *string `json:"full_description,omitempty"`
|
||||||
|
Tags []string `json:"tags,omitempty"`
|
||||||
|
Help *string `json:"help,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Location represents the exact location of the GitHub Code Scanning Alert in the scanned project.
|
||||||
|
type Location struct {
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
StartLine *int `json:"start_line,omitempty"`
|
||||||
|
EndLine *int `json:"end_line,omitempty"`
|
||||||
|
StartColumn *int `json:"start_column,omitempty"`
|
||||||
|
EndColumn *int `json:"end_column,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object.
|
||||||
|
type Message struct {
|
||||||
|
Text *string `json:"text,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference.
|
||||||
|
type MostRecentInstance struct {
|
||||||
|
Ref *string `json:"ref,omitempty"`
|
||||||
|
AnalysisKey *string `json:"analysis_key,omitempty"`
|
||||||
|
Environment *string `json:"environment,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
CommitSHA *string `json:"commit_sha,omitempty"`
|
||||||
|
Message *Message `json:"message,omitempty"`
|
||||||
|
Location *Location `json:"location,omitempty"`
|
||||||
|
Classifications []string `json:"classifications,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tool represents the tool used to generate a GitHub Code Scanning Alert.
|
||||||
|
type Tool struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
GUID *string `json:"guid,omitempty"`
|
||||||
|
Version *string `json:"version,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alert represents an individual GitHub Code Scanning Alert on a single repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository
|
||||||
|
type Alert struct {
|
||||||
|
RuleID *string `json:"rule_id,omitempty"`
|
||||||
|
RuleSeverity *string `json:"rule_severity,omitempty"`
|
||||||
|
RuleDescription *string `json:"rule_description,omitempty"`
|
||||||
|
Rule *Rule `json:"rule,omitempty"`
|
||||||
|
Tool *Tool `json:"tool,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
ClosedBy *User `json:"closed_by,omitempty"`
|
||||||
|
ClosedAt *Timestamp `json:"closed_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"`
|
||||||
|
DismissedBy *User `json:"dismissed_by,omitempty"`
|
||||||
|
DismissedAt *Timestamp `json:"dismissed_at,omitempty"`
|
||||||
|
DismissedReason *string `json:"dismissed_reason,omitempty"`
|
||||||
|
InstancesURL *string `json:"instances_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID returns the ID associated with an alert. It is the number at the end of the security alert's URL.
|
||||||
|
func (a *Alert) ID() int64 {
|
||||||
|
if a == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
s := a.GetHTMLURL()
|
||||||
|
|
||||||
|
// Check for an ID to parse at the end of the url
|
||||||
|
if i := strings.LastIndex(s, "/"); i >= 0 {
|
||||||
|
s = s[i+1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the alert ID as a 64-bit integer. Unable to convert or out of range returns 0.
|
||||||
|
id, err := strconv.ParseInt(s, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlertListOptions specifies optional parameters to the CodeScanningService.ListAlerts
|
||||||
|
// method.
|
||||||
|
type AlertListOptions struct {
|
||||||
|
// State of the code scanning alerts to list. Set to closed to list only closed code scanning alerts. Default: open
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Return code scanning alerts for a specific branch reference. The ref must be formatted as heads/<branch name>.
|
||||||
|
Ref string `url:"ref,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAlertsForRepo lists code scanning alerts for a repository.
|
||||||
|
//
|
||||||
|
// Lists all open code scanning alerts for the default branch (usually master) and protected branches in a repository.
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events
|
||||||
|
// read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#list-code-scanning-alerts-for-a-repository
|
||||||
|
func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *AlertListOptions) ([]*Alert, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var alerts []*Alert
|
||||||
|
resp, err := s.client.Do(ctx, req, &alerts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return alerts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAlert gets a single code scanning alert for a repository.
|
||||||
|
//
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint.
|
||||||
|
// GitHub Apps must have the security_events read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// The security alert_id is the number at the end of the security alert's URL.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#get-a-code-scanning-alert
|
||||||
|
func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string, id int64) (*Alert, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(Alert)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
188
vendor/github.com/google/go-github/v39/github/doc.go
generated
vendored
Normal file
188
vendor/github.com/google/go-github/v39/github/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package github provides a client for using the GitHub API.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
import "github.com/google/go-github/v39/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
|
||||||
|
import "github.com/google/go-github/github" // with go modules disabled
|
||||||
|
|
||||||
|
Construct a new GitHub client, then use the various services on the client to
|
||||||
|
access different parts of the GitHub API. For example:
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
// list all organizations for user "willnorris"
|
||||||
|
orgs, _, err := client.Organizations.List(ctx, "willnorris", nil)
|
||||||
|
|
||||||
|
Some API methods have optional parameters that can be passed. For example:
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
// list public repositories for org "github"
|
||||||
|
opt := &github.RepositoryListByOrgOptions{Type: "public"}
|
||||||
|
repos, _, err := client.Repositories.ListByOrg(ctx, "github", opt)
|
||||||
|
|
||||||
|
The services of a client divide the API into logical chunks and correspond to
|
||||||
|
the structure of the GitHub API documentation at
|
||||||
|
https://docs.github.com/en/free-pro-team@latest/rest/reference/.
|
||||||
|
|
||||||
|
NOTE: Using the https://godoc.org/context package, one can easily
|
||||||
|
pass cancelation signals and deadlines to various services of the client for
|
||||||
|
handling a request. In case there is no context available, then context.Background()
|
||||||
|
can be used as a starting point.
|
||||||
|
|
||||||
|
For more sample code snippets, head over to the https://github.com/google/go-github/tree/master/example directory.
|
||||||
|
|
||||||
|
Authentication
|
||||||
|
|
||||||
|
The go-github library does not directly handle authentication. Instead, when
|
||||||
|
creating a new client, pass an http.Client that can handle authentication for
|
||||||
|
you. The easiest and recommended way to do this is using the golang.org/x/oauth2
|
||||||
|
library, but you can always use any other library that provides an http.Client.
|
||||||
|
If you have an OAuth2 access token (for example, a personal API token), you can
|
||||||
|
use it with the oauth2 library using:
|
||||||
|
|
||||||
|
import "golang.org/x/oauth2"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ctx := context.Background()
|
||||||
|
ts := oauth2.StaticTokenSource(
|
||||||
|
&oauth2.Token{AccessToken: "... your access token ..."},
|
||||||
|
)
|
||||||
|
tc := oauth2.NewClient(ctx, ts)
|
||||||
|
|
||||||
|
client := github.NewClient(tc)
|
||||||
|
|
||||||
|
// list all repositories for the authenticated user
|
||||||
|
repos, _, err := client.Repositories.List(ctx, "", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
Note that when using an authenticated Client, all calls made by the client will
|
||||||
|
include the specified OAuth token. Therefore, authenticated clients should
|
||||||
|
almost never be shared between different users.
|
||||||
|
|
||||||
|
See the oauth2 docs for complete instructions on using that library.
|
||||||
|
|
||||||
|
For API methods that require HTTP Basic Authentication, use the
|
||||||
|
BasicAuthTransport.
|
||||||
|
|
||||||
|
GitHub Apps authentication can be provided by the
|
||||||
|
https://github.com/bradleyfalzon/ghinstallation package.
|
||||||
|
|
||||||
|
import "github.com/bradleyfalzon/ghinstallation"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
|
||||||
|
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, 1, 99, "2016-10-19.private-key.pem")
|
||||||
|
if err != nil {
|
||||||
|
// Handle error.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use installation transport with client
|
||||||
|
client := github.NewClient(&http.Client{Transport: itr})
|
||||||
|
|
||||||
|
// Use client...
|
||||||
|
}
|
||||||
|
|
||||||
|
Rate Limiting
|
||||||
|
|
||||||
|
GitHub imposes a rate limit on all API clients. Unauthenticated clients are
|
||||||
|
limited to 60 requests per hour, while authenticated clients can make up to
|
||||||
|
5,000 requests per hour. The Search API has a custom rate limit. Unauthenticated
|
||||||
|
clients are limited to 10 requests per minute, while authenticated clients
|
||||||
|
can make up to 30 requests per minute. To receive the higher rate limit when
|
||||||
|
making calls that are not issued on behalf of a user,
|
||||||
|
use UnauthenticatedRateLimitedTransport.
|
||||||
|
|
||||||
|
The returned Response.Rate value contains the rate limit information
|
||||||
|
from the most recent API call. If a recent enough response isn't
|
||||||
|
available, you can use RateLimits to fetch the most up-to-date rate
|
||||||
|
limit data for the client.
|
||||||
|
|
||||||
|
To detect an API rate limit error, you can check if its type is *github.RateLimitError:
|
||||||
|
|
||||||
|
repos, _, err := client.Repositories.List(ctx, "", nil)
|
||||||
|
if _, ok := err.(*github.RateLimitError); ok {
|
||||||
|
log.Println("hit rate limit")
|
||||||
|
}
|
||||||
|
|
||||||
|
Learn more about GitHub rate limiting at
|
||||||
|
https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#rate-limiting.
|
||||||
|
|
||||||
|
Accepted Status
|
||||||
|
|
||||||
|
Some endpoints may return a 202 Accepted status code, meaning that the
|
||||||
|
information required is not yet ready and was scheduled to be gathered on
|
||||||
|
the GitHub side. Methods known to behave like this are documented specifying
|
||||||
|
this behavior.
|
||||||
|
|
||||||
|
To detect this condition of error, you can check if its type is
|
||||||
|
*github.AcceptedError:
|
||||||
|
|
||||||
|
stats, _, err := client.Repositories.ListContributorsStats(ctx, org, repo)
|
||||||
|
if _, ok := err.(*github.AcceptedError); ok {
|
||||||
|
log.Println("scheduled on GitHub side")
|
||||||
|
}
|
||||||
|
|
||||||
|
Conditional Requests
|
||||||
|
|
||||||
|
The GitHub API has good support for conditional requests which will help
|
||||||
|
prevent you from burning through your rate limit, as well as help speed up your
|
||||||
|
application. go-github does not handle conditional requests directly, but is
|
||||||
|
instead designed to work with a caching http.Transport. We recommend using
|
||||||
|
https://github.com/gregjones/httpcache for that.
|
||||||
|
|
||||||
|
Learn more about GitHub conditional requests at
|
||||||
|
https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#conditional-requests.
|
||||||
|
|
||||||
|
Creating and Updating Resources
|
||||||
|
|
||||||
|
All structs for GitHub resources use pointer values for all non-repeated fields.
|
||||||
|
This allows distinguishing between unset fields and those set to a zero-value.
|
||||||
|
Helper functions have been provided to easily create these pointers for string,
|
||||||
|
bool, and int values. For example:
|
||||||
|
|
||||||
|
// create a new private repository named "foo"
|
||||||
|
repo := &github.Repository{
|
||||||
|
Name: github.String("foo"),
|
||||||
|
Private: github.Bool(true),
|
||||||
|
}
|
||||||
|
client.Repositories.Create(ctx, "", repo)
|
||||||
|
|
||||||
|
Users who have worked with protocol buffers should find this pattern familiar.
|
||||||
|
|
||||||
|
Pagination
|
||||||
|
|
||||||
|
All requests for resource collections (repos, pull requests, issues, etc.)
|
||||||
|
support pagination. Pagination options are described in the
|
||||||
|
github.ListOptions struct and passed to the list methods directly or as an
|
||||||
|
embedded type of a more specific list options struct (for example
|
||||||
|
github.PullRequestListOptions). Pages information is available via the
|
||||||
|
github.Response struct.
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
opt := &github.RepositoryListByOrgOptions{
|
||||||
|
ListOptions: github.ListOptions{PerPage: 10},
|
||||||
|
}
|
||||||
|
// get all pages of results
|
||||||
|
var allRepos []*github.Repository
|
||||||
|
for {
|
||||||
|
repos, resp, err := client.Repositories.ListByOrg(ctx, "github", opt)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allRepos = append(allRepos, repos...)
|
||||||
|
if resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
opt.Page = resp.NextPage
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
package github
|
12
vendor/github.com/google/go-github/v39/github/enterprise.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v39/github/enterprise.go
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// EnterpriseService provides access to the enterprise related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/
|
||||||
|
type EnterpriseService service
|
69
vendor/github.com/google/go-github/v39/github/enterprise_actions_runners.go
generated
vendored
Normal file
69
vendor/github.com/google/go-github/v39/github/enterprise_actions_runners.go
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#create-a-registration-token-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners/registration-token", enterprise)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunners lists all the self-hosted runners for a enterprise.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#list-self-hosted-runners-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunner forces the removal of a self-hosted runner from an enterprise using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#delete-a-self-hosted-runner-from-an-enterprise
|
||||||
|
func (s *EnterpriseService) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners/%v", enterprise, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
35
vendor/github.com/google/go-github/v39/github/enterprise_audit_log.go
generated
vendored
Normal file
35
vendor/github.com/google/go-github/v39/github/enterprise_audit_log.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2021 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetAuditLog gets the audit-log entries for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/reference/enterprise-admin#get-the-audit-log-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/audit-log", enterprise)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var auditEntries []*AuditEntry
|
||||||
|
resp, err := s.client.Do(ctx, req, &auditEntries)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return auditEntries, resp, nil
|
||||||
|
}
|
150
vendor/github.com/google/go-github/v39/github/event.go
generated
vendored
Normal file
150
vendor/github.com/google/go-github/v39/github/event.go
generated
vendored
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
// Copyright 2018 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Event represents a GitHub event.
|
||||||
|
type Event struct {
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Public *bool `json:"public,omitempty"`
|
||||||
|
RawPayload *json.RawMessage `json:"payload,omitempty"`
|
||||||
|
Repo *Repository `json:"repo,omitempty"`
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
Org *Organization `json:"org,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Event) String() string {
|
||||||
|
return Stringify(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParsePayload parses the event payload. For recognized event types,
|
||||||
|
// a value of the corresponding struct type will be returned.
|
||||||
|
func (e *Event) ParsePayload() (payload interface{}, err error) {
|
||||||
|
switch *e.Type {
|
||||||
|
case "BranchProtectionRuleEvent":
|
||||||
|
payload = &BranchProtectionRuleEvent{}
|
||||||
|
case "CheckRunEvent":
|
||||||
|
payload = &CheckRunEvent{}
|
||||||
|
case "CheckSuiteEvent":
|
||||||
|
payload = &CheckSuiteEvent{}
|
||||||
|
case "CommitCommentEvent":
|
||||||
|
payload = &CommitCommentEvent{}
|
||||||
|
case "ContentReferenceEvent":
|
||||||
|
payload = &ContentReferenceEvent{}
|
||||||
|
case "CreateEvent":
|
||||||
|
payload = &CreateEvent{}
|
||||||
|
case "DeleteEvent":
|
||||||
|
payload = &DeleteEvent{}
|
||||||
|
case "DeployKeyEvent":
|
||||||
|
payload = &DeployKeyEvent{}
|
||||||
|
case "DeploymentEvent":
|
||||||
|
payload = &DeploymentEvent{}
|
||||||
|
case "DeploymentStatusEvent":
|
||||||
|
payload = &DeploymentStatusEvent{}
|
||||||
|
case "ForkEvent":
|
||||||
|
payload = &ForkEvent{}
|
||||||
|
case "GitHubAppAuthorizationEvent":
|
||||||
|
payload = &GitHubAppAuthorizationEvent{}
|
||||||
|
case "GollumEvent":
|
||||||
|
payload = &GollumEvent{}
|
||||||
|
case "InstallationEvent":
|
||||||
|
payload = &InstallationEvent{}
|
||||||
|
case "InstallationRepositoriesEvent":
|
||||||
|
payload = &InstallationRepositoriesEvent{}
|
||||||
|
case "IssueCommentEvent":
|
||||||
|
payload = &IssueCommentEvent{}
|
||||||
|
case "IssuesEvent":
|
||||||
|
payload = &IssuesEvent{}
|
||||||
|
case "LabelEvent":
|
||||||
|
payload = &LabelEvent{}
|
||||||
|
case "MarketplacePurchaseEvent":
|
||||||
|
payload = &MarketplacePurchaseEvent{}
|
||||||
|
case "MemberEvent":
|
||||||
|
payload = &MemberEvent{}
|
||||||
|
case "MembershipEvent":
|
||||||
|
payload = &MembershipEvent{}
|
||||||
|
case "MetaEvent":
|
||||||
|
payload = &MetaEvent{}
|
||||||
|
case "MilestoneEvent":
|
||||||
|
payload = &MilestoneEvent{}
|
||||||
|
case "OrganizationEvent":
|
||||||
|
payload = &OrganizationEvent{}
|
||||||
|
case "OrgBlockEvent":
|
||||||
|
payload = &OrgBlockEvent{}
|
||||||
|
case "PackageEvent":
|
||||||
|
payload = &PackageEvent{}
|
||||||
|
case "PageBuildEvent":
|
||||||
|
payload = &PageBuildEvent{}
|
||||||
|
case "PingEvent":
|
||||||
|
payload = &PingEvent{}
|
||||||
|
case "ProjectEvent":
|
||||||
|
payload = &ProjectEvent{}
|
||||||
|
case "ProjectCardEvent":
|
||||||
|
payload = &ProjectCardEvent{}
|
||||||
|
case "ProjectColumnEvent":
|
||||||
|
payload = &ProjectColumnEvent{}
|
||||||
|
case "PublicEvent":
|
||||||
|
payload = &PublicEvent{}
|
||||||
|
case "PullRequestEvent":
|
||||||
|
payload = &PullRequestEvent{}
|
||||||
|
case "PullRequestReviewEvent":
|
||||||
|
payload = &PullRequestReviewEvent{}
|
||||||
|
case "PullRequestReviewCommentEvent":
|
||||||
|
payload = &PullRequestReviewCommentEvent{}
|
||||||
|
case "PullRequestTargetEvent":
|
||||||
|
payload = &PullRequestTargetEvent{}
|
||||||
|
case "PushEvent":
|
||||||
|
payload = &PushEvent{}
|
||||||
|
case "ReleaseEvent":
|
||||||
|
payload = &ReleaseEvent{}
|
||||||
|
case "RepositoryEvent":
|
||||||
|
payload = &RepositoryEvent{}
|
||||||
|
case "RepositoryDispatchEvent":
|
||||||
|
payload = &RepositoryDispatchEvent{}
|
||||||
|
case "RepositoryVulnerabilityAlertEvent":
|
||||||
|
payload = &RepositoryVulnerabilityAlertEvent{}
|
||||||
|
case "StarEvent":
|
||||||
|
payload = &StarEvent{}
|
||||||
|
case "StatusEvent":
|
||||||
|
payload = &StatusEvent{}
|
||||||
|
case "TeamEvent":
|
||||||
|
payload = &TeamEvent{}
|
||||||
|
case "TeamAddEvent":
|
||||||
|
payload = &TeamAddEvent{}
|
||||||
|
case "UserEvent":
|
||||||
|
payload = &UserEvent{}
|
||||||
|
case "WatchEvent":
|
||||||
|
payload = &WatchEvent{}
|
||||||
|
case "WorkflowDispatchEvent":
|
||||||
|
payload = &WorkflowDispatchEvent{}
|
||||||
|
case "WorkflowJobEvent":
|
||||||
|
payload = &WorkflowJobEvent{}
|
||||||
|
case "WorkflowRunEvent":
|
||||||
|
payload = &WorkflowRunEvent{}
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(*e.RawPayload, &payload)
|
||||||
|
return payload, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload returns the parsed event payload. For recognized event types,
|
||||||
|
// a value of the corresponding struct type will be returned.
|
||||||
|
//
|
||||||
|
// Deprecated: Use ParsePayload instead, which returns an error
|
||||||
|
// rather than panics if JSON unmarshaling raw payload fails.
|
||||||
|
func (e *Event) Payload() (payload interface{}) {
|
||||||
|
var err error
|
||||||
|
payload, err = e.ParsePayload()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return payload
|
||||||
|
}
|
1145
vendor/github.com/google/go-github/v39/github/event_types.go
generated
vendored
Normal file
1145
vendor/github.com/google/go-github/v39/github/event_types.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
364
vendor/github.com/google/go-github/v39/github/gists.go
generated
vendored
Normal file
364
vendor/github.com/google/go-github/v39/github/gists.go
generated
vendored
Normal file
|
@ -0,0 +1,364 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GistsService handles communication with the Gist related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/
|
||||||
|
type GistsService service
|
||||||
|
|
||||||
|
// Gist represents a GitHub's gist.
|
||||||
|
type Gist struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Public *bool `json:"public,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Files map[GistFilename]GistFile `json:"files,omitempty"`
|
||||||
|
Comments *int `json:"comments,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
GitPullURL *string `json:"git_pull_url,omitempty"`
|
||||||
|
GitPushURL *string `json:"git_push_url,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Gist) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistFilename represents filename on a gist.
|
||||||
|
type GistFilename string
|
||||||
|
|
||||||
|
// GistFile represents a file on a gist.
|
||||||
|
type GistFile struct {
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Filename *string `json:"filename,omitempty"`
|
||||||
|
Language *string `json:"language,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
RawURL *string `json:"raw_url,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g GistFile) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistCommit represents a commit on a gist.
|
||||||
|
type GistCommit struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Version *string `json:"version,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
ChangeStatus *CommitStats `json:"change_status,omitempty"`
|
||||||
|
CommittedAt *Timestamp `json:"committed_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gc GistCommit) String() string {
|
||||||
|
return Stringify(gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistFork represents a fork of a gist.
|
||||||
|
type GistFork struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gf GistFork) String() string {
|
||||||
|
return Stringify(gf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistListOptions specifies the optional parameters to the
|
||||||
|
// GistsService.List, GistsService.ListAll, and GistsService.ListStarred methods.
|
||||||
|
type GistListOptions struct {
|
||||||
|
// Since filters Gists by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gists for a user. Passing the empty string will list
|
||||||
|
// all public gists if called anonymously. However, if the call
|
||||||
|
// is authenticated, it will returns all gists for the authenticated
|
||||||
|
// user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gists-for-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gists-for-a-user
|
||||||
|
func (s *GistsService) List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/gists", user)
|
||||||
|
} else {
|
||||||
|
u = "gists"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAll lists all public gists.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-public-gists
|
||||||
|
func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
u, err := addOptions("gists/public", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarred lists starred gists of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-starred-gists
|
||||||
|
func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
u, err := addOptions("gists/starred", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist
|
||||||
|
func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
gist := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gist, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRevision gets a specific revision of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist-revision
|
||||||
|
func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/%v", id, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
gist := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gist, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a gist for authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist
|
||||||
|
func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) {
|
||||||
|
u := "gists"
|
||||||
|
req, err := s.client.NewRequest("POST", u, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist
|
||||||
|
func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCommits lists commits of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-commits
|
||||||
|
func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/commits", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gistCommits []*GistCommit
|
||||||
|
resp, err := s.client.Do(ctx, req, &gistCommits)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gistCommits, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist
|
||||||
|
func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Star a gist on behalf of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#star-a-gist
|
||||||
|
func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unstar a gist on a behalf of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#unstar-a-gist
|
||||||
|
func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStarred checks if a gist is starred by authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#check-if-a-gist-is-starred
|
||||||
|
func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
starred, err := parseBoolResponse(err)
|
||||||
|
return starred, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fork a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#fork-a-gist
|
||||||
|
func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/forks", id)
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForks lists forks of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-forks
|
||||||
|
func (s *GistsService) ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/forks", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gistForks []*GistFork
|
||||||
|
resp, err := s.client.Do(ctx, req, &gistForks)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gistForks, resp, nil
|
||||||
|
}
|
|
@ -6,13 +6,14 @@
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GistComment represents a Gist comment.
|
// GistComment represents a Gist comment.
|
||||||
type GistComment struct {
|
type GistComment struct {
|
||||||
ID *int `json:"id,omitempty"`
|
ID *int64 `json:"id,omitempty"`
|
||||||
URL *string `json:"url,omitempty"`
|
URL *string `json:"url,omitempty"`
|
||||||
Body *string `json:"body,omitempty"`
|
Body *string `json:"body,omitempty"`
|
||||||
User *User `json:"user,omitempty"`
|
User *User `json:"user,omitempty"`
|
||||||
|
@ -25,10 +26,10 @@ func (g GistComment) String() string {
|
||||||
|
|
||||||
// ListComments lists all comments for a gist.
|
// ListComments lists all comments for a gist.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-comments
|
||||||
func (s *GistsService) ListComments(gistID string, opt *ListOptions) ([]GistComment, *Response, error) {
|
func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) {
|
||||||
u := fmt.Sprintf("gists/%v/comments", gistID)
|
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||||
u, err := addOptions(u, opt)
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -38,19 +39,19 @@ func (s *GistsService) ListComments(gistID string, opt *ListOptions) ([]GistComm
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
comments := new([]GistComment)
|
var comments []*GistComment
|
||||||
resp, err := s.client.Do(req, comments)
|
resp, err := s.client.Do(ctx, req, &comments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *comments, resp, err
|
return comments, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetComment retrieves a single comment from a gist.
|
// GetComment retrieves a single comment from a gist.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/comments/#get-a-single-comment
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist-comment
|
||||||
func (s *GistsService) GetComment(gistID string, commentID int) (*GistComment, *Response, error) {
|
func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) {
|
||||||
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -58,18 +59,18 @@ func (s *GistsService) GetComment(gistID string, commentID int) (*GistComment, *
|
||||||
}
|
}
|
||||||
|
|
||||||
c := new(GistComment)
|
c := new(GistComment)
|
||||||
resp, err := s.client.Do(req, c)
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, resp, err
|
return c, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateComment creates a comment for a gist.
|
// CreateComment creates a comment for a gist.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/comments/#create-a-comment
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist-comment
|
||||||
func (s *GistsService) CreateComment(gistID string, comment *GistComment) (*GistComment, *Response, error) {
|
func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) {
|
||||||
u := fmt.Sprintf("gists/%v/comments", gistID)
|
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||||
req, err := s.client.NewRequest("POST", u, comment)
|
req, err := s.client.NewRequest("POST", u, comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -77,18 +78,18 @@ func (s *GistsService) CreateComment(gistID string, comment *GistComment) (*Gist
|
||||||
}
|
}
|
||||||
|
|
||||||
c := new(GistComment)
|
c := new(GistComment)
|
||||||
resp, err := s.client.Do(req, c)
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, resp, err
|
return c, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditComment edits an existing gist comment.
|
// EditComment edits an existing gist comment.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/comments/#edit-a-comment
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist-comment
|
||||||
func (s *GistsService) EditComment(gistID string, commentID int, comment *GistComment) (*GistComment, *Response, error) {
|
func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) {
|
||||||
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -96,23 +97,23 @@ func (s *GistsService) EditComment(gistID string, commentID int, comment *GistCo
|
||||||
}
|
}
|
||||||
|
|
||||||
c := new(GistComment)
|
c := new(GistComment)
|
||||||
resp, err := s.client.Do(req, c)
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, resp, err
|
return c, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteComment deletes a gist comment.
|
// DeleteComment deletes a gist comment.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gists/comments/#delete-a-comment
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist-comment
|
||||||
func (s *GistsService) DeleteComment(gistID string, commentID int) (*Response, error) {
|
func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) {
|
||||||
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
|
@ -8,7 +8,5 @@ package github
|
||||||
// GitService handles communication with the git data related
|
// GitService handles communication with the git data related
|
||||||
// methods of the GitHub API.
|
// methods of the GitHub API.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/
|
||||||
type GitService struct {
|
type GitService service
|
||||||
client *Client
|
|
||||||
}
|
|
69
vendor/github.com/google/go-github/v39/github/git_blobs.go
generated
vendored
Normal file
69
vendor/github.com/google/go-github/v39/github/git_blobs.go
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Blob represents a blob object.
|
||||||
|
type Blob struct {
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
Encoding *string `json:"encoding,omitempty"`
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlob fetches a blob from a repo given a SHA.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-blob
|
||||||
|
func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
blob := new(Blob)
|
||||||
|
resp, err := s.client.Do(ctx, req, blob)
|
||||||
|
return blob, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlobRaw fetches a blob's contents from a repo.
|
||||||
|
// Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-blob
|
||||||
|
func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", "application/vnd.github.v3.raw")
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
resp, err := s.client.Do(ctx, req, &buf)
|
||||||
|
return buf.Bytes(), resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBlob creates a blob object.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-blob
|
||||||
|
func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, blob)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Blob)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
return t, resp, err
|
||||||
|
}
|
200
vendor/github.com/google/go-github/v39/github/git_commits.go
generated
vendored
Normal file
200
vendor/github.com/google/go-github/v39/github/git_commits.go
generated
vendored
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/openpgp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SignatureVerification represents GPG signature verification.
|
||||||
|
type SignatureVerification struct {
|
||||||
|
Verified *bool `json:"verified,omitempty"`
|
||||||
|
Reason *string `json:"reason,omitempty"`
|
||||||
|
Signature *string `json:"signature,omitempty"`
|
||||||
|
Payload *string `json:"payload,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit represents a GitHub commit.
|
||||||
|
type Commit struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Author *CommitAuthor `json:"author,omitempty"`
|
||||||
|
Committer *CommitAuthor `json:"committer,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Tree *Tree `json:"tree,omitempty"`
|
||||||
|
Parents []*Commit `json:"parents,omitempty"`
|
||||||
|
Stats *CommitStats `json:"stats,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Verification *SignatureVerification `json:"verification,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
|
||||||
|
// CommentCount is the number of GitHub comments on the commit. This
|
||||||
|
// is only populated for requests that fetch GitHub data like
|
||||||
|
// Pulls.ListCommits, Repositories.ListCommits, etc.
|
||||||
|
CommentCount *int `json:"comment_count,omitempty"`
|
||||||
|
|
||||||
|
// SigningKey denotes a key to sign the commit with. If not nil this key will
|
||||||
|
// be used to sign the commit. The private key must be present and already
|
||||||
|
// decrypted. Ignored if Verification.Signature is defined.
|
||||||
|
SigningKey *openpgp.Entity `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Commit) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommitAuthor represents the author or committer of a commit. The commit
|
||||||
|
// author may not correspond to a GitHub User.
|
||||||
|
type CommitAuthor struct {
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
|
||||||
|
// The following fields are only populated by Webhook events.
|
||||||
|
Login *string `json:"username,omitempty"` // Renamed for go-github consistency.
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CommitAuthor) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCommit fetches the Commit object for a given SHA.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-commit
|
||||||
|
func (s *GitService) GetCommit(ctx context.Context, owner string, repo string, sha string) (*Commit, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/commits/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(Commit)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// createCommit represents the body of a CreateCommit request.
|
||||||
|
type createCommit struct {
|
||||||
|
Author *CommitAuthor `json:"author,omitempty"`
|
||||||
|
Committer *CommitAuthor `json:"committer,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Tree *string `json:"tree,omitempty"`
|
||||||
|
Parents []string `json:"parents,omitempty"`
|
||||||
|
Signature *string `json:"signature,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCommit creates a new commit in a repository.
|
||||||
|
// commit must not be nil.
|
||||||
|
//
|
||||||
|
// The commit.Committer is optional and will be filled with the commit.Author
|
||||||
|
// data if omitted. If the commit.Author is omitted, it will be filled in with
|
||||||
|
// the authenticated user’s information and the current date.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-commit
|
||||||
|
func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit) (*Commit, *Response, error) {
|
||||||
|
if commit == nil {
|
||||||
|
return nil, nil, fmt.Errorf("commit must be provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/commits", owner, repo)
|
||||||
|
|
||||||
|
parents := make([]string, len(commit.Parents))
|
||||||
|
for i, parent := range commit.Parents {
|
||||||
|
parents[i] = *parent.SHA
|
||||||
|
}
|
||||||
|
|
||||||
|
body := &createCommit{
|
||||||
|
Author: commit.Author,
|
||||||
|
Committer: commit.Committer,
|
||||||
|
Message: commit.Message,
|
||||||
|
Parents: parents,
|
||||||
|
}
|
||||||
|
if commit.Tree != nil {
|
||||||
|
body.Tree = commit.Tree.SHA
|
||||||
|
}
|
||||||
|
if commit.SigningKey != nil {
|
||||||
|
signature, err := createSignature(commit.SigningKey, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
body.Signature = &signature
|
||||||
|
}
|
||||||
|
if commit.Verification != nil {
|
||||||
|
body.Signature = commit.Verification.Signature
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(Commit)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSignature(signingKey *openpgp.Entity, commit *createCommit) (string, error) {
|
||||||
|
if signingKey == nil || commit == nil {
|
||||||
|
return "", errors.New("createSignature: invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
message, err := createSignatureMessage(commit)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
writer := new(bytes.Buffer)
|
||||||
|
reader := bytes.NewReader([]byte(message))
|
||||||
|
if err := openpgp.ArmoredDetachSign(writer, signingKey, reader, nil); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return writer.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSignatureMessage(commit *createCommit) (string, error) {
|
||||||
|
if commit == nil || commit.Message == nil || *commit.Message == "" || commit.Author == nil {
|
||||||
|
return "", errors.New("createSignatureMessage: invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
var message []string
|
||||||
|
|
||||||
|
if commit.Tree != nil {
|
||||||
|
message = append(message, fmt.Sprintf("tree %s", *commit.Tree))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, parent := range commit.Parents {
|
||||||
|
message = append(message, fmt.Sprintf("parent %s", parent))
|
||||||
|
}
|
||||||
|
|
||||||
|
message = append(message, fmt.Sprintf("author %s <%s> %d %s", commit.Author.GetName(), commit.Author.GetEmail(), commit.Author.GetDate().Unix(), commit.Author.GetDate().Format("-0700")))
|
||||||
|
|
||||||
|
committer := commit.Committer
|
||||||
|
if committer == nil {
|
||||||
|
committer = commit.Author
|
||||||
|
}
|
||||||
|
|
||||||
|
// There needs to be a double newline after committer
|
||||||
|
message = append(message, fmt.Sprintf("committer %s <%s> %d %s\n", committer.GetName(), committer.GetEmail(), committer.GetDate().Unix(), committer.GetDate().Format("-0700")))
|
||||||
|
message = append(message, *commit.Message)
|
||||||
|
|
||||||
|
return strings.Join(message, "\n"), nil
|
||||||
|
}
|
|
@ -6,7 +6,9 @@
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,6 +17,7 @@ type Reference struct {
|
||||||
Ref *string `json:"ref"`
|
Ref *string `json:"ref"`
|
||||||
URL *string `json:"url"`
|
URL *string `json:"url"`
|
||||||
Object *GitObject `json:"object"`
|
Object *GitObject `json:"object"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Reference) String() string {
|
func (r Reference) String() string {
|
||||||
|
@ -44,45 +47,55 @@ type updateRefRequest struct {
|
||||||
Force *bool `json:"force"`
|
Force *bool `json:"force"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRef fetches the Reference object for a given Git ref.
|
// GetRef fetches a single reference in a repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/refs/#get-a-reference
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-reference
|
||||||
func (s *GitService) GetRef(owner string, repo string, ref string) (*Reference, *Response, error) {
|
func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) {
|
||||||
ref = strings.TrimPrefix(ref, "refs/")
|
ref = strings.TrimPrefix(ref, "refs/")
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, ref)
|
u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref))
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
r := new(Reference)
|
r := new(Reference)
|
||||||
resp, err := s.client.Do(req, r)
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, resp, err
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// refURLEscape escapes every path segment of the given ref. Those must
|
||||||
|
// not contain escaped "/" - as "%2F" - or github will not recognize it.
|
||||||
|
func refURLEscape(ref string) string {
|
||||||
|
parts := strings.Split(ref, "/")
|
||||||
|
for i, s := range parts {
|
||||||
|
parts[i] = url.PathEscape(s)
|
||||||
|
}
|
||||||
|
return strings.Join(parts, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReferenceListOptions specifies optional parameters to the
|
// ReferenceListOptions specifies optional parameters to the
|
||||||
// GitService.ListRefs method.
|
// GitService.ListMatchingRefs method.
|
||||||
type ReferenceListOptions struct {
|
type ReferenceListOptions struct {
|
||||||
Type string `url:"-"`
|
Ref string `url:"-"`
|
||||||
|
|
||||||
ListOptions
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRefs lists all refs in a repository.
|
// ListMatchingRefs lists references in a repository that match a supplied ref.
|
||||||
|
// Use an empty ref to list all references.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/refs/#get-all-references
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#list-matching-references
|
||||||
func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([]Reference, *Response, error) {
|
func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) {
|
||||||
var u string
|
var ref string
|
||||||
if opt != nil && opt.Type != "" {
|
if opts != nil {
|
||||||
u = fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, opt.Type)
|
ref = strings.TrimPrefix(opts.Ref, "refs/")
|
||||||
} else {
|
|
||||||
u = fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
|
|
||||||
}
|
}
|
||||||
u, err := addOptions(u, opt)
|
u := fmt.Sprintf("repos/%v/%v/git/matching-refs/%v", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -92,19 +105,19 @@ func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([]
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var rs []Reference
|
var rs []*Reference
|
||||||
resp, err := s.client.Do(req, &rs)
|
resp, err := s.client.Do(ctx, req, &rs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rs, resp, err
|
return rs, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRef creates a new ref in a repository.
|
// CreateRef creates a new ref in a repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/refs/#create-a-reference
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-reference
|
||||||
func (s *GitService) CreateRef(owner string, repo string, ref *Reference) (*Reference, *Response, error) {
|
func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
|
||||||
req, err := s.client.NewRequest("POST", u, &createRefRequest{
|
req, err := s.client.NewRequest("POST", u, &createRefRequest{
|
||||||
// back-compat with previous behavior that didn't require 'refs/' prefix
|
// back-compat with previous behavior that didn't require 'refs/' prefix
|
||||||
|
@ -116,18 +129,18 @@ func (s *GitService) CreateRef(owner string, repo string, ref *Reference) (*Refe
|
||||||
}
|
}
|
||||||
|
|
||||||
r := new(Reference)
|
r := new(Reference)
|
||||||
resp, err := s.client.Do(req, r)
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, resp, err
|
return r, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRef updates an existing ref in a repository.
|
// UpdateRef updates an existing ref in a repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/refs/#update-a-reference
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#update-a-reference
|
||||||
func (s *GitService) UpdateRef(owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) {
|
func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) {
|
||||||
refPath := strings.TrimPrefix(*ref.Ref, "refs/")
|
refPath := strings.TrimPrefix(*ref.Ref, "refs/")
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refPath)
|
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refPath)
|
||||||
req, err := s.client.NewRequest("PATCH", u, &updateRefRequest{
|
req, err := s.client.NewRequest("PATCH", u, &updateRefRequest{
|
||||||
|
@ -139,24 +152,24 @@ func (s *GitService) UpdateRef(owner string, repo string, ref *Reference, force
|
||||||
}
|
}
|
||||||
|
|
||||||
r := new(Reference)
|
r := new(Reference)
|
||||||
resp, err := s.client.Do(req, r)
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, resp, err
|
return r, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRef deletes a ref from a repository.
|
// DeleteRef deletes a ref from a repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/refs/#delete-a-reference
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#delete-a-reference
|
||||||
func (s *GitService) DeleteRef(owner string, repo string, ref string) (*Response, error) {
|
func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) {
|
||||||
ref = strings.TrimPrefix(ref, "refs/")
|
ref = strings.TrimPrefix(ref, "refs/")
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, ref)
|
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref))
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
|
@ -6,20 +6,23 @@
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tag represents a tag object.
|
// Tag represents a tag object.
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Tag *string `json:"tag,omitempty"`
|
Tag *string `json:"tag,omitempty"`
|
||||||
SHA *string `json:"sha,omitempty"`
|
SHA *string `json:"sha,omitempty"`
|
||||||
URL *string `json:"url,omitempty"`
|
URL *string `json:"url,omitempty"`
|
||||||
Message *string `json:"message,omitempty"`
|
Message *string `json:"message,omitempty"`
|
||||||
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
||||||
Object *GitObject `json:"object,omitempty"`
|
Object *GitObject `json:"object,omitempty"`
|
||||||
|
Verification *SignatureVerification `json:"verification,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// createTagRequest represents the body of a CreateTag request. This is mostly
|
// createTagRequest represents the body of a CreateTag request. This is mostly
|
||||||
// identical to Tag with the exception that the object SHA and Type are
|
// identical to Tag with the exception that the object SHA and Type are
|
||||||
// top-level fields, rather than being nested inside a JSON object.
|
// top-level fields, rather than being nested inside a JSON object.
|
||||||
type createTagRequest struct {
|
type createTagRequest struct {
|
||||||
|
@ -30,10 +33,10 @@ type createTagRequest struct {
|
||||||
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTag fetchs a tag from a repo given a SHA.
|
// GetTag fetches a tag from a repo given a SHA.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/tags/#get-a-tag
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-tag
|
||||||
func (s *GitService) GetTag(owner string, repo string, sha string) (*Tag, *Response, error) {
|
func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha)
|
u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha)
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -41,14 +44,14 @@ func (s *GitService) GetTag(owner string, repo string, sha string) (*Tag, *Respo
|
||||||
}
|
}
|
||||||
|
|
||||||
tag := new(Tag)
|
tag := new(Tag)
|
||||||
resp, err := s.client.Do(req, tag)
|
resp, err := s.client.Do(ctx, req, tag)
|
||||||
return tag, resp, err
|
return tag, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTag creates a tag object.
|
// CreateTag creates a tag object.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/git/tags/#create-a-tag-object
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-tag-object
|
||||||
func (s *GitService) CreateTag(owner string, repo string, tag *Tag) (*Tag, *Response, error) {
|
func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo)
|
||||||
|
|
||||||
// convert Tag into a createTagRequest
|
// convert Tag into a createTagRequest
|
||||||
|
@ -68,6 +71,6 @@ func (s *GitService) CreateTag(owner string, repo string, tag *Tag) (*Tag, *Resp
|
||||||
}
|
}
|
||||||
|
|
||||||
t := new(Tag)
|
t := new(Tag)
|
||||||
resp, err := s.client.Do(req, t)
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
return t, resp, err
|
return t, resp, err
|
||||||
}
|
}
|
162
vendor/github.com/google/go-github/v39/github/git_trees.go
generated
vendored
Normal file
162
vendor/github.com/google/go-github/v39/github/git_trees.go
generated
vendored
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tree represents a GitHub tree.
|
||||||
|
type Tree struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Entries []*TreeEntry `json:"tree,omitempty"`
|
||||||
|
|
||||||
|
// Truncated is true if the number of items in the tree
|
||||||
|
// exceeded GitHub's maximum limit and the Entries were truncated
|
||||||
|
// in the response. Only populated for requests that fetch
|
||||||
|
// trees like Git.GetTree.
|
||||||
|
Truncated *bool `json:"truncated,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Tree) String() string {
|
||||||
|
return Stringify(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TreeEntry represents the contents of a tree structure. TreeEntry can
|
||||||
|
// represent either a blob, a commit (in the case of a submodule), or another
|
||||||
|
// tree.
|
||||||
|
type TreeEntry struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t TreeEntry) String() string {
|
||||||
|
return Stringify(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// treeEntryWithFileDelete is used internally to delete a file whose
|
||||||
|
// Content and SHA fields are empty. It does this by removing the "omitempty"
|
||||||
|
// tag modifier on the SHA field which causes the GitHub API to receive
|
||||||
|
// {"sha":null} and thereby delete the file.
|
||||||
|
type treeEntryWithFileDelete struct {
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TreeEntry) MarshalJSON() ([]byte, error) {
|
||||||
|
if t.SHA == nil && t.Content == nil {
|
||||||
|
return json.Marshal(struct {
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}{
|
||||||
|
nil,
|
||||||
|
t.Path,
|
||||||
|
t.Mode,
|
||||||
|
t.Type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return json.Marshal(struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}{
|
||||||
|
SHA: t.SHA,
|
||||||
|
Path: t.Path,
|
||||||
|
Mode: t.Mode,
|
||||||
|
Type: t.Type,
|
||||||
|
Size: t.Size,
|
||||||
|
Content: t.Content,
|
||||||
|
URL: t.URL,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTree fetches the Tree object for a given sha hash from a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-tree
|
||||||
|
func (s *GitService) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha)
|
||||||
|
if recursive {
|
||||||
|
u += "?recursive=1"
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Tree)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// createTree represents the body of a CreateTree request.
|
||||||
|
type createTree struct {
|
||||||
|
BaseTree string `json:"base_tree,omitempty"`
|
||||||
|
Entries []interface{} `json:"tree"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTree creates a new tree in a repository. If both a tree and a nested
|
||||||
|
// path modifying that tree are specified, it will overwrite the contents of
|
||||||
|
// that tree with the new path contents and write a new tree out.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-tree
|
||||||
|
func (s *GitService) CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo)
|
||||||
|
|
||||||
|
newEntries := make([]interface{}, 0, len(entries))
|
||||||
|
for _, entry := range entries {
|
||||||
|
if entry.Content == nil && entry.SHA == nil {
|
||||||
|
newEntries = append(newEntries, treeEntryWithFileDelete{
|
||||||
|
Path: entry.Path,
|
||||||
|
Mode: entry.Mode,
|
||||||
|
Type: entry.Type,
|
||||||
|
Size: entry.Size,
|
||||||
|
URL: entry.URL,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newEntries = append(newEntries, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
body := &createTree{
|
||||||
|
BaseTree: baseTree,
|
||||||
|
Entries: newEntries,
|
||||||
|
}
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Tree)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
18341
vendor/github.com/google/go-github/v39/github/github-accessors.go
generated
vendored
Normal file
18341
vendor/github.com/google/go-github/v39/github/github-accessors.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1254
vendor/github.com/google/go-github/v39/github/github.go
generated
vendored
Normal file
1254
vendor/github.com/google/go-github/v39/github/github.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -5,15 +5,16 @@
|
||||||
|
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// GitignoresService provides access to the gitignore related functions in the
|
// GitignoresService provides access to the gitignore related functions in the
|
||||||
// GitHub API.
|
// GitHub API.
|
||||||
//
|
//
|
||||||
// GitHub API docs: http://developer.github.com/v3/gitignore/
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/
|
||||||
type GitignoresService struct {
|
type GitignoresService service
|
||||||
client *Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gitignore represents a .gitignore file as returned by the GitHub API.
|
// Gitignore represents a .gitignore file as returned by the GitHub API.
|
||||||
type Gitignore struct {
|
type Gitignore struct {
|
||||||
|
@ -27,26 +28,26 @@ func (g Gitignore) String() string {
|
||||||
|
|
||||||
// List all available Gitignore templates.
|
// List all available Gitignore templates.
|
||||||
//
|
//
|
||||||
// http://developer.github.com/v3/gitignore/#listing-available-templates
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#listing-available-templates
|
||||||
func (s GitignoresService) List() ([]string, *Response, error) {
|
func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) {
|
||||||
req, err := s.client.NewRequest("GET", "gitignore/templates", nil)
|
req, err := s.client.NewRequest("GET", "gitignore/templates", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
availableTemplates := new([]string)
|
var availableTemplates []string
|
||||||
resp, err := s.client.Do(req, availableTemplates)
|
resp, err := s.client.Do(ctx, req, &availableTemplates)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *availableTemplates, resp, err
|
return availableTemplates, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a Gitignore by name.
|
// Get a Gitignore by name.
|
||||||
//
|
//
|
||||||
// http://developer.github.com/v3/gitignore/#get-a-single-template
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#get-a-gitignore-template
|
||||||
func (s GitignoresService) Get(name string) (*Gitignore, *Response, error) {
|
func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) {
|
||||||
u := fmt.Sprintf("gitignore/templates/%v", name)
|
u := fmt.Sprintf("gitignore/templates/%v", name)
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,10 +55,10 @@ func (s GitignoresService) Get(name string) (*Gitignore, *Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gitignore := new(Gitignore)
|
gitignore := new(Gitignore)
|
||||||
resp, err := s.client.Do(req, gitignore)
|
resp, err := s.client.Do(ctx, req, gitignore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return gitignore, resp, err
|
return gitignore, resp, nil
|
||||||
}
|
}
|
28
vendor/github.com/google/go-github/v39/github/interactions.go
generated
vendored
Normal file
28
vendor/github.com/google/go-github/v39/github/interactions.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2018 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// InteractionsService handles communication with the repository and organization related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/
|
||||||
|
type InteractionsService service
|
||||||
|
|
||||||
|
// InteractionRestriction represents the interaction restrictions for repository and organization.
|
||||||
|
type InteractionRestriction struct {
|
||||||
|
// Specifies the group of GitHub users who can
|
||||||
|
// comment, open issues, or create pull requests for the given repository.
|
||||||
|
// Possible values are: "existing_users", "contributors_only" and "collaborators_only".
|
||||||
|
Limit *string `json:"limit,omitempty"`
|
||||||
|
|
||||||
|
// Origin specifies the type of the resource to interact with.
|
||||||
|
// Possible values are: "repository" and "organization".
|
||||||
|
Origin *string `json:"origin,omitempty"`
|
||||||
|
|
||||||
|
// ExpiresAt specifies the time after which the interaction restrictions expire.
|
||||||
|
// The default expiry time is 24 hours from the time restriction is created.
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
80
vendor/github.com/google/go-github/v39/github/interactions_orgs.go
generated
vendored
Normal file
80
vendor/github.com/google/go-github/v39/github/interactions_orgs.go
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright 2019 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRestrictionsForOrg fetches the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#get-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
organizationInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organizationInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRestrictionsForOrg adds or updates the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// limit specifies the group of GitHub users who can comment, open issues, or create pull requests
|
||||||
|
// in public repositories for the given organization.
|
||||||
|
// Possible values are: "existing_users", "contributors_only", "collaborators_only".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#set-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
|
||||||
|
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
organizationInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organizationInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRestrictionsFromOrg removes the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#remove-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
80
vendor/github.com/google/go-github/v39/github/interactions_repos.go
generated
vendored
Normal file
80
vendor/github.com/google/go-github/v39/github/interactions_repos.go
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright 2018 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRestrictionsForRepo fetches the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#get-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
repositoryInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, repositoryInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositoryInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRestrictionsForRepo adds or updates the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// limit specifies the group of GitHub users who can comment, open issues, or create pull requests
|
||||||
|
// for the given repository.
|
||||||
|
// Possible values are: "existing_users", "contributors_only", "collaborators_only".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#set-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
|
||||||
|
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
repositoryInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, repositoryInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositoryInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRestrictionsFromRepo removes the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#remove-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
152
vendor/github.com/google/go-github/v39/github/issue_import.go
generated
vendored
Normal file
152
vendor/github.com/google/go-github/v39/github/issue_import.go
generated
vendored
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
// Copyright 2020 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueImportService handles communication with the issue import related
|
||||||
|
// methods of the Issue Import GitHub API.
|
||||||
|
type IssueImportService service
|
||||||
|
|
||||||
|
// IssueImportRequest represents a request to create an issue.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#supported-issue-and-comment-fields
|
||||||
|
type IssueImportRequest struct {
|
||||||
|
IssueImport IssueImport `json:"issue"`
|
||||||
|
Comments []*Comment `json:"comments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImport represents body of issue to import.
|
||||||
|
type IssueImport struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
Assignee *string `json:"assignee,omitempty"`
|
||||||
|
Milestone *int `json:"milestone,omitempty"`
|
||||||
|
Closed *bool `json:"closed,omitempty"`
|
||||||
|
Labels []string `json:"labels,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comment represents comments of issue to import.
|
||||||
|
type Comment struct {
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImportResponse represents the response of an issue import create request.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#import-issue-response
|
||||||
|
type IssueImportResponse struct {
|
||||||
|
ID *int `json:"id,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
ImportIssuesURL *string `json:"import_issues_url,omitempty"`
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
DocumentationURL *string `json:"documentation_url,omitempty"`
|
||||||
|
Errors []*IssueImportError `json:"errors,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImportError represents errors of an issue import create request.
|
||||||
|
type IssueImportError struct {
|
||||||
|
Location *string `json:"location,omitempty"`
|
||||||
|
Resource *string `json:"resource,omitempty"`
|
||||||
|
Field *string `json:"field,omitempty"`
|
||||||
|
Value *string `json:"value,omitempty"`
|
||||||
|
Code *string `json:"code,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new imported issue on the specified repository.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#start-an-issue-import
|
||||||
|
func (s *IssueImportService) Create(ctx context.Context, owner, repo string, issue *IssueImportRequest) (*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
i := new(IssueImportResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
aerr, ok := err.(*AcceptedError)
|
||||||
|
if ok {
|
||||||
|
decErr := json.Unmarshal(aerr.Raw, i)
|
||||||
|
if decErr != nil {
|
||||||
|
err = decErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckStatus checks the status of an imported issue.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#import-status-request
|
||||||
|
func (s *IssueImportService) CheckStatus(ctx context.Context, owner, repo string, issueID int64) (*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues/%v", owner, repo, issueID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
i := new(IssueImportResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckStatusSince checks the status of multiple imported issues since a given date.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#check-status-of-multiple-issues
|
||||||
|
func (s *IssueImportService) CheckStatusSince(ctx context.Context, owner, repo string, since time.Time) ([]*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues?since=%v", owner, repo, since.Format("2006-01-02"))
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
resp, err := s.client.Do(ctx, req, &b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i []*IssueImportResponse
|
||||||
|
err = json.Unmarshal(b.Bytes(), &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
335
vendor/github.com/google/go-github/v39/github/issues.go
generated
vendored
Normal file
335
vendor/github.com/google/go-github/v39/github/issues.go
generated
vendored
Normal file
|
@ -0,0 +1,335 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssuesService handles communication with the issue related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/
|
||||||
|
type IssuesService service
|
||||||
|
|
||||||
|
// Issue represents a GitHub issue on a repository.
|
||||||
|
//
|
||||||
|
// Note: As far as the GitHub API is concerned, every pull request is an issue,
|
||||||
|
// but not every issue is a pull request. Some endpoints, events, and webhooks
|
||||||
|
// may also return pull requests via this struct. If PullRequestLinks is nil,
|
||||||
|
// this is an issue, and if PullRequestLinks is not nil, this is a pull request.
|
||||||
|
// The IsPullRequest helper method can be used to check that.
|
||||||
|
type Issue struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
Locked *bool `json:"locked,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
AuthorAssociation *string `json:"author_association,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
Labels []*Label `json:"labels,omitempty"`
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
Comments *int `json:"comments,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
ClosedBy *User `json:"closed_by,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CommentsURL *string `json:"comments_url,omitempty"`
|
||||||
|
EventsURL *string `json:"events_url,omitempty"`
|
||||||
|
LabelsURL *string `json:"labels_url,omitempty"`
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
PullRequestLinks *PullRequestLinks `json:"pull_request,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
Reactions *Reactions `json:"reactions,omitempty"`
|
||||||
|
Assignees []*User `json:"assignees,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
|
||||||
|
// TextMatches is only populated from search results that request text matches
|
||||||
|
// See: search.go and https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#text-match-metadata
|
||||||
|
TextMatches []*TextMatch `json:"text_matches,omitempty"`
|
||||||
|
|
||||||
|
// ActiveLockReason is populated only when LockReason is provided while locking the issue.
|
||||||
|
// Possible values are: "off-topic", "too heated", "resolved", and "spam".
|
||||||
|
ActiveLockReason *string `json:"active_lock_reason,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Issue) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsPullRequest reports whether the issue is also a pull request. It uses the
|
||||||
|
// method recommended by GitHub's API documentation, which is to check whether
|
||||||
|
// PullRequestLinks is non-nil.
|
||||||
|
func (i Issue) IsPullRequest() bool {
|
||||||
|
return i.PullRequestLinks != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueRequest represents a request to create/edit an issue.
|
||||||
|
// It is separate from Issue above because otherwise Labels
|
||||||
|
// and Assignee fail to serialize to the correct JSON.
|
||||||
|
type IssueRequest struct {
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
Labels *[]string `json:"labels,omitempty"`
|
||||||
|
Assignee *string `json:"assignee,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
Milestone *int `json:"milestone,omitempty"`
|
||||||
|
Assignees *[]string `json:"assignees,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListOptions specifies the optional parameters to the IssuesService.List
|
||||||
|
// and IssuesService.ListByOrg methods.
|
||||||
|
type IssueListOptions struct {
|
||||||
|
// Filter specifies which issues to list. Possible values are: assigned,
|
||||||
|
// created, mentioned, subscribed, all. Default is "assigned".
|
||||||
|
Filter string `url:"filter,omitempty"`
|
||||||
|
|
||||||
|
// State filters issues based on their state. Possible values are: open,
|
||||||
|
// closed, all. Default is "open".
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Labels filters issues based on their label.
|
||||||
|
Labels []string `url:"labels,comma,omitempty"`
|
||||||
|
|
||||||
|
// Sort specifies how to sort issues. Possible values are: created, updated,
|
||||||
|
// and comments. Default value is "created".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort issues. Possible values are: asc, desc.
|
||||||
|
// Default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters issues by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// PullRequestLinks object is added to the Issue object when it's an issue included
|
||||||
|
// in the IssueCommentEvent webhook payload, if the webhook is fired by a comment on a PR.
|
||||||
|
type PullRequestLinks struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
DiffURL *string `json:"diff_url,omitempty"`
|
||||||
|
PatchURL *string `json:"patch_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the issues for the authenticated user. If all is true, list issues
|
||||||
|
// across all the user's visible repositories including owned, member, and
|
||||||
|
// organization repositories; if false, list only owned and member
|
||||||
|
// repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-user-account-issues-assigned-to-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issues-assigned-to-the-authenticated-user
|
||||||
|
func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if all {
|
||||||
|
u = "issues"
|
||||||
|
} else {
|
||||||
|
u = "user/issues"
|
||||||
|
}
|
||||||
|
return s.listIssues(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByOrg fetches the issues in the specified organization for the
|
||||||
|
// authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-organization-issues-assigned-to-the-authenticated-user
|
||||||
|
func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/issues", org)
|
||||||
|
return s.listIssues(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *IssuesService) listIssues(ctx context.Context, u string, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var issues []*Issue
|
||||||
|
resp, err := s.client.Do(ctx, req, &issues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issues, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListByRepoOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.ListByRepo method.
|
||||||
|
type IssueListByRepoOptions struct {
|
||||||
|
// Milestone limits issues for the specified milestone. Possible values are
|
||||||
|
// a milestone number, "none" for issues with no milestone, "*" for issues
|
||||||
|
// with any milestone.
|
||||||
|
Milestone string `url:"milestone,omitempty"`
|
||||||
|
|
||||||
|
// State filters issues based on their state. Possible values are: open,
|
||||||
|
// closed, all. Default is "open".
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Assignee filters issues based on their assignee. Possible values are a
|
||||||
|
// user name, "none" for issues that are not assigned, "*" for issues with
|
||||||
|
// any assigned user.
|
||||||
|
Assignee string `url:"assignee,omitempty"`
|
||||||
|
|
||||||
|
// Creator filters issues based on their creator.
|
||||||
|
Creator string `url:"creator,omitempty"`
|
||||||
|
|
||||||
|
// Mentioned filters issues to those mentioned a specific user.
|
||||||
|
Mentioned string `url:"mentioned,omitempty"`
|
||||||
|
|
||||||
|
// Labels filters issues based on their label.
|
||||||
|
Labels []string `url:"labels,omitempty,comma"`
|
||||||
|
|
||||||
|
// Sort specifies how to sort issues. Possible values are: created, updated,
|
||||||
|
// and comments. Default value is "created".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort issues. Possible values are: asc, desc.
|
||||||
|
// Default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters issues by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByRepo lists the issues for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-repository-issues
|
||||||
|
func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var issues []*Issue
|
||||||
|
resp, err := s.client.Do(ctx, req, &issues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issues, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue
|
||||||
|
func (s *IssuesService) Get(ctx context.Context, owner string, repo string, number int) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
issue := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issue, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new issue on the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-an-issue
|
||||||
|
func (s *IssuesService) Create(ctx context.Context, owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue
|
||||||
|
func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockIssueOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.Lock method.
|
||||||
|
type LockIssueOptions struct {
|
||||||
|
// LockReason specifies the reason to lock this issue.
|
||||||
|
// Providing a lock reason can help make it clearer to contributors why an issue
|
||||||
|
// was locked. Possible values are: "off-topic", "too heated", "resolved", and "spam".
|
||||||
|
LockReason string `json:"lock_reason,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock an issue's conversation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#lock-an-issue
|
||||||
|
func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int, opts *LockIssueOptions) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock an issue's conversation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#unlock-an-issue
|
||||||
|
func (s *IssuesService) Unlock(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
85
vendor/github.com/google/go-github/v39/github/issues_assignees.go
generated
vendored
Normal file
85
vendor/github.com/google/go-github/v39/github/issues_assignees.go
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListAssignees fetches all available assignees (owners and collaborators) to
|
||||||
|
// which issues may be assigned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-assignees
|
||||||
|
func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
var assignees []*User
|
||||||
|
resp, err := s.client.Do(ctx, req, &assignees)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return assignees, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAssignee checks if a user is an assignee for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#check-if-a-user-can-be-assigned
|
||||||
|
func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
assignee, err := parseBoolResponse(err)
|
||||||
|
return assignee, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddAssignees adds the provided GitHub users as assignees to the issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#add-assignees-to-an-issue
|
||||||
|
func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
|
||||||
|
users := &struct {
|
||||||
|
Assignees []string `json:"assignees,omitempty"`
|
||||||
|
}{Assignees: assignees}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, users)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
issue := &Issue{}
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
return issue, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveAssignees removes the provided GitHub users as assignees from the issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-assignees-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
|
||||||
|
users := &struct {
|
||||||
|
Assignees []string `json:"assignees,omitempty"`
|
||||||
|
}{Assignees: assignees}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, users)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
issue := &Issue{}
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
return issue, resp, err
|
||||||
|
}
|
154
vendor/github.com/google/go-github/v39/github/issues_comments.go
generated
vendored
Normal file
154
vendor/github.com/google/go-github/v39/github/issues_comments.go
generated
vendored
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueComment represents a comment left on an issue.
|
||||||
|
type IssueComment struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
Reactions *Reactions `json:"reactions,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
// AuthorAssociation is the comment author's relationship to the issue's repository.
|
||||||
|
// Possible values are "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".
|
||||||
|
AuthorAssociation *string `json:"author_association,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
IssueURL *string `json:"issue_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i IssueComment) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListCommentsOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.ListComments method.
|
||||||
|
type IssueListCommentsOptions struct {
|
||||||
|
// Sort specifies how to sort comments. Possible values are: created, updated.
|
||||||
|
Sort *string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort comments. Possible values are: asc, desc.
|
||||||
|
Direction *string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters comments by time.
|
||||||
|
Since *time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComments lists all comments on the specified issue. Specifying an issue
|
||||||
|
// number of 0 will return all comments on all issues for the repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-comments
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-comments-for-a-repository
|
||||||
|
func (s *IssuesService) ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if number == 0 {
|
||||||
|
u = fmt.Sprintf("repos/%v/%v/issues/comments", owner, repo)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var comments []*IssueComment
|
||||||
|
resp, err := s.client.Do(ctx, req, &comments)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetComment fetches the specified issue comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue-comment
|
||||||
|
func (s *IssuesService) GetComment(ctx context.Context, owner string, repo string, commentID int64) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
comment := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return comment, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateComment creates a new comment on the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-an-issue-comment
|
||||||
|
func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
c := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditComment updates an issue comment.
|
||||||
|
// A non-nil comment.Body must be provided. Other comment fields should be left nil.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue-comment
|
||||||
|
func (s *IssuesService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
c := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteComment deletes an issue comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-an-issue-comment
|
||||||
|
func (s *IssuesService) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
179
vendor/github.com/google/go-github/v39/github/issues_events.go
generated
vendored
Normal file
179
vendor/github.com/google/go-github/v39/github/issues_events.go
generated
vendored
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
// Copyright 2014 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueEvent represents an event that occurred around an Issue or Pull Request.
|
||||||
|
type IssueEvent struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
|
||||||
|
// The User that generated this event.
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
|
||||||
|
// Event identifies the actual type of Event that occurred. Possible
|
||||||
|
// values are:
|
||||||
|
//
|
||||||
|
// closed
|
||||||
|
// The Actor closed the issue.
|
||||||
|
// If the issue was closed by commit message, CommitID holds the SHA1 hash of the commit.
|
||||||
|
//
|
||||||
|
// merged
|
||||||
|
// The Actor merged into master a branch containing a commit mentioning the issue.
|
||||||
|
// CommitID holds the SHA1 of the merge commit.
|
||||||
|
//
|
||||||
|
// referenced
|
||||||
|
// The Actor committed to master a commit mentioning the issue in its commit message.
|
||||||
|
// CommitID holds the SHA1 of the commit.
|
||||||
|
//
|
||||||
|
// reopened, unlocked
|
||||||
|
// The Actor did that to the issue.
|
||||||
|
//
|
||||||
|
// locked
|
||||||
|
// The Actor locked the issue.
|
||||||
|
// LockReason holds the reason of locking the issue (if provided while locking).
|
||||||
|
//
|
||||||
|
// renamed
|
||||||
|
// The Actor changed the issue title from Rename.From to Rename.To.
|
||||||
|
//
|
||||||
|
// mentioned
|
||||||
|
// Someone unspecified @mentioned the Actor [sic] in an issue comment body.
|
||||||
|
//
|
||||||
|
// assigned, unassigned
|
||||||
|
// The Assigner assigned the issue to or removed the assignment from the Assignee.
|
||||||
|
//
|
||||||
|
// labeled, unlabeled
|
||||||
|
// The Actor added or removed the Label from the issue.
|
||||||
|
//
|
||||||
|
// milestoned, demilestoned
|
||||||
|
// The Actor added or removed the issue from the Milestone.
|
||||||
|
//
|
||||||
|
// subscribed, unsubscribed
|
||||||
|
// The Actor subscribed to or unsubscribed from notifications for an issue.
|
||||||
|
//
|
||||||
|
// head_ref_deleted, head_ref_restored
|
||||||
|
// The pull request’s branch was deleted or restored.
|
||||||
|
//
|
||||||
|
// review_dismissed
|
||||||
|
// The review was dismissed and `DismissedReview` will be populated below.
|
||||||
|
//
|
||||||
|
// review_requested, review_request_removed
|
||||||
|
// The Actor requested or removed the request for a review.
|
||||||
|
// RequestedReviewer and ReviewRequester will be populated below.
|
||||||
|
//
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
Issue *Issue `json:"issue,omitempty"`
|
||||||
|
|
||||||
|
// Only present on certain events; see above.
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
Assigner *User `json:"assigner,omitempty"`
|
||||||
|
CommitID *string `json:"commit_id,omitempty"`
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
Label *Label `json:"label,omitempty"`
|
||||||
|
Rename *Rename `json:"rename,omitempty"`
|
||||||
|
LockReason *string `json:"lock_reason,omitempty"`
|
||||||
|
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||||
|
DismissedReview *DismissedReview `json:"dismissed_review,omitempty"`
|
||||||
|
RequestedReviewer *User `json:"requested_reviewer,omitempty"`
|
||||||
|
ReviewRequester *User `json:"review_requester,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DismissedReview represents details for 'dismissed_review' events.
|
||||||
|
type DismissedReview struct {
|
||||||
|
// State represents the state of the dismissed review.
|
||||||
|
// Possible values are: "commented", "approved", and "changes_requested".
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
ReviewID *int64 `json:"review_id,omitempty"`
|
||||||
|
DismissalMessage *string `json:"dismissal_message,omitempty"`
|
||||||
|
DismissalCommitID *string `json:"dismissal_commit_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueEvents lists events for the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events
|
||||||
|
func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeProjectCardDetailsPreview)
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryEvents lists events for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events-for-a-repository
|
||||||
|
func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEvent returns the specified issue event.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue-event
|
||||||
|
func (s *IssuesService) GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
event := new(IssueEvent)
|
||||||
|
resp, err := s.client.Do(ctx, req, event)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return event, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename contains details for 'renamed' events.
|
||||||
|
type Rename struct {
|
||||||
|
From *string `json:"from,omitempty"`
|
||||||
|
To *string `json:"to,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Rename) String() string {
|
||||||
|
return Stringify(r)
|
||||||
|
}
|
231
vendor/github.com/google/go-github/v39/github/issues_labels.go
generated
vendored
Normal file
231
vendor/github.com/google/go-github/v39/github/issues_labels.go
generated
vendored
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Label represents a GitHub label on an Issue
|
||||||
|
type Label struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Color *string `json:"color,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Default *bool `json:"default,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l Label) String() string {
|
||||||
|
return Stringify(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabels lists all labels for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-a-repository
|
||||||
|
func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLabel gets a single label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-label
|
||||||
|
func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, name string) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
label := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return label, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLabel creates a new label on the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-a-label
|
||||||
|
func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo string, label *Label) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
l := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditLabel edits a label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-label
|
||||||
|
func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string, name string, label *Label) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
l := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteLabel deletes a label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-label
|
||||||
|
func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo string, name string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabelsByIssue lists all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-an-issue
|
||||||
|
func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLabelsToIssue adds labels to an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#add-labels-to-an-issue
|
||||||
|
func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var l []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLabelForIssue removes a label for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-a-label-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplaceLabelsForIssue replaces all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#set-labels-for-an-issue
|
||||||
|
func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var l []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLabelsForIssue removes all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-all-labels-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabelsForMilestone lists labels for every issue in a milestone.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-issues-in-a-milestone
|
||||||
|
func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
|
@ -6,13 +6,17 @@
|
||||||
package github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Milestone represents a Github repository milestone.
|
// Milestone represents a GitHub repository milestone.
|
||||||
type Milestone struct {
|
type Milestone struct {
|
||||||
URL *string `json:"url,omitempty"`
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
LabelsURL *string `json:"labels_url,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
Number *int `json:"number,omitempty"`
|
Number *int `json:"number,omitempty"`
|
||||||
State *string `json:"state,omitempty"`
|
State *string `json:"state,omitempty"`
|
||||||
Title *string `json:"title,omitempty"`
|
Title *string `json:"title,omitempty"`
|
||||||
|
@ -22,7 +26,9 @@ type Milestone struct {
|
||||||
ClosedIssues *int `json:"closed_issues,omitempty"`
|
ClosedIssues *int `json:"closed_issues,omitempty"`
|
||||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
DueOn *time.Time `json:"due_on,omitempty"`
|
DueOn *time.Time `json:"due_on,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Milestone) String() string {
|
func (m Milestone) String() string {
|
||||||
|
@ -33,24 +39,26 @@ func (m Milestone) String() string {
|
||||||
// IssuesService.ListMilestones method.
|
// IssuesService.ListMilestones method.
|
||||||
type MilestoneListOptions struct {
|
type MilestoneListOptions struct {
|
||||||
// State filters milestones based on their state. Possible values are:
|
// State filters milestones based on their state. Possible values are:
|
||||||
// open, closed. Default is "open".
|
// open, closed, all. Default is "open".
|
||||||
State string `url:"state,omitempty"`
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
// Sort specifies how to sort milestones. Possible values are: due_date, completeness.
|
// Sort specifies how to sort milestones. Possible values are: due_on, completeness.
|
||||||
// Default value is "due_date".
|
// Default value is "due_on".
|
||||||
Sort string `url:"sort,omitempty"`
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
// Direction in which to sort milestones. Possible values are: asc, desc.
|
// Direction in which to sort milestones. Possible values are: asc, desc.
|
||||||
// Default is "asc".
|
// Default is "asc".
|
||||||
Direction string `url:"direction,omitempty"`
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMilestones lists all milestones for a repository.
|
// ListMilestones lists all milestones for a repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-milestones
|
||||||
func (s *IssuesService) ListMilestones(owner string, repo string, opt *MilestoneListOptions) ([]Milestone, *Response, error) {
|
func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
||||||
u, err := addOptions(u, opt)
|
u, err := addOptions(u, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -60,19 +68,19 @@ func (s *IssuesService) ListMilestones(owner string, repo string, opt *Milestone
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
milestones := new([]Milestone)
|
var milestones []*Milestone
|
||||||
resp, err := s.client.Do(req, milestones)
|
resp, err := s.client.Do(ctx, req, &milestones)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *milestones, resp, err
|
return milestones, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMilestone gets a single milestone.
|
// GetMilestone gets a single milestone.
|
||||||
//
|
//
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-milestone
|
||||||
func (s *IssuesService) GetMilestone(owner string, repo string, number int) (*Milestone, *Response, error) {
|
func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
req, err := s.client.NewRequest("GET", u, nil)
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -80,18 +88,18 @@ func (s *IssuesService) GetMilestone(owner string, repo string, number int) (*Mi
|
||||||
}
|
}
|
||||||
|
|
||||||
milestone := new(Milestone)
|
milestone := new(Milestone)
|
||||||
resp, err := s.client.Do(req, milestone)
|
resp, err := s.client.Do(ctx, req, milestone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return milestone, resp, err
|
return milestone, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMilestone creates a new milestone on the specified repository.
|
// CreateMilestone creates a new milestone on the specified repository.
|
||||||
//
|
//
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/milestones/#create-a-milestone
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-a-milestone
|
||||||
func (s *IssuesService) CreateMilestone(owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) {
|
func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
||||||
req, err := s.client.NewRequest("POST", u, milestone)
|
req, err := s.client.NewRequest("POST", u, milestone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -99,18 +107,18 @@ func (s *IssuesService) CreateMilestone(owner string, repo string, milestone *Mi
|
||||||
}
|
}
|
||||||
|
|
||||||
m := new(Milestone)
|
m := new(Milestone)
|
||||||
resp, err := s.client.Do(req, m)
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, resp, err
|
return m, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditMilestone edits a milestone.
|
// EditMilestone edits a milestone.
|
||||||
//
|
//
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/milestones/#update-a-milestone
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-milestone
|
||||||
func (s *IssuesService) EditMilestone(owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) {
|
func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
req, err := s.client.NewRequest("PATCH", u, milestone)
|
req, err := s.client.NewRequest("PATCH", u, milestone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -118,23 +126,23 @@ func (s *IssuesService) EditMilestone(owner string, repo string, number int, mil
|
||||||
}
|
}
|
||||||
|
|
||||||
m := new(Milestone)
|
m := new(Milestone)
|
||||||
resp, err := s.client.Do(req, m)
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, resp, err
|
return nil, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, resp, err
|
return m, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMilestone deletes a milestone.
|
// DeleteMilestone deletes a milestone.
|
||||||
//
|
//
|
||||||
// GitHub API docs: https://developer.github.com/v3/issues/milestones/#delete-a-milestone
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-milestone
|
||||||
func (s *IssuesService) DeleteMilestone(owner string, repo string, number int) (*Response, error) {
|
func (s *IssuesService) DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.client.Do(req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
161
vendor/github.com/google/go-github/v39/github/issues_timeline.go
generated
vendored
Normal file
161
vendor/github.com/google/go-github/v39/github/issues_timeline.go
generated
vendored
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Timeline represents an event that occurred around an Issue or Pull Request.
|
||||||
|
//
|
||||||
|
// It is similar to an IssueEvent but may contain more information.
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/timeline/
|
||||||
|
type Timeline struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
CommitURL *string `json:"commit_url,omitempty"`
|
||||||
|
|
||||||
|
// The User object that generated the event.
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
|
||||||
|
// Event identifies the actual type of Event that occurred. Possible values
|
||||||
|
// are:
|
||||||
|
//
|
||||||
|
// assigned
|
||||||
|
// The issue was assigned to the assignee.
|
||||||
|
//
|
||||||
|
// closed
|
||||||
|
// The issue was closed by the actor. When the commit_id is present, it
|
||||||
|
// identifies the commit that closed the issue using "closes / fixes #NN"
|
||||||
|
// syntax.
|
||||||
|
//
|
||||||
|
// commented
|
||||||
|
// A comment was added to the issue.
|
||||||
|
//
|
||||||
|
// committed
|
||||||
|
// A commit was added to the pull request's 'HEAD' branch. Only provided
|
||||||
|
// for pull requests.
|
||||||
|
//
|
||||||
|
// cross-referenced
|
||||||
|
// The issue was referenced from another issue. The 'source' attribute
|
||||||
|
// contains the 'id', 'actor', and 'url' of the reference's source.
|
||||||
|
//
|
||||||
|
// demilestoned
|
||||||
|
// The issue was removed from a milestone.
|
||||||
|
//
|
||||||
|
// head_ref_deleted
|
||||||
|
// The pull request's branch was deleted.
|
||||||
|
//
|
||||||
|
// head_ref_restored
|
||||||
|
// The pull request's branch was restored.
|
||||||
|
//
|
||||||
|
// labeled
|
||||||
|
// A label was added to the issue.
|
||||||
|
//
|
||||||
|
// locked
|
||||||
|
// The issue was locked by the actor.
|
||||||
|
//
|
||||||
|
// mentioned
|
||||||
|
// The actor was @mentioned in an issue body.
|
||||||
|
//
|
||||||
|
// merged
|
||||||
|
// The issue was merged by the actor. The 'commit_id' attribute is the
|
||||||
|
// SHA1 of the HEAD commit that was merged.
|
||||||
|
//
|
||||||
|
// milestoned
|
||||||
|
// The issue was added to a milestone.
|
||||||
|
//
|
||||||
|
// referenced
|
||||||
|
// The issue was referenced from a commit message. The 'commit_id'
|
||||||
|
// attribute is the commit SHA1 of where that happened.
|
||||||
|
//
|
||||||
|
// renamed
|
||||||
|
// The issue title was changed.
|
||||||
|
//
|
||||||
|
// reopened
|
||||||
|
// The issue was reopened by the actor.
|
||||||
|
//
|
||||||
|
// reviewed
|
||||||
|
// The pull request was reviewed.
|
||||||
|
//
|
||||||
|
// subscribed
|
||||||
|
// The actor subscribed to receive notifications for an issue.
|
||||||
|
//
|
||||||
|
// unassigned
|
||||||
|
// The assignee was unassigned from the issue.
|
||||||
|
//
|
||||||
|
// unlabeled
|
||||||
|
// A label was removed from the issue.
|
||||||
|
//
|
||||||
|
// unlocked
|
||||||
|
// The issue was unlocked by the actor.
|
||||||
|
//
|
||||||
|
// unsubscribed
|
||||||
|
// The actor unsubscribed to stop receiving notifications for an issue.
|
||||||
|
//
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
|
||||||
|
// The string SHA of a commit that referenced this Issue or Pull Request.
|
||||||
|
CommitID *string `json:"commit_id,omitempty"`
|
||||||
|
// The timestamp indicating when the event occurred.
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
// The Label object including `name` and `color` attributes. Only provided for
|
||||||
|
// 'labeled' and 'unlabeled' events.
|
||||||
|
Label *Label `json:"label,omitempty"`
|
||||||
|
// The User object which was assigned to (or unassigned from) this Issue or
|
||||||
|
// Pull Request. Only provided for 'assigned' and 'unassigned' events.
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
// The Milestone object including a 'title' attribute.
|
||||||
|
// Only provided for 'milestoned' and 'demilestoned' events.
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
// The 'id', 'actor', and 'url' for the source of a reference from another issue.
|
||||||
|
// Only provided for 'cross-referenced' events.
|
||||||
|
Source *Source `json:"source,omitempty"`
|
||||||
|
// An object containing rename details including 'from' and 'to' attributes.
|
||||||
|
// Only provided for 'renamed' events.
|
||||||
|
Rename *Rename `json:"rename,omitempty"`
|
||||||
|
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||||
|
// The state of a submitted review. Can be one of: 'commented',
|
||||||
|
// 'changes_requested' or 'approved'.
|
||||||
|
// Only provided for 'reviewed' events.
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source represents a reference's source.
|
||||||
|
type Source struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Issue *Issue `json:"issue,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueTimeline lists events for the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-timeline-events-for-an-issue
|
||||||
|
func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
acceptHeaders := []string{mediaTypeTimelinePreview, mediaTypeProjectCardDetailsPreview}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var events []*Timeline
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
return events, resp, err
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue