Update vendor
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
296333412a
commit
fb344ab2f2
134 changed files with 2947 additions and 1419 deletions
38
vendor/github.com/google/go-github/v43/github/repos_merging.go
generated
vendored
38
vendor/github.com/google/go-github/v43/github/repos_merging.go
generated
vendored
|
|
@ -1,38 +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 (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// RepositoryMergeRequest represents a request to merge a branch in a
|
||||
// repository.
|
||||
type RepositoryMergeRequest struct {
|
||||
Base *string `json:"base,omitempty"`
|
||||
Head *string `json:"head,omitempty"`
|
||||
CommitMessage *string `json:"commit_message,omitempty"`
|
||||
}
|
||||
|
||||
// Merge a branch in the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#merge-a-branch
|
||||
func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/merges", owner, repo)
|
||||
req, err := s.client.NewRequest("POST", u, request)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
commit := new(RepositoryCommit)
|
||||
resp, err := s.client.Do(ctx, req, commit)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return commit, resp, nil
|
||||
}
|
||||
|
|
@ -8,5 +8,5 @@ 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/
|
||||
type ActionsService service
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
|
||||
type Artifact struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
|
|
@ -30,7 +30,7 @@ type Artifact struct {
|
|||
|
||||
// ArtifactList represents a list of GitHub artifacts.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#artifacts
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#artifacts
|
||||
type ArtifactList struct {
|
||||
TotalCount *int64 `json:"total_count,omitempty"`
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
|
|
@ -38,7 +38,7 @@ type ArtifactList struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -62,7 +62,7 @@ func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -86,7 +86,7 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -106,52 +106,31 @@ func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, ar
|
|||
|
||||
// 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/#download-an-artifact
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
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"))
|
||||
if err != nil {
|
||||
return nil, newResponse(resp), err
|
||||
}
|
||||
|
||||
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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -61,10 +61,18 @@ type SetRunnerGroupRunnersRequest struct {
|
|||
Runners []int64 `json:"runners"`
|
||||
}
|
||||
|
||||
// ListOrgRunnerGroupOptions extend ListOptions to have the optional parameters VisibleToRepository.
|
||||
type ListOrgRunnerGroupOptions struct {
|
||||
ListOptions
|
||||
|
||||
// Only return runner groups that are allowed to be used by this repository.
|
||||
VisibleToRepository string `url:"visible_to_repository,omitempty"`
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization
|
||||
func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOrgRunnerGroupOptions) (*RunnerGroups, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
|
|
@ -87,7 +95,7 @@ func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org s
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
|
@ -106,7 +114,7 @@ func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org str
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -120,7 +128,7 @@ func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
|
@ -139,7 +147,7 @@ func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
|
@ -158,7 +166,7 @@ func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
|
@ -183,7 +191,7 @@ func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, or
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -198,7 +206,7 @@ func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -213,7 +221,7 @@ func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -227,7 +235,7 @@ func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
|
@ -252,7 +260,7 @@ func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string,
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -266,7 +274,7 @@ func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -281,7 +289,7 @@ func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string,
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#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)
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ type ActionsEnabledOnOrgRepos struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -53,7 +53,7 @@ type RegistrationToken struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ type Runners struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -120,7 +120,7 @@ func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, op
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -145,7 +145,7 @@ type RemoveToken struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo stri
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, r
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -198,7 +198,7 @@ func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -242,7 +242,7 @@ func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner stri
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#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)
|
||||
|
|
@ -266,7 +266,7 @@ func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#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)
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#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)
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#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)
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ func (s *ActionsService) RemoveEnabledRepoInOrg(ctx context.Context, owner strin
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -344,7 +344,7 @@ func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -364,7 +364,7 @@ func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owne
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ func (s *ActionsService) getPublicKey(ctx context.Context, url string) (*PublicK
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-public-key
|
||||
func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/actions/secrets/public-key", owner, repo)
|
||||
return s.getPublicKey(ctx, url)
|
||||
|
|
@ -72,7 +72,7 @@ func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo strin
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-public-key
|
||||
func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org)
|
||||
return s.getPublicKey(ctx, url)
|
||||
|
|
@ -80,7 +80,7 @@ func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*Publ
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key
|
||||
func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/public-key", repoID, env)
|
||||
return s.getPublicKey(ctx, url)
|
||||
|
|
@ -124,7 +124,7 @@ func (s *ActionsService) listSecrets(ctx context.Context, url string, opts *List
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-repository-secrets
|
||||
func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/actions/secrets", owner, repo)
|
||||
return s.listSecrets(ctx, url, opts)
|
||||
|
|
@ -133,7 +133,7 @@ func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-organization-secrets
|
||||
func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets", org)
|
||||
return s.listSecrets(ctx, url, opts)
|
||||
|
|
@ -141,7 +141,7 @@ func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *L
|
|||
|
||||
// ListEnvSecrets lists all secrets available in an environment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-environment-secrets
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-environment-secrets
|
||||
func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/environments/%v/secrets", repoID, env)
|
||||
return s.listSecrets(ctx, url, opts)
|
||||
|
|
@ -164,7 +164,7 @@ func (s *ActionsService) getSecret(ctx context.Context, url string) (*Secret, *R
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-secret
|
||||
func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||
return s.getSecret(ctx, url)
|
||||
|
|
@ -172,7 +172,7 @@ func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name st
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-secret
|
||||
func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||
return s.getSecret(ctx, url)
|
||||
|
|
@ -180,13 +180,13 @@ func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*S
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret
|
||||
func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||
return s.getSecret(ctx, url)
|
||||
}
|
||||
|
||||
// SelectedRepoIDs are the repository IDs that have access to the secret.
|
||||
// SelectedRepoIDs are the repository IDs that have access to the actions secrets.
|
||||
type SelectedRepoIDs []int64
|
||||
|
||||
// EncryptedSecret represents a secret that is encrypted using a public key.
|
||||
|
|
@ -213,7 +213,7 @@ func (s *ActionsService) putSecret(ctx context.Context, url string, eSecret *Enc
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret
|
||||
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, eSecret.Name)
|
||||
return s.putSecret(ctx, url, eSecret)
|
||||
|
|
@ -221,7 +221,7 @@ func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, re
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-organization-secret
|
||||
func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name)
|
||||
return s.putSecret(ctx, url, eSecret)
|
||||
|
|
@ -229,7 +229,7 @@ func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string
|
|||
|
||||
// CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#create-or-update-an-environment-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret
|
||||
func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, eSecret.Name)
|
||||
return s.putSecret(ctx, url, eSecret)
|
||||
|
|
@ -246,7 +246,7 @@ func (s *ActionsService) deleteSecret(ctx context.Context, url string) (*Respons
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-a-repository-secret
|
||||
func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||
return s.deleteSecret(ctx, url)
|
||||
|
|
@ -254,7 +254,7 @@ func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-organization-secret
|
||||
func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||
return s.deleteSecret(ctx, url)
|
||||
|
|
@ -262,7 +262,7 @@ func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string)
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret
|
||||
func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||
return s.deleteSecret(ctx, url)
|
||||
|
|
@ -296,7 +296,7 @@ func (s *ActionsService) listSelectedReposForSecret(ctx context.Context, url str
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-selected-repositories-for-an-organization-secret
|
||||
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||
return s.listSelectedReposForSecret(ctx, url, opts)
|
||||
|
|
@ -317,7 +317,7 @@ func (s *ActionsService) setSelectedReposForSecret(ctx context.Context, url stri
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#set-selected-repositories-for-an-organization-secret
|
||||
func (s *ActionsService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||
return s.setSelectedReposForSecret(ctx, url, ids)
|
||||
|
|
@ -334,7 +334,7 @@ func (s *ActionsService) addSelectedRepoToSecret(ctx context.Context, url string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#add-selected-repository-to-an-organization-secret
|
||||
func (s *ActionsService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||
return s.addSelectedRepoToSecret(ctx, url)
|
||||
|
|
@ -351,7 +351,7 @@ func (s *ActionsService) removeSelectedRepoFromSecret(ctx context.Context, url s
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#remove-selected-repository-from-an-organization-secret
|
||||
func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||
return s.removeSelectedRepoFromSecret(ctx, url)
|
||||
|
|
@ -66,7 +66,7 @@ type ListWorkflowJobsOptions struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#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)
|
||||
|
|
@ -90,7 +90,7 @@ func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo strin
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#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)
|
||||
|
||||
|
|
@ -110,45 +110,20 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#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)
|
||||
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
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
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ type WorkflowRun struct {
|
|||
WorkflowURL *string `json:"workflow_url,omitempty"`
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
HeadRepository *Repository `json:"head_repository,omitempty"`
|
||||
Actor *User `json:"actor,omitempty"`
|
||||
}
|
||||
|
||||
// WorkflowRuns represents a slice of repository action workflow run.
|
||||
|
|
@ -93,6 +94,14 @@ type WorkflowRunAttemptOptions struct {
|
|||
ExcludePullRequests *bool `url:"exclude_pull_requests,omitempty"`
|
||||
}
|
||||
|
||||
// PendingDeploymentsRequest specifies body parameters to PendingDeployments.
|
||||
type PendingDeploymentsRequest struct {
|
||||
EnvironmentIDs []int64 `json:"environment_ids"`
|
||||
// State can be one of: "approved", "rejected".
|
||||
State string `json:"state"`
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
|
||||
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||
u, err := addOptions(endpoint, opts)
|
||||
if err != nil {
|
||||
|
|
@ -115,7 +124,7 @@ func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
|
@ -123,7 +132,7 @@ func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo s
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
|
@ -131,7 +140,7 @@ func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
|
@ -155,7 +164,7 @@ func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
||||
|
|
@ -175,7 +184,7 @@ func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo str
|
|||
|
||||
// GetWorkflowRunAttempt gets a specific workflow run attempt.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow-run-attempt
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run-attempt
|
||||
func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo string, runID int64, attemptNumber int, opts *WorkflowRunAttemptOptions) (*WorkflowRun, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v", owner, repo, runID, attemptNumber)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -199,7 +208,7 @@ func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
||||
|
|
@ -211,9 +220,37 @@ func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo stri
|
|||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// RerunFailedJobsByID re-runs all of the failed jobs and their dependent jobs in a workflow run by ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-failed-jobs-from-a-workflow-run
|
||||
func (s *ActionsService) RerunFailedJobsByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun-failed-jobs", owner, repo, runID)
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// RerunJobByID re-runs a job and its dependent jobs in a workflow run by ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run
|
||||
func (s *ActionsService) RerunJobByID(ctx context.Context, owner, repo string, jobID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/rerun", owner, repo, jobID)
|
||||
|
||||
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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
||||
|
|
@ -227,25 +264,27 @@ func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// DeleteWorkflowRun deletes a workflow run by ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-a-workflow-run
|
||||
func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
|
||||
|
||||
|
|
@ -259,7 +298,7 @@ func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo stri
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
||||
|
|
@ -273,7 +312,7 @@ func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#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)
|
||||
|
||||
|
|
@ -290,3 +329,23 @@ func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, rep
|
|||
|
||||
return workflowRunUsage, resp, nil
|
||||
}
|
||||
|
||||
// PendingDeployments approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run
|
||||
func (s *ActionsService) PendingDeployments(ctx context.Context, owner, repo string, runID int64, request *PendingDeploymentsRequest) ([]*Deployment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/pending_deployments", owner, repo, runID)
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, request)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var deployments []*Deployment
|
||||
resp, err := s.client.Do(ctx, req, &deployments)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return deployments, resp, nil
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ type CreateWorkflowDispatchEventRequest struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
|
@ -85,7 +85,7 @@ func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo s
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ func (s *ActionsService) getWorkflowUsage(ctx context.Context, url string) (*Wor
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, ow
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ func (s *ActionsService) createWorkflowDispatchEvent(ctx context.Context, url st
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
|
@ -186,7 +186,7 @@ func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo str
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
|
@ -194,7 +194,7 @@ func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, re
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
|
@ -202,7 +202,7 @@ func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo st
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#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)
|
||||
|
|
@ -10,7 +10,7 @@ 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/
|
||||
type ActivityService service
|
||||
|
||||
// FeedLink represents a link to a related resource.
|
||||
|
|
@ -45,14 +45,15 @@ type FeedLinks struct {
|
|||
// 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.
|
||||
//
|
||||
// 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.
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events
|
||||
func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
|
||||
u, err := addOptions("events", opts)
|
||||
if err != nil {
|
||||
|
|
@ -35,7 +35,7 @@ func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]
|
|||
|
||||
// ListRepositoryEvents lists events for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-events
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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)
|
||||
|
|
@ -59,7 +59,7 @@ func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/events#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)
|
||||
|
|
@ -83,7 +83,7 @@ func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owne
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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)
|
||||
|
|
@ -107,7 +107,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, r
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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)
|
||||
|
|
@ -132,8 +132,8 @@ func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org str
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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 {
|
||||
|
|
@ -163,8 +163,8 @@ func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user st
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-received-by-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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 {
|
||||
|
|
@ -194,7 +194,7 @@ func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user str
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/events#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)
|
||||
|
|
@ -19,7 +19,7 @@ type Notification struct {
|
|||
|
||||
// Reason identifies the event that triggered the notification.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#notification-reasons
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity#notification-reasons
|
||||
Reason *string `json:"reason,omitempty"`
|
||||
|
||||
Unread *bool `json:"unread,omitempty"`
|
||||
|
|
@ -49,7 +49,7 @@ type NotificationListOptions struct {
|
|||
|
||||
// ListNotifications lists all notifications for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-notifications-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user
|
||||
func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) {
|
||||
u := "notifications"
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -74,7 +74,7 @@ func (s *ActivityService) ListNotifications(ctx context.Context, opts *Notificat
|
|||
// ListRepositoryNotifications lists all notifications in a given repository
|
||||
// for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-notifications-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user
|
||||
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, err := addOptions(u, opts)
|
||||
|
|
@ -102,7 +102,7 @@ type markReadOptions struct {
|
|||
|
||||
// MarkNotificationsRead marks all notifications up to lastRead as read.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#mark-as-read
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read
|
||||
func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead time.Time) (*Response, error) {
|
||||
opts := &markReadOptions{
|
||||
LastReadAt: lastRead,
|
||||
|
|
@ -118,7 +118,7 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead ti
|
|||
// MarkRepositoryNotificationsRead marks all notifications up to lastRead in
|
||||
// the specified repository as read.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-repository-notifications-as-read
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read
|
||||
func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead time.Time) (*Response, error) {
|
||||
opts := &markReadOptions{
|
||||
LastReadAt: lastRead,
|
||||
|
|
@ -134,7 +134,7 @@ func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, o
|
|||
|
||||
// GetThread gets the specified notification thread.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread
|
||||
func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) {
|
||||
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notificati
|
|||
|
||||
// MarkThreadRead marks the specified thread as read.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-a-thread-as-read
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-a-thread-as-read
|
||||
func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) {
|
||||
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Respo
|
|||
// GetThreadSubscription checks to see if the authenticated user is subscribed
|
||||
// to a thread.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread-subscription-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user
|
||||
func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) {
|
||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string)
|
|||
// SetThreadSubscription sets the subscription for the specified thread for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#set-a-thread-subscription
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#set-a-thread-subscription
|
||||
func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) {
|
||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string,
|
|||
// DeleteThreadSubscription deletes the subscription for the specified thread
|
||||
// for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#delete-a-thread-subscription
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#delete-a-thread-subscription
|
||||
func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) {
|
||||
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -25,7 +25,7 @@ type Stargazer struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#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)
|
||||
|
|
@ -67,8 +67,8 @@ type ActivityListStarredOptions struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#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 != "" {
|
||||
|
|
@ -101,13 +101,14 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *Ac
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#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
|
||||
|
|
@ -115,24 +116,26 @@ func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#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)
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ type Subscription struct {
|
|||
|
||||
// ListWatchers lists watchers of a particular repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-watchers
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-watchers
|
||||
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, err := addOptions(u, opts)
|
||||
|
|
@ -52,8 +52,8 @@ func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string,
|
|||
// ListWatched lists the repositories the specified user is watching. Passing
|
||||
// the empty string will fetch watched repos for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-a-user
|
||||
func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) {
|
||||
var u string
|
||||
if user != "" {
|
||||
|
|
@ -84,7 +84,7 @@ func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *Li
|
|||
// repository for the authenticated user. If the authenticated user is not
|
||||
// watching the repository, a nil Subscription is returned.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-repository-subscription
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#get-a-repository-subscription
|
||||
func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner,
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#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)
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner,
|
|||
// This is used to stop watching a repository. To control whether or not to
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#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)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin
|
||||
type AdminService service
|
||||
|
||||
// TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group.
|
||||
|
|
@ -82,7 +82,7 @@ func (m Enterprise) String() string {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/enterprise-server/rest/enterprise-admin/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)
|
||||
|
|
@ -101,7 +101,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -153,7 +153,7 @@ func (s RepoStats) String() string {
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/
|
||||
type AppsService service
|
||||
|
||||
// App represents a GitHub App.
|
||||
|
|
@ -59,8 +59,9 @@ type InstallationTokenOptions struct {
|
|||
// 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
|
||||
//
|
||||
// https://docs.github.com/en/enterprise-server@3.0/rest/apps#create-an-installation-access-token-for-an-app
|
||||
// https://docs.github.com/en/rest/apps#create-an-installation-access-token-for-an-app
|
||||
type InstallationPermissions struct {
|
||||
Actions *string `json:"actions,omitempty"`
|
||||
Administration *string `json:"administration,omitempty"`
|
||||
|
|
@ -76,7 +77,9 @@ type InstallationPermissions struct {
|
|||
Metadata *string `json:"metadata,omitempty"`
|
||||
Members *string `json:"members,omitempty"`
|
||||
OrganizationAdministration *string `json:"organization_administration,omitempty"`
|
||||
OrganizationCustomRoles *string `json:"organization_custom_roles,omitempty"`
|
||||
OrganizationHooks *string `json:"organization_hooks,omitempty"`
|
||||
OrganizationPackages *string `json:"organization_packages,omitempty"`
|
||||
OrganizationPlan *string `json:"organization_plan,omitempty"`
|
||||
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
|
||||
OrganizationProjects *string `json:"organization_projects,omitempty"`
|
||||
|
|
@ -148,8 +151,8 @@ func (i Installation) String() string {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-the-authenticated-app
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-app
|
||||
func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) {
|
||||
var u string
|
||||
if appSlug != "" {
|
||||
|
|
@ -174,7 +177,7 @@ func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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 {
|
||||
|
|
@ -197,14 +200,14 @@ func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions)
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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 {
|
||||
|
|
@ -229,7 +232,7 @@ func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptio
|
|||
|
||||
// SuspendInstallation suspends the specified installation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#suspend-an-app-installation
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#suspend-an-app-installation
|
||||
func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||
|
||||
|
|
@ -243,7 +246,7 @@ func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Respo
|
|||
|
||||
// UnsuspendInstallation unsuspends the specified installation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#unsuspend-an-app-installation
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#unsuspend-an-app-installation
|
||||
func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||
|
||||
|
|
@ -257,7 +260,7 @@ func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Res
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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)
|
||||
|
||||
|
|
@ -271,7 +274,7 @@ func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Respon
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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)
|
||||
|
||||
|
|
@ -291,7 +294,7 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt
|
|||
|
||||
// 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
|
||||
// TODO: Find GitHub API docs.
|
||||
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)}
|
||||
|
|
@ -314,14 +317,14 @@ func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID i
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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))
|
||||
}
|
||||
|
|
@ -335,7 +338,7 @@ func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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))
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
// GetHookConfig returns the webhook configuration for a GitHub App.
|
||||
// The underlying transport must be authenticated as an app.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#get-a-webhook-configuration-for-an-app
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-webhook-configuration-for-an-app
|
||||
func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) {
|
||||
req, err := s.client.NewRequest("GET", "app/hook/config", nil)
|
||||
if err != nil {
|
||||
|
|
@ -31,7 +31,7 @@ func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response
|
|||
// UpdateHookConfig updates the webhook configuration for a GitHub App.
|
||||
// The underlying transport must be authenticated as an app.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#update-a-webhook-configuration-for-an-app
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps#update-a-webhook-configuration-for-an-app
|
||||
func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) {
|
||||
req, err := s.client.NewRequest("PATCH", "app/hook/config", config)
|
||||
if err != nil {
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ListHookDeliveries lists deliveries of an App webhook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/apps#list-deliveries-for-an-app-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook
|
||||
func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) {
|
||||
u, err := addOptions("app/hook/deliveries", opts)
|
||||
if err != nil {
|
||||
|
|
@ -35,7 +35,7 @@ func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOp
|
|||
|
||||
// GetHookDelivery returns the App webhook delivery with the specified ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/apps#get-a-delivery-for-an-app-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook
|
||||
func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||
u := fmt.Sprintf("app/hook/deliveries/%v", deliveryID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -54,7 +54,7 @@ func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*H
|
|||
|
||||
// RedeliverHookDelivery redelivers a delivery for an App webhook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/apps#redeliver-a-delivery-for-an-app-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook
|
||||
func (s *AppsService) RedeliverHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||
u := fmt.Sprintf("app/hook/deliveries/%v/attempts", deliveryID)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -19,7 +19,7 @@ type ListRepositories struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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 {
|
||||
|
|
@ -52,7 +52,7 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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)
|
||||
|
|
@ -84,7 +84,7 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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)
|
||||
|
|
@ -103,7 +103,7 @@ func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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)
|
||||
|
|
@ -116,7 +116,7 @@ func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#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)
|
||||
|
|
@ -31,7 +31,7 @@ type AppConfig struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/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)
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps#marketplace
|
||||
type MarketplaceService struct {
|
||||
client *Client
|
||||
// Stubbed controls whether endpoints that return stubbed data are used
|
||||
|
|
@ -21,7 +21,7 @@ type MarketplaceService struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps#testing-with-stubbed-endpoints
|
||||
Stubbed bool
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ type MarketplacePlanAccount struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps#list-plans
|
||||
func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) {
|
||||
uri := s.marketplaceURI("plans")
|
||||
u, err := addOptions(uri, opts)
|
||||
|
|
@ -101,7 +101,7 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -125,7 +125,7 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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))
|
||||
|
||||
|
|
@ -145,8 +145,8 @@ func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accou
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user-stubbed
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#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 {
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// Scope models a GitHub authorization scope.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth/#scopes
|
||||
// GitHub API docs: https://docs.github.com/en/rest/oauth/#scopes
|
||||
type Scope string
|
||||
|
||||
// This is the set of scopes for GitHub API V3
|
||||
|
|
@ -50,7 +50,7 @@ const (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations
|
||||
type AuthorizationsService service
|
||||
|
||||
// Authorization represents an individual GitHub authorization.
|
||||
|
|
@ -121,7 +121,7 @@ func (a AuthorizationRequest) String() string {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations#update-an-existing-authorization
|
||||
type AuthorizationUpdateRequest struct {
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
AddScopes []string `json:"add_scopes,omitempty"`
|
||||
|
|
@ -143,7 +143,7 @@ func (a AuthorizationUpdateRequest) String() string {
|
|||
//
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#check-a-token
|
||||
func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken
|
|||
//
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#reset-a-token
|
||||
func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-token
|
||||
func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToke
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-authorization
|
||||
func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/grant", clientID)
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// BillingService provides access to the billing related functions
|
||||
// in the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/billing
|
||||
// GitHub API docs: https://docs.github.com/en/rest/billing
|
||||
type BillingService service
|
||||
|
||||
// ActionBilling represents a GitHub Action billing.
|
||||
|
|
@ -65,7 +65,7 @@ type AdvancedSecurityCommittersBreakdown struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -79,12 +79,12 @@ func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return actionsOrgBilling, resp, err
|
||||
return actionsOrgBilling, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -98,13 +98,13 @@ func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string)
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return packagesOrgBilling, resp, err
|
||||
return packagesOrgBilling, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -118,12 +118,12 @@ func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return storageOrgBilling, resp, err
|
||||
return storageOrgBilling, resp, nil
|
||||
}
|
||||
|
||||
// GetAdvancedSecurityActiveCommittersOrg returns the GitHub Advanced Security active committers for an organization per repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-advanced-security-active-committers-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-advanced-security-active-committers-for-an-organization
|
||||
func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string) (*ActiveCommitters, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -137,12 +137,12 @@ func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Cont
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return activeOrgCommitters, resp, err
|
||||
return activeOrgCommitters, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -156,12 +156,12 @@ func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string)
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return actionsUserBilling, resp, err
|
||||
return actionsUserBilling, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-packages-billing-for-a-user
|
||||
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)
|
||||
|
|
@ -175,13 +175,13 @@ func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return packagesUserBilling, resp, err
|
||||
return packagesUserBilling, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -195,5 +195,5 @@ func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string)
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return storageUserBilling, resp, err
|
||||
return storageUserBilling, resp, nil
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/
|
||||
type ChecksService service
|
||||
|
||||
// CheckRun represents a GitHub check run on a repository associated with a GitHub app.
|
||||
|
|
@ -98,7 +98,7 @@ func (c CheckSuite) String() string {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -119,7 +119,7 @@ func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, che
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#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)
|
||||
|
|
@ -161,7 +161,7 @@ type CheckRunAction struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -194,7 +194,7 @@ type UpdateCheckRunOptions struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -215,7 +215,7 @@ func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -257,7 +257,7 @@ type ListCheckRunsResults struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -283,7 +283,7 @@ func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, re
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#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)
|
||||
|
|
@ -307,6 +307,22 @@ func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo
|
|||
return checkRunResults, resp, nil
|
||||
}
|
||||
|
||||
// ReRequestCheckRun triggers GitHub to rerequest an existing check run.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#rerequest-a-check-run
|
||||
func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/rerequest", owner, repo, checkRunID)
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, 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.
|
||||
|
|
@ -323,7 +339,7 @@ type ListCheckSuiteResults struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#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)
|
||||
|
|
@ -371,7 +387,7 @@ type PreferenceList struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#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)
|
||||
|
|
@ -398,7 +414,7 @@ type CreateCheckSuiteOptions struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#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)
|
||||
|
|
@ -419,7 +435,7 @@ func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#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)
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||
type CodeScanningService service
|
||||
|
||||
// Rule represents the complete details of GitHub Code Scanning alert type.
|
||||
|
|
@ -65,24 +65,29 @@ type Tool struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||
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"`
|
||||
Number *int `json:"number,omitempty"`
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
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"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
FixedAt *Timestamp `json:"fixed_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"`
|
||||
Instances []*MostRecentInstance `json:"instances,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.
|
||||
|
|
@ -132,7 +137,7 @@ type AnalysesListOptions struct {
|
|||
|
||||
// ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||
type ScanningAnalysis struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Ref *string `json:"ref,omitempty"`
|
||||
|
|
@ -153,7 +158,7 @@ type ScanningAnalysis struct {
|
|||
|
||||
// SarifAnalysis specifies the results of a code scanning job.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||
type SarifAnalysis struct {
|
||||
CommitSHA *string `json:"commit_sha,omitempty"`
|
||||
Ref *string `json:"ref,omitempty"`
|
||||
|
|
@ -165,19 +170,46 @@ type SarifAnalysis struct {
|
|||
|
||||
// SarifID identifies a sarif analysis upload.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||
type SarifID struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// ListAlertsForOrg lists code scanning alerts for an org.
|
||||
//
|
||||
// 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/rest/code-scanning#list-code-scanning-alerts-for-an-organization
|
||||
func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *AlertListOptions) ([]*Alert, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-scanning/alerts", 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 alerts []*Alert
|
||||
resp, err := s.client.Do(ctx, req, &alerts)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return alerts, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
|
@ -206,7 +238,7 @@ func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo
|
|||
//
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/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)
|
||||
|
||||
|
|
@ -230,7 +262,7 @@ func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string,
|
|||
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events
|
||||
// write permission to use this endpoint.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#upload-an-analysis-as-sarif-data
|
||||
func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, sarif *SarifAnalysis) (*SarifID, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs", owner, repo)
|
||||
|
||||
|
|
@ -254,7 +286,7 @@ func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo strin
|
|||
// 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/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-analyses-for-a-repository
|
||||
func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*ScanningAnalysis, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -283,7 +315,7 @@ func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, re
|
|||
//
|
||||
// The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#get-a-code-scanning-analysis-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-analysis-for-a-repository
|
||||
func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*ScanningAnalysis, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id)
|
||||
|
||||
|
|
@ -8,5 +8,5 @@ package github
|
|||
// DependabotService handles communication with the Dependabot related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/dependabot/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/
|
||||
type DependabotService service
|
||||
|
|
@ -27,7 +27,7 @@ func (s *DependabotService) getPublicKey(ctx context.Context, url string) (*Publ
|
|||
|
||||
// GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-a-repository-public-key
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-public-key
|
||||
func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/public-key", owner, repo)
|
||||
return s.getPublicKey(ctx, url)
|
||||
|
|
@ -35,7 +35,7 @@ func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo st
|
|||
|
||||
// GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-an-organization-public-key
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-public-key
|
||||
func (s *DependabotService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", org)
|
||||
return s.getPublicKey(ctx, url)
|
||||
|
|
@ -64,7 +64,7 @@ func (s *DependabotService) listSecrets(ctx context.Context, url string, opts *L
|
|||
// ListRepoSecrets lists all Dependabot secrets available in a repository
|
||||
// without revealing their encrypted values.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-repository-secrets
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-repository-secrets
|
||||
func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets", owner, repo)
|
||||
return s.listSecrets(ctx, url, opts)
|
||||
|
|
@ -73,7 +73,7 @@ func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo str
|
|||
// ListOrgSecrets lists all Dependabot secrets available in an organization
|
||||
// without revealing their encrypted values.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-organization-secrets
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-organization-secrets
|
||||
func (s *DependabotService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets", org)
|
||||
return s.listSecrets(ctx, url, opts)
|
||||
|
|
@ -96,7 +96,7 @@ func (s *DependabotService) getSecret(ctx context.Context, url string) (*Secret,
|
|||
|
||||
// GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-a-repository-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-secret
|
||||
func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
|
||||
return s.getSecret(ctx, url)
|
||||
|
|
@ -104,13 +104,26 @@ func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name
|
|||
|
||||
// GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-an-organization-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-secret
|
||||
func (s *DependabotService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
|
||||
return s.getSecret(ctx, url)
|
||||
}
|
||||
|
||||
func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
// DependabotEncryptedSecret represents a secret that is encrypted using a public key for Dependabot.
|
||||
//
|
||||
// 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 DependabotEncryptedSecret struct {
|
||||
Name string `json:"-"`
|
||||
KeyID string `json:"key_id"`
|
||||
EncryptedValue string `json:"encrypted_value"`
|
||||
Visibility string `json:"visibility,omitempty"`
|
||||
SelectedRepositoryIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids,omitempty"`
|
||||
}
|
||||
|
||||
func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||
req, err := s.client.NewRequest("PUT", url, eSecret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -121,16 +134,16 @@ func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *
|
|||
|
||||
// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#create-or-update-a-repository-secret
|
||||
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret
|
||||
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name)
|
||||
return s.putSecret(ctx, url, eSecret)
|
||||
}
|
||||
|
||||
// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#create-or-update-an-organization-secret
|
||||
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
|
||||
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
|
||||
return s.putSecret(ctx, url, eSecret)
|
||||
}
|
||||
|
|
@ -146,7 +159,7 @@ func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Resp
|
|||
|
||||
// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#delete-a-repository-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret
|
||||
func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
|
||||
return s.deleteSecret(ctx, url)
|
||||
|
|
@ -154,7 +167,7 @@ func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, n
|
|||
|
||||
// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#delete-an-organization-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret
|
||||
func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
|
||||
return s.deleteSecret(ctx, url)
|
||||
|
|
@ -162,7 +175,7 @@ func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name strin
|
|||
|
||||
// ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-selected-repositories-for-an-organization-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret
|
||||
func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
|
||||
u, err := addOptions(url, opts)
|
||||
|
|
@ -184,13 +197,16 @@ func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, o
|
|||
return result, resp, nil
|
||||
}
|
||||
|
||||
// DependabotSecretsSelectedRepoIDs are the repository IDs that have access to the dependabot secrets.
|
||||
type DependabotSecretsSelectedRepoIDs []string
|
||||
|
||||
// SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#set-selected-repositories-for-an-organization-secret
|
||||
func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret
|
||||
func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids DependabotSecretsSelectedRepoIDs) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
|
||||
type repoIDs struct {
|
||||
SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"`
|
||||
SelectedIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids"`
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("PUT", url, repoIDs{SelectedIDs: ids})
|
||||
|
|
@ -203,7 +219,7 @@ func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, or
|
|||
|
||||
// AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#add-selected-repository-to-an-organization-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret
|
||||
func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||
req, err := s.client.NewRequest("PUT", url, nil)
|
||||
|
|
@ -216,7 +232,7 @@ func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org,
|
|||
|
||||
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#remove-selected-repository-from-an-organization-secret
|
||||
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret
|
||||
func (s *DependabotService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||
|
|
@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API.
|
|||
|
||||
Usage:
|
||||
|
||||
import "github.com/google/go-github/v43/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
|
||||
import "github.com/google/go-github/v47/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
|
||||
|
|
@ -29,7 +29,7 @@ Some API methods have optional parameters that can be passed. For example:
|
|||
|
||||
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/.
|
||||
https://docs.github.com/en/rest .
|
||||
|
||||
NOTE: Using the https://godoc.org/context package, one can easily
|
||||
pass cancelation signals and deadlines to various services of the client for
|
||||
|
|
@ -38,7 +38,7 @@ 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
|
||||
# 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
|
||||
|
|
@ -110,7 +110,7 @@ To authenticate as an app, using a JWT:
|
|||
// Use client...
|
||||
}
|
||||
|
||||
Rate Limiting
|
||||
# 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
|
||||
|
|
@ -137,9 +137,9 @@ For secondary rate limits, you can check if its type is *github.AbuseRateLimitEr
|
|||
}
|
||||
|
||||
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.
|
||||
https://docs.github.com/en/rest/rate-limit .
|
||||
|
||||
Accepted Status
|
||||
# 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
|
||||
|
|
@ -154,7 +154,7 @@ To detect this condition of error, you can check if its type is
|
|||
log.Println("scheduled on GitHub side")
|
||||
}
|
||||
|
||||
Conditional Requests
|
||||
# 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
|
||||
|
|
@ -163,9 +163,9 @@ 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.
|
||||
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests.
|
||||
|
||||
Creating and Updating Resources
|
||||
# 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.
|
||||
|
|
@ -181,7 +181,7 @@ bool, and int values. For example:
|
|||
|
||||
Users who have worked with protocol buffers should find this pattern familiar.
|
||||
|
||||
Pagination
|
||||
# Pagination
|
||||
|
||||
All requests for resource collections (repos, pull requests, issues, etc.)
|
||||
support pagination. Pagination options are described in the
|
||||
|
|
@ -208,6 +208,5 @@ github.Response struct.
|
|||
}
|
||||
opt.Page = resp.NextPage
|
||||
}
|
||||
|
||||
*/
|
||||
package github
|
||||
|
|
@ -8,5 +8,5 @@ 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/
|
||||
type EnterpriseService service
|
||||
|
|
@ -10,9 +10,28 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository
|
||||
func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise)
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#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)
|
||||
|
||||
|
|
@ -32,7 +51,7 @@ func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterpr
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#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)
|
||||
|
|
@ -56,7 +75,7 @@ func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#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)
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/audit-log#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)
|
||||
|
|
@ -36,6 +36,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
|
|||
payload = &CheckRunEvent{}
|
||||
case "CheckSuiteEvent":
|
||||
payload = &CheckSuiteEvent{}
|
||||
case "CodeScanningAlertEvent":
|
||||
payload = &CodeScanningAlertEvent{}
|
||||
case "CommitCommentEvent":
|
||||
payload = &CommitCommentEvent{}
|
||||
case "ContentReferenceEvent":
|
||||
|
|
@ -102,6 +104,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
|
|||
payload = &PullRequestReviewEvent{}
|
||||
case "PullRequestReviewCommentEvent":
|
||||
payload = &PullRequestReviewCommentEvent{}
|
||||
case "PullRequestReviewThreadEvent":
|
||||
payload = &PullRequestReviewThreadEvent{}
|
||||
case "PullRequestTargetEvent":
|
||||
payload = &PullRequestTargetEvent{}
|
||||
case "PushEvent":
|
||||
|
|
@ -112,6 +116,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
|
|||
payload = &RepositoryEvent{}
|
||||
case "RepositoryDispatchEvent":
|
||||
payload = &RepositoryDispatchEvent{}
|
||||
case "RepositoryImportEvent":
|
||||
payload = &RepositoryImportEvent{}
|
||||
case "RepositoryVulnerabilityAlertEvent":
|
||||
payload = &RepositoryVulnerabilityAlertEvent{}
|
||||
case "SecretScanningAlertEvent":
|
||||
|
|
@ -106,10 +106,11 @@ type CreateEvent struct {
|
|||
RefType *string `json:"ref_type,omitempty"`
|
||||
MasterBranch *string `json:"master_branch,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
PusherType *string `json:"pusher_type,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
PusherType *string `json:"pusher_type,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
|
@ -493,13 +494,14 @@ type IssuesEvent struct {
|
|||
type LabelEvent struct {
|
||||
// Action is the action that was performed. Possible values are:
|
||||
// "created", "edited", "deleted"
|
||||
Action *string `json:"action,omitempty"`
|
||||
Label *Label `json:"label,omitempty"`
|
||||
Action *string `json:"action,omitempty"`
|
||||
Label *Label `json:"label,omitempty"`
|
||||
Changes *EditChange `json:"changes,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Changes *EditChange `json:"changes,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -574,6 +576,9 @@ type MetaEvent struct {
|
|||
Hook *Hook `json:"hook,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -682,7 +687,12 @@ type PingEvent struct {
|
|||
// The ID of the webhook that triggered the ping.
|
||||
HookID *int64 `json:"hook_id,omitempty"`
|
||||
// The webhook configuration.
|
||||
Hook *Hook `json:"hook,omitempty"`
|
||||
Hook *Hook `json:"hook,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -830,12 +840,30 @@ type PullRequestReviewCommentEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// PullRequestReviewThreadEvent is triggered when a comment made as part of a
|
||||
// review of a pull request is marked resolved or unresolved.
|
||||
// The Webhook event name is "pull_request_review_thread".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_thread
|
||||
type PullRequestReviewThreadEvent struct {
|
||||
// Action is the action that was performed on the comment.
|
||||
// Possible values are: "resolved", "unresolved".
|
||||
Action *string `json:"action,omitempty"`
|
||||
Thread *PullRequestThread `json:"thread,omitempty"`
|
||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled,
|
||||
// unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review,
|
||||
// locked, unlocked, a pull request review is requested, or a review request is removed.
|
||||
// The Webhook event name is "pull_request_target".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
|
||||
// GitHub API docs: https://docs.github.com/en/actions/events-that-trigger-workflows#pull_request_target
|
||||
type PullRequestTargetEvent struct {
|
||||
// Action is the action that was performed. Possible values are:
|
||||
// "assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened",
|
||||
|
|
@ -885,6 +913,7 @@ type PushEvent struct {
|
|||
DistinctSize *int `json:"distinct_size,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Action *string `json:"action,omitempty"`
|
||||
After *string `json:"after,omitempty"`
|
||||
Created *bool `json:"created,omitempty"`
|
||||
Deleted *bool `json:"deleted,omitempty"`
|
||||
|
|
@ -926,8 +955,8 @@ type HeadCommit struct {
|
|||
Modified []string `json:"modified,omitempty"`
|
||||
}
|
||||
|
||||
func (p HeadCommit) String() string {
|
||||
return Stringify(p)
|
||||
func (h HeadCommit) String() string {
|
||||
return Stringify(h)
|
||||
}
|
||||
|
||||
// PushEventRepository represents the repo object in a PushEvent payload.
|
||||
|
|
@ -1032,6 +1061,17 @@ type RepositoryDispatchEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// RepositoryImportEvent represents the activity related to a repository being imported to GitHub.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import
|
||||
type RepositoryImportEvent struct {
|
||||
// Status represents the final state of the import. This can be one of "success", "cancelled", or "failure".
|
||||
Status *string `json:"status,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// RepositoryVulnerabilityAlertEvent is triggered when a security alert is created, dismissed, or resolved.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository_vulnerability_alert
|
||||
|
|
@ -1039,14 +1079,17 @@ type RepositoryVulnerabilityAlertEvent struct {
|
|||
// Action is the action that was performed. Possible values are: "create", "dismiss", "resolve".
|
||||
Action *string `json:"action,omitempty"`
|
||||
|
||||
//The security alert of the vulnerable dependency.
|
||||
// The security alert of the vulnerable dependency.
|
||||
Alert *RepositoryVulnerabilityAlert `json:"alert,omitempty"`
|
||||
|
||||
//The repository of the vulnerable dependency.
|
||||
// The repository of the vulnerable dependency.
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
|
||||
// The user that triggered the event.
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// RepositoryVulnerabilityAlert represents a repository security alert.
|
||||
|
|
@ -1248,3 +1291,71 @@ type WorkflowRunEvent struct {
|
|||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityAdvisory represents the advisory object in SecurityAdvisoryEvent payload.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory
|
||||
type SecurityAdvisory struct {
|
||||
GHSAID *string `json:"ghsa_id,omitempty"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Severity *string `json:"severity,omitempty"`
|
||||
Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"`
|
||||
References []*AdvisoryReference `json:"references,omitempty"`
|
||||
PublishedAt *Timestamp `json:"published_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"`
|
||||
Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"`
|
||||
}
|
||||
|
||||
// AdvisoryIdentifier represents the identifier for a Security Advisory.
|
||||
type AdvisoryIdentifier struct {
|
||||
Value *string `json:"value,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// AdvisoryReference represents the reference url for the security advisory.
|
||||
type AdvisoryReference struct {
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// AdvisoryVulnerability represents the vulnerability object for a Security Advisory.
|
||||
type AdvisoryVulnerability struct {
|
||||
Package *VulnerabilityPackage `json:"package,omitempty"`
|
||||
Severity *string `json:"severity,omitempty"`
|
||||
VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"`
|
||||
FirstPatchedVersion *FirstPatchedVersion `json:"first_patched_version,omitempty"`
|
||||
}
|
||||
|
||||
// VulnerabilityPackage represents the package object for an Advisory Vulnerability.
|
||||
type VulnerabilityPackage struct {
|
||||
Ecosystem *string `json:"ecosystem,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// FirstPatchedVersion represents the identifier for the first patched version of that vulnerability.
|
||||
type FirstPatchedVersion struct {
|
||||
Identifier *string `json:"identifier,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityAdvisoryEvent is triggered when a security-related vulnerability is found in software on GitHub.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory
|
||||
type SecurityAdvisoryEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
SecurityAdvisory *SecurityAdvisory `json:"security_advisory,omitempty"`
|
||||
}
|
||||
|
||||
// CodeScanningAlertEvent is triggered when a code scanning finds a potential vulnerability or error in your code.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert
|
||||
type CodeScanningAlertEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Alert *Alert `json:"alert,omitempty"`
|
||||
Ref *string `json:"ref,omitempty"`
|
||||
// CommitOID is the commit SHA of the code scanning alert
|
||||
CommitOID *string `json:"commit_oid,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists
|
||||
type GistsService service
|
||||
|
||||
// Gist represents a GitHub's gist.
|
||||
|
|
@ -96,8 +96,8 @@ type GistListOptions struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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 != "" {
|
||||
|
|
@ -126,7 +126,7 @@ func (s *GistsService) List(ctx context.Context, user string, opts *GistListOpti
|
|||
|
||||
// ListAll lists all public gists.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-public-gists
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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 {
|
||||
|
|
@ -149,7 +149,7 @@ func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*G
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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 {
|
||||
|
|
@ -172,7 +172,7 @@ func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) (
|
|||
|
||||
// Get a single gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -191,7 +191,7 @@ func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, er
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -210,7 +210,7 @@ func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist,
|
|||
|
||||
// Create a gist for authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -229,7 +229,7 @@ func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response
|
|||
|
||||
// Edit a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -248,7 +248,7 @@ func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist,
|
|||
|
||||
// ListCommits lists commits of a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-commits
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -272,49 +272,53 @@ func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOpt
|
|||
|
||||
// Delete a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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
|
||||
|
|
@ -322,7 +326,7 @@ func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Respons
|
|||
|
||||
// Fork a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#fork-a-gist
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -341,7 +345,7 @@ func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, e
|
|||
|
||||
// ListForks lists forks of a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-forks
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/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)
|
||||
|
|
@ -26,7 +26,7 @@ func (g GistComment) String() string {
|
|||
|
||||
// ListComments lists all comments for a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-comments
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#list-gist-comments
|
||||
func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) {
|
||||
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -50,7 +50,7 @@ func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *Li
|
|||
|
||||
// GetComment retrieves a single comment from a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#get-a-gist-comment
|
||||
func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) {
|
||||
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -69,7 +69,7 @@ func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID
|
|||
|
||||
// CreateComment creates a comment for a gist.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#create-a-gist-comment
|
||||
func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) {
|
||||
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||
req, err := s.client.NewRequest("POST", u, comment)
|
||||
|
|
@ -88,7 +88,7 @@ func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment
|
|||
|
||||
// EditComment edits an existing gist comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#update-a-gist-comment
|
||||
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)
|
||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||
|
|
@ -107,7 +107,7 @@ func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID
|
|||
|
||||
// DeleteComment deletes a gist comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#delete-a-gist-comment
|
||||
func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -8,5 +8,5 @@ package github
|
|||
// GitService handles communication with the git data related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/
|
||||
type GitService service
|
||||
|
|
@ -23,7 +23,7 @@ type Blob struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#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)
|
||||
|
|
@ -33,29 +33,38 @@ func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha
|
|||
|
||||
blob := new(Blob)
|
||||
resp, err := s.client.Do(ctx, req, blob)
|
||||
return blob, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return blob, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#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
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), resp, nil
|
||||
}
|
||||
|
||||
// CreateBlob creates a blob object.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-blob
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#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)
|
||||
|
|
@ -65,5 +74,9 @@ func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string,
|
|||
|
||||
t := new(Blob)
|
||||
resp, err := s.client.Do(ctx, req, t)
|
||||
return t, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return t, resp, nil
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ func (c CommitAuthor) String() string {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/commits#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)
|
||||
|
|
@ -104,7 +104,7 @@ type createCommit struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/commits#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")
|
||||
|
|
@ -49,7 +49,7 @@ type updateRefRequest struct {
|
|||
|
||||
// GetRef fetches a single reference in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-reference
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/refs#get-a-reference
|
||||
func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) {
|
||||
ref = strings.TrimPrefix(ref, "refs/")
|
||||
u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref))
|
||||
|
|
@ -88,7 +88,7 @@ type ReferenceListOptions struct {
|
|||
// ListMatchingRefs lists references in a repository that match a supplied ref.
|
||||
// Use an empty ref to list all references.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#list-matching-references
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/refs#list-matching-references
|
||||
func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) {
|
||||
var ref string
|
||||
if opts != nil {
|
||||
|
|
@ -116,7 +116,7 @@ func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, o
|
|||
|
||||
// CreateRef creates a new ref in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-reference
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/refs#create-a-reference
|
||||
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)
|
||||
req, err := s.client.NewRequest("POST", u, &createRefRequest{
|
||||
|
|
@ -139,10 +139,10 @@ func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, r
|
|||
|
||||
// UpdateRef updates an existing ref in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#update-a-reference
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/refs#update-a-reference
|
||||
func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) {
|
||||
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, refURLEscape(refPath))
|
||||
req, err := s.client.NewRequest("PATCH", u, &updateRefRequest{
|
||||
SHA: ref.Object.SHA,
|
||||
Force: &force,
|
||||
|
|
@ -162,7 +162,7 @@ func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, r
|
|||
|
||||
// DeleteRef deletes a ref from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#delete-a-reference
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/refs#delete-a-reference
|
||||
func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) {
|
||||
ref = strings.TrimPrefix(ref, "refs/")
|
||||
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref))
|
||||
|
|
@ -35,7 +35,7 @@ type createTagRequest struct {
|
|||
|
||||
// GetTag fetches a tag from a repo given a SHA.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-tag
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/tags#get-a-tag
|
||||
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)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -45,12 +45,16 @@ func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha
|
|||
|
||||
tag := new(Tag)
|
||||
resp, err := s.client.Do(ctx, req, tag)
|
||||
return tag, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return tag, resp, nil
|
||||
}
|
||||
|
||||
// CreateTag creates a tag object.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-tag-object
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/tags#create-a-tag-object
|
||||
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)
|
||||
|
||||
|
|
@ -72,5 +76,9 @@ func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, t
|
|||
|
||||
t := new(Tag)
|
||||
resp, err := s.client.Do(ctx, req, t)
|
||||
return t, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return t, resp, nil
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ func (t *TreeEntry) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/trees#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 {
|
||||
|
|
@ -124,7 +124,7 @@ type createTree struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/git/trees#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)
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -28,9 +28,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
defaultBaseURL = "https://api.github.com/"
|
||||
uploadBaseURL = "https://uploads.github.com/"
|
||||
userAgent = "go-github"
|
||||
Version = "v47.0.0"
|
||||
|
||||
defaultBaseURL = "https://api.github.com/"
|
||||
defaultUserAgent = "go-github" + "/" + Version
|
||||
uploadBaseURL = "https://uploads.github.com/"
|
||||
|
||||
headerRateLimit = "X-RateLimit-Limit"
|
||||
headerRateRemaining = "X-RateLimit-Remaining"
|
||||
|
|
@ -130,10 +132,10 @@ const (
|
|||
// https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/
|
||||
mediaTypeListPullsOrBranchesForCommitPreview = "application/vnd.github.groot-preview+json"
|
||||
|
||||
// https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#repository-creation-permissions
|
||||
// https://docs.github.com/en/rest/previews/#repository-creation-permissions
|
||||
mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json"
|
||||
|
||||
// https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#create-and-use-repository-templates
|
||||
// https://docs.github.com/en/rest/previews/#create-and-use-repository-templates
|
||||
mediaTypeRepositoryTemplatePreview = "application/vnd.github.baptiste-preview+json"
|
||||
|
||||
// https://developer.github.com/changes/2019-10-03-multi-line-comments/
|
||||
|
|
@ -301,7 +303,7 @@ func NewClient(httpClient *http.Client) *Client {
|
|||
baseURL, _ := url.Parse(defaultBaseURL)
|
||||
uploadURL, _ := url.Parse(uploadBaseURL)
|
||||
|
||||
c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL}
|
||||
c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: defaultUserAgent, UploadURL: uploadURL}
|
||||
c.common.client = c
|
||||
c.Actions = (*ActionsService)(&c.common)
|
||||
c.Activity = (*ActivityService)(&c.common)
|
||||
|
|
@ -353,6 +355,7 @@ func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*C
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(baseEndpoint.Path, "/") {
|
||||
baseEndpoint.Path += "/"
|
||||
}
|
||||
|
|
@ -366,6 +369,7 @@ func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*C
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(uploadEndpoint.Path, "/") {
|
||||
uploadEndpoint.Path += "/"
|
||||
}
|
||||
|
|
@ -390,6 +394,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ
|
|||
if !strings.HasSuffix(c.BaseURL.Path, "/") {
|
||||
return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL)
|
||||
}
|
||||
|
||||
u, err := c.BaseURL.Parse(urlStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -421,6 +426,33 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ
|
|||
return req, nil
|
||||
}
|
||||
|
||||
// NewFormRequest 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.
|
||||
// Body is sent with Content-Type: application/x-www-form-urlencoded.
|
||||
func (c *Client) NewFormRequest(urlStr string, body io.Reader) (*http.Request, error) {
|
||||
if !strings.HasSuffix(c.BaseURL.Path, "/") {
|
||||
return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL)
|
||||
}
|
||||
|
||||
u, err := c.BaseURL.Parse(urlStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, u.String(), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header.Set("Accept", mediaTypeV3)
|
||||
if c.UserAgent != "" {
|
||||
req.Header.Set("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.
|
||||
|
|
@ -437,6 +469,7 @@ func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, m
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.ContentLength = size
|
||||
|
||||
if mediaType == "" {
|
||||
|
|
@ -621,6 +654,7 @@ func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, erro
|
|||
if ctx == nil {
|
||||
return nil, errNonNilContext
|
||||
}
|
||||
|
||||
req = withContext(ctx, req)
|
||||
|
||||
rateLimitCategory := category(req.URL.Path)
|
||||
|
|
@ -765,7 +799,7 @@ func compareHTTPResponse(r1, r2 *http.Response) bool {
|
|||
/*
|
||||
An ErrorResponse reports one or more errors caused by an API request.
|
||||
|
||||
GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors
|
||||
GitHub API docs: https://docs.github.com/en/rest/#client-errors
|
||||
*/
|
||||
type ErrorResponse struct {
|
||||
Response *http.Response // HTTP response that caused this error
|
||||
|
|
@ -775,7 +809,7 @@ type ErrorResponse struct {
|
|||
Block *ErrorBlock `json:"block,omitempty"`
|
||||
// Most errors will also include a documentation_url field pointing
|
||||
// to some content that might help you resolve the error, see
|
||||
// https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors
|
||||
// https://docs.github.com/en/rest/#client-errors
|
||||
DocumentationURL string `json:"documentation_url,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -895,7 +929,7 @@ func (ae *AcceptedError) Is(target error) bool {
|
|||
}
|
||||
|
||||
// AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the
|
||||
// "documentation_url" field value equal to "https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits".
|
||||
// "documentation_url" field value equal to "https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits".
|
||||
type AbuseRateLimitError struct {
|
||||
Response *http.Response // HTTP response that caused this error
|
||||
Message string `json:"message"` // error message
|
||||
|
|
@ -942,23 +976,23 @@ func sanitizeURL(uri *url.URL) *url.URL {
|
|||
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
|
||||
custom:
|
||||
some resources return this (e.g. github.User.CreateKey()), additional
|
||||
information is set in the Message field of the Error
|
||||
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
|
||||
custom:
|
||||
some resources return this (e.g. github.User.CreateKey()), additional
|
||||
information is set in the Message field of the Error
|
||||
|
||||
GitHub error responses structure are often undocumented and inconsistent.
|
||||
Sometimes error is just a simple string (Issue #540).
|
||||
In such cases, Message represents an error message as a workaround.
|
||||
|
||||
GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors
|
||||
GitHub API docs: https://docs.github.com/en/rest/#client-errors
|
||||
*/
|
||||
type Error struct {
|
||||
Resource string `json:"resource"` // resource on which the error occurred
|
||||
|
|
@ -996,6 +1030,7 @@ 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 {
|
||||
|
|
@ -1076,15 +1111,26 @@ type RateLimits struct {
|
|||
// requests are limited to 60 per hour. Authenticated requests are
|
||||
// limited to 5,000 per hour.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#rate-limiting
|
||||
// GitHub API docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
|
||||
Core *Rate `json:"core"`
|
||||
|
||||
// The rate limit for search API requests. Unauthenticated requests
|
||||
// are limited to 10 requests per minutes. Authenticated requests are
|
||||
// limited to 30 per minute.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#rate-limit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/search#rate-limit
|
||||
Search *Rate `json:"search"`
|
||||
|
||||
// GitHub API docs: https://docs.github.com/en/graphql/overview/resource-limitations#rate-limit
|
||||
GraphQL *Rate `json:"graphql"`
|
||||
|
||||
// GitHub API dos: https://docs.github.com/en/rest/rate-limit
|
||||
IntegrationManifest *Rate `json:"integration_manifest"`
|
||||
|
||||
SourceImport *Rate `json:"source_import"`
|
||||
CodeScanningUpload *Rate `json:"code_scanning_upload"`
|
||||
ActionsRunnerRegistration *Rate `json:"actions_runner_registration"`
|
||||
SCIM *Rate `json:"scim"`
|
||||
}
|
||||
|
||||
func (r RateLimits) String() string {
|
||||
|
|
@ -1096,6 +1142,12 @@ type rateLimitCategory uint8
|
|||
const (
|
||||
coreCategory rateLimitCategory = iota
|
||||
searchCategory
|
||||
graphqlCategory
|
||||
integrationManifestCategory
|
||||
sourceImportCategory
|
||||
codeScanningUploadCategory
|
||||
actionsRunnerRegistrationCategory
|
||||
scimCategory
|
||||
|
||||
categories // An array of this length will be able to contain all rate limit categories.
|
||||
)
|
||||
|
|
@ -1136,6 +1188,24 @@ func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error)
|
|||
if response.Resources.Search != nil {
|
||||
c.rateLimits[searchCategory] = *response.Resources.Search
|
||||
}
|
||||
if response.Resources.GraphQL != nil {
|
||||
c.rateLimits[graphqlCategory] = *response.Resources.GraphQL
|
||||
}
|
||||
if response.Resources.IntegrationManifest != nil {
|
||||
c.rateLimits[integrationManifestCategory] = *response.Resources.IntegrationManifest
|
||||
}
|
||||
if response.Resources.SourceImport != nil {
|
||||
c.rateLimits[sourceImportCategory] = *response.Resources.SourceImport
|
||||
}
|
||||
if response.Resources.CodeScanningUpload != nil {
|
||||
c.rateLimits[codeScanningUploadCategory] = *response.Resources.CodeScanningUpload
|
||||
}
|
||||
if response.Resources.ActionsRunnerRegistration != nil {
|
||||
c.rateLimits[actionsRunnerRegistrationCategory] = *response.Resources.ActionsRunnerRegistration
|
||||
}
|
||||
if response.Resources.SCIM != nil {
|
||||
c.rateLimits[scimCategory] = *response.Resources.SCIM
|
||||
}
|
||||
c.rateMu.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -1173,7 +1243,7 @@ that need to use a higher rate limit associated with your OAuth application.
|
|||
This will add the client id and secret as a base64-encoded string in the format
|
||||
ClientID:ClientSecret and apply it as an "Authorization": "Basic" header.
|
||||
|
||||
See https://docs.github.com/en/free-pro-team@latest/rest/reference/#unauthenticated-rate-limited-requests for
|
||||
See https://docs.github.com/en/rest/#unauthenticated-rate-limited-requests for
|
||||
more information.
|
||||
*/
|
||||
type UnauthenticatedRateLimitedTransport struct {
|
||||
|
|
@ -1279,6 +1349,35 @@ func formatRateReset(d time.Duration) string {
|
|||
return fmt.Sprintf("[rate reset in %v]", timeString)
|
||||
}
|
||||
|
||||
// When using roundTripWithOptionalFollowRedirect, note that it
|
||||
// is the responsibility of the caller to close the response body.
|
||||
func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, followRedirects bool) (*http.Response, error) {
|
||||
req, err := c.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 c.client.Transport == nil {
|
||||
resp, err = http.DefaultTransport.RoundTrip(req)
|
||||
} else {
|
||||
resp, err = c.client.Transport.RoundTrip(req)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If redirect response is returned, follow it
|
||||
if followRedirects && resp.StatusCode == http.StatusMovedPermanently {
|
||||
resp.Body.Close()
|
||||
u = resp.Header.Get("Location")
|
||||
resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, false)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 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 { return &v }
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// GitignoresService provides access to the gitignore related functions in the
|
||||
// GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gitignore/
|
||||
type GitignoresService service
|
||||
|
||||
// Gitignore represents a .gitignore file as returned by the GitHub API.
|
||||
|
|
@ -28,7 +28,7 @@ func (g Gitignore) String() string {
|
|||
|
||||
// List all available Gitignore templates.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#listing-available-templates
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gitignore/#listing-available-templates
|
||||
func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) {
|
||||
req, err := s.client.NewRequest("GET", "gitignore/templates", nil)
|
||||
if err != nil {
|
||||
|
|
@ -46,7 +46,7 @@ func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, erro
|
|||
|
||||
// Get a Gitignore by name.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#get-a-gitignore-template
|
||||
// GitHub API docs: https://docs.github.com/en/rest/gitignore#get-a-gitignore-template
|
||||
func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) {
|
||||
u := fmt.Sprintf("gitignore/templates/%v", name)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -8,7 +8,7 @@ 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/
|
||||
type InteractionsService service
|
||||
|
||||
// InteractionRestriction represents the interaction restrictions for repository and organization.
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#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)
|
||||
|
|
@ -39,7 +39,7 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#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)
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, orga
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#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)
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#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)
|
||||
|
|
@ -39,7 +39,7 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#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)
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, own
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#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)
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// 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/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/
|
||||
type IssuesService service
|
||||
|
||||
// Issue represents a GitHub issue on a repository.
|
||||
|
|
@ -54,7 +54,7 @@ type Issue struct {
|
|||
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
|
||||
// See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata
|
||||
TextMatches []*TextMatch `json:"text_matches,omitempty"`
|
||||
|
||||
// ActiveLockReason is populated only when LockReason is provided while locking the issue.
|
||||
|
|
@ -77,13 +77,15 @@ func (i Issue) IsPullRequest() bool {
|
|||
// 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"`
|
||||
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"`
|
||||
// StateReason can be 'completed' or 'not_planned'.
|
||||
StateReason *string `json:"state_reason,omitempty"`
|
||||
Milestone *int `json:"milestone,omitempty"`
|
||||
Assignees *[]string `json:"assignees,omitempty"`
|
||||
}
|
||||
|
||||
// IssueListOptions specifies the optional parameters to the IssuesService.List
|
||||
|
|
@ -128,8 +130,8 @@ type PullRequestLinks struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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 {
|
||||
|
|
@ -143,7 +145,7 @@ func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptio
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -214,7 +216,7 @@ type IssueListByRepoOptions struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -241,7 +243,7 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo strin
|
|||
|
||||
// Get a single issue.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -263,7 +265,7 @@ func (s *IssuesService) Get(ctx context.Context, owner string, repo string, numb
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -280,9 +282,9 @@ func (s *IssuesService) Create(ctx context.Context, owner string, repo string, i
|
|||
return i, resp, nil
|
||||
}
|
||||
|
||||
// Edit an issue.
|
||||
// Edit (update) an issue.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -303,7 +305,7 @@ func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, num
|
|||
//
|
||||
// This is a helper method to explicitly update an issue with a `null` milestone, thereby removing it.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue
|
||||
func (s *IssuesService) RemoveMilestone(ctx context.Context, owner, repo string, issueNumber int) (*Issue, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, issueNumber)
|
||||
req, err := s.client.NewRequest("PATCH", u, &struct {
|
||||
|
|
@ -333,7 +335,7 @@ type LockIssueOptions struct {
|
|||
|
||||
// Lock an issue's conversation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#lock-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -346,7 +348,7 @@ func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, num
|
|||
|
||||
// Unlock an issue's conversation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#unlock-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/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)
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#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)
|
||||
|
|
@ -25,6 +25,7 @@ func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, o
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var assignees []*User
|
||||
resp, err := s.client.Do(ctx, req, &assignees)
|
||||
if err != nil {
|
||||
|
|
@ -36,13 +37,14 @@ func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, o
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#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
|
||||
|
|
@ -50,7 +52,7 @@ func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#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"`
|
||||
|
|
@ -63,12 +65,16 @@ func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, nu
|
|||
|
||||
issue := &Issue{}
|
||||
resp, err := s.client.Do(ctx, req, issue)
|
||||
return issue, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return issue, resp, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#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"`
|
||||
|
|
@ -81,5 +87,9 @@ func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string,
|
|||
|
||||
issue := &Issue{}
|
||||
resp, err := s.client.Do(ctx, req, issue)
|
||||
return issue, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return issue, resp, nil
|
||||
}
|
||||
|
|
@ -50,8 +50,8 @@ type IssueListCommentsOptions struct {
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#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 {
|
||||
|
|
@ -83,7 +83,7 @@ func (s *IssuesService) ListComments(ctx context.Context, owner string, repo str
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#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)
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ func (s *IssuesService) GetComment(ctx context.Context, owner string, repo strin
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#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)
|
||||
|
|
@ -125,7 +125,7 @@ func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo st
|
|||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#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)
|
||||
|
|
@ -143,7 +143,7 @@ func (s *IssuesService) EditComment(ctx context.Context, owner string, repo stri
|
|||
|
||||
// DeleteComment deletes an issue comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-an-issue-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#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)
|
||||
|
|
@ -100,7 +100,7 @@ type DismissedReview struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/events#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)
|
||||
|
|
@ -126,7 +126,7 @@ func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/events#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)
|
||||
|
|
@ -150,7 +150,7 @@ func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo st
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/events#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)
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ func (l Label) String() string {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -51,7 +51,7 @@ func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo strin
|
|||
|
||||
// GetLabel gets a single label.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-label
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -70,7 +70,7 @@ func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -89,7 +89,7 @@ func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo stri
|
|||
|
||||
// EditLabel edits a label.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-label
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -108,7 +108,7 @@ func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string
|
|||
|
||||
// DeleteLabel deletes a label.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-label
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -120,7 +120,7 @@ func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo stri
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -144,7 +144,7 @@ func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, rep
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -163,7 +163,7 @@ func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -176,7 +176,7 @@ func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, r
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -195,7 +195,7 @@ func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -208,7 +208,7 @@ func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string,
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#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)
|
||||
|
|
@ -55,7 +55,7 @@ type MilestoneListOptions struct {
|
|||
|
||||
// ListMilestones lists all milestones for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-milestones
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#list-milestones
|
||||
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, err := addOptions(u, opts)
|
||||
|
|
@ -79,7 +79,7 @@ func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo s
|
|||
|
||||
// GetMilestone gets a single milestone.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-milestone
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#get-a-milestone
|
||||
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)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -98,7 +98,7 @@ func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo str
|
|||
|
||||
// CreateMilestone creates a new milestone on the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-a-milestone
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#create-a-milestone
|
||||
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)
|
||||
req, err := s.client.NewRequest("POST", u, milestone)
|
||||
|
|
@ -117,7 +117,7 @@ func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo
|
|||
|
||||
// EditMilestone edits a milestone.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-milestone
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#update-a-milestone
|
||||
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)
|
||||
req, err := s.client.NewRequest("PATCH", u, milestone)
|
||||
|
|
@ -136,7 +136,7 @@ func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo st
|
|||
|
||||
// DeleteMilestone deletes a milestone.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-milestone
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#delete-a-milestone
|
||||
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)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -161,7 +161,7 @@ type Source struct {
|
|||
|
||||
// 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
|
||||
// GitHub API docs: https://docs.github.com/en/rest/issues/timeline#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)
|
||||
|
|
@ -180,5 +180,9 @@ func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo strin
|
|||
|
||||
var events []*Timeline
|
||||
resp, err := s.client.Do(ctx, req, &events)
|
||||
return events, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return events, resp, nil
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// LicensesService handles communication with the license related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/licenses/
|
||||
type LicensesService service
|
||||
|
||||
// RepositoryLicense represents the license for a repository.
|
||||
|
|
@ -60,7 +60,7 @@ func (l License) String() string {
|
|||
|
||||
// List popular open source licenses.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#list-all-licenses
|
||||
// GitHub API docs: https://docs.github.com/en/rest/licenses/#list-all-licenses
|
||||
func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) {
|
||||
req, err := s.client.NewRequest("GET", "licenses", nil)
|
||||
if err != nil {
|
||||
|
|
@ -78,7 +78,7 @@ func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, erro
|
|||
|
||||
// Get extended metadata for one license.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-a-license
|
||||
// GitHub API docs: https://docs.github.com/en/rest/licenses#get-a-license
|
||||
func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) {
|
||||
u := fmt.Sprintf("licenses/%s", licenseName)
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ var (
|
|||
"branch_protection_rule": "BranchProtectionRuleEvent",
|
||||
"check_run": "CheckRunEvent",
|
||||
"check_suite": "CheckSuiteEvent",
|
||||
"code_scanning_alert": "CodeScanningAlertEvent",
|
||||
"commit_comment": "CommitCommentEvent",
|
||||
"content_reference": "ContentReferenceEvent",
|
||||
"create": "CreateEvent",
|
||||
|
|
@ -81,10 +82,12 @@ var (
|
|||
"pull_request": "PullRequestEvent",
|
||||
"pull_request_review": "PullRequestReviewEvent",
|
||||
"pull_request_review_comment": "PullRequestReviewCommentEvent",
|
||||
"pull_request_review_thread": "PullRequestReviewThreadEvent",
|
||||
"pull_request_target": "PullRequestTargetEvent",
|
||||
"push": "PushEvent",
|
||||
"repository": "RepositoryEvent",
|
||||
"repository_dispatch": "RepositoryDispatchEvent",
|
||||
"repository_import": "RepositoryImportEvent",
|
||||
"repository_vulnerability_alert": "RepositoryVulnerabilityAlertEvent",
|
||||
"release": "ReleaseEvent",
|
||||
"secret_scanning_alert": "SecretScanningAlertEvent",
|
||||
|
|
@ -154,13 +157,13 @@ func messageMAC(signature string) ([]byte, func() hash.Hash, error) {
|
|||
//
|
||||
// Example usage:
|
||||
//
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// // read signature from request
|
||||
// signature := ""
|
||||
// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// // Process payload...
|
||||
// }
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// // read signature from request
|
||||
// signature := ""
|
||||
// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// // Process payload...
|
||||
// }
|
||||
func ValidatePayloadFromBody(contentType string, readable io.Reader, signature string, secretToken []byte) (payload []byte, err error) {
|
||||
var body []byte // Raw body that GitHub uses to calculate the signature.
|
||||
|
||||
|
|
@ -218,12 +221,11 @@ func ValidatePayloadFromBody(contentType string, readable io.Reader, signature s
|
|||
//
|
||||
// Example usage:
|
||||
//
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// // Process payload...
|
||||
// }
|
||||
//
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// // Process payload...
|
||||
// }
|
||||
func ValidatePayload(r *http.Request, secretToken []byte) (payload []byte, err error) {
|
||||
signature := r.Header.Get(SHA256SignatureHeader)
|
||||
if signature == "" {
|
||||
|
|
@ -276,20 +278,19 @@ func DeliveryID(r *http.Request) string {
|
|||
//
|
||||
// Example usage:
|
||||
//
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// event, err := github.ParseWebHook(github.WebHookType(r), payload)
|
||||
// if err != nil { ... }
|
||||
// switch event := event.(type) {
|
||||
// case *github.CommitCommentEvent:
|
||||
// processCommitCommentEvent(event)
|
||||
// case *github.CreateEvent:
|
||||
// processCreateEvent(event)
|
||||
// ...
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||
// if err != nil { ... }
|
||||
// event, err := github.ParseWebHook(github.WebHookType(r), payload)
|
||||
// if err != nil { ... }
|
||||
// switch event := event.(type) {
|
||||
// case *github.CommitCommentEvent:
|
||||
// processCommitCommentEvent(event)
|
||||
// case *github.CreateEvent:
|
||||
// processCreateEvent(event)
|
||||
// ...
|
||||
// }
|
||||
// }
|
||||
func ParseWebHook(messageType string, payload []byte) (interface{}, error) {
|
||||
eventType, ok := eventTypeMapping[messageType]
|
||||
if !ok {
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
// MigrationService provides access to the migration related functions
|
||||
// in the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migration/
|
||||
type MigrationService service
|
||||
|
||||
// Migration represents a GitHub migration (archival).
|
||||
|
|
@ -74,7 +74,7 @@ type startMigration struct {
|
|||
// StartMigration starts the generation of a migration archive.
|
||||
// repos is a slice of repository names to migrate.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-an-organization-migration
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#start-an-organization-migration
|
||||
func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations", org)
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos
|
|||
|
||||
// ListMigrations lists the most recent migrations.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#list-organization-migrations
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#list-organization-migrations
|
||||
func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -131,7 +131,7 @@ func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts
|
|||
// MigrationStatus gets the status of a specific migration archive.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-an-organization-migration-status
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#get-an-organization-migration-status
|
||||
func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations/%v", org, id)
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id i
|
|||
// MigrationArchiveURL fetches a migration archive URL.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#download-an-organization-migration-archive
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#download-an-organization-migration-archive
|
||||
func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string,
|
|||
// DeleteMigration deletes a previous migration archive.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#delete-an-organization-migration-archive
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#delete-an-organization-migration-archive
|
||||
func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id i
|
|||
// You should unlock each migrated repository and delete them when the migration
|
||||
// is complete and you no longer need the source data.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#unlock-an-organization-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#unlock-an-organization-repository
|
||||
func (s *MigrationService) UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/migrations/%v/repos/%v/lock", org, id, repo)
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ func (i Import) String() string {
|
|||
|
||||
// SourceImportAuthor identifies an author imported from a source repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/source_imports/#get-commit-authors
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-commit-authors
|
||||
type SourceImportAuthor struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
RemoteID *string `json:"remote_id,omitempty"`
|
||||
|
|
@ -132,7 +132,7 @@ func (a SourceImportAuthor) String() string {
|
|||
|
||||
// LargeFile identifies a file larger than 100MB found during a repository import.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/source_imports/#get-large-files
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-large-files
|
||||
type LargeFile struct {
|
||||
RefName *string `json:"ref_name,omitempty"`
|
||||
Path *string `json:"path,omitempty"`
|
||||
|
|
@ -146,7 +146,7 @@ func (f LargeFile) String() string {
|
|||
|
||||
// StartImport initiates a repository import.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-an-import
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#start-an-import
|
||||
func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||
req, err := s.client.NewRequest("PUT", u, in)
|
||||
|
|
@ -165,7 +165,7 @@ func (s *MigrationService) StartImport(ctx context.Context, owner, repo string,
|
|||
|
||||
// ImportProgress queries for the status and progress of an ongoing repository import.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-an-import-status
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-an-import-status
|
||||
func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -184,7 +184,7 @@ func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo strin
|
|||
|
||||
// UpdateImport initiates a repository import.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#update-an-import
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-an-import
|
||||
func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||
req, err := s.client.NewRequest("PATCH", u, in)
|
||||
|
|
@ -213,7 +213,7 @@ func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string,
|
|||
// This method and MapCommitAuthor allow you to provide correct Git author
|
||||
// information.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-commit-authors
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-commit-authors
|
||||
func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -234,7 +234,7 @@ func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string
|
|||
// application can continue updating authors any time before you push new
|
||||
// commits to the repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#map-a-commit-author
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#map-a-commit-author
|
||||
func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo string, id int64, author *SourceImportAuthor) (*SourceImportAuthor, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import/authors/%v", owner, repo, id)
|
||||
req, err := s.client.NewRequest("PATCH", u, author)
|
||||
|
|
@ -255,7 +255,7 @@ func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo stri
|
|||
// files larger than 100MB. Only the UseLFS field on the provided Import is
|
||||
// used.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#update-git-lfs-preference
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-git-lfs-preference
|
||||
func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import/lfs", owner, repo)
|
||||
req, err := s.client.NewRequest("PATCH", u, in)
|
||||
|
|
@ -274,7 +274,7 @@ func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo str
|
|||
|
||||
// LargeFiles lists files larger than 100MB found during the import.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-large-files
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-large-files
|
||||
func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -293,7 +293,7 @@ func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) (
|
|||
|
||||
// CancelImport stops an import for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#cancel-an-import
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#cancel-an-import
|
||||
func (s *MigrationService) CancelImport(ctx context.Context, owner, repo string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -67,7 +67,7 @@ type startUserMigration struct {
|
|||
// StartUserMigration starts the generation of a migration archive.
|
||||
// repos is a slice of repository names to migrate.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-a-user-migration
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#start-a-user-migration
|
||||
func (s *MigrationService) StartUserMigration(ctx context.Context, repos []string, opts *UserMigrationOptions) (*UserMigration, *Response, error) {
|
||||
u := "user/migrations"
|
||||
|
||||
|
|
@ -96,9 +96,13 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin
|
|||
|
||||
// ListUserMigrations lists the most recent migrations.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#list-user-migrations
|
||||
func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) {
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#list-user-migrations
|
||||
func (s *MigrationService) ListUserMigrations(ctx context.Context, opts *ListOptions) ([]*UserMigration, *Response, error) {
|
||||
u := "user/migrations"
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
|
|
@ -120,7 +124,7 @@ func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigra
|
|||
// UserMigrationStatus gets the status of a specific migration archive.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-a-user-migration-status
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#get-a-user-migration-status
|
||||
func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (*UserMigration, *Response, error) {
|
||||
u := fmt.Sprintf("user/migrations/%v", id)
|
||||
|
||||
|
|
@ -144,7 +148,7 @@ func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (*
|
|||
// UserMigrationArchiveURL gets the URL for a specific migration archive.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#download-a-user-migration-archive
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#download-a-user-migration-archive
|
||||
func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) {
|
||||
url := fmt.Sprintf("user/migrations/%v/archive", id)
|
||||
|
||||
|
|
@ -178,7 +182,7 @@ func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64
|
|||
// DeleteUserMigration will delete a previous migration archive.
|
||||
// id is the migration ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#delete-a-user-migration-archive
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#delete-a-user-migration-archive
|
||||
func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (*Response, error) {
|
||||
url := fmt.Sprintf("user/migrations/%v/archive", id)
|
||||
|
||||
|
|
@ -198,7 +202,7 @@ func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (*
|
|||
// You should unlock each migrated repository and delete them when the migration
|
||||
// is complete and you no longer need the source data.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#unlock-a-user-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#unlock-a-user-repository
|
||||
func (s *MigrationService) UnlockUserRepo(ctx context.Context, id int64, repo string) (*Response, error) {
|
||||
url := fmt.Sprintf("user/migrations/%v/repos/%v/lock", id, repo)
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ type markdownRequest struct {
|
|||
|
||||
// Markdown renders an arbitrary Markdown document.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/markdown/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/markdown/
|
||||
func (c *Client) Markdown(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
|
||||
request := &markdownRequest{Text: String(text)}
|
||||
if opts != nil {
|
||||
|
|
@ -67,7 +67,7 @@ func (c *Client) Markdown(ctx context.Context, text string, opts *MarkdownOption
|
|||
|
||||
// ListEmojis returns the emojis available to use on GitHub.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/emojis/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/emojis/
|
||||
func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
|
||||
req, err := c.NewRequest("GET", "emojis", nil)
|
||||
if err != nil {
|
||||
|
|
@ -97,7 +97,7 @@ func (c *CodeOfConduct) String() string {
|
|||
|
||||
// ListCodesOfConduct returns all codes of conduct.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/codes_of_conduct/#list-all-codes-of-conduct
|
||||
// GitHub API docs: https://docs.github.com/en/rest/codes_of_conduct/#list-all-codes-of-conduct
|
||||
func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
|
||||
req, err := c.NewRequest("GET", "codes_of_conduct", nil)
|
||||
if err != nil {
|
||||
|
|
@ -118,7 +118,7 @@ func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Res
|
|||
|
||||
// GetCodeOfConduct returns an individual code of conduct.
|
||||
//
|
||||
// https://docs.github.com/en/free-pro-team@latest/rest/reference/codes_of_conduct/#get-an-individual-code-of-conduct
|
||||
// https://docs.github.com/en/rest/codes_of_conduct/#get-an-individual-code-of-conduct
|
||||
func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
|
||||
u := fmt.Sprintf("codes_of_conduct/%s", key)
|
||||
req, err := c.NewRequest("GET", u, nil)
|
||||
|
|
@ -176,13 +176,21 @@ type APIMeta struct {
|
|||
|
||||
// An array of SSH keys.
|
||||
SSHKeys []string `json:"ssh_keys,omitempty"`
|
||||
|
||||
// An array of IP addresses in CIDR format specifying the addresses
|
||||
// which serve GitHub websites.
|
||||
Web []string `json:"web,omitempty"`
|
||||
|
||||
// An array of IP addresses in CIDR format specifying the addresses
|
||||
// which serve GitHub APIs.
|
||||
API []string `json:"api,omitempty"`
|
||||
}
|
||||
|
||||
// APIMeta returns information about GitHub.com, the service. Or, if you access
|
||||
// this endpoint on your organization’s GitHub Enterprise installation, this
|
||||
// endpoint provides information about that installation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/meta#get-github-meta-information
|
||||
// GitHub API docs: https://docs.github.com/en/rest/meta#get-github-meta-information
|
||||
func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) {
|
||||
req, err := c.NewRequest("GET", "meta", nil)
|
||||
if err != nil {
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// OrganizationsService provides access to the organization related functions
|
||||
// in the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/
|
||||
type OrganizationsService service
|
||||
|
||||
// Organization represents a GitHub organization account.
|
||||
|
|
@ -65,6 +65,9 @@ type Organization struct {
|
|||
MembersCanCreatePrivateRepos *bool `json:"members_can_create_private_repositories,omitempty"`
|
||||
MembersCanCreateInternalRepos *bool `json:"members_can_create_internal_repositories,omitempty"`
|
||||
|
||||
// MembersCanForkPrivateRepos toggles whether organization members can fork private organization repositories.
|
||||
MembersCanForkPrivateRepos *bool `json:"members_can_fork_private_repositories,omitempty"`
|
||||
|
||||
// MembersAllowedRepositoryCreationType denotes if organization members can create repositories
|
||||
// and the type of repositories they can create. Possible values are: "all", "private", or "none".
|
||||
//
|
||||
|
|
@ -79,6 +82,20 @@ type Organization struct {
|
|||
MembersCanCreatePublicPages *bool `json:"members_can_create_public_pages,omitempty"`
|
||||
// MembersCanCreatePrivatePages toggles whether organization members can create private GitHub Pages sites.
|
||||
MembersCanCreatePrivatePages *bool `json:"members_can_create_private_pages,omitempty"`
|
||||
// WebCommitSignoffRequire toggles
|
||||
WebCommitSignoffRequired *bool `json:"web_commit_signoff_required,omitempty"`
|
||||
// AdvancedSecurityAuditLogEnabled toggles whether the advanced security audit log is enabled.
|
||||
AdvancedSecurityEnabledForNewRepos *bool `json:"advanced_security_enabled_for_new_repositories,omitempty"`
|
||||
// DependabotAlertsEnabled toggles whether dependabot alerts are enabled.
|
||||
DependabotAlertsEnabledForNewRepos *bool `json:"dependabot_alerts_enabled_for_new_repositories,omitempty"`
|
||||
// DependabotSecurityUpdatesEnabled toggles whether dependabot security updates are enabled.
|
||||
DependabotSecurityUpdatesEnabledForNewRepos *bool `json:"dependabot_security_updates_enabled_for_new_repositories,omitempty"`
|
||||
// DependabotGraphEnabledForNewRepos toggles whether dependabot graph is enabled on new repositories.
|
||||
DependencyGraphEnabledForNewRepos *bool `json:"dependency_graph_enabled_for_new_repositories,omitempty"`
|
||||
// SecretScanningEnabled toggles whether secret scanning is enabled on new repositories.
|
||||
SecretScanningEnabledForNewRepos *bool `json:"secret_scanning_enabled_for_new_repositories,omitempty"`
|
||||
// SecretScanningPushProtectionEnabledForNewRepos toggles whether secret scanning push protection is enabled on new repositories.
|
||||
SecretScanningPushProtectionEnabledForNewRepos *bool `json:"secret_scanning_push_protection_enabled_for_new_repositories,omitempty"`
|
||||
|
||||
// API URLs
|
||||
URL *string `json:"url,omitempty"`
|
||||
|
|
@ -132,7 +149,7 @@ type OrganizationsListOptions struct {
|
|||
// listing the next set of organizations, use the ID of the last-returned organization
|
||||
// as the opts.Since parameter for the next call.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations
|
||||
func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error) {
|
||||
u, err := addOptions("organizations", opts)
|
||||
if err != nil {
|
||||
|
|
@ -155,8 +172,8 @@ func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsL
|
|||
// List the organizations for a user. Passing the empty string will list
|
||||
// organizations for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-a-user
|
||||
func (s *OrganizationsService) List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error) {
|
||||
var u string
|
||||
if user != "" {
|
||||
|
|
@ -185,7 +202,7 @@ func (s *OrganizationsService) List(ctx context.Context, user string, opts *List
|
|||
|
||||
// Get fetches an organization by name.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#get-an-organization
|
||||
func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v", org)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -226,7 +243,7 @@ func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organiza
|
|||
|
||||
// Edit an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#update-an-organization
|
||||
func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v", name)
|
||||
req, err := s.client.NewRequest("PATCH", u, org)
|
||||
|
|
@ -248,7 +265,7 @@ func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organ
|
|||
|
||||
// ListInstallations lists installations for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-app-installations-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-app-installations-for-an-organization
|
||||
func (s *OrganizationsService) ListInstallations(ctx context.Context, org string, opts *ListOptions) (*OrganizationInstallations, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/installations", org)
|
||||
|
||||
|
|
@ -10,9 +10,9 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// ActionsAllowed represents selected actions that are allowed in an organization.
|
||||
// ActionsAllowed represents selected actions that are allowed.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-allowed-actions-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions
|
||||
type ActionsAllowed struct {
|
||||
GithubOwnedAllowed *bool `json:"github_owned_allowed,omitempty"`
|
||||
VerifiedAllowed *bool `json:"verified_allowed,omitempty"`
|
||||
|
|
@ -25,7 +25,7 @@ func (a ActionsAllowed) String() string {
|
|||
|
||||
// GetActionsAllowed gets the actions that are allowed in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-allowed-actions-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization
|
||||
func (s *OrganizationsService) GetActionsAllowed(ctx context.Context, org string) (*ActionsAllowed, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org)
|
||||
|
||||
|
|
@ -45,14 +45,19 @@ func (s *OrganizationsService) GetActionsAllowed(ctx context.Context, org string
|
|||
|
||||
// EditActionsAllowed sets the actions that are allowed in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-allowed-actions-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-organization
|
||||
func (s *OrganizationsService) EditActionsAllowed(ctx context.Context, org string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org)
|
||||
req, err := s.client.NewRequest("PUT", u, actionsAllowed)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
p := new(ActionsAllowed)
|
||||
resp, err := s.client.Do(ctx, req, p)
|
||||
return p, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return p, resp, nil
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ActionsPermissions represents a policy for repositories and allowed actions in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#permissions
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions
|
||||
type ActionsPermissions struct {
|
||||
EnabledRepositories *string `json:"enabled_repositories,omitempty"`
|
||||
AllowedActions *string `json:"allowed_actions,omitempty"`
|
||||
|
|
@ -25,7 +25,7 @@ func (a ActionsPermissions) String() string {
|
|||
|
||||
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-github-actions-permissions-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-github-actions-permissions-for-an-organization
|
||||
func (s *OrganizationsService) GetActionsPermissions(ctx context.Context, org string) (*ActionsPermissions, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/actions/permissions", org)
|
||||
|
||||
|
|
@ -45,14 +45,19 @@ func (s *OrganizationsService) GetActionsPermissions(ctx context.Context, org st
|
|||
|
||||
// EditActionsPermissions sets the permissions policy for repositories and allowed actions in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-github-actions-permissions-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-github-actions-permissions-for-an-organization
|
||||
func (s *OrganizationsService) EditActionsPermissions(ctx context.Context, org string, actionsPermissions ActionsPermissions) (*ActionsPermissions, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/actions/permissions", org)
|
||||
req, err := s.client.NewRequest("PUT", u, actionsPermissions)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
p := new(ActionsPermissions)
|
||||
resp, err := s.client.Do(ctx, req, p)
|
||||
return p, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return p, resp, nil
|
||||
}
|
||||
|
|
@ -70,6 +70,7 @@ type AuditEntry struct {
|
|||
Repo *string `json:"repo,omitempty"`
|
||||
Repository *string `json:"repository,omitempty"`
|
||||
RepositoryPublic *bool `json:"repository_public,omitempty"`
|
||||
RunAttempt *int64 `json:"run_attempt,omitempty"`
|
||||
RunnerGroupID *int64 `json:"runner_group_id,omitempty"`
|
||||
RunnerGroupName *string `json:"runner_group_name,omitempty"`
|
||||
RunnerID *int64 `json:"runner_id,omitempty"`
|
||||
|
|
@ -93,7 +94,7 @@ type AuditEntry struct {
|
|||
|
||||
// GetAuditLog gets the audit-log entries for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#get-the-audit-log-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#get-the-audit-log-for-an-organization
|
||||
func (s *OrganizationsService) GetAuditLog(ctx context.Context, org string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/audit-log", org)
|
||||
u, err := addOptions(u, opts)
|
||||
46
vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go
generated
vendored
Normal file
46
vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2022 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"
|
||||
)
|
||||
|
||||
// OrganizationCustomRepoRoles represents custom repository roles available in specified organization.
|
||||
type OrganizationCustomRepoRoles struct {
|
||||
TotalCount *int `json:"total_count,omitempty"`
|
||||
CustomRepoRoles []*CustomRepoRoles `json:"custom_roles,omitempty"`
|
||||
}
|
||||
|
||||
// CustomRepoRoles represents custom repository roles for an organization.
|
||||
// See https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization
|
||||
// for more information.
|
||||
type CustomRepoRoles struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// ListCustomRepoRoles lists the custom repository roles available in this organization.
|
||||
// In order to see custom repository roles in an organization, the authenticated user must be an organization owner.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization
|
||||
func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/custom_roles", org)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
customRepoRoles := new(OrganizationCustomRepoRoles)
|
||||
resp, err := s.client.Do(ctx, req, customRepoRoles)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return customRepoRoles, resp, nil
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ListHooks lists all Hooks for the specified organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-webhooks
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#list-organization-webhooks
|
||||
func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts *ListOptions) ([]*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -36,16 +36,21 @@ func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts *
|
|||
|
||||
// GetHook returns a single specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#get-an-organization-webhook
|
||||
func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64) (*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(ctx, req, hook)
|
||||
return hook, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return hook, resp, nil
|
||||
}
|
||||
|
||||
// CreateHook creates a Hook for the specified org.
|
||||
|
|
@ -54,7 +59,7 @@ func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64
|
|||
// Note that only a subset of the hook fields are used and hook must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#create-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#create-an-organization-webhook
|
||||
func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks", org)
|
||||
|
||||
|
|
@ -81,38 +86,45 @@ func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook
|
|||
|
||||
// EditHook updates a specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#update-an-organization-webhook
|
||||
func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int64, 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(ctx, req, h)
|
||||
return h, resp, err
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return h, resp, nil
|
||||
}
|
||||
|
||||
// PingHook triggers a 'ping' event to be sent to the Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#ping-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#ping-an-organization-webhook
|
||||
func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int64) (*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(ctx, req, nil)
|
||||
}
|
||||
|
||||
// DeleteHook deletes a specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#delete-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#delete-an-organization-webhook
|
||||
func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int64) (*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(ctx, req, nil)
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ListHookDeliveries lists webhook deliveries for a webhook configured in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#list-deliveries-for-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#list-deliveries-for-an-organization-webhook
|
||||
func (s *OrganizationsService) ListHookDeliveries(ctx context.Context, org string, id int64, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries", org, id)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -36,7 +36,7 @@ func (s *OrganizationsService) ListHookDeliveries(ctx context.Context, org strin
|
|||
|
||||
// GetHookDelivery returns a delivery for a webhook configured in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#get-a-webhook-delivery-for-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#get-a-webhook-delivery-for-an-organization-webhook
|
||||
func (s *OrganizationsService) GetHookDelivery(ctx context.Context, owner string, hookID, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries/%v", owner, hookID, deliveryID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -55,7 +55,7 @@ func (s *OrganizationsService) GetHookDelivery(ctx context.Context, owner string
|
|||
|
||||
// RedeliverHookDelivery redelivers a delivery for a webhook configured in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#redeliver-a-delivery-for-an-organization-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook
|
||||
func (s *OrganizationsService) RedeliverHookDelivery(ctx context.Context, owner string, hookID, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries/%v/attempts", owner, hookID, deliveryID)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -71,8 +71,8 @@ type ListMembersOptions struct {
|
|||
// 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: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-members
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-public-organization-members
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-members
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-public-organization-members
|
||||
func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts *ListMembersOptions) ([]*User, *Response, error) {
|
||||
var u string
|
||||
if opts != nil && opts.PublicOnly {
|
||||
|
|
@ -101,7 +101,7 @@ func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts
|
|||
|
||||
// IsMember checks if a user is a member of an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-organization-membership-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#check-organization-membership-for-a-user
|
||||
func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) (bool, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/members/%v", org, user)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -116,7 +116,7 @@ func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) (
|
|||
|
||||
// IsPublicMember checks if a user is a public member of an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-public-organization-membership-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#check-public-organization-membership-for-a-user
|
||||
func (s *OrganizationsService) IsPublicMember(ctx context.Context, org, user string) (bool, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -131,7 +131,7 @@ func (s *OrganizationsService) IsPublicMember(ctx context.Context, org, user str
|
|||
|
||||
// RemoveMember removes a user from all teams of an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-an-organization-member
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-an-organization-member
|
||||
func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/members/%v", org, user)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -145,7 +145,7 @@ func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user strin
|
|||
// PublicizeMembership publicizes a user's membership in an organization. (A
|
||||
// user cannot publicize the membership for another user.)
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#set-public-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user
|
||||
func (s *OrganizationsService) PublicizeMembership(ctx context.Context, org, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
||||
req, err := s.client.NewRequest("PUT", u, nil)
|
||||
|
|
@ -158,7 +158,7 @@ func (s *OrganizationsService) PublicizeMembership(ctx context.Context, org, use
|
|||
|
||||
// ConcealMembership conceals a user's membership in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-public-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user
|
||||
func (s *OrganizationsService) ConcealMembership(ctx context.Context, org, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/public_members/%v", org, user)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -181,7 +181,7 @@ type ListOrgMembershipsOptions struct {
|
|||
|
||||
// ListOrgMemberships lists the organization memberships for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-memberships-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-memberships-for-the-authenticated-user
|
||||
func (s *OrganizationsService) ListOrgMemberships(ctx context.Context, opts *ListOrgMembershipsOptions) ([]*Membership, *Response, error) {
|
||||
u := "user/memberships/orgs"
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -207,8 +207,8 @@ func (s *OrganizationsService) ListOrgMemberships(ctx context.Context, opts *Lis
|
|||
// Passing an empty string for user will get the membership for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-organization-membership-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#get-organization-membership-for-a-user
|
||||
func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org string) (*Membership, *Response, error) {
|
||||
var u string
|
||||
if user != "" {
|
||||
|
|
@ -235,8 +235,8 @@ func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org s
|
|||
// Passing an empty string for user will edit the membership for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#set-organization-membership-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#set-organization-membership-for-a-user
|
||||
func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org string, membership *Membership) (*Membership, *Response, error) {
|
||||
var u, method string
|
||||
if user != "" {
|
||||
|
|
@ -264,7 +264,7 @@ func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org
|
|||
// 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://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-organization-membership-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-organization-membership-for-a-user
|
||||
func (s *OrganizationsService) RemoveOrgMembership(ctx context.Context, user, org string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/memberships/%v", org, user)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -277,7 +277,7 @@ func (s *OrganizationsService) RemoveOrgMembership(ctx context.Context, user, or
|
|||
|
||||
// ListPendingOrgInvitations returns a list of pending invitations.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-pending-organization-invitations
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-pending-organization-invitations
|
||||
func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/invitations", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -295,6 +295,7 @@ func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, or
|
|||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return pendingInvitations, resp, nil
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +323,7 @@ type CreateOrgInvitationOptions struct {
|
|||
// In order to create invitations in an organization,
|
||||
// the authenticated user must be an organization owner.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#create-an-organization-invitation
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#create-an-organization-invitation
|
||||
func (s *OrganizationsService) CreateOrgInvitation(ctx context.Context, org string, opts *CreateOrgInvitationOptions) (*Invitation, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/invitations", org)
|
||||
|
||||
|
|
@ -336,13 +337,14 @@ func (s *OrganizationsService) CreateOrgInvitation(ctx context.Context, org stri
|
|||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return invitation, resp, nil
|
||||
}
|
||||
|
||||
// ListOrgInvitationTeams lists all teams associated with an invitation. In order to see invitations in an organization,
|
||||
// the authenticated user must be an organization owner.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-invitation-teams
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-invitation-teams
|
||||
func (s *OrganizationsService) ListOrgInvitationTeams(ctx context.Context, org, invitationID string, opts *ListOptions) ([]*Team, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/invitations/%v/teams", org, invitationID)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -360,12 +362,13 @@ func (s *OrganizationsService) ListOrgInvitationTeams(ctx context.Context, org,
|
|||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return orgInvitationTeams, resp, nil
|
||||
}
|
||||
|
||||
// ListFailedOrgInvitations returns a list of failed inviatations.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#list-failed-organization-invitations
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations
|
||||
func (s *OrganizationsService) ListFailedOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/failed_invitations", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -27,7 +27,7 @@ type ListOutsideCollaboratorsOptions struct {
|
|||
// Warning: The API may change without advance notice during the preview period.
|
||||
// Preview features are not supported for production use.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-outside-collaborators-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#list-outside-collaborators-for-an-organization
|
||||
func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org string, opts *ListOutsideCollaboratorsOptions) ([]*User, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/outside_collaborators", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -52,7 +52,7 @@ func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org
|
|||
// RemoveOutsideCollaborator removes a user from the list of outside collaborators;
|
||||
// consequently, removing them from all the organization's repositories.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-outside-collaborator-from-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#remove-outside-collaborator-from-an-organization
|
||||
func (s *OrganizationsService) RemoveOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/outside_collaborators/%v", org, user)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -69,7 +69,7 @@ func (s *OrganizationsService) RemoveOutsideCollaborator(ctx context.Context, or
|
|||
// Responses for converting a non-member or the last owner to an outside collaborator
|
||||
// are listed in GitHub API docs.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#convert-an-organization-member-to-outside-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#convert-an-organization-member-to-outside-collaborator
|
||||
func (s *OrganizationsService) ConvertMemberToOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/outside_collaborators/%v", org, user)
|
||||
req, err := s.client.NewRequest("PUT", u, nil)
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// List the packages for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#list-packages-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#list-packages-for-an-organization
|
||||
func (s *OrganizationsService) ListPackages(ctx context.Context, org string, opts *PackageListOptions) ([]*Package, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -36,7 +36,7 @@ func (s *OrganizationsService) ListPackages(ctx context.Context, org string, opt
|
|||
|
||||
// Get a package by name from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-for-an-organization
|
||||
func (s *OrganizationsService) GetPackage(ctx context.Context, org, packageType, packageName string) (*Package, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v", org, packageType, packageName)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -55,7 +55,7 @@ func (s *OrganizationsService) GetPackage(ctx context.Context, org, packageType,
|
|||
|
||||
// Delete a package from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-a-package-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#delete-a-package-for-an-organization
|
||||
func (s *OrganizationsService) DeletePackage(ctx context.Context, org, packageType, packageName string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v", org, packageType, packageName)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -68,7 +68,7 @@ func (s *OrganizationsService) DeletePackage(ctx context.Context, org, packageTy
|
|||
|
||||
// Restore a package to an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-a-package-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#restore-a-package-for-an-organization
|
||||
func (s *OrganizationsService) RestorePackage(ctx context.Context, org, packageType, packageName string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v/restore", org, packageType, packageName)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -81,7 +81,7 @@ func (s *OrganizationsService) RestorePackage(ctx context.Context, org, packageT
|
|||
|
||||
// Get all versions of a package in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-all-package-versions-for-a-package-owned-by-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization
|
||||
func (s *OrganizationsService) PackageGetAllVersions(ctx context.Context, org, packageType, packageName string, opts *PackageListOptions) ([]*PackageVersion, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions", org, packageType, packageName)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -105,7 +105,7 @@ func (s *OrganizationsService) PackageGetAllVersions(ctx context.Context, org, p
|
|||
|
||||
// Get a specific version of a package in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-version-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-version-for-an-organization
|
||||
func (s *OrganizationsService) PackageGetVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*PackageVersion, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v", org, packageType, packageName, packageVersionID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -124,7 +124,7 @@ func (s *OrganizationsService) PackageGetVersion(ctx context.Context, org, packa
|
|||
|
||||
// Delete a package version from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-package-version-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#delete-package-version-for-an-organization
|
||||
func (s *OrganizationsService) PackageDeleteVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v", org, packageType, packageName, packageVersionID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -137,7 +137,7 @@ func (s *OrganizationsService) PackageDeleteVersion(ctx context.Context, org, pa
|
|||
|
||||
// Restore a package version to an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-package-version-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/packages#restore-package-version-for-an-organization
|
||||
func (s *OrganizationsService) PackageRestoreVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v/restore", org, packageType, packageName, packageVersionID)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ListProjects lists the projects for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-organization-projects
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/projects#list-organization-projects
|
||||
func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/projects", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -39,7 +39,7 @@ func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opt
|
|||
|
||||
// CreateProject creates a GitHub Project for the specified organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-an-organization-project
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/projects#create-an-organization-project
|
||||
func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/projects", org)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// ListBlockedUsers lists all the users blocked by an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-users-blocked-by-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#list-users-blocked-by-an-organization
|
||||
func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string, opts *ListOptions) ([]*User, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/blocks", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -39,7 +39,7 @@ func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string,
|
|||
|
||||
// IsBlocked reports whether specified user is blocked from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-if-a-user-is-blocked-by-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization
|
||||
func (s *OrganizationsService) IsBlocked(ctx context.Context, org string, user string) (bool, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/blocks/%v", org, user)
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ func (s *OrganizationsService) IsBlocked(ctx context.Context, org string, user s
|
|||
|
||||
// BlockUser blocks specified user from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#block-a-user-from-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#block-a-user-from-an-organization
|
||||
func (s *OrganizationsService) BlockUser(ctx context.Context, org string, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/blocks/%v", org, user)
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ func (s *OrganizationsService) BlockUser(ctx context.Context, org string, user s
|
|||
|
||||
// UnblockUser unblocks specified user from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#unblock-a-user-from-an-organization
|
||||
// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#unblock-a-user-from-an-organization
|
||||
func (s *OrganizationsService) UnblockUser(ctx context.Context, org string, user string) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/blocks/%v", org, user)
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// ProjectsService provides access to the projects functions in the
|
||||
// GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects
|
||||
type ProjectsService service
|
||||
|
||||
// Project represents a GitHub Project.
|
||||
|
|
@ -43,7 +43,7 @@ func (p Project) String() string {
|
|||
|
||||
// GetProject gets a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/projects#get-a-project
|
||||
func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -90,7 +90,7 @@ type ProjectOptions struct {
|
|||
|
||||
// UpdateProject updates a repository project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-a-project
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/projects#update-a-project
|
||||
func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *ProjectOptions) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
|
|
@ -112,7 +112,7 @@ func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *Pro
|
|||
|
||||
// DeleteProject deletes a GitHub Project from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/projects#delete-a-project
|
||||
func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -128,7 +128,7 @@ func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Respons
|
|||
|
||||
// ProjectColumn represents a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/projects/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/projects/
|
||||
type ProjectColumn struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
|
@ -142,7 +142,7 @@ type ProjectColumn struct {
|
|||
|
||||
// ListProjectColumns lists the columns of a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-columns
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#list-project-columns
|
||||
func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int64, opts *ListOptions) ([]*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/columns", projectID)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -169,7 +169,7 @@ func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int6
|
|||
|
||||
// GetProjectColumn gets a column of a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project-column
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#get-a-project-column
|
||||
func (s *ProjectsService) GetProjectColumn(ctx context.Context, id int64) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -199,7 +199,7 @@ type ProjectColumnOptions struct {
|
|||
|
||||
// CreateProjectColumn creates a column for the specified (by number) project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-project-column
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#create-a-project-column
|
||||
func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/columns", projectID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -221,7 +221,7 @@ func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int
|
|||
|
||||
// UpdateProjectColumn updates a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-an-existing-project-column
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#update-an-existing-project-column
|
||||
func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", columnID)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
|
|
@ -243,7 +243,7 @@ func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int6
|
|||
|
||||
// DeleteProjectColumn deletes a column from a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project-column
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#delete-a-project-column
|
||||
func (s *ProjectsService) DeleteProjectColumn(ctx context.Context, columnID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", columnID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -267,7 +267,7 @@ type ProjectColumnMoveOptions struct {
|
|||
|
||||
// MoveProjectColumn moves a column within a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#move-a-project-column
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/columns#move-a-project-column
|
||||
func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnMoveOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/moves", columnID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -283,7 +283,7 @@ func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64,
|
|||
|
||||
// ProjectCard represents a card in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/cards/#get-a-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards/#get-a-project-card
|
||||
type ProjectCard struct {
|
||||
URL *string `json:"url,omitempty"`
|
||||
ColumnURL *string `json:"column_url,omitempty"`
|
||||
|
|
@ -318,7 +318,7 @@ type ProjectCardListOptions struct {
|
|||
|
||||
// ListProjectCards lists the cards in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-cards
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#list-project-cards
|
||||
func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opts *ProjectCardListOptions) ([]*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/cards", columnID)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -345,7 +345,7 @@ func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64,
|
|||
|
||||
// GetProjectCard gets a card in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#get-a-project-card
|
||||
func (s *ProjectsService) GetProjectCard(ctx context.Context, cardID int64) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -383,7 +383,7 @@ type ProjectCardOptions struct {
|
|||
|
||||
// CreateProjectCard creates a card in the specified column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#create-a-project-card
|
||||
func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/cards", columnID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -405,7 +405,7 @@ func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64,
|
|||
|
||||
// UpdateProjectCard updates a card of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-an-existing-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#update-an-existing-project-card
|
||||
func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
|
|
@ -427,7 +427,7 @@ func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, o
|
|||
|
||||
// DeleteProjectCard deletes a card from a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#delete-a-project-card
|
||||
func (s *ProjectsService) DeleteProjectCard(ctx context.Context, cardID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -455,7 +455,7 @@ type ProjectCardMoveOptions struct {
|
|||
|
||||
// MoveProjectCard moves a card within a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#move-a-project-card
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/cards#move-a-project-card
|
||||
func (s *ProjectsService) MoveProjectCard(ctx context.Context, cardID int64, opts *ProjectCardMoveOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v/moves", cardID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -485,7 +485,7 @@ type ProjectCollaboratorOptions struct {
|
|||
// AddProjectCollaborator adds a collaborator to an organization project and sets
|
||||
// their permission level. You must be an organization owner or a project admin to add a collaborator.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#add-project-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#add-project-collaborator
|
||||
func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64, username string, opts *ProjectCollaboratorOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v", id, username)
|
||||
req, err := s.client.NewRequest("PUT", u, opts)
|
||||
|
|
@ -502,7 +502,7 @@ func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64,
|
|||
// RemoveProjectCollaborator removes a collaborator from an organization project.
|
||||
// You must be an organization owner or a project admin to remove a collaborator.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#remove-user-as-a-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#remove-user-as-a-collaborator
|
||||
func (s *ProjectsService) RemoveProjectCollaborator(ctx context.Context, id int64, username string) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v", id, username)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -538,7 +538,7 @@ type ListCollaboratorOptions struct {
|
|||
// with access through default organization permissions, and organization owners. You must be an
|
||||
// organization owner or a project admin to list collaborators.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-collaborators
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#list-project-collaborators
|
||||
func (s *ProjectsService) ListProjectCollaborators(ctx context.Context, id int64, opts *ListCollaboratorOptions) ([]*User, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators", id)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -576,7 +576,7 @@ type ProjectPermissionLevel struct {
|
|||
// project. Possible values for the permission key: "admin", "write", "read", "none".
|
||||
// You must be an organization owner or a project admin to review a user's permission level.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-project-permission-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#get-project-permission-for-a-user
|
||||
func (s *ProjectsService) ReviewProjectCollaboratorPermission(ctx context.Context, id int64, username string) (*ProjectPermissionLevel, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v/permission", id, username)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
// PullRequestsService handles communication with the pull request related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/
|
||||
type PullRequestsService service
|
||||
|
||||
// PullRequestAutoMerge represents the "auto_merge" response for a PullRequest.
|
||||
|
|
@ -143,7 +143,7 @@ type PullRequestListOptions struct {
|
|||
|
||||
// List the pull requests for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-pull-requests
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-pull-requests
|
||||
func (s *PullRequestsService) List(ctx context.Context, owner string, repo string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -170,7 +170,7 @@ func (s *PullRequestsService) List(ctx context.Context, owner string, repo strin
|
|||
// The results may include open and closed pull requests.
|
||||
// By default, the PullRequestListOptions State filters for "open".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/commits/#list-pull-requests-associated-with-a-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit
|
||||
func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v/pulls", owner, repo, sha)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -196,7 +196,7 @@ func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, ow
|
|||
|
||||
// Get a single pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request
|
||||
func (s *PullRequestsService) Get(ctx context.Context, 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)
|
||||
|
|
@ -215,7 +215,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string
|
|||
|
||||
// GetRaw gets a single pull request in raw (diff or patch) format.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request
|
||||
func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo string, number int, opts RawOptions) (string, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -254,7 +254,7 @@ type NewPullRequest struct {
|
|||
|
||||
// Create a new pull request on the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request
|
||||
func (s *PullRequestsService) Create(ctx context.Context, 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)
|
||||
|
|
@ -293,7 +293,7 @@ type PullRequestBranchUpdateResponse struct {
|
|||
// A follow up request, after a delay of a second or so, should result
|
||||
// in a successful request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-pull-request-branch
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request-branch
|
||||
func (s *PullRequestsService) UpdateBranch(ctx context.Context, owner, repo string, number int, opts *PullRequestBranchUpdateOptions) (*PullRequestBranchUpdateResponse, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/update-branch", owner, repo, number)
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ type pullRequestUpdate struct {
|
|||
// The following fields are editable: Title, Body, State, Base.Ref and MaintainerCanModify.
|
||||
// Base.Ref updates the base branch of the pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request
|
||||
func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) {
|
||||
if pull == nil {
|
||||
return nil, nil, fmt.Errorf("pull must be provided")
|
||||
|
|
@ -365,7 +365,7 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo strin
|
|||
|
||||
// ListCommits lists the commits in a pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-commits-on-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-commits-on-a-pull-request
|
||||
func (s *PullRequestsService) ListCommits(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*RepositoryCommit, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -389,7 +389,7 @@ func (s *PullRequestsService) ListCommits(ctx context.Context, owner string, rep
|
|||
|
||||
// ListFiles lists the files in a pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-pull-requests-files
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files
|
||||
func (s *PullRequestsService) ListFiles(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*CommitFile, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/files", owner, repo, number)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -413,7 +413,7 @@ func (s *PullRequestsService) ListFiles(ctx context.Context, owner string, repo
|
|||
|
||||
// IsMerged checks if a pull request has been merged.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#check-if-a-pull-request-has-been-merged
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#check-if-a-pull-request-has-been-merged
|
||||
func (s *PullRequestsService) IsMerged(ctx context.Context, 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)
|
||||
|
|
@ -455,7 +455,7 @@ type pullRequestMergeRequest struct {
|
|||
// Merge a pull request.
|
||||
// commitMessage is an extra detail to append to automatic commit message.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#merge-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#merge-a-pull-request
|
||||
func (s *PullRequestsService) Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *PullRequestOptions) (*PullRequestMergeResult, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number)
|
||||
|
||||
|
|
@ -66,8 +66,8 @@ type PullRequestListCommentsOptions struct {
|
|||
// pull request number of 0 will return all comments on all pull requests for
|
||||
// the repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-review-comments-on-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-review-comments-in-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#list-review-comments-on-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#list-review-comments-in-a-repository
|
||||
func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo string, number int, opts *PullRequestListCommentsOptions) ([]*PullRequestComment, *Response, error) {
|
||||
var u string
|
||||
if number == 0 {
|
||||
|
|
@ -100,7 +100,7 @@ func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo stri
|
|||
|
||||
// GetComment fetches the specified pull request comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-review-comment-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#get-a-review-comment-for-a-pull-request
|
||||
func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string, commentID int64) (*PullRequestComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -123,7 +123,7 @@ func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string
|
|||
|
||||
// CreateComment creates a new comment on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-comment-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request
|
||||
func (s *PullRequestsService) CreateComment(ctx context.Context, owner, 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)
|
||||
|
|
@ -145,7 +145,7 @@ func (s *PullRequestsService) CreateComment(ctx context.Context, owner, repo str
|
|||
|
||||
// CreateCommentInReplyTo creates a new comment as a reply to an existing pull request comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-comment-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request
|
||||
func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner, repo string, number int, body string, commentID int64) (*PullRequestComment, *Response, error) {
|
||||
comment := &struct {
|
||||
Body string `json:"body,omitempty"`
|
||||
|
|
@ -172,7 +172,7 @@ func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner,
|
|||
// EditComment updates a pull request 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/pulls/#update-a-review-comment-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#update-a-review-comment-for-a-pull-request
|
||||
func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo string, commentID int64, comment *PullRequestComment) (*PullRequestComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
|
||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||
|
|
@ -191,7 +191,7 @@ func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo strin
|
|||
|
||||
// DeleteComment deletes a pull request comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#delete-a-review-comment-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#delete-a-review-comment-for-a-pull-request
|
||||
func (s *PullRequestsService) DeleteComment(ctx context.Context, owner, repo string, commentID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -25,7 +25,7 @@ type Reviewers struct {
|
|||
|
||||
// RequestReviewers creates a review request for the provided reviewers for the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#request-reviewers-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#request-reviewers-for-a-pull-request
|
||||
func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number)
|
||||
req, err := s.client.NewRequest("POST", u, &reviewers)
|
||||
|
|
@ -44,7 +44,7 @@ func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo
|
|||
|
||||
// ListReviewers lists reviewers whose reviews have been requested on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-requested-reviewers-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#list-requested-reviewers-for-a-pull-request
|
||||
func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/requested_reviewers", owner, repo, number)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -68,7 +68,7 @@ func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo str
|
|||
|
||||
// RemoveReviewers removes the review request for the provided reviewers for the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#remove-requested-reviewers-from-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#remove-requested-reviewers-from-a-pull-request
|
||||
func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number)
|
||||
req, err := s.client.NewRequest("DELETE", u, &reviewers)
|
||||
|
|
@ -101,7 +101,7 @@ func (r PullRequestReviewDismissalRequest) String() string {
|
|||
|
||||
// ListReviews lists all reviews on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-reviews-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#list-reviews-for-a-pull-request
|
||||
func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -125,7 +125,7 @@ func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo strin
|
|||
|
||||
// GetReview fetches the specified pull request review.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#get-a-review-for-a-pull-request
|
||||
func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID)
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string,
|
|||
|
||||
// DeletePendingReview deletes the specified pull request pending review.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#delete-a-pending-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#delete-a-pending-review-for-a-pull-request
|
||||
func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID)
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, re
|
|||
|
||||
// ListReviewComments lists all the comments for the specified review.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-comments-for-a-pull-request-review
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#list-comments-for-a-pull-request-review
|
||||
func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, repo string, number int, reviewID int64, opts *ListOptions) ([]*PullRequestComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -189,39 +189,41 @@ func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, rep
|
|||
|
||||
// CreateReview creates a new review on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request
|
||||
//
|
||||
// In order to use multi-line comments, you must use the "comfort fade" preview.
|
||||
// This replaces the use of the "Position" field in comments with 4 new fields:
|
||||
// [Start]Side, and [Start]Line.
|
||||
//
|
||||
// [Start]Side, and [Start]Line.
|
||||
//
|
||||
// These new fields must be used for ALL comments (including single-line),
|
||||
// with the following restrictions (empirically observed, so subject to change).
|
||||
//
|
||||
// For single-line "comfort fade" comments, you must use:
|
||||
//
|
||||
// Path: &path, // as before
|
||||
// Body: &body, // as before
|
||||
// Side: &"RIGHT" (or "LEFT")
|
||||
// Line: &123, // NOT THE SAME AS POSITION, this is an actual line number.
|
||||
// Path: &path, // as before
|
||||
// Body: &body, // as before
|
||||
// Side: &"RIGHT" (or "LEFT")
|
||||
// Line: &123, // NOT THE SAME AS POSITION, this is an actual line number.
|
||||
//
|
||||
// If StartSide or StartLine is used with single-line comments, a 422 is returned.
|
||||
//
|
||||
// For multi-line "comfort fade" comments, you must use:
|
||||
//
|
||||
// Path: &path, // as before
|
||||
// Body: &body, // as before
|
||||
// StartSide: &"RIGHT" (or "LEFT")
|
||||
// Side: &"RIGHT" (or "LEFT")
|
||||
// StartLine: &120,
|
||||
// Line: &125,
|
||||
// Path: &path, // as before
|
||||
// Body: &body, // as before
|
||||
// StartSide: &"RIGHT" (or "LEFT")
|
||||
// Side: &"RIGHT" (or "LEFT")
|
||||
// StartLine: &120,
|
||||
// Line: &125,
|
||||
//
|
||||
// Suggested edits are made by commenting on the lines to replace, and including the
|
||||
// suggested edit in a block like this (it may be surrounded in non-suggestion markdown):
|
||||
//
|
||||
// ```suggestion
|
||||
// Use this instead.
|
||||
// It is waaaaaay better.
|
||||
// ```
|
||||
// ```suggestion
|
||||
// Use this instead.
|
||||
// It is waaaaaay better.
|
||||
// ```
|
||||
func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number)
|
||||
|
||||
|
|
@ -250,7 +252,7 @@ func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo stri
|
|||
|
||||
// UpdateReview updates the review summary on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#update-a-review-for-a-pull-request
|
||||
func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo string, number int, reviewID int64, body string) (*PullRequestReview, *Response, error) {
|
||||
opts := &struct {
|
||||
Body string `json:"body"`
|
||||
|
|
@ -273,7 +275,7 @@ func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo stri
|
|||
|
||||
// SubmitReview submits a specified review on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#submit-a-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#submit-a-review-for-a-pull-request
|
||||
func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID)
|
||||
|
||||
|
|
@ -293,7 +295,7 @@ func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo stri
|
|||
|
||||
// DismissReview dismisses a specified review on the specified pull request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#dismiss-a-review-for-a-pull-request
|
||||
// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request
|
||||
func (s *PullRequestsService) DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID)
|
||||
|
||||
17
vendor/github.com/google/go-github/v47/github/pulls_threads.go
generated
vendored
Normal file
17
vendor/github.com/google/go-github/v47/github/pulls_threads.go
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2022 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
|
||||
|
||||
// PullRequestThread represents a thread of comments on a pull request.
|
||||
type PullRequestThread struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Comments []*PullRequestComment `json:"comments,omitempty"`
|
||||
}
|
||||
|
||||
func (p PullRequestThread) String() string {
|
||||
return Stringify(p)
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// ReactionsService provides access to the reactions-related functions in the
|
||||
// GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions
|
||||
type ReactionsService service
|
||||
|
||||
// Reaction represents a GitHub reaction.
|
||||
|
|
@ -60,7 +60,7 @@ type ListCommentReactionOptions struct {
|
|||
|
||||
// ListCommentReactions lists the reactions for a commit comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-commit-comment
|
||||
func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListCommentReactionOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -90,7 +90,7 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo
|
|||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-commit-comment
|
||||
func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id)
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, rep
|
|||
|
||||
// DeleteCommentReaction deletes the reaction for a commit comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-commit-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction
|
||||
func (s *ReactionsService) DeleteCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions/%v", owner, repo, commentID, reactionID)
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ func (s *ReactionsService) DeleteCommentReaction(ctx context.Context, owner, rep
|
|||
|
||||
// DeleteCommentReactionByID deletes the reaction for a commit comment by repository ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-commit-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction
|
||||
func (s *ReactionsService) DeleteCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repositories/%v/comments/%v/reactions/%v", repoID, commentID, reactionID)
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ func (s *ReactionsService) DeleteCommentReactionByID(ctx context.Context, repoID
|
|||
|
||||
// ListIssueReactions lists the reactions for an issue.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-an-issue
|
||||
func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -162,7 +162,7 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s
|
|||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-an-issue
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-an-issue
|
||||
func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number)
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo
|
|||
|
||||
// DeleteIssueReaction deletes the reaction to an issue.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-reaction
|
||||
func (s *ReactionsService) DeleteIssueReaction(ctx context.Context, owner, repo string, issueNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/issues/%v/reactions/%v", owner, repo, issueNumber, reactionID)
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ func (s *ReactionsService) DeleteIssueReaction(ctx context.Context, owner, repo
|
|||
|
||||
// DeleteIssueReactionByID deletes the reaction to an issue by repository ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-reaction
|
||||
func (s *ReactionsService) DeleteIssueReactionByID(ctx context.Context, repoID, issueNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/issues/%v/reactions/%v", repoID, issueNumber, reactionID)
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ func (s *ReactionsService) DeleteIssueReactionByID(ctx context.Context, repoID,
|
|||
|
||||
// ListIssueCommentReactions lists the reactions for an issue comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-an-issue-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-an-issue-comment
|
||||
func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -234,7 +234,7 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner,
|
|||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-an-issue-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-an-issue-comment
|
||||
func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id)
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner
|
|||
|
||||
// DeleteIssueCommentReaction deletes the reaction to an issue comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction
|
||||
func (s *ReactionsService) DeleteIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions/%v", owner, repo, commentID, reactionID)
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ func (s *ReactionsService) DeleteIssueCommentReaction(ctx context.Context, owner
|
|||
|
||||
// DeleteIssueCommentReactionByID deletes the reaction to an issue comment by repository ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction
|
||||
func (s *ReactionsService) DeleteIssueCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/issues/comments/%v/reactions/%v", repoID, commentID, reactionID)
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ func (s *ReactionsService) DeleteIssueCommentReactionByID(ctx context.Context, r
|
|||
|
||||
// ListPullRequestCommentReactions lists the reactions for a pull request review comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-pull-request-review-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-pull-request-review-comment
|
||||
func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -306,7 +306,7 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context,
|
|||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-pull-request-review-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-pull-request-review-comment
|
||||
func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id)
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context,
|
|||
|
||||
// DeletePullRequestCommentReaction deletes the reaction to a pull request review comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-pull-request-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction
|
||||
func (s *ReactionsService) DeletePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions/%v", owner, repo, commentID, reactionID)
|
||||
|
||||
|
|
@ -339,7 +339,7 @@ func (s *ReactionsService) DeletePullRequestCommentReaction(ctx context.Context,
|
|||
|
||||
// DeletePullRequestCommentReactionByID deletes the reaction to a pull request review comment by repository ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-pull-request-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction
|
||||
func (s *ReactionsService) DeletePullRequestCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("repositories/%v/pulls/comments/%v/reactions/%v", repoID, commentID, reactionID)
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ func (s *ReactionsService) DeletePullRequestCommentReactionByID(ctx context.Cont
|
|||
|
||||
// ListTeamDiscussionReactions lists the reactions for a team discussion.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-team-discussion-legacy
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-team-discussion-legacy
|
||||
func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opts *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -375,7 +375,7 @@ func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, team
|
|||
// CreateTeamDiscussionReaction creates a reaction for a team discussion.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-team-discussion-legacy
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-legacy
|
||||
func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber)
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, tea
|
|||
|
||||
// DeleteTeamDiscussionReaction deletes the reaction to a team discussion.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-team-discussion-reaction
|
||||
func (s *ReactionsService) DeleteTeamDiscussionReaction(ctx context.Context, org, teamSlug string, discussionNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/reactions/%v", org, teamSlug, discussionNumber, reactionID)
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ func (s *ReactionsService) DeleteTeamDiscussionReaction(ctx context.Context, org
|
|||
|
||||
// DeleteTeamDiscussionReactionByOrgIDAndTeamID deletes the reaction to a team discussion by organization ID and team ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion
|
||||
func (s *ReactionsService) DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/reactions/%v", orgID, teamID, discussionNumber, reactionID)
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ func (s *ReactionsService) DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx cont
|
|||
|
||||
// ListTeamDiscussionCommentReactions lists the reactions for a team discussion comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-team-discussion-comment-legacy
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-team-discussion-comment-legacy
|
||||
func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opts *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -442,7 +442,7 @@ func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Contex
|
|||
// CreateTeamDiscussionCommentReaction creates a reaction for a team discussion comment.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-team-discussion-comment-legacy
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-comment-legacy
|
||||
func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber)
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Conte
|
|||
|
||||
// DeleteTeamDiscussionCommentReaction deletes the reaction to a team discussion comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-team-discussion-comment-reaction
|
||||
func (s *ReactionsService) DeleteTeamDiscussionCommentReaction(ctx context.Context, org, teamSlug string, discussionNumber, commentNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v/reactions/%v", org, teamSlug, discussionNumber, commentNumber, reactionID)
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ func (s *ReactionsService) DeleteTeamDiscussionCommentReaction(ctx context.Conte
|
|||
|
||||
// DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID deletes the reaction to a team discussion comment by organization ID and team ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-comment-reaction
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-comment
|
||||
func (s *ReactionsService) DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber, commentNumber int, reactionID int64) (*Response, error) {
|
||||
url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v/reactions/%v", orgID, teamID, discussionNumber, commentNumber, reactionID)
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ func (s *ReactionsService) deleteReaction(ctx context.Context, url string) (*Res
|
|||
// added the reaction type to this release.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-release
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-release
|
||||
func (s *ReactionsService) CreateReleaseReaction(ctx context.Context, owner, repo string, releaseID int64, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/releases/%v/reactions", owner, repo, releaseID)
|
||||
|
||||
|
|
@ -21,56 +21,62 @@ var ErrBranchNotProtected = errors.New("branch is not protected")
|
|||
// RepositoriesService handles communication with the repository related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/
|
||||
type RepositoriesService service
|
||||
|
||||
// Repository represents a GitHub repository.
|
||||
type Repository struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_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"`
|
||||
CodeOfConduct *CodeOfConduct `json:"code_of_conduct,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,omitempty"`
|
||||
ForksCount *int `json:"forks_count,omitempty"`
|
||||
NetworkCount *int `json:"network_count,omitempty"`
|
||||
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
|
||||
OpenIssues *int `json:"open_issues,omitempty"` // Deprecated: Replaced by OpenIssuesCount. For backward compatibility OpenIssues is still populated.
|
||||
StargazersCount *int `json:"stargazers_count,omitempty"`
|
||||
SubscribersCount *int `json:"subscribers_count,omitempty"`
|
||||
WatchersCount *int `json:"watchers_count,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility WatchersCount is still populated.
|
||||
Watchers *int `json:"watchers,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility Watchers is still populated.
|
||||
Size *int `json:"size,omitempty"`
|
||||
AutoInit *bool `json:"auto_init,omitempty"`
|
||||
Parent *Repository `json:"parent,omitempty"`
|
||||
Source *Repository `json:"source,omitempty"`
|
||||
TemplateRepository *Repository `json:"template_repository,omitempty"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
Permissions map[string]bool `json:"permissions,omitempty"`
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"`
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"`
|
||||
AllowForking *bool `json:"allow_forking,omitempty"`
|
||||
DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
|
||||
Topics []string `json:"topics,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
Disabled *bool `json:"disabled,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_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"`
|
||||
CodeOfConduct *CodeOfConduct `json:"code_of_conduct,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,omitempty"`
|
||||
ForksCount *int `json:"forks_count,omitempty"`
|
||||
NetworkCount *int `json:"network_count,omitempty"`
|
||||
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
|
||||
OpenIssues *int `json:"open_issues,omitempty"` // Deprecated: Replaced by OpenIssuesCount. For backward compatibility OpenIssues is still populated.
|
||||
StargazersCount *int `json:"stargazers_count,omitempty"`
|
||||
SubscribersCount *int `json:"subscribers_count,omitempty"`
|
||||
WatchersCount *int `json:"watchers_count,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility WatchersCount is still populated.
|
||||
Watchers *int `json:"watchers,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility Watchers is still populated.
|
||||
Size *int `json:"size,omitempty"`
|
||||
AutoInit *bool `json:"auto_init,omitempty"`
|
||||
Parent *Repository `json:"parent,omitempty"`
|
||||
Source *Repository `json:"source,omitempty"`
|
||||
TemplateRepository *Repository `json:"template_repository,omitempty"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
Permissions map[string]bool `json:"permissions,omitempty"`
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"`
|
||||
AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"`
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"`
|
||||
AllowForking *bool `json:"allow_forking,omitempty"`
|
||||
DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
|
||||
UseSquashPRTitleAsDefault *bool `json:"use_squash_pr_title_as_default,omitempty"`
|
||||
SquashMergeCommitTitle *string `json:"squash_merge_commit_title,omitempty"` // Can be one of: "PR_TITLE", "COMMIT_OR_PR_TITLE"
|
||||
SquashMergeCommitMessage *string `json:"squash_merge_commit_message,omitempty"` // Can be one of: "PR_BODY", "COMMIT_MESSAGES", "BLANK"
|
||||
MergeCommitTitle *string `json:"merge_commit_title,omitempty"` // Can be one of: "PR_TITLE", "MERGE_MESSAGE"
|
||||
MergeCommitMessage *string `json:"merge_commit_message,omitempty"` // Can be one of: "PR_BODY", "PR_TITLE", "BLANK"
|
||||
Topics []string `json:"topics,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
Disabled *bool `json:"disabled,omitempty"`
|
||||
|
||||
// Only provided when using RepositoriesService.Get while in preview
|
||||
License *License `json:"license,omitempty"`
|
||||
|
|
@ -132,13 +138,17 @@ type Repository struct {
|
|||
TeamsURL *string `json:"teams_url,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
|
||||
// See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata
|
||||
TextMatches []*TextMatch `json:"text_matches,omitempty"`
|
||||
|
||||
// Visibility is only used for Create and Edit endpoints. The visibility field
|
||||
// overrides the field parameter when both are used.
|
||||
// Can be one of public, private or internal.
|
||||
Visibility *string `json:"visibility,omitempty"`
|
||||
|
||||
// RoleName is only returned by the API 'check team permissions for a repository'.
|
||||
// See: teams.go (IsTeamRepoByID) https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository
|
||||
RoleName *string `json:"role_name,omitempty"`
|
||||
}
|
||||
|
||||
func (r Repository) String() string {
|
||||
|
|
@ -228,8 +238,8 @@ func (s SecretScanning) String() string {
|
|||
// List the repositories for a user. Passing the empty string will list
|
||||
// repositories for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repositories-for-a-user
|
||||
func (s *RepositoriesService) List(ctx context.Context, user string, opts *RepositoryListOptions) ([]*Repository, *Response, error) {
|
||||
var u string
|
||||
if user != "" {
|
||||
|
|
@ -280,7 +290,7 @@ type RepositoryListByOrgOptions struct {
|
|||
|
||||
// ListByOrg lists the repositories for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-organization-repositories
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-organization-repositories
|
||||
func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opts *RepositoryListByOrgOptions) ([]*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/repos", org)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -315,7 +325,7 @@ type RepositoryListAllOptions struct {
|
|||
|
||||
// ListAll lists all GitHub repositories in the order that they were created.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-public-repositories
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-public-repositories
|
||||
func (s *RepositoriesService) ListAll(ctx context.Context, opts *RepositoryListAllOptions) ([]*Repository, *Response, error) {
|
||||
u, err := addOptions("repositories", opts)
|
||||
if err != nil {
|
||||
|
|
@ -357,15 +367,21 @@ type createRepoRequest struct {
|
|||
// Creating an organization repository. Required for non-owners.
|
||||
TeamID *int64 `json:"team_id,omitempty"`
|
||||
|
||||
AutoInit *bool `json:"auto_init,omitempty"`
|
||||
GitignoreTemplate *string `json:"gitignore_template,omitempty"`
|
||||
LicenseTemplate *string `json:"license_template,omitempty"`
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"`
|
||||
AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"`
|
||||
AllowForking *bool `json:"allow_forking,omitempty"`
|
||||
DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
|
||||
AutoInit *bool `json:"auto_init,omitempty"`
|
||||
GitignoreTemplate *string `json:"gitignore_template,omitempty"`
|
||||
LicenseTemplate *string `json:"license_template,omitempty"`
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"`
|
||||
AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"`
|
||||
AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"`
|
||||
AllowForking *bool `json:"allow_forking,omitempty"`
|
||||
DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
|
||||
UseSquashPRTitleAsDefault *bool `json:"use_squash_pr_title_as_default,omitempty"`
|
||||
SquashMergeCommitTitle *string `json:"squash_merge_commit_title,omitempty"`
|
||||
SquashMergeCommitMessage *string `json:"squash_merge_commit_message,omitempty"`
|
||||
MergeCommitTitle *string `json:"merge_commit_title,omitempty"`
|
||||
MergeCommitMessage *string `json:"merge_commit_message,omitempty"`
|
||||
}
|
||||
|
||||
// Create a new repository. If an organization is specified, the new
|
||||
|
|
@ -380,8 +396,8 @@ type createRepoRequest struct {
|
|||
// changes propagate throughout its servers. You may set up a loop with
|
||||
// exponential back-off to verify repository's creation.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-an-organization-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-for-the-authenticated-user
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-an-organization-repository
|
||||
func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error) {
|
||||
var u string
|
||||
if org != "" {
|
||||
|
|
@ -391,25 +407,31 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo
|
|||
}
|
||||
|
||||
repoReq := &createRepoRequest{
|
||||
Name: repo.Name,
|
||||
Description: repo.Description,
|
||||
Homepage: repo.Homepage,
|
||||
Private: repo.Private,
|
||||
Visibility: repo.Visibility,
|
||||
HasIssues: repo.HasIssues,
|
||||
HasProjects: repo.HasProjects,
|
||||
HasWiki: repo.HasWiki,
|
||||
IsTemplate: repo.IsTemplate,
|
||||
TeamID: repo.TeamID,
|
||||
AutoInit: repo.AutoInit,
|
||||
GitignoreTemplate: repo.GitignoreTemplate,
|
||||
LicenseTemplate: repo.LicenseTemplate,
|
||||
AllowSquashMerge: repo.AllowSquashMerge,
|
||||
AllowMergeCommit: repo.AllowMergeCommit,
|
||||
AllowRebaseMerge: repo.AllowRebaseMerge,
|
||||
AllowAutoMerge: repo.AllowAutoMerge,
|
||||
AllowForking: repo.AllowForking,
|
||||
DeleteBranchOnMerge: repo.DeleteBranchOnMerge,
|
||||
Name: repo.Name,
|
||||
Description: repo.Description,
|
||||
Homepage: repo.Homepage,
|
||||
Private: repo.Private,
|
||||
Visibility: repo.Visibility,
|
||||
HasIssues: repo.HasIssues,
|
||||
HasProjects: repo.HasProjects,
|
||||
HasWiki: repo.HasWiki,
|
||||
IsTemplate: repo.IsTemplate,
|
||||
TeamID: repo.TeamID,
|
||||
AutoInit: repo.AutoInit,
|
||||
GitignoreTemplate: repo.GitignoreTemplate,
|
||||
LicenseTemplate: repo.LicenseTemplate,
|
||||
AllowSquashMerge: repo.AllowSquashMerge,
|
||||
AllowMergeCommit: repo.AllowMergeCommit,
|
||||
AllowRebaseMerge: repo.AllowRebaseMerge,
|
||||
AllowUpdateBranch: repo.AllowUpdateBranch,
|
||||
AllowAutoMerge: repo.AllowAutoMerge,
|
||||
AllowForking: repo.AllowForking,
|
||||
DeleteBranchOnMerge: repo.DeleteBranchOnMerge,
|
||||
UseSquashPRTitleAsDefault: repo.UseSquashPRTitleAsDefault,
|
||||
SquashMergeCommitTitle: repo.SquashMergeCommitTitle,
|
||||
SquashMergeCommitMessage: repo.SquashMergeCommitMessage,
|
||||
MergeCommitTitle: repo.MergeCommitTitle,
|
||||
MergeCommitMessage: repo.MergeCommitMessage,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, repoReq)
|
||||
|
|
@ -441,7 +463,7 @@ type TemplateRepoRequest struct {
|
|||
|
||||
// CreateFromTemplate generates a repository from a template.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-using-a-template
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-using-a-template
|
||||
func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, templateRepoReq *TemplateRepoRequest) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/generate", templateOwner, templateRepo)
|
||||
|
||||
|
|
@ -462,7 +484,7 @@ func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOw
|
|||
|
||||
// Get fetches a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository
|
||||
func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -471,7 +493,7 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep
|
|||
}
|
||||
|
||||
// TODO: remove custom Accept header when the license support fully launches
|
||||
// https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-a-repositorys-license
|
||||
// https://docs.github.com/en/rest/licenses/#get-a-repositorys-license
|
||||
acceptHeaders := []string{
|
||||
mediaTypeCodesOfConductPreview,
|
||||
mediaTypeTopicsPreview,
|
||||
|
|
@ -490,10 +512,12 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep
|
|||
}
|
||||
|
||||
// GetCodeOfConduct gets the contents of a repository's code of conduct.
|
||||
// Note that https://docs.github.com/en/rest/codes-of-conduct#about-the-codes-of-conduct-api
|
||||
// says to use the GET /repos/{owner}/{repo} endpoint.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/codes-of-conduct/#get-the-code-of-conduct-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository
|
||||
func (s *RepositoriesService) GetCodeOfConduct(ctx context.Context, owner, repo string) (*CodeOfConduct, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/community/code_of_conduct", owner, repo)
|
||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
@ -502,13 +526,13 @@ func (s *RepositoriesService) GetCodeOfConduct(ctx context.Context, owner, repo
|
|||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
|
||||
|
||||
coc := new(CodeOfConduct)
|
||||
resp, err := s.client.Do(ctx, req, coc)
|
||||
r := new(Repository)
|
||||
resp, err := s.client.Do(ctx, req, r)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return coc, resp, nil
|
||||
return r.GetCodeOfConduct(), resp, nil
|
||||
}
|
||||
|
||||
// GetByID fetches a repository.
|
||||
|
|
@ -532,7 +556,7 @@ func (s *RepositoriesService) GetByID(ctx context.Context, id int64) (*Repositor
|
|||
|
||||
// Edit updates a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository
|
||||
func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repository *Repository) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
||||
req, err := s.client.NewRequest("PATCH", u, repository)
|
||||
|
|
@ -553,7 +577,7 @@ func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repo
|
|||
|
||||
// Delete a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#delete-a-repository
|
||||
func (s *RepositoriesService) Delete(ctx context.Context, owner, repo string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v", owner, repo)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -600,7 +624,7 @@ type ListContributorsOptions struct {
|
|||
|
||||
// GetVulnerabilityAlerts checks if vulnerability alerts are enabled for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#check-if-vulnerability-alerts-are-enabled-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository
|
||||
func (s *RepositoriesService) GetVulnerabilityAlerts(ctx context.Context, owner, repository string) (bool, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository)
|
||||
|
||||
|
|
@ -614,13 +638,12 @@ func (s *RepositoriesService) GetVulnerabilityAlerts(ctx context.Context, owner,
|
|||
|
||||
resp, err := s.client.Do(ctx, req, nil)
|
||||
vulnerabilityAlertsEnabled, err := parseBoolResponse(err)
|
||||
|
||||
return vulnerabilityAlertsEnabled, resp, err
|
||||
}
|
||||
|
||||
// EnableVulnerabilityAlerts enables vulnerability alerts and the dependency graph for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-vulnerability-alerts
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-vulnerability-alerts
|
||||
func (s *RepositoriesService) EnableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository)
|
||||
|
||||
|
|
@ -637,7 +660,7 @@ func (s *RepositoriesService) EnableVulnerabilityAlerts(ctx context.Context, own
|
|||
|
||||
// DisableVulnerabilityAlerts disables vulnerability alerts and the dependency graph for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-vulnerability-alerts
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#disable-vulnerability-alerts
|
||||
func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository)
|
||||
|
||||
|
|
@ -654,7 +677,7 @@ func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, ow
|
|||
|
||||
// EnableAutomatedSecurityFixes enables the automated security fixes for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-automated-security-fixes
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-automated-security-fixes
|
||||
func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)
|
||||
|
||||
|
|
@ -671,7 +694,7 @@ func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context,
|
|||
|
||||
// DisableAutomatedSecurityFixes disables vulnerability alerts and the dependency graph for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-automated-security-fixes
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#disable-automated-security-fixes
|
||||
func (s *RepositoriesService) DisableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)
|
||||
|
||||
|
|
@ -688,7 +711,7 @@ func (s *RepositoriesService) DisableAutomatedSecurityFixes(ctx context.Context,
|
|||
|
||||
// ListContributors lists contributors for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-contributors
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-contributors
|
||||
func (s *RepositoriesService) ListContributors(ctx context.Context, owner string, repository string, opts *ListContributorsOptions) ([]*Contributor, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/contributors", owner, repository)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -714,12 +737,12 @@ func (s *RepositoriesService) ListContributors(ctx context.Context, owner string
|
|||
// specifies the languages and the number of bytes of code written in that
|
||||
// language. For example:
|
||||
//
|
||||
// {
|
||||
// "C": 78769,
|
||||
// "Python": 7769
|
||||
// }
|
||||
// {
|
||||
// "C": 78769,
|
||||
// "Python": 7769
|
||||
// }
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-languages
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-languages
|
||||
func (s *RepositoriesService) ListLanguages(ctx context.Context, 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)
|
||||
|
|
@ -738,7 +761,7 @@ func (s *RepositoriesService) ListLanguages(ctx context.Context, owner string, r
|
|||
|
||||
// ListTeams lists the teams for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-teams
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-teams
|
||||
func (s *RepositoriesService) ListTeams(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Team, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/teams", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -770,7 +793,7 @@ type RepositoryTag struct {
|
|||
|
||||
// ListTags lists tags for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-tags
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-tags
|
||||
func (s *RepositoriesService) ListTags(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*RepositoryTag, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/tags", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -882,7 +905,7 @@ type RequiredStatusChecks struct {
|
|||
Contexts []string `json:"contexts,omitempty"`
|
||||
// The list of status checks to require in order to merge into this
|
||||
// branch.
|
||||
Checks []*RequiredStatusCheck `json:"checks,omitempty"`
|
||||
Checks []*RequiredStatusCheck `json:"checks"`
|
||||
}
|
||||
|
||||
// RequiredStatusChecksRequest represents a request to edit a protected branch's status checks.
|
||||
|
|
@ -908,6 +931,8 @@ type RequiredStatusCheck struct {
|
|||
|
||||
// PullRequestReviewsEnforcement represents the pull request reviews enforcement of a protected branch.
|
||||
type PullRequestReviewsEnforcement struct {
|
||||
// Allow specific users, teams, or apps to bypass pull request requirements.
|
||||
BypassPullRequestAllowances *BypassPullRequestAllowances `json:"bypass_pull_request_allowances,omitempty"`
|
||||
// Specifies which users and teams can dismiss pull request reviews.
|
||||
DismissalRestrictions *DismissalRestrictions `json:"dismissal_restrictions,omitempty"`
|
||||
// Specifies if approved reviews are dismissed automatically, when a new commit is pushed.
|
||||
|
|
@ -923,6 +948,8 @@ type PullRequestReviewsEnforcement struct {
|
|||
// enforcement of a protected branch. It is separate from PullRequestReviewsEnforcement above
|
||||
// because the request structure is different from the response structure.
|
||||
type PullRequestReviewsEnforcementRequest struct {
|
||||
// Allow specific users, teams, or apps to bypass pull request requirements.
|
||||
BypassPullRequestAllowancesRequest *BypassPullRequestAllowancesRequest `json:"bypass_pull_request_allowances,omitempty"`
|
||||
// Specifies which users and teams should be allowed to dismiss pull request reviews.
|
||||
// User and team dismissal restrictions are only available for
|
||||
// organization-owned repositories. Must be nil for personal repositories.
|
||||
|
|
@ -940,6 +967,8 @@ type PullRequestReviewsEnforcementRequest struct {
|
|||
// enforcement of a protected branch. It is separate from PullRequestReviewsEnforcementRequest above
|
||||
// because the patch request does not require all fields to be initialized.
|
||||
type PullRequestReviewsEnforcementUpdate struct {
|
||||
// Allow specific users, teams, or apps to bypass pull request requirements.
|
||||
BypassPullRequestAllowancesRequest *BypassPullRequestAllowancesRequest `json:"bypass_pull_request_allowances,omitempty"`
|
||||
// Specifies which users and teams can dismiss pull request reviews. Can be omitted.
|
||||
DismissalRestrictionsRequest *DismissalRestrictionsRequest `json:"dismissal_restrictions,omitempty"`
|
||||
// Specifies if approved reviews can be dismissed automatically, when a new commit is pushed. Can be omitted.
|
||||
|
|
@ -1001,6 +1030,29 @@ type BranchRestrictionsRequest struct {
|
|||
Apps []string `json:"apps,omitempty"`
|
||||
}
|
||||
|
||||
// BypassPullRequestAllowances represents the people, teams, or apps who are allowed to bypass required pull requests.
|
||||
type BypassPullRequestAllowances struct {
|
||||
// The list of users allowed to bypass pull request requirements.
|
||||
Users []*User `json:"users"`
|
||||
// The list of teams allowed to bypass pull request requirements.
|
||||
Teams []*Team `json:"teams"`
|
||||
// The list of apps allowed to bypass pull request requirements.
|
||||
Apps []*App `json:"apps"`
|
||||
}
|
||||
|
||||
// BypassPullRequestAllowancesRequest represents the people, teams, or apps who are
|
||||
// allowed to bypass required pull requests.
|
||||
// It is separate from BypassPullRequestAllowances above because the request structure is
|
||||
// different from the response structure.
|
||||
type BypassPullRequestAllowancesRequest struct {
|
||||
// The list of user logins allowed to bypass pull request requirements.
|
||||
Users []string `json:"users"`
|
||||
// The list of team slugs allowed to bypass pull request requirements.
|
||||
Teams []string `json:"teams"`
|
||||
// The list of app slugs allowed to bypass pull request requirements.
|
||||
Apps []string `json:"apps"`
|
||||
}
|
||||
|
||||
// DismissalRestrictions specifies which users and teams can dismiss pull request reviews.
|
||||
type DismissalRestrictions struct {
|
||||
// The list of users who can dimiss pull request reviews.
|
||||
|
|
@ -1030,7 +1082,7 @@ type SignaturesProtectedBranch struct {
|
|||
|
||||
// ListBranches lists branches for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-branches
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branches#list-branches
|
||||
func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, repo string, opts *BranchListOptions) ([]*Branch, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -1054,11 +1106,11 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re
|
|||
|
||||
// GetBranch gets the specified branch for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-branch
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branches#get-a-branch
|
||||
func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch string, followRedirects bool) (*Branch, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, branch)
|
||||
|
||||
resp, err := s.getBranchFromURL(ctx, u, followRedirects)
|
||||
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -1073,33 +1125,6 @@ func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch
|
|||
return b, newResponse(resp), err
|
||||
}
|
||||
|
||||
func (s *RepositoriesService) getBranchFromURL(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
|
||||
}
|
||||
|
||||
// If redirect response is returned, follow it
|
||||
if followRedirects && resp.StatusCode == http.StatusMovedPermanently {
|
||||
resp.Body.Close()
|
||||
u = resp.Header.Get("Location")
|
||||
resp, err = s.getBranchFromURL(ctx, u, false)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// renameBranchRequest represents a request to rename a branch.
|
||||
type renameBranchRequest struct {
|
||||
NewName string `json:"new_name"`
|
||||
|
|
@ -1110,7 +1135,7 @@ type renameBranchRequest struct {
|
|||
// To rename a non-default branch: Users must have push access. GitHub Apps must have the `contents:write` repository permission.
|
||||
// To rename the default branch: Users must have admin or owner permissions. GitHub Apps must have the `administration:write` repository permission.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#rename-a-branch
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branches#rename-a-branch
|
||||
func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, branch, newName string) (*Branch, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/rename", owner, repo, branch)
|
||||
r := &renameBranchRequest{NewName: newName}
|
||||
|
|
@ -1130,7 +1155,7 @@ func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, bra
|
|||
|
||||
// GetBranchProtection gets the protection of a given branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-branch-protection
|
||||
func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, repo, branch string) (*Protection, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1155,7 +1180,7 @@ func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, re
|
|||
|
||||
// GetRequiredStatusChecks gets the required status checks for a given protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-status-checks-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-status-checks-protection
|
||||
func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*RequiredStatusChecks, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1177,7 +1202,7 @@ func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner
|
|||
|
||||
// ListRequiredStatusChecksContexts lists the required status checks contexts for a given protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-status-check-contexts
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-all-status-check-contexts
|
||||
func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Context, owner, repo, branch string) (contexts []string, resp *Response, err error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks/contexts", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1198,7 +1223,7 @@ func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Conte
|
|||
|
||||
// UpdateBranchProtection updates the protection of a given branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
|
||||
func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("PUT", u, preq)
|
||||
|
|
@ -1220,7 +1245,7 @@ func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner,
|
|||
|
||||
// RemoveBranchProtection removes the protection of a given branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-branch-protection
|
||||
func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, repo, branch string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -1233,7 +1258,7 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner,
|
|||
|
||||
// GetSignaturesProtectedBranch gets required signatures of protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-commit-signature-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-commit-signature-protection
|
||||
func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1256,7 +1281,7 @@ func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context,
|
|||
// RequireSignaturesOnProtectedBranch makes signed commits required on a protected branch.
|
||||
// It requires admin access and branch protection to be enabled.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-commit-signature-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#create-commit-signature-protection
|
||||
func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -1273,12 +1298,12 @@ func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Con
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return r, resp, err
|
||||
return r, resp, nil
|
||||
}
|
||||
|
||||
// OptionalSignaturesOnProtectedBranch removes required signed commits on a given branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-commit-signature-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-commit-signature-protection
|
||||
func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -1294,7 +1319,7 @@ func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Co
|
|||
|
||||
// UpdateRequiredStatusChecks updates the required status checks for a given protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-status-check-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-status-check-protection
|
||||
func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, owner, repo, branch string, sreq *RequiredStatusChecksRequest) (*RequiredStatusChecks, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("PATCH", u, sreq)
|
||||
|
|
@ -1313,7 +1338,7 @@ func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, ow
|
|||
|
||||
// RemoveRequiredStatusChecks removes the required status checks for a given protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#remove-status-check-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-status-check-protection
|
||||
func (s *RepositoriesService) RemoveRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -1326,7 +1351,7 @@ func (s *RepositoriesService) RemoveRequiredStatusChecks(ctx context.Context, ow
|
|||
|
||||
// License gets the contents of a repository's license if one is detected.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-the-license-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/licenses#get-the-license-for-a-repository
|
||||
func (s *RepositoriesService) License(ctx context.Context, owner, repo string) (*RepositoryLicense, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/license", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1345,7 +1370,7 @@ func (s *RepositoriesService) License(ctx context.Context, owner, repo string) (
|
|||
|
||||
// GetPullRequestReviewEnforcement gets pull request review enforcement of a protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-pull-request-review-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-pull-request-review-protection
|
||||
func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1368,7 +1393,7 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex
|
|||
// UpdatePullRequestReviewEnforcement patches pull request review enforcement of a protected branch.
|
||||
// It requires admin access and branch protection to be enabled.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection
|
||||
func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string, patch *PullRequestReviewsEnforcementUpdate) (*PullRequestReviewsEnforcement, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("PATCH", u, patch)
|
||||
|
|
@ -1385,13 +1410,13 @@ func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Con
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return r, resp, err
|
||||
return r, resp, nil
|
||||
}
|
||||
|
||||
// DisableDismissalRestrictions disables dismissal restrictions of a protected branch.
|
||||
// It requires admin access and branch protection to be enabled.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection
|
||||
func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
|
||||
|
||||
|
|
@ -1413,12 +1438,12 @@ func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context,
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return r, resp, err
|
||||
return r, resp, nil
|
||||
}
|
||||
|
||||
// RemovePullRequestReviewEnforcement removes pull request enforcement of a protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-pull-request-review-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-pull-request-review-protection
|
||||
func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -1431,7 +1456,7 @@ func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Con
|
|||
|
||||
// GetAdminEnforcement gets admin enforcement information of a protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-admin-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-admin-branch-protection
|
||||
func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1451,7 +1476,7 @@ func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, re
|
|||
// AddAdminEnforcement adds admin enforcement to a protected branch.
|
||||
// It requires admin access and branch protection to be enabled.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-admin-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-admin-branch-protection
|
||||
func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -1465,12 +1490,12 @@ func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, re
|
|||
return nil, resp, err
|
||||
}
|
||||
|
||||
return r, resp, err
|
||||
return r, resp, nil
|
||||
}
|
||||
|
||||
// RemoveAdminEnforcement removes admin enforcement from a protected branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-admin-branch-protection
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-admin-branch-protection
|
||||
func (s *RepositoriesService) RemoveAdminEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -1488,7 +1513,7 @@ type repositoryTopics struct {
|
|||
|
||||
// ListAllTopics lists topics for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-repository-topics
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#get-all-repository-topics
|
||||
func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo string) ([]string, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/topics", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1508,9 +1533,9 @@ func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo str
|
|||
return topics.Names, resp, nil
|
||||
}
|
||||
|
||||
// ReplaceAllTopics replaces topics for a repository.
|
||||
// ReplaceAllTopics replaces all repository topics.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#replace-all-repository-topics
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#replace-all-repository-topics
|
||||
func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/topics", owner, repo)
|
||||
t := &repositoryTopics{
|
||||
|
|
@ -1539,7 +1564,7 @@ func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo
|
|||
// ListApps lists the GitHub apps that have push access to a given protected branch.
|
||||
// It requires the GitHub apps to have `write` access to the `content` permission.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-apps-with-access-to-the-protected-branch
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch
|
||||
func (s *RepositoriesService) ListApps(ctx context.Context, owner, repo, branch string) ([]*App, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -1562,7 +1587,7 @@ func (s *RepositoriesService) ListApps(ctx context.Context, owner, repo, branch
|
|||
//
|
||||
// Note: The list of users, apps, and teams in total is limited to 100 items.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-app-access-restrictions
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-app-access-restrictions
|
||||
func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("PUT", u, slug)
|
||||
|
|
@ -1584,7 +1609,7 @@ func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner,
|
|||
//
|
||||
// Note: The list of users, apps, and teams in total is limited to 100 items.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#add-app-access-restrictions
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#add-app-access-restrictions
|
||||
func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("POST", u, slug)
|
||||
|
|
@ -1606,7 +1631,7 @@ func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, rep
|
|||
//
|
||||
// Note: The list of users, apps, and teams in total is limited to 100 items.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#remove-app-access-restrictions
|
||||
// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-app-access-restrictions
|
||||
func (s *RepositoriesService) RemoveAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
|
||||
req, err := s.client.NewRequest("DELETE", u, slug)
|
||||
|
|
@ -1637,7 +1662,7 @@ type TransferRequest struct {
|
|||
// A follow up request, after a delay of a second or so, should result
|
||||
// in a successful request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#transfer-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#transfer-a-repository
|
||||
func (s *RepositoriesService) Transfer(ctx context.Context, owner, repo string, transfer TransferRequest) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/transfer", owner, repo)
|
||||
|
||||
|
|
@ -1666,7 +1691,7 @@ type DispatchRequestOptions struct {
|
|||
|
||||
// Dispatch triggers a repository_dispatch event in a GitHub Actions workflow.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-dispatch-event
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event
|
||||
func (s *RepositoriesService) Dispatch(ctx context.Context, owner, repo string, opts DispatchRequestOptions) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/dispatches", owner, repo)
|
||||
|
||||
49
vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go
generated
vendored
Normal file
49
vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2022 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"
|
||||
)
|
||||
|
||||
// GetActionsAllowed gets the allowed actions and reusable workflows for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-a-repository
|
||||
func (s *RepositoriesService) GetActionsAllowed(ctx context.Context, org, repo string) (*ActionsAllowed, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
actionsAllowed := new(ActionsAllowed)
|
||||
resp, err := s.client.Do(ctx, req, actionsAllowed)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return actionsAllowed, resp, nil
|
||||
}
|
||||
|
||||
// EditActionsAllowed sets the allowed actions and reusable workflows for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-a-repository
|
||||
func (s *RepositoriesService) EditActionsAllowed(ctx context.Context, org, repo string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo)
|
||||
req, err := s.client.NewRequest("PUT", u, actionsAllowed)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
p := new(ActionsAllowed)
|
||||
resp, err := s.client.Do(ctx, req, p)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return p, resp, nil
|
||||
}
|
||||
62
vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go
generated
vendored
Normal file
62
vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright 2022 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"
|
||||
)
|
||||
|
||||
// ActionsPermissionsRepository represents a policy for repositories and allowed actions in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions
|
||||
type ActionsPermissionsRepository struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
AllowedActions *string `json:"allowed_actions,omitempty"`
|
||||
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
|
||||
}
|
||||
|
||||
func (a ActionsPermissionsRepository) String() string {
|
||||
return Stringify(a)
|
||||
}
|
||||
|
||||
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-github-actions-permissions-for-a-repository
|
||||
func (s *RepositoriesService) GetActionsPermissions(ctx context.Context, owner, repo string) (*ActionsPermissionsRepository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/permissions", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
permissions := new(ActionsPermissionsRepository)
|
||||
resp, err := s.client.Do(ctx, req, permissions)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return permissions, resp, nil
|
||||
}
|
||||
|
||||
// EditActionsPermissions sets the permissions policy for repositories and allowed actions in a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-github-actions-permissions-for-a-repository
|
||||
func (s *RepositoriesService) EditActionsPermissions(ctx context.Context, owner, repo string, actionsPermissionsRepository ActionsPermissionsRepository) (*ActionsPermissionsRepository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/permissions", owner, repo)
|
||||
req, err := s.client.NewRequest("PUT", u, actionsPermissionsRepository)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
permissions := new(ActionsPermissionsRepository)
|
||||
resp, err := s.client.Do(ctx, req, permissions)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return permissions, resp, nil
|
||||
}
|
||||
|
|
@ -12,21 +12,23 @@ import (
|
|||
|
||||
// AutolinkOptions specifies parameters for RepositoriesService.AddAutolink method.
|
||||
type AutolinkOptions struct {
|
||||
KeyPrefix *string `json:"key_prefix,omitempty"`
|
||||
URLTemplate *string `json:"url_template,omitempty"`
|
||||
KeyPrefix *string `json:"key_prefix,omitempty"`
|
||||
URLTemplate *string `json:"url_template,omitempty"`
|
||||
IsAlphanumeric *bool `json:"is_alphanumeric,omitempty"`
|
||||
}
|
||||
|
||||
// Autolink represents autolinks to external resources like JIRA issues and Zendesk tickets.
|
||||
type Autolink struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
KeyPrefix *string `json:"key_prefix,omitempty"`
|
||||
URLTemplate *string `json:"url_template,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
KeyPrefix *string `json:"key_prefix,omitempty"`
|
||||
URLTemplate *string `json:"url_template,omitempty"`
|
||||
IsAlphanumeric *bool `json:"is_alphanumeric,omitempty"`
|
||||
}
|
||||
|
||||
// ListAutolinks returns a list of autolinks configured for the given repository.
|
||||
// Information about autolinks are only available to repository administrators.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#list-all-autolinks-of-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository
|
||||
func (s *RepositoriesService) ListAutolinks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Autolink, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/autolinks", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -51,7 +53,7 @@ func (s *RepositoriesService) ListAutolinks(ctx context.Context, owner, repo str
|
|||
// AddAutolink creates an autolink reference for a repository.
|
||||
// Users with admin access to the repository can create an autolink.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#create-an-autolink-reference-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#create-an-autolink-reference-for-a-repository
|
||||
func (s *RepositoriesService) AddAutolink(ctx context.Context, owner, repo string, opts *AutolinkOptions) (*Autolink, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/autolinks", owner, repo)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
|
|
@ -70,7 +72,7 @@ func (s *RepositoriesService) AddAutolink(ctx context.Context, owner, repo strin
|
|||
// GetAutolink returns a single autolink reference by ID that was configured for the given repository.
|
||||
// Information about autolinks are only available to repository administrators.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-an-autolink-reference-of-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#get-an-autolink-reference-of-a-repository
|
||||
func (s *RepositoriesService) GetAutolink(ctx context.Context, owner, repo string, id int64) (*Autolink, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/autolinks/%v", owner, repo, id)
|
||||
|
||||
|
|
@ -91,7 +93,7 @@ func (s *RepositoriesService) GetAutolink(ctx context.Context, owner, repo strin
|
|||
// DeleteAutolink deletes a single autolink reference by ID that was configured for the given repository.
|
||||
// Information about autolinks are only available to repository administrators.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#delete-an-autolink-reference-from-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository
|
||||
func (s *RepositoriesService) DeleteAutolink(ctx context.Context, owner, repo string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/autolinks/%v", owner, repo, id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
46
vendor/github.com/google/go-github/v47/github/repos_codeowners.go
generated
vendored
Normal file
46
vendor/github.com/google/go-github/v47/github/repos_codeowners.go
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2022 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"
|
||||
)
|
||||
|
||||
// CodeownersErrors represents a list of syntax errors detected in the CODEOWNERS file.
|
||||
type CodeownersErrors struct {
|
||||
Errors []*CodeownersError `json:"errors"`
|
||||
}
|
||||
|
||||
// CodeownersError represents a syntax error detected in the CODEOWNERS file.
|
||||
type CodeownersError struct {
|
||||
Line int `json:"line"`
|
||||
Column int `json:"column"`
|
||||
Kind string `json:"kind"`
|
||||
Source string `json:"source"`
|
||||
Suggestion *string `json:"suggestion,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// GetCodeownersErrors lists any syntax errors that are detected in the CODEOWNERS file.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-codeowners-errors
|
||||
func (s *RepositoriesService) GetCodeownersErrors(ctx context.Context, owner, repo string) (*CodeownersErrors, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/codeowners/errors", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
codeownersErrors := &CodeownersErrors{}
|
||||
resp, err := s.client.Do(ctx, req, codeownersErrors)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return codeownersErrors, resp, nil
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ type ListCollaboratorsOptions struct {
|
|||
}
|
||||
|
||||
// CollaboratorInvitation represents an invitation created when adding a collaborator.
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/collaborators/#response-when-a-new-invitation-is-created
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/collaborators/#response-when-a-new-invitation-is-created
|
||||
type CollaboratorInvitation struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
|
|
@ -41,7 +41,7 @@ type CollaboratorInvitation struct {
|
|||
|
||||
// ListCollaborators lists the GitHub users that have access to the repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-collaborators
|
||||
// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#list-repository-collaborators
|
||||
func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo string, opts *ListCollaboratorsOptions) ([]*User, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -68,7 +68,7 @@ func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo
|
|||
// Note: This will return false if the user is not a collaborator OR the user
|
||||
// is not a GitHub user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#check-if-a-user-is-a-repository-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#check-if-a-user-is-a-repository-collaborator
|
||||
func (s *RepositoriesService) IsCollaborator(ctx context.Context, 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)
|
||||
|
|
@ -91,7 +91,8 @@ type RepositoryPermissionLevel struct {
|
|||
}
|
||||
|
||||
// GetPermissionLevel retrieves the specific permission level a collaborator has for a given repository.
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-repository-permissions-for-a-user
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user
|
||||
func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, repo, user string) (*RepositoryPermissionLevel, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/collaborators/%v/permission", owner, repo, user)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -104,6 +105,7 @@ func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, rep
|
|||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return rpl, resp, nil
|
||||
}
|
||||
|
||||
|
|
@ -125,30 +127,33 @@ type RepositoryAddCollaboratorOptions struct {
|
|||
// AddCollaborator sends an invitation to the specified GitHub user
|
||||
// to become a collaborator to the given repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#add-a-repository-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#add-a-repository-collaborator
|
||||
func (s *RepositoriesService) AddCollaborator(ctx context.Context, owner, repo, user string, opts *RepositoryAddCollaboratorOptions) (*CollaboratorInvitation, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user)
|
||||
req, err := s.client.NewRequest("PUT", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
acr := new(CollaboratorInvitation)
|
||||
resp, err := s.client.Do(ctx, req, acr)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return acr, resp, 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: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#remove-a-repository-collaborator
|
||||
// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#remove-a-repository-collaborator
|
||||
func (s *RepositoriesService) RemoveCollaborator(ctx context.Context, 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(ctx, req, nil)
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ func (r RepositoryComment) String() string {
|
|||
|
||||
// ListComments lists all the comments for the repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commit-comments-for-a-repository
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#list-commit-comments-for-a-repository
|
||||
func (s *RepositoriesService) ListComments(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -63,7 +63,7 @@ func (s *RepositoriesService) ListComments(ctx context.Context, owner, repo stri
|
|||
|
||||
// ListCommitComments lists all the comments for a given commit SHA.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commit-comments
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#list-commit-comments
|
||||
func (s *RepositoriesService) ListCommitComments(ctx context.Context, owner, repo, sha string, opts *ListOptions) ([]*RepositoryComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -91,7 +91,7 @@ func (s *RepositoriesService) ListCommitComments(ctx context.Context, owner, rep
|
|||
// CreateComment creates a comment for the given commit.
|
||||
// Note: GitHub allows for comments to be created for non-existing files and positions.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#create-a-commit-comment
|
||||
func (s *RepositoriesService) CreateComment(ctx context.Context, owner, repo, sha string, comment *RepositoryComment) (*RepositoryComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha)
|
||||
req, err := s.client.NewRequest("POST", u, comment)
|
||||
|
|
@ -110,7 +110,7 @@ func (s *RepositoriesService) CreateComment(ctx context.Context, owner, repo, sh
|
|||
|
||||
// GetComment gets a single comment from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#get-a-commit-comment
|
||||
func (s *RepositoriesService) GetComment(ctx context.Context, owner, repo string, id int64) (*RepositoryComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -132,7 +132,7 @@ func (s *RepositoriesService) GetComment(ctx context.Context, owner, repo string
|
|||
|
||||
// UpdateComment updates the body of a single comment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#update-a-commit-comment
|
||||
func (s *RepositoriesService) UpdateComment(ctx context.Context, owner, repo string, id int64, comment *RepositoryComment) (*RepositoryComment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id)
|
||||
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||
|
|
@ -151,7 +151,7 @@ func (s *RepositoriesService) UpdateComment(ctx context.Context, owner, repo str
|
|||
|
||||
// DeleteComment deletes a single comment from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-commit-comment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/comments#delete-a-commit-comment
|
||||
func (s *RepositoriesService) DeleteComment(ctx context.Context, owner, repo string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -124,7 +124,7 @@ type BranchCommit struct {
|
|||
|
||||
// ListCommits lists the commits of a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commits
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-commits
|
||||
func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo string, opts *CommitsListOptions) ([]*RepositoryCommit, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -148,8 +148,8 @@ func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo strin
|
|||
|
||||
// GetCommit fetches the specified commit, including all details about it.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-single-commit
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-single-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit
|
||||
func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha string, opts *ListOptions) (*RepositoryCommit, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -173,7 +173,7 @@ func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha st
|
|||
|
||||
// GetCommitRaw fetches the specified commit in raw (diff or patch) format.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit
|
||||
func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, repo string, sha string, opts RawOptions) (string, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -202,7 +202,7 @@ func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, re
|
|||
// GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is
|
||||
// supplied and no new commits have occurred, a 304 Unmodified response is returned.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit
|
||||
func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, ref, lastSHA string) (string, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, refURLEscape(ref))
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, re
|
|||
|
||||
// CompareCommits compares a range of commits with each other.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#compare-two-commits
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#compare-two-commits
|
||||
func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo string, base, head string, opts *ListOptions) (*CommitsComparison, *Response, error) {
|
||||
escapedBase := url.QueryEscape(base)
|
||||
escapedHead := url.QueryEscape(head)
|
||||
|
|
@ -258,7 +258,7 @@ func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo st
|
|||
// To compare branches across other repositories in the same network as "repo",
|
||||
// use the format "<USERNAME>:branch".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#compare-two-commits
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#compare-two-commits
|
||||
func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo, base, head string, opts RawOptions) (string, *Response, error) {
|
||||
escapedBase := url.QueryEscape(base)
|
||||
escapedHead := url.QueryEscape(head)
|
||||
|
|
@ -291,7 +291,7 @@ func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo
|
|||
// ListBranchesHeadCommit gets all branches where the given commit SHA is the HEAD,
|
||||
// or latest commit for the branch.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-branches-for-head-commit
|
||||
// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-branches-for-head-commit
|
||||
func (s *RepositoriesService) ListBranchesHeadCommit(ctx context.Context, owner, repo, sha string) ([]*BranchCommit, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/commits/%v/branches-where-head", owner, repo, sha)
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ type CommunityHealthMetrics struct {
|
|||
|
||||
// GetCommunityHealthMetrics retrieves all the community health metrics for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-community-profile-metrics
|
||||
// GitHub API docs: https://docs.github.com/en/rest/metrics/community#get-community-profile-metrics
|
||||
func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Repository contents API methods.
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/contents/
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents/
|
||||
|
||||
package github
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ type RepositoryContentResponse struct {
|
|||
// RepositoryContentFileOptions specifies optional parameters for CreateFile, UpdateFile, and DeleteFile.
|
||||
type RepositoryContentFileOptions struct {
|
||||
Message *string `json:"message,omitempty"`
|
||||
Content []byte `json:"content,omitempty"` // unencoded
|
||||
Content []byte `json:"content"` // unencoded
|
||||
SHA *string `json:"sha,omitempty"`
|
||||
Branch *string `json:"branch,omitempty"`
|
||||
Author *CommitAuthor `json:"author,omitempty"`
|
||||
|
|
@ -95,22 +95,25 @@ func (r *RepositoryContent) GetContent() (string, error) {
|
|||
|
||||
// GetReadme gets the Readme file for the repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository-readme
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents#get-a-repository-readme
|
||||
func (s *RepositoriesService) GetReadme(ctx context.Context, owner, repo string, opts *RepositoryContentGetOptions) (*RepositoryContent, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/readme", 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
|
||||
}
|
||||
|
||||
readme := new(RepositoryContent)
|
||||
resp, err := s.client.Do(ctx, req, readme)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return readme, resp, nil
|
||||
}
|
||||
|
||||
|
|
@ -129,18 +132,22 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
|
|||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
for _, contents := range dirContents {
|
||||
if *contents.Name == filename {
|
||||
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
|
||||
return nil, resp, fmt.Errorf("no download link found for %s", filepath)
|
||||
}
|
||||
|
||||
dlResp, err := s.client.client.Get(*contents.DownloadURL)
|
||||
if err != nil {
|
||||
return nil, &Response{Response: dlResp}, err
|
||||
}
|
||||
|
||||
return dlResp.Body, &Response{Response: dlResp}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir)
|
||||
}
|
||||
|
||||
|
|
@ -159,18 +166,22 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne
|
|||
if err != nil {
|
||||
return nil, nil, resp, err
|
||||
}
|
||||
|
||||
for _, contents := range dirContents {
|
||||
if *contents.Name == filename {
|
||||
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
|
||||
return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath)
|
||||
}
|
||||
|
||||
dlResp, err := s.client.client.Get(*contents.DownloadURL)
|
||||
if err != nil {
|
||||
return nil, contents, &Response{Response: dlResp}, err
|
||||
}
|
||||
|
||||
return dlResp.Body, contents, &Response{Response: dlResp}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir)
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +192,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne
|
|||
// as possible, both result types will be returned but only one will contain a
|
||||
// value and the other will be nil.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-repository-content
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents#get-repository-content
|
||||
func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path string, opts *RepositoryContentGetOptions) (fileContent *RepositoryContent, directoryContent []*RepositoryContent, resp *Response, err error) {
|
||||
escapedPath := (&url.URL{Path: strings.TrimSuffix(path, "/")}).String()
|
||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, escapedPath)
|
||||
|
|
@ -189,77 +200,88 @@ func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path
|
|||
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(ctx, req, &rawJSON)
|
||||
if err != nil {
|
||||
return nil, nil, resp, err
|
||||
}
|
||||
|
||||
fileUnmarshalError := json.Unmarshal(rawJSON, &fileContent)
|
||||
if fileUnmarshalError == nil {
|
||||
return fileContent, nil, resp, nil
|
||||
}
|
||||
|
||||
directoryUnmarshalError := json.Unmarshal(rawJSON, &directoryContent)
|
||||
if directoryUnmarshalError == nil {
|
||||
return nil, directoryContent, resp, nil
|
||||
}
|
||||
|
||||
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: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-or-update-file-contents
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents
|
||||
func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
||||
req, err := s.client.NewRequest("PUT", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
createResponse := new(RepositoryContentResponse)
|
||||
resp, err := s.client.Do(ctx, req, createResponse)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return createResponse, resp, nil
|
||||
}
|
||||
|
||||
// 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: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-or-update-file-contents
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents
|
||||
func (s *RepositoriesService) UpdateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
||||
req, err := s.client.NewRequest("PUT", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
updateResponse := new(RepositoryContentResponse)
|
||||
resp, err := s.client.Do(ctx, req, updateResponse)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return updateResponse, resp, nil
|
||||
}
|
||||
|
||||
// DeleteFile deletes a file from a repository and returns the commit.
|
||||
// Requires the blob SHA of the file to be deleted.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-file
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents#delete-a-file
|
||||
func (s *RepositoriesService) DeleteFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
|
||||
req, err := s.client.NewRequest("DELETE", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
deleteResponse := new(RepositoryContentResponse)
|
||||
resp, err := s.client.Do(ctx, req, deleteResponse)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return deleteResponse, resp, nil
|
||||
}
|
||||
|
||||
|
|
@ -278,46 +300,26 @@ const (
|
|||
// repository. The archiveFormat can be specified by either the github.Tarball
|
||||
// or github.Zipball constant.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/contents/#get-archive-link
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/contents/#get-archive-link
|
||||
func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, followRedirects bool) (*url.URL, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat)
|
||||
if opts != nil && opts.Ref != "" {
|
||||
u += fmt.Sprintf("/%s", opts.Ref)
|
||||
}
|
||||
resp, err := s.getArchiveLinkFromURL(ctx, u, followRedirects)
|
||||
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
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 *RepositoriesService) getArchiveLinkFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) {
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, newResponse(resp), 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.getArchiveLinkFromURL(ctx, u, false)
|
||||
}
|
||||
return resp, err
|
||||
return parsedURL, newResponse(resp), nil
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ type DeploymentsListOptions struct {
|
|||
|
||||
// ListDeployments lists the deployments of a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-deployments
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#list-deployments
|
||||
func (s *RepositoriesService) ListDeployments(ctx context.Context, owner, repo string, opts *DeploymentsListOptions) ([]*Deployment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -87,7 +87,7 @@ func (s *RepositoriesService) ListDeployments(ctx context.Context, owner, repo s
|
|||
|
||||
// GetDeployment returns a single deployment of a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-deployment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#get-a-deployment
|
||||
func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Deployment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v", owner, repo, deploymentID)
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo str
|
|||
|
||||
// CreateDeployment creates a new deployment for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-deployment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#create-a-deployment
|
||||
func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo string, request *DeploymentRequest) (*Deployment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo)
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo
|
|||
|
||||
// DeleteDeployment deletes an existing deployment for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-deployment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#delete-a-deployment
|
||||
func (s *RepositoriesService) DeleteDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v", owner, repo, deploymentID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -175,7 +175,7 @@ type DeploymentStatusRequest struct {
|
|||
|
||||
// ListDeploymentStatuses lists the statuses of a given deployment of a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-deployment-statuses
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#list-deployment-statuses
|
||||
func (s *RepositoriesService) ListDeploymentStatuses(ctx context.Context, owner, repo string, deployment int64, opts *ListOptions) ([]*DeploymentStatus, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -203,7 +203,7 @@ func (s *RepositoriesService) ListDeploymentStatuses(ctx context.Context, owner,
|
|||
|
||||
// GetDeploymentStatus returns a single deployment status of a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-deployment-status
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#get-a-deployment-status
|
||||
func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, repo string, deploymentID, deploymentStatusID int64) (*DeploymentStatus, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses/%v", owner, repo, deploymentID, deploymentStatusID)
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, re
|
|||
|
||||
// CreateDeploymentStatus creates a new status for a deployment.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-deployment-status
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#create-a-deployment-status
|
||||
func (s *RepositoriesService) CreateDeploymentStatus(ctx context.Context, owner, repo string, deployment int64, request *DeploymentStatusRequest) (*DeploymentStatus, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment)
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ func (r *RequiredReviewer) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// ListEnvironments lists all environments for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-all-environments
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#get-all-environments
|
||||
func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo string, opts *EnvironmentListOptions) (*EnvResponse, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/environments", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -127,7 +127,7 @@ func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo
|
|||
|
||||
// GetEnvironment get a single environment for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-an-environment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#get-an-environment
|
||||
func (s *RepositoriesService) GetEnvironment(ctx context.Context, owner, repo, name string) (*Environment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name)
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ type CreateUpdateEnvironment struct {
|
|||
|
||||
// CreateUpdateEnvironment create or update a new environment for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#create-or-update-an-environment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
|
||||
func (s *RepositoriesService) CreateUpdateEnvironment(ctx context.Context, owner, repo, name string, environment *CreateUpdateEnvironment) (*Environment, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name)
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func (s *RepositoriesService) CreateUpdateEnvironment(ctx context.Context, owner
|
|||
|
||||
// DeleteEnvironment delete an environment from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#delete-an-environment
|
||||
// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#delete-an-environment
|
||||
func (s *RepositoriesService) DeleteEnvironment(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name)
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ type RepositoryListForksOptions struct {
|
|||
|
||||
// ListForks lists the forks of the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-forks
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/forks#list-forks
|
||||
func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, opts *RepositoryListForksOptions) ([]*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/forks", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -53,7 +53,9 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string,
|
|||
// RepositoriesService.CreateFork method.
|
||||
type RepositoryCreateForkOptions struct {
|
||||
// The organization to fork the repository into.
|
||||
Organization string `url:"organization,omitempty"`
|
||||
Organization string `url:"organization,omitempty"`
|
||||
Name string `url:"name,omitempty"`
|
||||
DefaultBranchOnly bool `url:"default_branch_only,omitempty"`
|
||||
}
|
||||
|
||||
// CreateFork creates a fork of the specified repository.
|
||||
|
|
@ -65,7 +67,7 @@ type RepositoryCreateForkOptions struct {
|
|||
// A follow up request, after a delay of a second or so, should result
|
||||
// in a successful request.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-fork
|
||||
// GitHub API docs: https://docs.github.com/en/rest/repos/forks#create-a-fork
|
||||
func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string, opts *RepositoryCreateForkOptions) (*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/forks", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -8,6 +8,9 @@ package github
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -18,57 +21,22 @@ import (
|
|||
// here to account for these differences.
|
||||
//
|
||||
// GitHub API docs: https://help.github.com/articles/post-receive-hooks
|
||||
type WebHookPayload struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
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"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
Pusher *User `json:"pusher,omitempty"`
|
||||
Ref *string `json:"ref,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
func (w WebHookPayload) String() string {
|
||||
return Stringify(w)
|
||||
}
|
||||
//
|
||||
// Deprecated: Please use PushEvent instead.
|
||||
type WebHookPayload = PushEvent
|
||||
|
||||
// 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)
|
||||
}
|
||||
//
|
||||
// Deprecated: Please use HeadCommit instead.
|
||||
type WebHookCommit = HeadCommit
|
||||
|
||||
// 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)
|
||||
}
|
||||
//
|
||||
// Deprecated: Please use CommitAuthor instead.
|
||||
// NOTE Breaking API change: the `Username` field is now called `Login`.
|
||||
type WebHookAuthor = CommitAuthor
|
||||
|
||||
// Hook represents a GitHub (web and service) hook for a repository.
|
||||
type Hook struct {
|
||||
|
|
@ -112,7 +80,7 @@ type createHookRequest struct {
|
|||
// Note that only a subset of the hook fields are used and hook must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#create-a-repository-webhook
|
||||
func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string, hook *Hook) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo)
|
||||
|
||||
|
|
@ -139,7 +107,7 @@ func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string
|
|||
|
||||
// ListHooks lists all Hooks for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-webhooks
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#list-repository-webhooks
|
||||
func (s *RepositoriesService) ListHooks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
|
|
@ -163,7 +131,7 @@ func (s *RepositoriesService) ListHooks(ctx context.Context, owner, repo string,
|
|||
|
||||
// GetHook returns a single specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#get-a-repository-webhook
|
||||
func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, id int64) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
|
@ -181,7 +149,7 @@ func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, i
|
|||
|
||||
// EditHook updates a specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#update-a-repository-webhook
|
||||
func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, id int64, hook *Hook) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
||||
req, err := s.client.NewRequest("PATCH", u, hook)
|
||||
|
|
@ -199,7 +167,7 @@ func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string,
|
|||
|
||||
// DeleteHook deletes a specified Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#delete-a-repository-webhook
|
||||
func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
|
@ -211,7 +179,7 @@ func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string
|
|||
|
||||
// PingHook triggers a 'ping' event to be sent to the Hook.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#ping-a-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#ping-a-repository-webhook
|
||||
func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d/pings", owner, repo, id)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -223,7 +191,7 @@ func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string,
|
|||
|
||||
// TestHook triggers a test Hook by github.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#test-the-push-repository-webhook
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#test-the-push-repository-webhook
|
||||
func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks/%d/tests", owner, repo, id)
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
|
@ -232,3 +200,55 @@ func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string,
|
|||
}
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// Subscribe lets servers register to receive updates when a topic is updated.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks#pubsubhubbub
|
||||
func (s *RepositoriesService) Subscribe(ctx context.Context, owner, repo, event, callback string, secret []byte) (*Response, error) {
|
||||
req, err := s.createWebSubRequest("subscribe", owner, repo, event, callback, secret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// Unsubscribe lets servers unregister to no longer receive updates when a topic is updated.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/webhooks#pubsubhubbub
|
||||
func (s *RepositoriesService) Unsubscribe(ctx context.Context, owner, repo, event, callback string, secret []byte) (*Response, error) {
|
||||
req, err := s.createWebSubRequest("unsubscribe", owner, repo, event, callback, secret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// createWebSubRequest returns a subscribe/unsubscribe request that implements
|
||||
// the WebSub (formerly PubSubHubbub) protocol.
|
||||
//
|
||||
// See: https://www.w3.org/TR/websub/#subscriber-sends-subscription-request
|
||||
func (s *RepositoriesService) createWebSubRequest(hubMode, owner, repo, event, callback string, secret []byte) (*http.Request, error) {
|
||||
topic := fmt.Sprintf(
|
||||
"https://github.com/%s/%s/events/%s",
|
||||
owner,
|
||||
repo,
|
||||
event,
|
||||
)
|
||||
form := url.Values{}
|
||||
form.Add("hub.mode", hubMode)
|
||||
form.Add("hub.topic", topic)
|
||||
form.Add("hub.callback", callback)
|
||||
if secret != nil {
|
||||
form.Add("hub.secret", string(secret))
|
||||
}
|
||||
body := strings.NewReader(form.Encode())
|
||||
|
||||
req, err := s.client.NewFormRequest("hub", body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue