Browse Source

[Vendor] upgrade google/go-github to v32.1.0 (#12361)

* upgrate go-github client to v32.1.0

* migrate
pull/5339/merge
6543 GitHub 5 days ago
parent
commit
b3e06523c1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
100 changed files with 12006 additions and 6036 deletions
  1. +1
    -1
      go.mod
  2. +2
    -6
      go.sum
  3. +1
    -1
      modules/migrations/error.go
  4. +4
    -4
      modules/migrations/github.go
  5. +0
    -230
      vendor/github.com/google/go-github/v24/github/apps.go
  6. +0
    -457
      vendor/github.com/google/go-github/v24/github/teams.go
  7. +0
    -155
      vendor/github.com/google/go-github/v24/github/teams_discussion_comments.go
  8. +0
    -160
      vendor/github.com/google/go-github/v24/github/teams_discussions.go
  9. +0
    -174
      vendor/github.com/google/go-github/v24/github/teams_members.go
  10. +67
    -1
      vendor/github.com/google/go-github/v32/AUTHORS
  11. +0
    -0
      vendor/github.com/google/go-github/v32/LICENSE
  12. +12
    -0
      vendor/github.com/google/go-github/v32/github/actions.go
  13. +164
    -0
      vendor/github.com/google/go-github/v32/github/actions_artifacts.go
  14. +277
    -0
      vendor/github.com/google/go-github/v32/github/actions_runners.go
  15. +299
    -0
      vendor/github.com/google/go-github/v32/github/actions_secrets.go
  16. +149
    -0
      vendor/github.com/google/go-github/v32/github/actions_workflow_jobs.go
  17. +235
    -0
      vendor/github.com/google/go-github/v32/github/actions_workflow_runs.go
  18. +138
    -0
      vendor/github.com/google/go-github/v32/github/actions_workflows.go
  19. +7
    -7
      vendor/github.com/google/go-github/v32/github/activity.go
  20. +23
    -21
      vendor/github.com/google/go-github/v32/github/activity_events.go
  21. +9
    -9
      vendor/github.com/google/go-github/v32/github/activity_notifications.go
  22. +9
    -8
      vendor/github.com/google/go-github/v32/github/activity_star.go
  23. +6
    -5
      vendor/github.com/google/go-github/v32/github/activity_watching.go
  24. +18
    -0
      vendor/github.com/google/go-github/v32/github/admin.go
  25. +89
    -0
      vendor/github.com/google/go-github/v32/github/admin_orgs.go
  26. +2
    -2
      vendor/github.com/google/go-github/v32/github/admin_stats.go
  27. +133
    -0
      vendor/github.com/google/go-github/v32/github/admin_users.go
  28. +349
    -0
      vendor/github.com/google/go-github/v32/github/apps.go
  29. +21
    -8
      vendor/github.com/google/go-github/v32/github/apps_installation.go
  30. +53
    -0
      vendor/github.com/google/go-github/v32/github/apps_manifest.go
  31. +11
    -9
      vendor/github.com/google/go-github/v32/github/apps_marketplace.go
  32. +38
    -192
      vendor/github.com/google/go-github/v32/github/authorizations.go
  33. +34
    -33
      vendor/github.com/google/go-github/v32/github/checks.go
  34. +117
    -0
      vendor/github.com/google/go-github/v32/github/code-scanning.go
  35. +1
    -1
      vendor/github.com/google/go-github/v32/github/doc.go
  36. +12
    -0
      vendor/github.com/google/go-github/v32/github/event.go
  37. +154
    -40
      vendor/github.com/google/go-github/v32/github/event_types.go
  38. +21
    -15
      vendor/github.com/google/go-github/v32/github/gists.go
  39. +7
    -7
      vendor/github.com/google/go-github/v32/github/gists_comments.go
  40. +0
    -0
      vendor/github.com/google/go-github/v32/github/git.go
  41. +0
    -0
      vendor/github.com/google/go-github/v32/github/git_blobs.go
  42. +66
    -1
      vendor/github.com/google/go-github/v32/github/git_commits.go
  43. +22
    -66
      vendor/github.com/google/go-github/v32/github/git_refs.go
  44. +0
    -0
      vendor/github.com/google/go-github/v32/github/git_tags.go
  45. +69
    -6
      vendor/github.com/google/go-github/v32/github/git_trees.go
  46. +6446
    -3582
      vendor/github.com/google/go-github/v32/github/github-accessors.go
  47. +132
    -78
      vendor/github.com/google/go-github/v32/github/github.go
  48. +3
    -3
      vendor/github.com/google/go-github/v32/github/gitignore.go
  49. +0
    -0
      vendor/github.com/google/go-github/v32/github/interactions.go
  50. +1
    -1
      vendor/github.com/google/go-github/v32/github/interactions_orgs.go
  51. +1
    -1
      vendor/github.com/google/go-github/v32/github/interactions_repos.go
  52. +48
    -52
      vendor/github.com/google/go-github/v32/github/issues.go
  53. +3
    -3
      vendor/github.com/google/go-github/v32/github/issues_assignees.go
  54. +11
    -10
      vendor/github.com/google/go-github/v32/github/issues_comments.go
  55. +29
    -15
      vendor/github.com/google/go-github/v32/github/issues_events.go
  56. +11
    -41
      vendor/github.com/google/go-github/v32/github/issues_labels.go
  57. +4
    -4
      vendor/github.com/google/go-github/v32/github/issues_milestones.go
  58. +3
    -3
      vendor/github.com/google/go-github/v32/github/issues_timeline.go
  59. +1
    -1
      vendor/github.com/google/go-github/v32/github/licenses.go
  60. +22
    -8
      vendor/github.com/google/go-github/v32/github/messages.go
  61. +15
    -11
      vendor/github.com/google/go-github/v32/github/migrations.go
  62. +9
    -33
      vendor/github.com/google/go-github/v32/github/migrations_source_import.go
  63. +6
    -6
      vendor/github.com/google/go-github/v32/github/migrations_user.go
  64. +6
    -6
      vendor/github.com/google/go-github/v32/github/misc.go
  65. +67
    -7
      vendor/github.com/google/go-github/v32/github/orgs.go
  66. +9
    -8
      vendor/github.com/google/go-github/v32/github/orgs_hooks.go
  67. +25
    -31
      vendor/github.com/google/go-github/v32/github/orgs_members.go
  68. +5
    -5
      vendor/github.com/google/go-github/v32/github/orgs_outside_collaborators.go
  69. +4
    -4
      vendor/github.com/google/go-github/v32/github/orgs_projects.go
  70. +6
    -6
      vendor/github.com/google/go-github/v32/github/orgs_users_blocking.go
  71. +101
    -0
      vendor/github.com/google/go-github/v32/github/packages.go
  72. +28
    -28
      vendor/github.com/google/go-github/v32/github/projects.go
  73. +99
    -22
      vendor/github.com/google/go-github/v32/github/pulls.go
  74. +24
    -10
      vendor/github.com/google/go-github/v32/github/pulls_comments.go
  75. +6
    -5
      vendor/github.com/google/go-github/v32/github/pulls_reviewers.go
  76. +115
    -11
      vendor/github.com/google/go-github/v32/github/pulls_reviews.go
  77. +143
    -28
      vendor/github.com/google/go-github/v32/github/reactions.go
  78. +421
    -115
      vendor/github.com/google/go-github/v32/github/repos.go
  79. +31
    -14
      vendor/github.com/google/go-github/v32/github/repos_collaborators.go
  80. +7
    -6
      vendor/github.com/google/go-github/v32/github/repos_comments.go
  81. +53
    -21
      vendor/github.com/google/go-github/v32/github/repos_commits.go
  82. +1
    -1
      vendor/github.com/google/go-github/v32/github/repos_community_health.go
  83. +48
    -29
      vendor/github.com/google/go-github/v32/github/repos_contents.go
  84. +46
    -25
      vendor/github.com/google/go-github/v32/github/repos_deployments.go
  85. +4
    -4
      vendor/github.com/google/go-github/v32/github/repos_forks.go
  86. +21
    -21
      vendor/github.com/google/go-github/v32/github/repos_hooks.go
  87. +3
    -3
      vendor/github.com/google/go-github/v32/github/repos_invitations.go
  88. +6
    -26
      vendor/github.com/google/go-github/v32/github/repos_keys.go
  89. +1
    -1
      vendor/github.com/google/go-github/v32/github/repos_merging.go
  90. +96
    -18
      vendor/github.com/google/go-github/v32/github/repos_pages.go
  91. +2
    -2
      vendor/github.com/google/go-github/v32/github/repos_prereceive_hooks.go
  92. +4
    -4
      vendor/github.com/google/go-github/v32/github/repos_projects.go
  93. +55
    -28
      vendor/github.com/google/go-github/v32/github/repos_releases.go
  94. +8
    -8
      vendor/github.com/google/go-github/v32/github/repos_stats.go
  95. +17
    -17
      vendor/github.com/google/go-github/v32/github/repos_statuses.go
  96. +8
    -8
      vendor/github.com/google/go-github/v32/github/repos_traffic.go
  97. +79
    -43
      vendor/github.com/google/go-github/v32/github/search.go
  98. +0
    -0
      vendor/github.com/google/go-github/v32/github/strings.go
  99. +850
    -0
      vendor/github.com/google/go-github/v32/github/teams.go
  100. +242
    -0
      vendor/github.com/google/go-github/v32/github/teams_discussion_comments.go

+ 1
- 1
go.mod View File

@@ -50,7 +50,7 @@ require (
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
github.com/golang/protobuf v1.4.1 // indirect
github.com/google/go-github/v24 v24.0.1
github.com/google/go-github/v32 v32.1.0
github.com/google/uuid v1.1.1
github.com/gorilla/context v1.1.1
github.com/hashicorp/go-retryablehttp v0.6.6 // indirect


+ 2
- 6
go.sum View File

@@ -349,10 +349,8 @@ github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v24 v24.0.1 h1:KCt1LjMJEey1qvPXxa9SjaWxwTsCWSq6p2Ju57UR4Q4=
github.com/google/go-github/v24 v24.0.1/go.mod h1:CRqaW1Uns1TCkP0wqTpxYyRxRjxwvKU/XSS44u6X74M=
github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II=
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -736,7 +734,6 @@ go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -811,7 +808,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=


+ 1
- 1
modules/migrations/error.go View File

@@ -8,7 +8,7 @@ package migrations
import (
"errors"

"github.com/google/go-github/v24/github"
"github.com/google/go-github/v32/github"
)

var (


+ 4
- 4
modules/migrations/github.go View File

@@ -18,7 +18,7 @@ import (
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"

"github.com/google/go-github/v24/github"
"github.com/google/go-github/v32/github"
"golang.org/x/oauth2"
)

@@ -364,7 +364,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
}
var labels = make([]*base.Label, 0, len(issue.Labels))
for _, l := range issue.Labels {
labels = append(labels, convertGithubLabel(&l))
labels = append(labels, convertGithubLabel(l))
}

var email string
@@ -425,8 +425,8 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
asc = "asc"
)
opt := &github.IssueListCommentsOptions{
Sort: created,
Direction: asc,
Sort: &created,
Direction: &asc,
ListOptions: github.ListOptions{
PerPage: 100,
},


+ 0
- 230
vendor/github.com/google/go-github/v24/github/apps.go View File

@@ -1,230 +0,0 @@
// 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://developer.github.com/v3/apps/
type AppsService service

// App represents a GitHub App.
type App struct {
ID *int64 `json:"id,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 *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

// InstallationToken represents an installation token.
type InstallationToken struct {
Token *string `json:"token,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

// InstallationPermissions lists the permissions for metadata, contents, issues and single file for an installation.
type InstallationPermissions struct {
Metadata *string `json:"metadata,omitempty"`
Contents *string `json:"contents,omitempty"`
Issues *string `json:"issues,omitempty"`
SingleFile *string `json:"single_file,omitempty"`
}

// Installation represents a GitHub Apps installation.
type Installation struct {
ID *int64 `json:"id,omitempty"`
AppID *int64 `json:"app_id,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"`
Permissions *InstallationPermissions `json:"permissions,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,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://developer.github.com/v3/apps/#get-a-single-github-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
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)

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://developer.github.com/v3/apps/#find-installations
func (s *AppsService) ListInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("app/installations", 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", mediaTypeIntegrationPreview)

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://developer.github.com/v3/apps/#get-a-single-installation
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://developer.github.com/v3/apps/#list-installations-for-user
func (s *AppsService) ListUserInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("user/installations", 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", mediaTypeIntegrationPreview)

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
}

// CreateInstallationToken creates a new installation token.
//
// GitHub API docs: https://developer.github.com/v3/apps/#create-a-new-installation-token
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64) (*InstallationToken, *Response, error) {
u := fmt.Sprintf("app/installations/%v/access_tokens", id)

req, err := s.client.NewRequest("POST", u, nil)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)

t := new(InstallationToken)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// FindOrganizationInstallation finds the organization's installation information.
//
// GitHub API docs: https://developer.github.com/v3/apps/#find-organization-installation
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://developer.github.com/v3/apps/#find-repository-installation
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://developer.github.com/v3/apps/#find-repository-installation
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
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeIntegrationPreview)

i := new(Installation)
resp, err := s.client.Do(ctx, req, i)
if err != nil {
return nil, resp, err
}

return i, resp, nil
}

+ 0
- 457
vendor/github.com/google/go-github/v24/github/teams.go View File

@@ -1,457 +0,0 @@
// 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"
"strings"
"time"
)

// TeamsService provides access to the team-related functions
// in the GitHub API.
//
// GitHub API docs: https://developer.github.com/v3/teams/
type TeamsService service

// Team represents a team within a GitHub organization. Teams are used to
// manage access to an organization's repositories.
type Team struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
URL *string `json:"url,omitempty"`
Slug *string `json:"slug,omitempty"`

// Permission specifies the default permission for repositories owned by the team.
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"`
MembersURL *string `json:"members_url,omitempty"`
RepositoriesURL *string `json:"repositories_url,omitempty"`
Parent *Team `json:"parent,omitempty"`

// LDAPDN is only available in GitHub Enterprise and when the team
// membership is synchronized with LDAP.
LDAPDN *string `json:"ldap_dn,omitempty"`
}

func (t Team) String() string {
return Stringify(t)
}

// Invitation represents a team member's invitation status.
type Invitation struct {
ID *int64 `json:"id,omitempty"`
Login *string `json:"login,omitempty"`
Email *string `json:"email,omitempty"`
// Role can be one of the values - 'direct_member', 'admin', 'billing_manager', 'hiring_manager', or 'reinstate'.
Role *string `json:"role,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Inviter *User `json:"inviter,omitempty"`
TeamCount *int `json:"team_count,omitempty"`
InvitationTeamURL *string `json:"invitation_team_url,omitempty"`
}

func (i Invitation) String() string {
return Stringify(i)
}

// ListTeams lists all of the teams for an organization.
//
// GitHub API docs: https://developer.github.com/v3/teams/#list-teams
func (s *TeamsService) ListTeams(ctx context.Context, 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
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

var teams []*Team
resp, err := s.client.Do(ctx, req, &teams)
if err != nil {
return nil, resp, err
}

return teams, resp, nil
}

// GetTeam fetches a team by ID.
//
// GitHub API docs: https://developer.github.com/v3/teams/#get-team
func (s *TeamsService) GetTeam(ctx context.Context, team int64) (*Team, *Response, error) {
u := fmt.Sprintf("teams/%v", team)
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", mediaTypeNestedTeamsPreview)

t := new(Team)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// NewTeam represents a team to be created or modified.
type NewTeam struct {
Name string `json:"name"` // Name of the team. (Required.)
Description *string `json:"description,omitempty"`
Maintainers []string `json:"maintainers,omitempty"`
RepoNames []string `json:"repo_names,omitempty"`
ParentTeamID *int64 `json:"parent_team_id,omitempty"`

// Deprecated: 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"`

// LDAPDN may be used in GitHub Enterprise when the team membership
// is synchronized with LDAP.
LDAPDN *string `json:"ldap_dn,omitempty"`
}

func (s NewTeam) String() string {
return Stringify(s)
}

// CreateTeam creates a new team within an organization.
//
// GitHub API docs: https://developer.github.com/v3/teams/#create-team
func (s *TeamsService) CreateTeam(ctx context.Context, org string, team NewTeam) (*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
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

t := new(Team)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// EditTeam edits a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/#edit-team
func (s *TeamsService) EditTeam(ctx context.Context, id int64, team NewTeam) (*Team, *Response, error) {
u := fmt.Sprintf("teams/%v", id)
req, err := s.client.NewRequest("PATCH", u, team)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

t := new(Team)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// DeleteTeam deletes a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/#delete-team
func (s *TeamsService) DeleteTeam(ctx context.Context, team int64) (*Response, error) {
u := fmt.Sprintf("teams/%v", team)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}

req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

return s.client.Do(ctx, req, nil)
}

// ListChildTeams lists child teams for a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/#list-child-teams
func (s *TeamsService) ListChildTeams(ctx context.Context, teamID int64, opt *ListOptions) ([]*Team, *Response, error) {
u := fmt.Sprintf("teams/%v/teams", teamID)
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", mediaTypeNestedTeamsPreview)

var teams []*Team
resp, err := s.client.Do(ctx, req, &teams)
if err != nil {
return nil, resp, err
}

return teams, resp, nil
}

// ListTeamRepos lists the repositories that the specified team has access to.
//
// GitHub API docs: https://developer.github.com/v3/teams/#list-team-repos
func (s *TeamsService) ListTeamRepos(ctx context.Context, team int64, 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
}

// TODO: remove custom Accept header when topics API fully launches.
headers := []string{mediaTypeTopicsPreview, mediaTypeNestedTeamsPreview}
req.Header.Set("Accept", strings.Join(headers, ", "))

var repos []*Repository
resp, err := s.client.Do(ctx, req, &repos)
if err != nil {
return nil, resp, err
}

return repos, resp, nil
}

// 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: https://developer.github.com/v3/teams/#check-if-a-team-manages-a-repository
func (s *TeamsService) IsTeamRepo(ctx context.Context, team int64, 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
}

headers := []string{mediaTypeOrgPermissionRepo, mediaTypeNestedTeamsPreview}
req.Header.Set("Accept", strings.Join(headers, ", "))

repository := new(Repository)
resp, err := s.client.Do(ctx, req, repository)
if err != nil {
return nil, resp, err
}

return repository, resp, nil
}

// TeamAddTeamRepoOptions specifies the optional parameters to the
// TeamsService.AddTeamRepo method.
type TeamAddTeamRepoOptions 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: https://developer.github.com/v3/teams/#add-team-repo
func (s *TeamsService) AddTeamRepo(ctx context.Context, team int64, owner string, repo string, opt *TeamAddTeamRepoOptions) (*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
}

return s.client.Do(ctx, 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: https://developer.github.com/v3/teams/#remove-team-repo
func (s *TeamsService) RemoveTeamRepo(ctx context.Context, team int64, 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(ctx, req, nil)
}

// ListUserTeams lists a user's teams
// GitHub API docs: https://developer.github.com/v3/teams/#list-user-teams
func (s *TeamsService) ListUserTeams(ctx context.Context, 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
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

var teams []*Team
resp, err := s.client.Do(ctx, req, &teams)
if err != nil {
return nil, resp, err
}

return teams, resp, nil
}

// ListTeamProjects lists the organization projects for a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/#list-team-projects
func (s *TeamsService) ListTeamProjects(ctx context.Context, teamID int64) ([]*Project, *Response, error) {
u := fmt.Sprintf("teams/%v/projects", teamID)

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{mediaTypeNestedTeamsPreview, mediaTypeProjectsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

var projects []*Project
resp, err := s.client.Do(ctx, req, &projects)
if err != nil {
return nil, resp, err
}

return projects, resp, nil
}

// ReviewTeamProjects checks whether a team has read, write, or admin
// permissions for an organization project.
//
// GitHub API docs: https://developer.github.com/v3/teams/#review-a-team-project
func (s *TeamsService) ReviewTeamProjects(ctx context.Context, teamID, projectID int64) (*Project, *Response, error) {
u := fmt.Sprintf("teams/%v/projects/%v", teamID, projectID)
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{mediaTypeNestedTeamsPreview, mediaTypeProjectsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

projects := &Project{}
resp, err := s.client.Do(ctx, req, &projects)
if err != nil {
return nil, resp, err
}

return projects, resp, nil
}

// TeamProjectOptions specifies the optional parameters to the
// TeamsService.AddTeamProject method.
type TeamProjectOptions struct {
// Permission specifies the permission to grant to the team for this project.
// Possible values are:
// "read" - team members can read, but not write to or administer this project.
// "write" - team members can read and write, but not administer this project.
// "admin" - team members can read, write and administer this project.
//
Permission *string `json:"permission,omitempty"`
}

// AddTeamProject adds an organization project to a team. To add a project to a team or
// update the team's permission on a project, the authenticated user must have admin
// permissions for the project.
//
// GitHub API docs: https://developer.github.com/v3/teams/#add-or-update-team-project
func (s *TeamsService) AddTeamProject(ctx context.Context, teamID, projectID int64, opt *TeamProjectOptions) (*Response, error) {
u := fmt.Sprintf("teams/%v/projects/%v", teamID, projectID)
req, err := s.client.NewRequest("PUT", u, opt)
if err != nil {
return nil, err
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeNestedTeamsPreview, mediaTypeProjectsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

return s.client.Do(ctx, req, nil)
}

// RemoveTeamProject removes an organization project from a team. An organization owner or
// a team maintainer can remove any project from the team. To remove a project from a team
// as an organization member, the authenticated user must have "read" access to both the team
// and project, or "admin" access to the team or project.
// Note: This endpoint removes the project from the team, but does not delete it.
//
// GitHub API docs: https://developer.github.com/v3/teams/#remove-team-project
func (s *TeamsService) RemoveTeamProject(ctx context.Context, teamID int64, projectID int64) (*Response, error) {
u := fmt.Sprintf("teams/%v/projects/%v", teamID, projectID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeNestedTeamsPreview, mediaTypeProjectsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

return s.client.Do(ctx, req, nil)
}

+ 0
- 155
vendor/github.com/google/go-github/v24/github/teams_discussion_comments.go View File

@@ -1,155 +0,0 @@
// 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"
)

// DiscussionComment represents a GitHub dicussion in a team.
type DiscussionComment struct {
Author *User `json:"author,omitempty"`
Body *string `json:"body,omitempty"`
BodyHTML *string `json:"body_html,omitempty"`
BodyVersion *string `json:"body_version,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
LastEditedAt *Timestamp `json:"last_edited_at,omitempty"`
DiscussionURL *string `json:"discussion_url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Number *int `json:"number,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
URL *string `json:"url,omitempty"`
Reactions *Reactions `json:"reactions,omitempty"`
}

func (c DiscussionComment) String() string {
return Stringify(c)
}

// DiscussionCommentListOptions specifies optional parameters to the
// TeamServices.ListComments method.
type DiscussionCommentListOptions struct {
// Sorts the discussion comments by the date they were created.
// Accepted values are asc and desc. Default is desc.
Direction string `url:"direction,omitempty"`
}

// ListComments lists all comments on a team discussion.
// Authenticated user must grant read:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussion_comments/#list-comments
func (s *TeamsService) ListComments(ctx context.Context, teamID int64, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments", teamID, discussionNumber)
u, err := addOptions(u, options)
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", mediaTypeTeamDiscussionsPreview)

var comments []*DiscussionComment
resp, err := s.client.Do(ctx, req, &comments)
if err != nil {
return nil, resp, err
}

return comments, resp, nil
}

// GetComment gets a specific comment on a team discussion.
// Authenticated user must grant read:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussion_comments/#get-a-single-comment
func (s *TeamsService) GetComment(ctx context.Context, teamID int64, discussionNumber, commentNumber int) (*DiscussionComment, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v", teamID, discussionNumber, commentNumber)
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", mediaTypeTeamDiscussionsPreview)

discussionComment := &DiscussionComment{}
resp, err := s.client.Do(ctx, req, discussionComment)
if err != nil {
return nil, resp, err
}

return discussionComment, resp, nil
}

// CreateComment creates a new discussion post on a team discussion.
// Authenticated user must grant write:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussion_comments/#create-a-comment
func (s *TeamsService) CreateComment(ctx context.Context, teamID int64, discsusionNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments", teamID, discsusionNumber)
req, err := s.client.NewRequest("POST", u, comment)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamDiscussionsPreview)

discussionComment := &DiscussionComment{}
resp, err := s.client.Do(ctx, req, discussionComment)
if err != nil {
return nil, resp, err
}

return discussionComment, resp, nil
}

// EditComment edits the body text of a discussion comment.
// Authenticated user must grant write:discussion scope.
// User is allowed to edit body of a comment only.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussion_comments/#edit-a-comment
func (s *TeamsService) EditComment(ctx context.Context, teamID int64, discussionNumber, commentNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v", teamID, discussionNumber, commentNumber)
req, err := s.client.NewRequest("PATCH", u, comment)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamDiscussionsPreview)

discussionComment := &DiscussionComment{}
resp, err := s.client.Do(ctx, req, discussionComment)
if err != nil {
return nil, resp, err
}

return discussionComment, resp, nil
}

// DeleteComment deletes a comment on a team discussion.
// Authenticated user must grant write:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussion_comments/#delete-a-comment
func (s *TeamsService) DeleteComment(ctx context.Context, teamID int64, discussionNumber, commentNumber int) (*Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v", teamID, discussionNumber, commentNumber)
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", mediaTypeTeamDiscussionsPreview)

return s.client.Do(ctx, req, nil)
}

+ 0
- 160
vendor/github.com/google/go-github/v24/github/teams_discussions.go View File

@@ -1,160 +0,0 @@
// 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"
)

// TeamDiscussion represents a GitHub dicussion in a team.
type TeamDiscussion struct {
Author *User `json:"author,omitempty"`
Body *string `json:"body,omitempty"`
BodyHTML *string `json:"body_html,omitempty"`
BodyVersion *string `json:"body_version,omitempty"`
CommentsCount *int `json:"comments_count,omitempty"`
CommentsURL *string `json:"comments_url,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
LastEditedAt *Timestamp `json:"last_edited_at,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Number *int `json:"number,omitempty"`
Pinned *bool `json:"pinned,omitempty"`
Private *bool `json:"private,omitempty"`
TeamURL *string `json:"team_url,omitempty"`
Title *string `json:"title,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
URL *string `json:"url,omitempty"`
Reactions *Reactions `json:"reactions,omitempty"`
}

func (d TeamDiscussion) String() string {
return Stringify(d)
}

// DiscussionListOptions specifies optional parameters to the
// TeamServices.ListDiscussions method.
type DiscussionListOptions struct {
// Sorts the discussion by the date they were created.
// Accepted values are asc and desc. Default is desc.
Direction string `url:"direction,omitempty"`
}

// ListDiscussions lists all discussions on team's page.
// Authenticated user must grant read:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#list-discussions
func (s *TeamsService) ListDiscussions(ctx context.Context, teamID int64, options *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions", teamID)
u, err := addOptions(u, options)
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", mediaTypeTeamDiscussionsPreview)

var teamDiscussions []*TeamDiscussion
resp, err := s.client.Do(ctx, req, &teamDiscussions)
if err != nil {
return nil, resp, err
}

return teamDiscussions, resp, nil
}

// GetDiscussion gets a specific discussion on a team's page.
// Authenticated user must grant read:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#get-a-single-discussion
func (s *TeamsService) GetDiscussion(ctx context.Context, teamID int64, discussionNumber int) (*TeamDiscussion, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber)
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", mediaTypeTeamDiscussionsPreview)

teamDiscussion := &TeamDiscussion{}
resp, err := s.client.Do(ctx, req, teamDiscussion)
if err != nil {
return nil, resp, err
}

return teamDiscussion, resp, nil
}

// CreateDiscussion creates a new discussion post on a team's page.
// Authenticated user must grant write:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#create-a-discussion
func (s *TeamsService) CreateDiscussion(ctx context.Context, teamID int64, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions", teamID)
req, err := s.client.NewRequest("POST", u, discussion)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamDiscussionsPreview)

teamDiscussion := &TeamDiscussion{}
resp, err := s.client.Do(ctx, req, teamDiscussion)
if err != nil {
return nil, resp, err
}

return teamDiscussion, resp, nil
}

// EditDiscussion edits the title and body text of a discussion post.
// Authenticated user must grant write:discussion scope.
// User is allowed to change Title and Body of a discussion only.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#edit-a-discussion
func (s *TeamsService) EditDiscussion(ctx context.Context, teamID int64, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber)
req, err := s.client.NewRequest("PATCH", u, discussion)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamDiscussionsPreview)

teamDiscussion := &TeamDiscussion{}
resp, err := s.client.Do(ctx, req, teamDiscussion)
if err != nil {
return nil, resp, err
}

return teamDiscussion, resp, nil
}

// DeleteDiscussion deletes a discussion from team's page.
// Authenticated user must grant write:discussion scope.
//
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#delete-a-discussion
func (s *TeamsService) DeleteDiscussion(ctx context.Context, teamID int64, discussionNumber int) (*Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber)
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", mediaTypeTeamDiscussionsPreview)

return s.client.Do(ctx, req, nil)
}

+ 0
- 174
vendor/github.com/google/go-github/v24/github/teams_members.go View File

@@ -1,174 +0,0 @@
// 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"
)

// TeamListTeamMembersOptions specifies the optional parameters to the
// TeamsService.ListTeamMembers method.
type TeamListTeamMembersOptions 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: https://developer.github.com/v3/teams/members/#list-team-members
func (s *TeamsService) ListTeamMembers(ctx context.Context, team int64, opt *TeamListTeamMembersOptions) ([]*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
}

req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

var members []*User
resp, err := s.client.Do(ctx, req, &members)
if err != nil {
return nil, resp, err
}

return members, resp, nil
}

// IsTeamMember checks if a user is a member of the specified team.
//
// GitHub API docs: https://developer.github.com/v3/teams/members/#get-team-member
//
// Deprecated: This API has been marked as deprecated in the Github API docs,
// TeamsService.GetTeamMembership method should be used instead.
func (s *TeamsService) IsTeamMember(ctx context.Context, team int64, 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(ctx, req, nil)
member, err := parseBoolResponse(err)
return member, resp, err
}

// GetTeamMembership returns the membership status for a user in a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/members/#get-team-membership
func (s *TeamsService) GetTeamMembership(ctx context.Context, team int64, 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
}

req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

t := new(Membership)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// TeamAddTeamMembershipOptions specifies the optional
// parameters to the TeamsService.AddTeamMembership method.
type TeamAddTeamMembershipOptions 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/teams/members/#add-or-update-team-membership
func (s *TeamsService) AddTeamMembership(ctx context.Context, team int64, user string, opt *TeamAddTeamMembershipOptions) (*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
}

t := new(Membership)
resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}

return t, resp, nil
}

// RemoveTeamMembership removes a user from a team.
//
// GitHub API docs: https://developer.github.com/v3/teams/members/#remove-team-membership
func (s *TeamsService) RemoveTeamMembership(ctx context.Context, team int64, 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(ctx, req, nil)
}

// ListPendingTeamInvitations get pending invitaion list in team.
// Warning: The API may change without advance notice during the preview period.
// Preview features are not supported for production use.
//
// GitHub API docs: https://developer.github.com/v3/teams/members/#list-pending-team-invitations
func (s *TeamsService) ListPendingTeamInvitations(ctx context.Context, team int64, opt *ListOptions) ([]*Invitation, *Response, error) {
u := fmt.Sprintf("teams/%v/invitations", 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
}

var pendingInvitations []*Invitation
resp, err := s.client.Do(ctx, req, &pendingInvitations)
if err != nil {
return nil, resp, err
}

return pendingInvitations, resp, nil
}

vendor/github.com/google/go-github/v24/AUTHORS → vendor/github.com/google/go-github/v32/AUTHORS View File

@@ -9,22 +9,31 @@
# their employer, as appropriate).

178inaba <[email protected]>
2BFL <[email protected]>
413x <[email protected]>
Abhinav Gupta <[email protected]>
adrienzieba <[email protected]>
Ahmed Hagy <[email protected]>
Aidan Steele <[email protected]>
Ainsley Chong <[email protected]>
ajz01 <[email protected]>
Akeda Bagus <[email protected]>
Akhil Mohan <[email protected]>
Alec Thomas <[email protected]>
Aleks Clark <[email protected]>
Alex Bramley <[email protected]>
Alex Orr <[email protected]>
Alexander Harkness <[email protected]>
Allen Sun <[email protected]>
Amey Sakhadeo <[email protected]>
Anders Janmyr <[email protected]>
Andreas Garnæs <https://github.com/andreas>
Andrew Ryabchun <[email protected]>
Andy Grunwald <[email protected]>
Andy Hume <[email protected]>
Andy Lindeman <[email protected]>
angie pinilla <[email protected]>
anjanashenoy <[email protected]>
Anshuman Bhartiya <[email protected]>
Antoine <[email protected]>
Antoine Pelisse <[email protected]>
@@ -33,6 +42,7 @@ appilon <[email protected]>
Aravind <[email protected]>
Arda Kuyumcu <[email protected]>
Arıl Bozoluk <[email protected]>
Austin Burdine <[email protected]>
Austin Dizzy <[email protected]>
Ben Batha <[email protected]>
Benjamen Keroack <[email protected]>
@@ -47,13 +57,18 @@ Brandon Cook <[email protected]>
Brian Egizi <[email protected]>
Bryan Boreham <[email protected]>
Cami Diez <[email protected]>
Carl Johnson <[email protected]>
Carlos Alexandro Becker <[email protected]>
Carlos Tadeu Panato Junior <[email protected]>
chandresh-pancholi <[email protected]>
Charles Fenwick Elliott <[email protected]>
Charlie Yan <[email protected]>
Chris King <[email protected]>
Chris Raborg <[email protected]>
Chris Roche <[email protected]>
Chris Schaefer <[email protected]>
chrisforrette <[email protected]>
Christian Muehlhaeuser <[email protected]>
Christoph Sassenberg <[email protected]>
Colin Misare <github.com/cmisare>
Craig Peterson <[email protected]>
@@ -61,10 +76,14 @@ Cristian Maglie <[email protected]>
Daehyeok Mun <[email protected]>
Daniel Leavitt <[email protected]>
Daniel Nilsson <[email protected]>
Daoq <[email protected]>
Dave Du Cros <[email protected]>
Dave Henderson <[email protected]>
Dave Protasowski <[email protected]>
David Deng <[email protected]>
David Jannotta <[email protected]>
David Ji <github.com/davidji99>
David Lopez Reyes <[email protected]>
Davide Zipeto <[email protected]>
Dennis Webb <[email protected]>
Dhi Aurrahman <[email protected]>
@@ -74,22 +93,26 @@ dmnlk <[email protected]>
Don Petersen <[email protected]>
Doug Turner <[email protected]>
Drew Fradette <[email protected]>
Eivind <[email protected]>
Eli Uriegas <[email protected]>
Elliott Beach <[email protected]>
Emerson Wood <[email protected]>
eperm <[email protected]>
Erick Fejta <[email protected]>
erwinvaneyk <[email protected]>
Evan Elias <[email protected]>
Fabrice <[email protected]>
Felix Geisendörfer <[email protected]>
Filippo Valsorda <[email protected]>
Florian Forster <[email protected]>
Francesc Gil <[email protected]>
Francis <[email protected]>
Francisco Guimarães <[email protected]>
Fredrik Jönsson <[email protected]>
Garrett Squire <[email protected]>
George Kontridze <[email protected]>
Georgy Buranov <[email protected]>
Glen Mailer <[email protected]>
Gnahz <[email protected]>
Google Inc.
Grachev Mikhail <[email protected]>
@@ -99,13 +122,16 @@ Guz Alexander <[email protected]>
Guðmundur Bjarni Ólafsson <[email protected]>
Hanno Hecker <[email protected]>
Hari haran <[email protected]>
haya14busa <[email protected]>
haya14busa <[email protected]>
Huy Tr <[email protected]>
huydx <[email protected]>
i2bskn <[email protected]>
Ioannis Georgoulas <[email protected]>
Isao Jonas <[email protected]>
isqua <[email protected]>
Jameel Haffejee <[email protected]>
James Cockbain <[email protected]>
Jan Kosecki <[email protected]>
Javier Campanini <[email protected]>
Jens Rantil <[email protected]>
@@ -117,6 +143,7 @@ Joan Saum <[email protected]>
Joe Tsai <[email protected]>
John Barton <[email protected]>
John Engelman <[email protected]>
Jordan Brockopp <[email protected]>
Jordan Sussman <[email protected]>
Joshua Bezaleel Abednego <[email protected]>
JP Phillips <[email protected]>
@@ -124,11 +151,12 @@ jpbelanger-mtl <[email protected]>
Juan Basso <[email protected]>
Julien Garcia Gonzalez <[email protected]>
Julien Rostand <[email protected]>
Junya Kono <[email protected]>
Justin Abrahms <[email protected]>
Jusung Lee <[email protected]>
jzhoucliqr <[email protected]>
kadern0 <[email protected]>
Katrina Owen <[email protected]>
Kautilya Tripathi < [email protected]>
Kautilya Tripathi <[email protected]>
Keita Urashima <[email protected]>
Kevin Burke <[email protected]>
@@ -137,15 +165,21 @@ Kookheon Kwon <[email protected]>
Krzysztof Kowalczyk <[email protected]>
Kshitij Saraogi <[email protected]>
kyokomi <[email protected]>
Laurent Verdoïa <[email protected]>
Liam Galvin <[email protected]>
Lovro Mažgon <[email protected]>
Lucas Alcantara <[email protected]>
Luke Evers <[email protected]>
Luke Kysow <[email protected]>
Luke Roberts <[email protected]>
Luke Young <[email protected]ydrantlabs.org>
lynn [they] <[email protected]>
Maksim Zhylinski <[email protected]>
Mark Tareshawty <[email protected]>
Martin-Louis Bright <[email protected]>
Martins Sipenko <[email protected]>
Marwan Sulaiman <[email protected]>
Masayuki Izumi <[email protected]>
Mat Geist <[email protected]>
Matt <[email protected]>
Matt Brender <[email protected]>
@@ -155,6 +189,7 @@ Maxime Bury <[email protected]>
Michael Spiegel <[email protected]>
Michael Tiller <[email protected]>
Michał Glapa <[email protected]>
Nadav Kaner <[email protected]>
Nathan VanBenschoten <[email protected]>
Navaneeth Suresh <[email protected]>
Neil O'Toole <[email protected]>
@@ -163,6 +198,7 @@ Nick Spragg <[email protected]>
Nikhita Raghunath <[email protected]>
Noah Zoschke <[email protected]>
ns-cweber <[email protected]>
Ole Orhagen <[email protected]>
Oleg Kovalov <[email protected]>
Ondřej Kupka <[email protected]>
Palash Nigam <[email protected]>
@@ -170,29 +206,43 @@ Panagiotis Moustafellos <[email protected]>
Parham Alvani <[email protected]>
Parker Moore <[email protected]>
parkhyukjun89 <[email protected]>
Patrick DeVivo <[email protected]>
Patrick Marabeas <[email protected]>
Pavel Shtanko <[email protected]>
Pete Wagner <[email protected]>
Petr Shevtsov <[email protected]>
Pierre Carrier <[email protected]>
Piotr Zurek <[email protected]>
Pratik Mallya <[email protected]>
Qais Patankar <[email protected]>
Quang Le Hong <[email protected]>
Quentin Leffray <[email protected]>
Quinn Slack <[email protected]>
Rackspace US, Inc.
Radek Simko <[email protected]>
Radliński Ignacy <[email protected]>
Rajat Jindal <[email protected]>
Rajendra arora <[email protected]>
Ranbir Singh <[email protected]>
Ravi Shekhar Jethani <[email protected]>
RaviTeja Pothana <[email protected]>
rc1140 <[email protected]>
Red Hat, Inc.
Reinier Timmer <[email protected]>
Ricco Førgaard <[email protected]>
Rob Figueiredo <[email protected]>
Rohit Upadhyay <[email protected]>
Ronak Jain <[email protected]>
Ruben Vereecken <[email protected]>
Ryan Leung <[email protected]>
Ryan Lower <[email protected]>
Ryo Nakao <[email protected]>
Safwan Olaimat <[email protected]>
Sahil Dua <[email protected]>
saisi <[email protected]>
Sam Minnée <[email protected]>
Sandeep Sukhani <[email protected]>
Sander Knape <[email protected]>
Sander van Harmelen <[email protected]>
Sanket Payghan <[email protected]>
Sarasa Kisaragi <[email protected]>
@@ -200,30 +250,46 @@ Sean Wang <[email protected]>
Sebastian Mandrean <[email protected]>
Sebastian Mæland Pedersen <[email protected]>
Sergey Romanov <[email protected]>
Sergio Garcia <[email protected]>
Sevki <[email protected]>
Shagun Khemka <[email protected]>
shakeelrao <[email protected]>
Shawn Catanzarite <[email protected]>
Shawn Smith <[email protected]>
Shibasis Patel <[email protected]>
Shrikrishna Singh <[email protected]>
sona-tar <[email protected]>
SoundCloud, Ltd.
Sridhar Mocherla <[email protected]>
SriVignessh Pss <[email protected]>
Stefan Sedich <[email protected]>
Stian Eikeland <[email protected]>
Suhaib Mujahid <[email protected]>
Szymon Kodrebski <[email protected]>
Takayuki Watanabe <[email protected]>
Taketoshi Fujiwara <[email protected]>
Tasya Aditya Rukmana <[email protected]>
Thomas Bruyelle <[email protected]>
Timothée Peignier <[email protected]>
tkhandel <[email protected]>
Trey Tacon <[email protected]>
ttacon <[email protected]>
Vaibhav Singh <[email protected]>
Varadarajan Aravamudhan <[email protected]>
Victor Castell <[email protected]>
Victor Vrantchan <[email protected]>
vikkyomkar <[email protected]>
Vlad Ungureanu <[email protected]>
Wasim Thabraze <[email protected]>
Weslei Juan Moser Pereira <[email protected]>
Will Maier <[email protected]>
Willem D'Haeseleer <[email protected]>
William Bailey <[email protected]>
William Cooke <[email protected]>
xibz <[email protected]>
Yann Malet <[email protected]>
Yannick Utard <[email protected]>
Yicheng Qin <[email protected]>
Yosuke Akatsuka <[email protected]>
Yumikiyo Osanai <[email protected]>
Zach Latta <[email protected]>

vendor/github.com/google/go-github/v24/LICENSE → vendor/github.com/google/go-github/v32/LICENSE View File


+ 12
- 0
vendor/github.com/google/go-github/v32/github/actions.go View 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://developer.github.com/v3/actions/
type ActionsService service

+ 164
- 0
vendor/github.com/google/go-github/v32/github/actions_artifacts.go View 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://developer.github.com/v3/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://developer.github.com/v3/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://developer.github.com/v3/actions/artifacts/#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://developer.github.com/v3/actions/artifacts/#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://developer.github.com/v3/actions/artifacts/#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://developer.github.com/v3/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://developer.github.com/v3/actions/artifacts/#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)
}

+ 277
- 0
vendor/github.com/google/go-github/v32/github/actions_runners.go View File

@@ -0,0 +1,277 @@
// 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"`
}

// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
//
// GitHub API docs: https://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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"`
}

// 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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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
}

// GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID.
//
// GitHub API docs: https://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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://developer.github.com/v3/actions/self-hosted-runners/#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)
}

+ 299
- 0
vendor/github.com/google/go-github/v32/github/actions_secrets.go View File

@@ -0,0 +1,299 @@
// 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"
)

// PublicKey represents the public key that should be used to encrypt secrets.
type PublicKey struct {
KeyID *string `json:"key_id"`
Key *string `json:"key"`
}

// GetRepoPublicKey gets a public key that should be used for secret encryption.
//
// GitHub API docs: https://developer.github.com/v3/actions/secrets/#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://developer.github.com/v3/actions/secrets/#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
}

// 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"`
}