Update go-github

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-12-18 16:09:49 +00:00
parent 66bf762cd6
commit 0dd4f38691
182 changed files with 5731 additions and 1998 deletions

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/go-openapi/strfmt v0.21.10 github.com/go-openapi/strfmt v0.21.10
github.com/go-openapi/swag v0.22.5 github.com/go-openapi/swag v0.22.5
github.com/golang-jwt/jwt/v5 v5.2.0 github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/go-github/v55 v55.0.1-0.20230921135834-aa3fcbe7aabc github.com/google/go-github/v57 v57.0.0
github.com/google/uuid v1.5.0 github.com/google/uuid v1.5.0
github.com/gorilla/handlers v1.5.2 github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1

4
go.sum
View file

@ -66,8 +66,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v55 v55.0.1-0.20230921135834-aa3fcbe7aabc h1:wZybOt4gfOPJmwpe3CZFJYoREaqgngGeo1Y29zZePhg= github.com/google/go-github/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs=
github.com/google/go-github/v55 v55.0.1-0.20230921135834-aa3fcbe7aabc/go.mod h1:dx9O5B1Z9+WYDRfSIkPdJ/jszShiNtl++jbgL/3OM2c= github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=

View file

@ -26,7 +26,7 @@ import (
"github.com/cloudbase/garm/util/appdefaults" "github.com/cloudbase/garm/util/appdefaults"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/google/uuid" "github.com/google/uuid"
) )

View file

@ -5,7 +5,7 @@ package mocks
import ( import (
context "context" context "context"
github "github.com/google/go-github/v55/github" github "github.com/google/go-github/v57/github"
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
) )

View file

@ -5,7 +5,7 @@ package mocks
import ( import (
context "context" context "context"
github "github.com/google/go-github/v55/github" github "github.com/google/go-github/v57/github"
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
) )

View file

@ -5,7 +5,7 @@ package mocks
import ( import (
context "context" context "context"
github "github.com/google/go-github/v55/github" github "github.com/google/go-github/v57/github"
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
) )

View file

@ -5,7 +5,7 @@ package mocks
import ( import (
context "context" context "context"
github "github.com/google/go-github/v55/github" github "github.com/google/go-github/v57/github"
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
) )

View file

@ -3,7 +3,7 @@ package common
import ( import (
"context" "context"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
) )
type OrganizationHooks interface { type OrganizationHooks interface {

View file

@ -6,7 +6,7 @@ import (
runnerErrors "github.com/cloudbase/garm-provider-common/errors" runnerErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm/params" "github.com/cloudbase/garm/params"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View file

@ -17,7 +17,7 @@ import (
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util" "github.com/cloudbase/garm/util"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View file

@ -21,7 +21,7 @@ import (
"github.com/cloudbase/garm/params" "github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
) )
type poolHelper interface { type poolHelper interface {

View file

@ -31,7 +31,7 @@ import (
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util" "github.com/cloudbase/garm/util"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View file

@ -34,7 +34,7 @@ import (
"github.com/cloudbase/garm/params" "github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"

View file

@ -31,7 +31,7 @@ import (
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util" "github.com/cloudbase/garm/util"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View file

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )

View file

@ -24,7 +24,7 @@ import (
"github.com/cloudbase/garm/params" "github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner/common" "github.com/cloudbase/garm/runner/common"
"github.com/google/go-github/v55/github" "github.com/google/go-github/v57/github"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )

View file

@ -1,247 +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 (
"bytes"
"context"
"fmt"
"net/url"
)
// MarkdownOptions specifies optional parameters to the Markdown method.
type MarkdownOptions struct {
// Mode identifies the rendering mode. Possible values are:
// markdown - render a document as plain Markdown, just like
// README files are rendered.
//
// gfm - to render a document as user-content, e.g. like user
// comments or issues are rendered. In GFM mode, hard line breaks are
// always taken into account, and issue and user mentions are linked
// accordingly.
//
// Default is "markdown".
Mode string
// Context identifies the repository context. Only taken into account
// when rendering as "gfm".
Context string
}
type markdownRequest struct {
Text *string `json:"text,omitempty"`
Mode *string `json:"mode,omitempty"`
Context *string `json:"context,omitempty"`
}
// Markdown renders an arbitrary Markdown document.
//
// 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 {
if opts.Mode != "" {
request.Mode = String(opts.Mode)
}
if opts.Context != "" {
request.Context = String(opts.Context)
}
}
req, err := c.NewRequest("POST", "markdown", request)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := c.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}
// ListEmojis returns the emojis available to use on GitHub.
//
// 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 {
return nil, nil, err
}
var emoji map[string]string
resp, err := c.Do(ctx, req, &emoji)
if err != nil {
return nil, resp, err
}
return emoji, resp, nil
}
// CodeOfConduct represents a code of conduct.
type CodeOfConduct struct {
Name *string `json:"name,omitempty"`
Key *string `json:"key,omitempty"`
URL *string `json:"url,omitempty"`
Body *string `json:"body,omitempty"`
}
func (c *CodeOfConduct) String() string {
return Stringify(c)
}
// ListCodesOfConduct returns 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 {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
var cs []*CodeOfConduct
resp, err := c.Do(ctx, req, &cs)
if err != nil {
return nil, resp, err
}
return cs, resp, nil
}
// GetCodeOfConduct returns 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)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
coc := new(CodeOfConduct)
resp, err := c.Do(ctx, req, coc)
if err != nil {
return nil, resp, err
}
return coc, resp, nil
}
// APIMeta represents metadata about the GitHub API.
type APIMeta struct {
// An Array of IP addresses in CIDR format specifying the addresses
// that incoming service hooks will originate from on GitHub.com.
Hooks []string `json:"hooks,omitempty"`
// An Array of IP addresses in CIDR format specifying the Git servers
// for GitHub.com.
Git []string `json:"git,omitempty"`
// Whether authentication with username and password is supported.
// (GitHub Enterprise instances using CAS or OAuth for authentication
// will return false. Features like Basic Authentication with a
// username and password, sudo mode, and two-factor authentication are
// not supported on these servers.)
VerifiablePasswordAuthentication *bool `json:"verifiable_password_authentication,omitempty"`
// An array of IP addresses in CIDR format specifying the addresses
// which serve GitHub Pages websites.
Pages []string `json:"pages,omitempty"`
// An Array of IP addresses specifying the addresses that source imports
// will originate from on GitHub.com.
Importer []string `json:"importer,omitempty"`
// An array of IP addresses in CIDR format specifying the IP addresses
// GitHub Actions will originate from.
Actions []string `json:"actions,omitempty"`
// An array of IP addresses in CIDR format specifying the IP addresses
// Dependabot will originate from.
Dependabot []string `json:"dependabot,omitempty"`
// A map of algorithms to SSH key fingerprints.
SSHKeyFingerprints map[string]string `json:"ssh_key_fingerprints,omitempty"`
// 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 organizations GitHub Enterprise installation, this
// endpoint provides information about that installation.
//
// 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 {
return nil, nil, err
}
meta := new(APIMeta)
resp, err := c.Do(ctx, req, meta)
if err != nil {
return nil, resp, err
}
return meta, resp, nil
}
// Octocat returns an ASCII art octocat with the specified message in a speech
// bubble. If message is empty, a random zen phrase is used.
func (c *Client) Octocat(ctx context.Context, message string) (string, *Response, error) {
u := "octocat"
if message != "" {
u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message))
}
req, err := c.NewRequest("GET", u, nil)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := c.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}
// Zen returns a random line from The Zen of GitHub.
//
// see also: http://warpspire.com/posts/taste/
func (c *Client) Zen(ctx context.Context) (string, *Response, error) {
req, err := c.NewRequest("GET", "zen", nil)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := c.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}

View file

@ -1,63 +0,0 @@
// Copyright 2021 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// ActionsAllowed represents selected actions that are allowed.
//
// 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"`
PatternsAllowed []string `json:"patterns_allowed,omitempty"`
}
func (a ActionsAllowed) String() string {
return Stringify(a)
}
// GetActionsAllowed gets the actions that are allowed in 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)
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 actions that are allowed in 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)
if err != nil {
return nil, resp, err
}
return p, resp, nil
}

View file

@ -1,63 +0,0 @@
// Copyright 2021 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// ActionsPermissions represents a policy for repositories and allowed actions in an organization.
//
// 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"`
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
}
func (a ActionsPermissions) String() string {
return Stringify(a)
}
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in 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)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
permissions := new(ActionsPermissions)
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 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)
if err != nil {
return nil, resp, err
}
return p, resp, nil
}

View file

@ -1,156 +0,0 @@
// Copyright 2021 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// GetAuditLogOptions sets up optional parameters to query audit-log endpoint.
type GetAuditLogOptions struct {
Phrase *string `url:"phrase,omitempty"` // A search phrase. (Optional.)
Include *string `url:"include,omitempty"` // Event type includes. Can be one of "web", "git", "all". Default: "web". (Optional.)
Order *string `url:"order,omitempty"` // The order of audit log events. Can be one of "asc" or "desc". Default: "desc". (Optional.)
ListCursorOptions
}
// HookConfig describes metadata about a webhook configuration.
type HookConfig struct {
ContentType *string `json:"content_type,omitempty"`
InsecureSSL *string `json:"insecure_ssl,omitempty"`
URL *string `json:"url,omitempty"`
// Secret is returned obfuscated by GitHub, but it can be set for outgoing requests.
Secret *string `json:"secret,omitempty"`
}
// ActorLocation contains information about reported location for an actor.
type ActorLocation struct {
CountryCode *string `json:"country_code,omitempty"`
}
// PolicyOverrideReason contains user-supplied information about why a policy was overridden.
type PolicyOverrideReason struct {
Code *string `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
}
// AuditEntry describes the fields that may be represented by various audit-log "action" entries.
// For a list of actions see - https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#audit-log-actions
type AuditEntry struct {
ActorIP *string `json:"actor_ip,omitempty"`
Action *string `json:"action,omitempty"` // The name of the action that was performed, for example `user.login` or `repo.create`.
Active *bool `json:"active,omitempty"`
ActiveWas *bool `json:"active_was,omitempty"`
Actor *string `json:"actor,omitempty"` // The actor who performed the action.
ActorLocation *ActorLocation `json:"actor_location,omitempty"`
BlockedUser *string `json:"blocked_user,omitempty"`
Business *string `json:"business,omitempty"`
CancelledAt *Timestamp `json:"cancelled_at,omitempty"`
CompletedAt *Timestamp `json:"completed_at,omitempty"`
Conclusion *string `json:"conclusion,omitempty"`
Config *HookConfig `json:"config,omitempty"`
ConfigWas *HookConfig `json:"config_was,omitempty"`
ContentType *string `json:"content_type,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
DeployKeyFingerprint *string `json:"deploy_key_fingerprint,omitempty"`
DocumentID *string `json:"_document_id,omitempty"`
Emoji *string `json:"emoji,omitempty"`
EnvironmentName *string `json:"environment_name,omitempty"`
Event *string `json:"event,omitempty"`
Events []string `json:"events,omitempty"`
EventsWere []string `json:"events_were,omitempty"`
Explanation *string `json:"explanation,omitempty"`
Fingerprint *string `json:"fingerprint,omitempty"`
HashedToken *string `json:"hashed_token,omitempty"`
HeadBranch *string `json:"head_branch,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"`
HookID *int64 `json:"hook_id,omitempty"`
IsHostedRunner *bool `json:"is_hosted_runner,omitempty"`
JobName *string `json:"job_name,omitempty"`
JobWorkflowRef *string `json:"job_workflow_ref,omitempty"`
LimitedAvailability *bool `json:"limited_availability,omitempty"`
Message *string `json:"message,omitempty"`
Name *string `json:"name,omitempty"`
OAuthApplicationID *int64 `json:"oauth_application_id,omitempty"`
OldUser *string `json:"old_user,omitempty"`
OldPermission *string `json:"old_permission,omitempty"` // The permission level for membership changes, for example `admin` or `read`.
OpenSSHPublicKey *string `json:"openssh_public_key,omitempty"`
OperationType *string `json:"operation_type,omitempty"`
Org *string `json:"org,omitempty"`
OrgID *int64 `json:"org_id,omitempty"`
OverriddenCodes []string `json:"overridden_codes,omitempty"`
Permission *string `json:"permission,omitempty"` // The permission level for membership changes, for example `admin` or `read`.
PreviousVisibility *string `json:"previous_visibility,omitempty"`
ProgrammaticAccessType *string `json:"programmatic_access_type,omitempty"`
PullRequestID *int64 `json:"pull_request_id,omitempty"`
PullRequestTitle *string `json:"pull_request_title,omitempty"`
PullRequestURL *string `json:"pull_request_url,omitempty"`
ReadOnly *string `json:"read_only,omitempty"`
Reasons []*PolicyOverrideReason `json:"reasons,omitempty"`
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"`
RunnerLabels []string `json:"runner_labels,omitempty"`
RunnerName *string `json:"runner_name,omitempty"`
RunNumber *int64 `json:"run_number,omitempty"`
SecretsPassed []string `json:"secrets_passed,omitempty"`
SourceVersion *string `json:"source_version,omitempty"`
StartedAt *Timestamp `json:"started_at,omitempty"`
TargetLogin *string `json:"target_login,omitempty"`
TargetVersion *string `json:"target_version,omitempty"`
Team *string `json:"team,omitempty"`
Timestamp *Timestamp `json:"@timestamp,omitempty"` // The time the audit log event occurred, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time).
TokenID *int64 `json:"token_id,omitempty"`
TokenScopes *string `json:"token_scopes,omitempty"`
Topic *string `json:"topic,omitempty"`
TransportProtocolName *string `json:"transport_protocol_name,omitempty"` // A human readable name for the protocol (for example, HTTP or SSH) used to transfer Git data.
TransportProtocol *int `json:"transport_protocol,omitempty"` // The type of protocol (for example, HTTP=1 or SSH=2) used to transfer Git data.
TriggerID *int64 `json:"trigger_id,omitempty"`
User *string `json:"user,omitempty"` // The user that was affected by the action performed (if available).
UserAgent *string `json:"user_agent,omitempty"`
Visibility *string `json:"visibility,omitempty"` // The repository visibility, for example `public` or `private`.
WorkflowID *int64 `json:"workflow_id,omitempty"`
WorkflowRunID *int64 `json:"workflow_run_id,omitempty"`
Data *AuditEntryData `json:"data,omitempty"`
}
// AuditEntryData represents additional information stuffed into a `data` field.
type AuditEntryData struct {
OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change
OldLogin *string `json:"old_login,omitempty"` // The previous name of the organization, for a name change
}
// GetAuditLog gets the audit-log entries 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)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var auditEntries []*AuditEntry
resp, err := s.client.Do(ctx, req, &auditEntries)
if err != nil {
return nil, resp, err
}
return auditEntries, resp, nil
}

View file

@ -1,37 +0,0 @@
// Copyright 2023 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"
)
type SecurityAdvisoriesService service
// RequestCVE requests a Common Vulnerabilities and Exposures (CVE) for a repository security advisory.
// The ghsaID is the GitHub Security Advisory identifier of the advisory.
//
// GitHub API docs: https://docs.github.com/en/rest/security-advisories/repository-advisories#request-a-cve-for-a-repository-security-advisory
func (s *SecurityAdvisoriesService) RequestCVE(ctx context.Context, owner, repo, ghsaID string) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/security-advisories/%v/cve", owner, repo, ghsaID)
req, err := s.client.NewRequest("POST", url, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
if _, ok := err.(*AcceptedError); ok {
return resp, nil
}
return resp, err
}
return resp, nil
}

View file

@ -8,5 +8,5 @@ package github
// ActionsService handles communication with the actions related // ActionsService handles communication with the actions related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/ // GitHub API docs: https://docs.github.com/rest/actions/
type ActionsService service type ActionsService service

View file

@ -14,7 +14,7 @@ import (
// ArtifactWorkflowRun represents a GitHub artifact's workflow run. // ArtifactWorkflowRun represents a GitHub artifact's workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts // GitHub API docs: https://docs.github.com/rest/actions/artifacts
type ArtifactWorkflowRun struct { type ArtifactWorkflowRun struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
RepositoryID *int64 `json:"repository_id,omitempty"` RepositoryID *int64 `json:"repository_id,omitempty"`
@ -27,7 +27,7 @@ type ArtifactWorkflowRun struct {
// data between jobs in a workflow and provide storage for data // data between jobs in a workflow and provide storage for data
// once a workflow is complete. // once a workflow is complete.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts // GitHub API docs: https://docs.github.com/rest/actions/artifacts
type Artifact struct { type Artifact struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"` NodeID *string `json:"node_id,omitempty"`
@ -44,7 +44,7 @@ type Artifact struct {
// ArtifactList represents a list of GitHub artifacts. // ArtifactList represents a list of GitHub artifacts.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#artifacts // GitHub API docs: https://docs.github.com/rest/actions/artifacts#artifacts
type ArtifactList struct { type ArtifactList struct {
TotalCount *int64 `json:"total_count,omitempty"` TotalCount *int64 `json:"total_count,omitempty"`
Artifacts []*Artifact `json:"artifacts,omitempty"` Artifacts []*Artifact `json:"artifacts,omitempty"`
@ -52,7 +52,9 @@ type ArtifactList struct {
// ListArtifacts lists all artifacts that belong to a repository. // ListArtifacts lists all artifacts that belong to a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-artifacts-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-artifacts-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/artifacts
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -76,7 +78,9 @@ func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string,
// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run. // ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts // GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-workflow-run-artifacts
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts
func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", owner, repo, runID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -100,7 +104,9 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re
// GetArtifact gets a specific artifact for a workflow run. // GetArtifact gets a specific artifact for a workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact // GitHub API docs: https://docs.github.com/rest/actions/artifacts#get-an-artifact
//
//meta:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
@ -120,11 +126,13 @@ func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, ar
// DownloadArtifact gets a redirect URL to download an archive for a repository. // DownloadArtifact gets a redirect URL to download an archive for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact // GitHub API docs: https://docs.github.com/rest/actions/artifacts#download-an-artifact
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) { //
//meta:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID) u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -144,7 +152,9 @@ func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo strin
// DeleteArtifact deletes a workflow run artifact. // DeleteArtifact deletes a workflow run artifact.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#delete-an-artifact // GitHub API docs: https://docs.github.com/rest/actions/artifacts#delete-an-artifact
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}
func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)

View file

@ -12,7 +12,7 @@ import (
// ActionsCache represents a GitHub action cache. // ActionsCache represents a GitHub action cache.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#about-the-cache-api // GitHub API docs: https://docs.github.com/rest/actions/cache#about-the-cache-api
type ActionsCache struct { type ActionsCache struct {
ID *int64 `json:"id,omitempty" url:"-"` ID *int64 `json:"id,omitempty" url:"-"`
Ref *string `json:"ref,omitempty" url:"ref"` Ref *string `json:"ref,omitempty" url:"ref"`
@ -25,7 +25,7 @@ type ActionsCache struct {
// ActionsCacheList represents a list of GitHub actions Cache. // ActionsCacheList represents a list of GitHub actions Cache.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#list-github-actions-caches-for-a-repository
type ActionsCacheList struct { type ActionsCacheList struct {
TotalCount int `json:"total_count"` TotalCount int `json:"total_count"`
ActionsCaches []*ActionsCache `json:"actions_caches,omitempty"` ActionsCaches []*ActionsCache `json:"actions_caches,omitempty"`
@ -33,7 +33,7 @@ type ActionsCacheList struct {
// ActionsCacheUsage represents a GitHub Actions Cache Usage object. // ActionsCacheUsage represents a GitHub Actions Cache Usage object.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-a-repository
type ActionsCacheUsage struct { type ActionsCacheUsage struct {
FullName string `json:"full_name"` FullName string `json:"full_name"`
ActiveCachesSizeInBytes int64 `json:"active_caches_size_in_bytes"` ActiveCachesSizeInBytes int64 `json:"active_caches_size_in_bytes"`
@ -42,7 +42,7 @@ type ActionsCacheUsage struct {
// ActionsCacheUsageList represents a list of repositories with GitHub Actions cache usage for an organization. // ActionsCacheUsageList represents a list of repositories with GitHub Actions cache usage for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-a-repository
type ActionsCacheUsageList struct { type ActionsCacheUsageList struct {
TotalCount int `json:"total_count"` TotalCount int `json:"total_count"`
RepoCacheUsage []*ActionsCacheUsage `json:"repository_cache_usages,omitempty"` RepoCacheUsage []*ActionsCacheUsage `json:"repository_cache_usages,omitempty"`
@ -50,7 +50,7 @@ type ActionsCacheUsageList struct {
// TotalCacheUsage represents total GitHub actions cache usage of an organization or enterprise. // TotalCacheUsage represents total GitHub actions cache usage of an organization or enterprise.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-enterprise // GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-an-enterprise
type TotalCacheUsage struct { type TotalCacheUsage struct {
TotalActiveCachesUsageSizeInBytes int64 `json:"total_active_caches_size_in_bytes"` TotalActiveCachesUsageSizeInBytes int64 `json:"total_active_caches_size_in_bytes"`
TotalActiveCachesCount int `json:"total_active_caches_count"` TotalActiveCachesCount int `json:"total_active_caches_count"`
@ -58,7 +58,7 @@ type TotalCacheUsage struct {
// ActionsCacheListOptions represents a list of all possible optional Query parameters for ListCaches method. // ActionsCacheListOptions represents a list of all possible optional Query parameters for ListCaches method.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#list-github-actions-caches-for-a-repository
type ActionsCacheListOptions struct { type ActionsCacheListOptions struct {
ListOptions ListOptions
// The Git reference for the results you want to list. // The Git reference for the results you want to list.
@ -77,7 +77,9 @@ type ActionsCacheListOptions struct {
// //
// Permissions: must have the actions:read permission to use this endpoint. // Permissions: must have the actions:read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#list-github-actions-caches-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/caches
func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opts *ActionsCacheListOptions) (*ActionsCacheList, *Response, error) { func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opts *ActionsCacheListOptions) (*ActionsCacheList, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -107,7 +109,9 @@ func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opt
// //
// Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint. // Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-github-actions-caches-for-a-repository-using-a-cache-key // GitHub API docs: https://docs.github.com/rest/actions/cache#delete-github-actions-caches-for-a-repository-using-a-cache-key
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/caches
func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key string, ref *string) (*Response, error) { func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key string, ref *string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo)
u, err := addOptions(u, ActionsCache{Key: &key, Ref: ref}) u, err := addOptions(u, ActionsCache{Key: &key, Ref: ref})
@ -127,7 +131,9 @@ func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key
// //
// Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint. // Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id // GitHub API docs: https://docs.github.com/rest/actions/cache#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/caches/{cache_id}
func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo string, cacheID int64) (*Response, error) { func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo string, cacheID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches/%v", owner, repo, cacheID) u := fmt.Sprintf("repos/%v/%v/actions/caches/%v", owner, repo, cacheID)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -144,7 +150,9 @@ func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo strin
// Permissions: Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an // Permissions: Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an
// access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint. // access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/cache/usage
func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo string) (*ActionsCacheUsage, *Response, error) { func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo string) (*ActionsCacheUsage, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/cache/usage", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/cache/usage", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -167,7 +175,9 @@ func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo s
// Permissions: You must authenticate using an access token with the read:org scope to use this endpoint. // Permissions: You must authenticate using an access token with the read:org scope to use this endpoint.
// GitHub Apps must have the organization_admistration:read permission to use this endpoint. // GitHub Apps must have the organization_admistration:read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-repositories-with-github-actions-cache-usage-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/cache#list-repositories-with-github-actions-cache-usage-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/cache/usage-by-repository
func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org string, opts *ListOptions) (*ActionsCacheUsageList, *Response, error) { func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org string, opts *ListOptions) (*ActionsCacheUsageList, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/cache/usage-by-repository", org) u := fmt.Sprintf("orgs/%v/actions/cache/usage-by-repository", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -195,7 +205,9 @@ func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org str
// Permissions: You must authenticate using an access token with the read:org scope to use this endpoint. // Permissions: You must authenticate using an access token with the read:org scope to use this endpoint.
// GitHub Apps must have the organization_admistration:read permission to use this endpoint. // GitHub Apps must have the organization_admistration:read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/cache/usage
func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org string) (*TotalCacheUsage, *Response, error) { func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org string) (*TotalCacheUsage, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/cache/usage", org) u := fmt.Sprintf("orgs/%v/actions/cache/usage", org)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -217,7 +229,9 @@ func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org strin
// //
// Permissions: You must authenticate using an access token with the "admin:enterprise" scope to use this endpoint. // Permissions: You must authenticate using an access token with the "admin:enterprise" scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/cache#get-github-actions-cache-usage-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/cache/usage
func (s *ActionsService) GetTotalCacheUsageForEnterprise(ctx context.Context, enterprise string) (*TotalCacheUsage, *Response, error) { func (s *ActionsService) GetTotalCacheUsageForEnterprise(ctx context.Context, enterprise string) (*TotalCacheUsage, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/cache/usage", enterprise) u := fmt.Sprintf("enterprises/%v/actions/cache/usage", enterprise)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)

View file

@ -18,7 +18,9 @@ type OIDCSubjectClaimCustomTemplate struct {
// GetOrgOIDCSubjectClaimCustomTemplate gets the subject claim customization template for an organization. // GetOrgOIDCSubjectClaimCustomTemplate gets the subject claim customization template for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/oidc/customization/sub
func (s *ActionsService) GetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string) (*OIDCSubjectClaimCustomTemplate, *Response, error) { func (s *ActionsService) GetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org) u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u) return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
@ -26,7 +28,9 @@ func (s *ActionsService) GetOrgOIDCSubjectClaimCustomTemplate(ctx context.Contex
// GetRepoOIDCSubjectClaimCustomTemplate gets the subject claim customization template for a repository. // GetRepoOIDCSubjectClaimCustomTemplate gets the subject claim customization template for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/oidc/customization/sub
func (s *ActionsService) GetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string) (*OIDCSubjectClaimCustomTemplate, *Response, error) { func (s *ActionsService) GetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u) return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
@ -49,7 +53,9 @@ func (s *ActionsService) getOIDCSubjectClaimCustomTemplate(ctx context.Context,
// SetOrgOIDCSubjectClaimCustomTemplate sets the subject claim customization for an organization. // SetOrgOIDCSubjectClaimCustomTemplate sets the subject claim customization for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/oidc/customization/sub
func (s *ActionsService) SetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) { func (s *ActionsService) SetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org) u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template) return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template)
@ -57,7 +63,9 @@ func (s *ActionsService) SetOrgOIDCSubjectClaimCustomTemplate(ctx context.Contex
// SetRepoOIDCSubjectClaimCustomTemplate sets the subject claim customization for a repository. // SetRepoOIDCSubjectClaimCustomTemplate sets the subject claim customization for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository
//
//meta:operation PUT /repos/{owner}/{repo}/actions/oidc/customization/sub
func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) { func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template) return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template)

View file

@ -0,0 +1,207 @@
// Copyright 2023 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"
)
// ActionsEnabledOnEnterpriseRepos represents all the repositories in an enterprise for which Actions is enabled.
type ActionsEnabledOnEnterpriseRepos struct {
TotalCount int `json:"total_count"`
Organizations []*Organization `json:"organizations"`
}
// ActionsPermissionsEnterprise represents a policy for allowed actions in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions
type ActionsPermissionsEnterprise struct {
EnabledOrganizations *string `json:"enabled_organizations,omitempty"`
AllowedActions *string `json:"allowed_actions,omitempty"`
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
}
func (a ActionsPermissionsEnterprise) String() string {
return Stringify(a)
}
// GetActionsPermissionsInEnterprise gets the GitHub Actions permissions policy for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#get-github-actions-permissions-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/permissions
func (s *ActionsService) GetActionsPermissionsInEnterprise(ctx context.Context, enterprise string) (*ActionsPermissionsEnterprise, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
permissions := new(ActionsPermissionsEnterprise)
resp, err := s.client.Do(ctx, req, permissions)
if err != nil {
return nil, resp, err
}
return permissions, resp, nil
}
// EditActionsPermissionsInEnterprise sets the permissions policy in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#set-github-actions-permissions-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions
func (s *ActionsService) EditActionsPermissionsInEnterprise(ctx context.Context, enterprise string, actionsPermissionsEnterprise ActionsPermissionsEnterprise) (*ActionsPermissionsEnterprise, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions", enterprise)
req, err := s.client.NewRequest("PUT", u, actionsPermissionsEnterprise)
if err != nil {
return nil, nil, err
}
p := new(ActionsPermissionsEnterprise)
resp, err := s.client.Do(ctx, req, p)
if err != nil {
return nil, resp, err
}
return p, resp, nil
}
// ListEnabledOrgsInEnterprise lists the selected organizations that are enabled for GitHub Actions in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#list-selected-organizations-enabled-for-github-actions-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/permissions/organizations
func (s *ActionsService) ListEnabledOrgsInEnterprise(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnEnterpriseRepos, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/organizations", owner)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
orgs := &ActionsEnabledOnEnterpriseRepos{}
resp, err := s.client.Do(ctx, req, orgs)
if err != nil {
return nil, resp, err
}
return orgs, resp, nil
}
// SetEnabledOrgsInEnterprise replaces the list of selected organizations that are enabled for GitHub Actions in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#set-selected-organizations-enabled-for-github-actions-in-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/organizations
func (s *ActionsService) SetEnabledOrgsInEnterprise(ctx context.Context, owner string, organizationIDs []int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/organizations", owner)
req, err := s.client.NewRequest("PUT", u, struct {
IDs []int64 `json:"selected_organization_ids"`
}{IDs: organizationIDs})
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// AddEnabledOrgInEnterprise adds an organization to the list of selected organizations that are enabled for GitHub Actions in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#enable-a-selected-organization-for-github-actions-in-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/organizations/{org_id}
func (s *ActionsService) AddEnabledOrgInEnterprise(ctx context.Context, owner string, organizationID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/organizations/%v", owner, organizationID)
req, err := s.client.NewRequest("PUT", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// RemoveEnabledOrgInEnterprise removes an organization from the list of selected organizations that are enabled for GitHub Actions in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#disable-a-selected-organization-for-github-actions-in-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/permissions/organizations/{org_id}
func (s *ActionsService) RemoveEnabledOrgInEnterprise(ctx context.Context, owner string, organizationID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/organizations/%v", owner, organizationID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// GetActionsAllowedInEnterprise gets the actions that are allowed in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/permissions/selected-actions
func (s *ActionsService) GetActionsAllowedInEnterprise(ctx context.Context, enterprise string) (*ActionsAllowed, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/selected-actions", enterprise)
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
}
// EditActionsAllowedInEnterprise sets the actions that are allowed in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/selected-actions
func (s *ActionsService) EditActionsAllowedInEnterprise(ctx context.Context, enterprise string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/permissions/selected-actions", enterprise)
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
}

View file

@ -0,0 +1,220 @@
// Copyright 2023 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"
)
// ActionsPermissions represents a policy for repositories and allowed actions in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions
type ActionsPermissions struct {
EnabledRepositories *string `json:"enabled_repositories,omitempty"`
AllowedActions *string `json:"allowed_actions,omitempty"`
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
}
func (a ActionsPermissions) String() string {
return Stringify(a)
}
// ActionsEnabledOnOrgRepos represents all the repositories in an organization for which Actions is enabled.
type ActionsEnabledOnOrgRepos struct {
TotalCount int `json:"total_count"`
Repositories []*Repository `json:"repositories"`
}
// ActionsAllowed represents selected actions that are allowed.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions
type ActionsAllowed struct {
GithubOwnedAllowed *bool `json:"github_owned_allowed,omitempty"`
VerifiedAllowed *bool `json:"verified_allowed,omitempty"`
PatternsAllowed []string `json:"patterns_allowed,omitempty"`
}
func (a ActionsAllowed) String() string {
return Stringify(a)
}
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#get-github-actions-permissions-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/permissions
func (s *ActionsService) GetActionsPermissions(ctx context.Context, org string) (*ActionsPermissions, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions", org)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
permissions := new(ActionsPermissions)
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 an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#set-github-actions-permissions-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/permissions
func (s *ActionsService) 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)
if err != nil {
return nil, resp, err
}
return p, resp, nil
}
// ListEnabledReposInOrg lists the selected repositories that are enabled for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization
//
//meta:operation GET /orgs/{org}/actions/permissions/repositories
func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnOrgRepos, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
repos := &ActionsEnabledOnOrgRepos{}
resp, err := s.client.Do(ctx, req, repos)
if err != nil {
return nil, resp, err
}
return repos, resp, nil
}
// SetEnabledReposInOrg replaces the list of selected repositories that are enabled for GitHub Actions in an organization..
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#set-selected-repositories-enabled-for-github-actions-in-an-organization
//
//meta:operation PUT /orgs/{org}/actions/permissions/repositories
func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string, repositoryIDs []int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
req, err := s.client.NewRequest("PUT", u, struct {
IDs []int64 `json:"selected_repository_ids"`
}{IDs: repositoryIDs})
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// AddEnabledReposInOrg adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#enable-a-selected-repository-for-github-actions-in-an-organization
//
//meta:operation PUT /orgs/{org}/actions/permissions/repositories/{repository_id}
func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
req, err := s.client.NewRequest("PUT", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// RemoveEnabledReposInOrg removes a single repository from the list of enabled repos for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#disable-a-selected-repository-for-github-actions-in-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}
func (s *ActionsService) RemoveEnabledReposInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// GetActionsAllowed gets the actions that are allowed in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/permissions/selected-actions
func (s *ActionsService) GetActionsAllowed(ctx context.Context, org string) (*ActionsAllowed, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org)
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 actions that are allowed in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/permissions/selected-actions
func (s *ActionsService) 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)
if err != nil {
return nil, resp, err
}
return p, resp, nil
}

View file

@ -67,7 +67,9 @@ type RepoRequiredWorkflows struct {
// ListOrgRequiredWorkflows lists the RequiredWorkflows for an org. // ListOrgRequiredWorkflows lists the RequiredWorkflows for an org.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-required-workflows // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation GET /orgs/{org}/actions/required_workflows
func (s *ActionsService) ListOrgRequiredWorkflows(ctx context.Context, org string, opts *ListOptions) (*OrgRequiredWorkflows, *Response, error) { func (s *ActionsService) ListOrgRequiredWorkflows(ctx context.Context, org string, opts *ListOptions) (*OrgRequiredWorkflows, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows", org) url := fmt.Sprintf("orgs/%v/actions/required_workflows", org)
u, err := addOptions(url, opts) u, err := addOptions(url, opts)
@ -91,7 +93,9 @@ func (s *ActionsService) ListOrgRequiredWorkflows(ctx context.Context, org strin
// CreateRequiredWorkflow creates the required workflow in an org. // CreateRequiredWorkflow creates the required workflow in an org.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#create-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation POST /orgs/{org}/actions/required_workflows
func (s *ActionsService) CreateRequiredWorkflow(ctx context.Context, org string, createRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) { func (s *ActionsService) CreateRequiredWorkflow(ctx context.Context, org string, createRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows", org) url := fmt.Sprintf("orgs/%v/actions/required_workflows", org)
req, err := s.client.NewRequest("POST", url, createRequiredWorkflowOptions) req, err := s.client.NewRequest("POST", url, createRequiredWorkflowOptions)
@ -110,7 +114,9 @@ func (s *ActionsService) CreateRequiredWorkflow(ctx context.Context, org string,
// GetRequiredWorkflowByID get the RequiredWorkflows for an org by its ID. // GetRequiredWorkflowByID get the RequiredWorkflows for an org by its ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-required-workflows // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation GET /orgs/{org}/actions/required_workflows/{workflow_id}
func (s *ActionsService) GetRequiredWorkflowByID(ctx context.Context, owner string, requiredWorkflowID int64) (*OrgRequiredWorkflow, *Response, error) { func (s *ActionsService) GetRequiredWorkflowByID(ctx context.Context, owner string, requiredWorkflowID int64) (*OrgRequiredWorkflow, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", owner, requiredWorkflowID) u := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", owner, requiredWorkflowID)
@ -130,7 +136,9 @@ func (s *ActionsService) GetRequiredWorkflowByID(ctx context.Context, owner stri
// UpdateRequiredWorkflow updates a required workflow in an org. // UpdateRequiredWorkflow updates a required workflow in an org.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#update-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation PATCH /orgs/{org}/actions/required_workflows/{workflow_id}
func (s *ActionsService) UpdateRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64, updateRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) { func (s *ActionsService) UpdateRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64, updateRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID) url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID)
req, err := s.client.NewRequest("PATCH", url, updateRequiredWorkflowOptions) req, err := s.client.NewRequest("PATCH", url, updateRequiredWorkflowOptions)
@ -149,7 +157,9 @@ func (s *ActionsService) UpdateRequiredWorkflow(ctx context.Context, org string,
// DeleteRequiredWorkflow deletes a required workflow in an org. // DeleteRequiredWorkflow deletes a required workflow in an org.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#update-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation DELETE /orgs/{org}/actions/required_workflows/{workflow_id}
func (s *ActionsService) DeleteRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64) (*Response, error) { func (s *ActionsService) DeleteRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID) url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID)
req, err := s.client.NewRequest("DELETE", url, nil) req, err := s.client.NewRequest("DELETE", url, nil)
@ -161,7 +171,9 @@ func (s *ActionsService) DeleteRequiredWorkflow(ctx context.Context, org string,
// ListRequiredWorkflowSelectedRepos lists the Repositories selected for a workflow. // ListRequiredWorkflowSelectedRepos lists the Repositories selected for a workflow.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-selected-repositories-for-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation GET /orgs/{org}/actions/required_workflows/{workflow_id}/repositories
func (s *ActionsService) ListRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, opts *ListOptions) (*RequiredWorkflowSelectedRepos, *Response, error) { func (s *ActionsService) ListRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, opts *ListOptions) (*RequiredWorkflowSelectedRepos, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories", org, requiredWorkflowID) url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories", org, requiredWorkflowID)
u, err := addOptions(url, opts) u, err := addOptions(url, opts)
@ -184,7 +196,9 @@ func (s *ActionsService) ListRequiredWorkflowSelectedRepos(ctx context.Context,
// SetRequiredWorkflowSelectedRepos sets the Repositories selected for a workflow. // SetRequiredWorkflowSelectedRepos sets the Repositories selected for a workflow.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#sets-repositories-for-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation PUT /orgs/{org}/actions/required_workflows/{workflow_id}/repositories
func (s *ActionsService) SetRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, ids SelectedRepoIDs) (*Response, error) { func (s *ActionsService) SetRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, ids SelectedRepoIDs) (*Response, error) {
type repoIDs struct { type repoIDs struct {
SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"` SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"`
@ -200,7 +214,9 @@ func (s *ActionsService) SetRequiredWorkflowSelectedRepos(ctx context.Context, o
// AddRepoToRequiredWorkflow adds the Repository to a required workflow. // AddRepoToRequiredWorkflow adds the Repository to a required workflow.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#add-a-repository-to-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation PUT /orgs/{org}/actions/required_workflows/{workflow_id}/repositories/{repository_id}
func (s *ActionsService) AddRepoToRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) { func (s *ActionsService) AddRepoToRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID) url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID)
req, err := s.client.NewRequest("PUT", url, nil) req, err := s.client.NewRequest("PUT", url, nil)
@ -212,7 +228,9 @@ func (s *ActionsService) AddRepoToRequiredWorkflow(ctx context.Context, org stri
// RemoveRepoFromRequiredWorkflow removes the Repository from a required workflow. // RemoveRepoFromRequiredWorkflow removes the Repository from a required workflow.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#add-a-repository-to-a-required-workflow // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation DELETE /orgs/{org}/actions/required_workflows/{workflow_id}/repositories/{repository_id}
func (s *ActionsService) RemoveRepoFromRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) { func (s *ActionsService) RemoveRepoFromRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID) url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID)
req, err := s.client.NewRequest("DELETE", url, nil) req, err := s.client.NewRequest("DELETE", url, nil)
@ -224,7 +242,9 @@ func (s *ActionsService) RemoveRepoFromRequiredWorkflow(ctx context.Context, org
// ListRepoRequiredWorkflows lists the RequiredWorkflows for a repo. // ListRepoRequiredWorkflows lists the RequiredWorkflows for a repo.
// //
// Github API docs:https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-repository-required-workflows // GitHub API docs: https://docs.github.com/actions/using-workflows/required-workflows
//
//meta:operation GET /repos/{owner}/{repo}/actions/required_workflows
func (s *ActionsService) ListRepoRequiredWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*RepoRequiredWorkflows, *Response, error) { func (s *ActionsService) ListRepoRequiredWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*RepoRequiredWorkflows, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/required_workflows", owner, repo) url := fmt.Sprintf("repos/%v/%v/actions/required_workflows", owner, repo)
u, err := addOptions(url, opts) u, err := addOptions(url, opts)

View file

@ -80,7 +80,9 @@ type ListOrgRunnerGroupOptions struct {
// ListOrganizationRunnerGroups lists all self-hosted runner groups configured in an organization. // ListOrganizationRunnerGroups lists all self-hosted runner groups configured in an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runner-groups
func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOrgRunnerGroupOptions) (*RunnerGroups, *Response, error) { func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOrgRunnerGroupOptions) (*RunnerGroups, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org) u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -104,7 +106,9 @@ func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org s
// GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID. // GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runner-groups/{runner_group_id}
func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, *Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -123,7 +127,9 @@ func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org str
// DeleteOrganizationRunnerGroup deletes a self-hosted runner group from an organization. // DeleteOrganizationRunnerGroup deletes 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/runner-groups/{runner_group_id}
func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) { func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
@ -137,7 +143,9 @@ func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org
// CreateOrganizationRunnerGroup creates a new self-hosted runner group for an organization. // CreateOrganizationRunnerGroup creates a new 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/runner-groups
func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) { func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org) u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
req, err := s.client.NewRequest("POST", u, createReq) req, err := s.client.NewRequest("POST", u, createReq)
@ -156,7 +164,9 @@ func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org
// UpdateOrganizationRunnerGroup updates a self-hosted runner group for an organization. // UpdateOrganizationRunnerGroup updates 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization
//
//meta:operation PATCH /orgs/{org}/actions/runner-groups/{runner_group_id}
func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org string, groupID int64, updateReq UpdateRunnerGroupRequest) (*RunnerGroup, *Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
req, err := s.client.NewRequest("PATCH", u, updateReq) req, err := s.client.NewRequest("PATCH", u, updateReq)
@ -175,7 +185,9 @@ func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org
// ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization. // 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/actions/self-hosted-runner-groups#list-repository-access-to-a-self-hosted-runner-group-in-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
//
//meta:operation GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories
func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, opts *ListOptions) (*ListRepositories, *Response, error) { 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 := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -200,7 +212,9 @@ 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 // 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. // with a new List of repositories.
// //
// 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#set-repository-access-for-a-self-hosted-runner-group-in-an-organization
//
//meta:operation PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories
func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, ids SetRepoAccessRunnerGroupRequest) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
@ -215,7 +229,9 @@ 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. // 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'. // The runner group must have visibility set to 'selected'.
// //
// 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#add-repository-access-to-a-self-hosted-runner-group-in-an-organization
//
//meta:operation PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}
func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
@ -230,7 +246,9 @@ 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. // 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'. // The runner group must have visibility set to 'selected'.
// //
// 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}
func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
@ -244,7 +262,9 @@ func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context,
// ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group. // ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners
func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string, groupID int64, opts *ListOptions) (*Runners, *Response, error) { 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 := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -269,7 +289,9 @@ 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 // SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an organization runner group
// with a new list of runners. // with a new list of runners.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/runners
func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
@ -283,7 +305,9 @@ func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string,
// AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an organization. // AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#add-a-self-hosted-runner-to-a-group-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}
func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)
@ -298,7 +322,9 @@ func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string,
// RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization. // RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization.
// The runner is then returned to the default group. // The runner is then returned to the default group.
// //
// 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 // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id}
func (s *ActionsService) RemoveRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)

View file

@ -20,15 +20,11 @@ type RunnerApplicationDownload struct {
SHA256Checksum *string `json:"sha256_checksum,omitempty"` SHA256Checksum *string `json:"sha256_checksum,omitempty"`
} }
// ActionsEnabledOnOrgRepos represents all the repositories in an organization for which Actions is enabled.
type ActionsEnabledOnOrgRepos struct {
TotalCount int `json:"total_count"`
Repositories []*Repository `json:"repositories"`
}
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // 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 // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/runners/downloads
func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) { func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runners/downloads", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/runners/downloads", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -64,7 +60,9 @@ type JITRunnerConfig struct {
// GenerateOrgJITConfig generate a just-in-time configuration for an organization. // GenerateOrgJITConfig generate a just-in-time configuration for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/runners/generate-jitconfig
func (s *ActionsService) GenerateOrgJITConfig(ctx context.Context, owner string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) { func (s *ActionsService) GenerateOrgJITConfig(ctx context.Context, owner string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/generate-jitconfig", owner) u := fmt.Sprintf("orgs/%v/actions/runners/generate-jitconfig", owner)
req, err := s.client.NewRequest("POST", u, request) req, err := s.client.NewRequest("POST", u, request)
@ -83,7 +81,9 @@ func (s *ActionsService) GenerateOrgJITConfig(ctx context.Context, owner string,
// GenerateRepoJITConfig generates a just-in-time configuration for a repository. // GenerateRepoJITConfig generates a just-in-time configuration for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig
func (s *ActionsService) GenerateRepoJITConfig(ctx context.Context, owner, repo string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) { func (s *ActionsService) GenerateRepoJITConfig(ctx context.Context, owner, repo string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runners/generate-jitconfig", owner, repo) u := fmt.Sprintf("repos/%v/%v/actions/runners/generate-jitconfig", owner, repo)
req, err := s.client.NewRequest("POST", u, request) req, err := s.client.NewRequest("POST", u, request)
@ -108,7 +108,9 @@ type RegistrationToken struct {
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner. // CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/actions/runners/registration-token
func (s *ActionsService) CreateRegistrationToken(ctx context.Context, owner, repo string) (*RegistrationToken, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runners/registration-token", owner, repo)
@ -151,7 +153,9 @@ type Runners struct {
// ListRunners lists all the self-hosted runners for a repository. // ListRunners lists all the 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 // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/runners
func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/actions/runners", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -175,7 +179,9 @@ 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. // GetRunner gets a specific self-hosted runner for a repository using its runner ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/runners/{runner_id}
func (s *ActionsService) GetRunner(ctx context.Context, owner, repo string, runnerID int64) (*Runner, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -200,7 +206,9 @@ type RemoveToken struct {
// CreateRemoveToken creates a token that can be used to remove a self-hosted runner from a repository. // 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/rest/actions/self-hosted-runners#create-a-remove-token-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-a-remove-token-for-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/actions/runners/remove-token
func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo string) (*RemoveToken, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runners/remove-token", owner, repo)
@ -220,7 +228,9 @@ 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. // RemoveRunner forces the removal of a self-hosted runner in a repository using the runner id.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-a-repository // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-a-repository
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}
func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
@ -234,7 +244,9 @@ func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, r
// ListOrganizationRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // ListOrganizationRunnerApplicationDownloads 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-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-runner-applications-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runners/downloads
func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) { func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/downloads", owner) u := fmt.Sprintf("orgs/%v/actions/runners/downloads", owner)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -253,7 +265,9 @@ func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.
// CreateOrganizationRegistrationToken creates a token that can be used to add a self-hosted runner to an organization. // 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/rest/actions/self-hosted-runners#create-a-registration-token-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-a-registration-token-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/runners/registration-token
func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) { func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/registration-token", owner) u := fmt.Sprintf("orgs/%v/actions/runners/registration-token", owner)
@ -273,7 +287,9 @@ func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context
// ListOrganizationRunners lists all the self-hosted runners for an organization. // ListOrganizationRunners lists all the 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 // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runners
func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) { func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners", owner) u := fmt.Sprintf("orgs/%v/actions/runners", owner)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -295,92 +311,11 @@ func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner stri
return runners, resp, nil return runners, resp, nil
} }
// ListEnabledReposInOrg lists the selected repositories that are enabled for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/en/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)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
repos := &ActionsEnabledOnOrgRepos{}
resp, err := s.client.Do(ctx, req, repos)
if err != nil {
return nil, resp, err
}
return repos, resp, nil
}
// SetEnabledReposInOrg replaces the list of selected repositories that are enabled for GitHub Actions in an organization..
//
// GitHub API docs: https://docs.github.com/en/rest/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)
req, err := s.client.NewRequest("PUT", u, struct {
IDs []int64 `json:"selected_repository_ids"`
}{IDs: repositoryIDs})
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// AddEnabledReposInOrg adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/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)
req, err := s.client.NewRequest("PUT", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// RemoveEnabledRepoInOrg removes a single repository from the list of enabled repos for GitHub Actions in an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/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)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID. // GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/runners/{runner_id}
func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) { func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID) u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -399,7 +334,9 @@ 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. // 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/rest/actions/self-hosted-runners#create-a-remove-token-for-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#create-a-remove-token-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/runners/remove-token
func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) { func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/remove-token", owner) u := fmt.Sprintf("orgs/%v/actions/runners/remove-token", owner)
@ -419,7 +356,9 @@ func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owne
// RemoveOrganizationRunner forces the removal of a self-hosted runner from an organization using the runner id. // RemoveOrganizationRunner forces the removal of a self-hosted runner from an organization using the runner id.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-organization // GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/runners/{runner_id}
func (s *ActionsService) RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) { func (s *ActionsService) RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID) u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)

View file

@ -64,7 +64,9 @@ func (s *ActionsService) getPublicKey(ctx context.Context, url string) (*PublicK
// GetRepoPublicKey gets a public key that should be used for secret encryption. // GetRepoPublicKey gets a public key that should be used for secret encryption.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-public-key // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-a-repository-public-key
//
//meta:operation GET /repos/{owner}/{repo}/actions/secrets/public-key
func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/actions/secrets/public-key", owner, repo)
return s.getPublicKey(ctx, url) return s.getPublicKey(ctx, url)
@ -72,7 +74,9 @@ func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo strin
// GetOrgPublicKey gets a public key that should be used for secret encryption. // GetOrgPublicKey gets a public key that should be used for secret encryption.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-public-key // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-organization-public-key
//
//meta:operation GET /orgs/{org}/actions/secrets/public-key
func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) { func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org) url := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org)
return s.getPublicKey(ctx, url) return s.getPublicKey(ctx, url)
@ -80,7 +84,9 @@ func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*Publ
// GetEnvPublicKey gets a public key that should be used for secret encryption. // GetEnvPublicKey gets a public key that should be used for secret encryption.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-environment-public-key
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key
func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) { 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) url := fmt.Sprintf("repositories/%v/environments/%v/secrets/public-key", repoID, env)
return s.getPublicKey(ctx, url) return s.getPublicKey(ctx, url)
@ -124,7 +130,9 @@ func (s *ActionsService) listSecrets(ctx context.Context, url string, opts *List
// ListRepoSecrets lists all secrets available in a repository // ListRepoSecrets lists all secrets available in a repository
// without revealing their encrypted values. // without revealing their encrypted values.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-repository-secrets // GitHub API docs: https://docs.github.com/rest/actions/secrets#list-repository-secrets
//
//meta:operation GET /repos/{owner}/{repo}/actions/secrets
func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/actions/secrets", owner, repo)
return s.listSecrets(ctx, url, opts) return s.listSecrets(ctx, url, opts)
@ -133,7 +141,9 @@ func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string
// ListOrgSecrets lists all secrets available in an organization // ListOrgSecrets lists all secrets available in an organization
// without revealing their encrypted values. // without revealing their encrypted values.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-organization-secrets // GitHub API docs: https://docs.github.com/rest/actions/secrets#list-organization-secrets
//
//meta:operation GET /orgs/{org}/actions/secrets
func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) { func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/secrets", org) url := fmt.Sprintf("orgs/%v/actions/secrets", org)
return s.listSecrets(ctx, url, opts) return s.listSecrets(ctx, url, opts)
@ -141,7 +151,9 @@ func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *L
// ListEnvSecrets lists all secrets available in an environment. // ListEnvSecrets lists all secrets available in an environment.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-environment-secrets // GitHub API docs: https://docs.github.com/rest/actions/secrets#list-environment-secrets
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets
func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) { 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) url := fmt.Sprintf("repositories/%v/environments/%v/secrets", repoID, env)
return s.listSecrets(ctx, url, opts) return s.listSecrets(ctx, url, opts)
@ -164,7 +176,9 @@ func (s *ActionsService) getSecret(ctx context.Context, url string) (*Secret, *R
// GetRepoSecret gets a single repository secret without revealing its encrypted value. // GetRepoSecret gets a single repository secret without revealing its encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-a-repository-secret
//
//meta:operation GET /repos/{owner}/{repo}/actions/secrets/{secret_name}
func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
return s.getSecret(ctx, url) return s.getSecret(ctx, url)
@ -172,7 +186,9 @@ func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name st
// GetOrgSecret gets a single organization secret without revealing its encrypted value. // GetOrgSecret gets a single organization secret without revealing its encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-organization-secret
//
//meta:operation GET /orgs/{org}/actions/secrets/{secret_name}
func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) { func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name) url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
return s.getSecret(ctx, url) return s.getSecret(ctx, url)
@ -180,7 +196,9 @@ func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*S
// GetEnvSecret gets a single environment secret without revealing its encrypted value. // GetEnvSecret gets a single environment secret without revealing its encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-environment-secret
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) { 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) url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
return s.getSecret(ctx, url) return s.getSecret(ctx, url)
@ -213,7 +231,9 @@ func (s *ActionsService) putSecret(ctx context.Context, url string, eSecret *Enc
// CreateOrUpdateRepoSecret creates or updates a repository secret with an encrypted value. // CreateOrUpdateRepoSecret creates or updates a repository secret with an encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#create-or-update-a-repository-secret
//
//meta:operation PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, eSecret.Name)
return s.putSecret(ctx, url, eSecret) return s.putSecret(ctx, url, eSecret)
@ -221,7 +241,9 @@ func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, re
// CreateOrUpdateOrgSecret creates or updates an organization secret with an encrypted value. // CreateOrUpdateOrgSecret creates or updates an organization secret with an encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret
//
//meta:operation PUT /orgs/{org}/actions/secrets/{secret_name}
func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) { func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name) url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name)
return s.putSecret(ctx, url, eSecret) return s.putSecret(ctx, url, eSecret)
@ -229,7 +251,9 @@ func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string
// CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value. // CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#create-or-update-an-environment-secret
//
//meta:operation PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) { 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) url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, eSecret.Name)
return s.putSecret(ctx, url, eSecret) return s.putSecret(ctx, url, eSecret)
@ -246,7 +270,9 @@ func (s *ActionsService) deleteSecret(ctx context.Context, url string) (*Respons
// DeleteRepoSecret deletes a secret in a repository using the secret name. // DeleteRepoSecret deletes a secret in a repository using the secret name.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-a-repository-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#delete-a-repository-secret
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}
func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
return s.deleteSecret(ctx, url) return s.deleteSecret(ctx, url)
@ -254,7 +280,9 @@ func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name
// DeleteOrgSecret deletes a secret in an organization using the secret name. // DeleteOrgSecret deletes a secret in an organization using the secret name.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#delete-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/actions/secrets/{secret_name}
func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) { func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name) url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
return s.deleteSecret(ctx, url) return s.deleteSecret(ctx, url)
@ -262,7 +290,9 @@ func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string)
// DeleteEnvSecret deletes a secret in an environment using the secret name. // DeleteEnvSecret deletes a secret in an environment using the secret name.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#delete-an-environment-secret
//
//meta:operation DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) { 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) url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
return s.deleteSecret(ctx, url) return s.deleteSecret(ctx, url)
@ -296,7 +326,9 @@ func (s *ActionsService) listSelectedReposForSecret(ctx context.Context, url str
// ListSelectedReposForOrgSecret lists all repositories that have access to a secret. // ListSelectedReposForOrgSecret lists all repositories that have access to a secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-selected-repositories-for-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#list-selected-repositories-for-an-organization-secret
//
//meta:operation GET /orgs/{org}/actions/secrets/{secret_name}/repositories
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { 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) url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
return s.listSelectedReposForSecret(ctx, url, opts) return s.listSelectedReposForSecret(ctx, url, opts)
@ -317,7 +349,9 @@ func (s *ActionsService) setSelectedReposForSecret(ctx context.Context, url stri
// SetSelectedReposForOrgSecret sets the repositories that have access to a secret. // SetSelectedReposForOrgSecret sets the repositories that have access to a secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#set-selected-repositories-for-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#set-selected-repositories-for-an-organization-secret
//
//meta:operation PUT /orgs/{org}/actions/secrets/{secret_name}/repositories
func (s *ActionsService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
return s.setSelectedReposForSecret(ctx, url, ids) return s.setSelectedReposForSecret(ctx, url, ids)
@ -334,7 +368,9 @@ func (s *ActionsService) addSelectedRepoToSecret(ctx context.Context, url string
// AddSelectedRepoToOrgSecret adds a repository to an organization secret. // AddSelectedRepoToOrgSecret adds a repository to an organization secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#add-selected-repository-to-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#add-selected-repository-to-an-organization-secret
//
//meta:operation PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}
func (s *ActionsService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
return s.addSelectedRepoToSecret(ctx, url) return s.addSelectedRepoToSecret(ctx, url)
@ -351,7 +387,9 @@ func (s *ActionsService) removeSelectedRepoFromSecret(ctx context.Context, url s
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization secret. // RemoveSelectedRepoFromOrgSecret removes a repository from an organization secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#remove-selected-repository-from-an-organization-secret // GitHub API docs: https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}
func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
return s.removeSelectedRepoFromSecret(ctx, url) return s.removeSelectedRepoFromSecret(ctx, url)

View file

@ -51,7 +51,9 @@ func (s *ActionsService) listVariables(ctx context.Context, url string, opts *Li
// ListRepoVariables lists all variables available in a repository. // ListRepoVariables lists all variables available in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#list-repository-variables // GitHub API docs: https://docs.github.com/rest/actions/variables#list-repository-variables
//
//meta:operation GET /repos/{owner}/{repo}/actions/variables
func (s *ActionsService) ListRepoVariables(ctx context.Context, owner, repo string, opts *ListOptions) (*ActionsVariables, *Response, error) { func (s *ActionsService) ListRepoVariables(ctx context.Context, owner, repo string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/variables", owner, repo) url := fmt.Sprintf("repos/%v/%v/actions/variables", owner, repo)
return s.listVariables(ctx, url, opts) return s.listVariables(ctx, url, opts)
@ -59,7 +61,9 @@ func (s *ActionsService) ListRepoVariables(ctx context.Context, owner, repo stri
// ListOrgVariables lists all variables available in an organization. // ListOrgVariables lists all variables available in an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#list-organization-variables // GitHub API docs: https://docs.github.com/rest/actions/variables#list-organization-variables
//
//meta:operation GET /orgs/{org}/actions/variables
func (s *ActionsService) ListOrgVariables(ctx context.Context, org string, opts *ListOptions) (*ActionsVariables, *Response, error) { func (s *ActionsService) ListOrgVariables(ctx context.Context, org string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables", org) url := fmt.Sprintf("orgs/%v/actions/variables", org)
return s.listVariables(ctx, url, opts) return s.listVariables(ctx, url, opts)
@ -67,7 +71,9 @@ func (s *ActionsService) ListOrgVariables(ctx context.Context, org string, opts
// ListEnvVariables lists all variables available in an environment. // ListEnvVariables lists all variables available in an environment.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#list-environment-variables // GitHub API docs: https://docs.github.com/rest/actions/variables#list-environment-variables
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/variables
func (s *ActionsService) ListEnvVariables(ctx context.Context, repoID int, env string, opts *ListOptions) (*ActionsVariables, *Response, error) { func (s *ActionsService) ListEnvVariables(ctx context.Context, repoID int, env string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env) url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env)
return s.listVariables(ctx, url, opts) return s.listVariables(ctx, url, opts)
@ -90,7 +96,9 @@ func (s *ActionsService) getVariable(ctx context.Context, url string) (*ActionsV
// GetRepoVariable gets a single repository variable. // GetRepoVariable gets a single repository variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#get-a-repository-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#get-a-repository-variable
//
//meta:operation GET /repos/{owner}/{repo}/actions/variables/{name}
func (s *ActionsService) GetRepoVariable(ctx context.Context, owner, repo, name string) (*ActionsVariable, *Response, error) { func (s *ActionsService) GetRepoVariable(ctx context.Context, owner, repo, name string) (*ActionsVariable, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, name) url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, name)
return s.getVariable(ctx, url) return s.getVariable(ctx, url)
@ -98,7 +106,9 @@ func (s *ActionsService) GetRepoVariable(ctx context.Context, owner, repo, name
// GetOrgVariable gets a single organization variable. // GetOrgVariable gets a single organization variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#get-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#get-an-organization-variable
//
//meta:operation GET /orgs/{org}/actions/variables/{name}
func (s *ActionsService) GetOrgVariable(ctx context.Context, org, name string) (*ActionsVariable, *Response, error) { func (s *ActionsService) GetOrgVariable(ctx context.Context, org, name string) (*ActionsVariable, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, name) url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, name)
return s.getVariable(ctx, url) return s.getVariable(ctx, url)
@ -106,7 +116,9 @@ func (s *ActionsService) GetOrgVariable(ctx context.Context, org, name string) (
// GetEnvVariable gets a single environment variable. // GetEnvVariable gets a single environment variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#get-an-environment-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#get-an-environment-variable
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) GetEnvVariable(ctx context.Context, repoID int, env, variableName string) (*ActionsVariable, *Response, error) { func (s *ActionsService) GetEnvVariable(ctx context.Context, repoID int, env, variableName string) (*ActionsVariable, *Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName) url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName)
return s.getVariable(ctx, url) return s.getVariable(ctx, url)
@ -122,7 +134,9 @@ func (s *ActionsService) postVariable(ctx context.Context, url string, variable
// CreateRepoVariable creates a repository variable. // CreateRepoVariable creates a repository variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#create-a-repository-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#create-a-repository-variable
//
//meta:operation POST /repos/{owner}/{repo}/actions/variables
func (s *ActionsService) CreateRepoVariable(ctx context.Context, owner, repo string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) CreateRepoVariable(ctx context.Context, owner, repo string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/variables", owner, repo) url := fmt.Sprintf("repos/%v/%v/actions/variables", owner, repo)
return s.postVariable(ctx, url, variable) return s.postVariable(ctx, url, variable)
@ -130,7 +144,9 @@ func (s *ActionsService) CreateRepoVariable(ctx context.Context, owner, repo str
// CreateOrgVariable creates an organization variable. // CreateOrgVariable creates an organization variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#create-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#create-an-organization-variable
//
//meta:operation POST /orgs/{org}/actions/variables
func (s *ActionsService) CreateOrgVariable(ctx context.Context, org string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) CreateOrgVariable(ctx context.Context, org string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables", org) url := fmt.Sprintf("orgs/%v/actions/variables", org)
return s.postVariable(ctx, url, variable) return s.postVariable(ctx, url, variable)
@ -138,7 +154,9 @@ func (s *ActionsService) CreateOrgVariable(ctx context.Context, org string, vari
// CreateEnvVariable creates an environment variable. // CreateEnvVariable creates an environment variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#create-an-environment-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#create-an-environment-variable
//
//meta:operation POST /repositories/{repository_id}/environments/{environment_name}/variables
func (s *ActionsService) CreateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) CreateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env) url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env)
return s.postVariable(ctx, url, variable) return s.postVariable(ctx, url, variable)
@ -154,7 +172,9 @@ func (s *ActionsService) patchVariable(ctx context.Context, url string, variable
// UpdateRepoVariable updates a repository variable. // UpdateRepoVariable updates a repository variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#update-a-repository-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#update-a-repository-variable
//
//meta:operation PATCH /repos/{owner}/{repo}/actions/variables/{name}
func (s *ActionsService) UpdateRepoVariable(ctx context.Context, owner, repo string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) UpdateRepoVariable(ctx context.Context, owner, repo string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, variable.Name) url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, variable.Name)
return s.patchVariable(ctx, url, variable) return s.patchVariable(ctx, url, variable)
@ -162,7 +182,9 @@ func (s *ActionsService) UpdateRepoVariable(ctx context.Context, owner, repo str
// UpdateOrgVariable updates an organization variable. // UpdateOrgVariable updates an organization variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#update-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#update-an-organization-variable
//
//meta:operation PATCH /orgs/{org}/actions/variables/{name}
func (s *ActionsService) UpdateOrgVariable(ctx context.Context, org string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) UpdateOrgVariable(ctx context.Context, org string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, variable.Name) url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, variable.Name)
return s.patchVariable(ctx, url, variable) return s.patchVariable(ctx, url, variable)
@ -170,7 +192,9 @@ func (s *ActionsService) UpdateOrgVariable(ctx context.Context, org string, vari
// UpdateEnvVariable updates an environment variable. // UpdateEnvVariable updates an environment variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#create-an-environment-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#update-an-environment-variable
//
//meta:operation PATCH /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) UpdateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) { func (s *ActionsService) UpdateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variable.Name) url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variable.Name)
return s.patchVariable(ctx, url, variable) return s.patchVariable(ctx, url, variable)
@ -187,7 +211,9 @@ func (s *ActionsService) deleteVariable(ctx context.Context, url string) (*Respo
// DeleteRepoVariable deletes a variable in a repository. // DeleteRepoVariable deletes a variable in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#delete-a-repository-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#delete-a-repository-variable
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/variables/{name}
func (s *ActionsService) DeleteRepoVariable(ctx context.Context, owner, repo, name string) (*Response, error) { func (s *ActionsService) DeleteRepoVariable(ctx context.Context, owner, repo, name string) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, name) url := fmt.Sprintf("repos/%v/%v/actions/variables/%v", owner, repo, name)
return s.deleteVariable(ctx, url) return s.deleteVariable(ctx, url)
@ -195,7 +221,9 @@ func (s *ActionsService) DeleteRepoVariable(ctx context.Context, owner, repo, na
// DeleteOrgVariable deletes a variable in an organization. // DeleteOrgVariable deletes a variable in an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#delete-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#delete-an-organization-variable
//
//meta:operation DELETE /orgs/{org}/actions/variables/{name}
func (s *ActionsService) DeleteOrgVariable(ctx context.Context, org, name string) (*Response, error) { func (s *ActionsService) DeleteOrgVariable(ctx context.Context, org, name string) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, name) url := fmt.Sprintf("orgs/%v/actions/variables/%v", org, name)
return s.deleteVariable(ctx, url) return s.deleteVariable(ctx, url)
@ -203,7 +231,9 @@ func (s *ActionsService) DeleteOrgVariable(ctx context.Context, org, name string
// DeleteEnvVariable deletes a variable in an environment. // DeleteEnvVariable deletes a variable in an environment.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#delete-an-environment-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#delete-an-environment-variable
//
//meta:operation DELETE /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) DeleteEnvVariable(ctx context.Context, repoID int, env, variableName string) (*Response, error) { func (s *ActionsService) DeleteEnvVariable(ctx context.Context, repoID int, env, variableName string) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName) url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName)
return s.deleteVariable(ctx, url) return s.deleteVariable(ctx, url)
@ -231,7 +261,9 @@ func (s *ActionsService) listSelectedReposForVariable(ctx context.Context, url s
// ListSelectedReposForOrgVariable lists all repositories that have access to a variable. // ListSelectedReposForOrgVariable lists all repositories that have access to a variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#list-selected-repositories-for-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#list-selected-repositories-for-an-organization-variable
//
//meta:operation GET /orgs/{org}/actions/variables/{name}/repositories
func (s *ActionsService) ListSelectedReposForOrgVariable(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { func (s *ActionsService) ListSelectedReposForOrgVariable(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories", org, name) url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories", org, name)
return s.listSelectedReposForVariable(ctx, url, opts) return s.listSelectedReposForVariable(ctx, url, opts)
@ -252,7 +284,9 @@ func (s *ActionsService) setSelectedReposForVariable(ctx context.Context, url st
// SetSelectedReposForOrgVariable sets the repositories that have access to a variable. // SetSelectedReposForOrgVariable sets the repositories that have access to a variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#set-selected-repositories-for-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#set-selected-repositories-for-an-organization-variable
//
//meta:operation PUT /orgs/{org}/actions/variables/{name}/repositories
func (s *ActionsService) SetSelectedReposForOrgVariable(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) { func (s *ActionsService) SetSelectedReposForOrgVariable(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories", org, name) url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories", org, name)
return s.setSelectedReposForVariable(ctx, url, ids) return s.setSelectedReposForVariable(ctx, url, ids)
@ -269,7 +303,9 @@ func (s *ActionsService) addSelectedRepoToVariable(ctx context.Context, url stri
// AddSelectedRepoToOrgVariable adds a repository to an organization variable. // AddSelectedRepoToOrgVariable adds a repository to an organization variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#add-selected-repository-to-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#add-selected-repository-to-an-organization-variable
//
//meta:operation PUT /orgs/{org}/actions/variables/{name}/repositories/{repository_id}
func (s *ActionsService) AddSelectedRepoToOrgVariable(ctx context.Context, org, name string, repo *Repository) (*Response, error) { func (s *ActionsService) AddSelectedRepoToOrgVariable(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories/%v", org, name, *repo.ID) url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories/%v", org, name, *repo.ID)
return s.addSelectedRepoToVariable(ctx, url) return s.addSelectedRepoToVariable(ctx, url)
@ -286,7 +322,9 @@ func (s *ActionsService) removeSelectedRepoFromVariable(ctx context.Context, url
// RemoveSelectedRepoFromOrgVariable removes a repository from an organization variable. // RemoveSelectedRepoFromOrgVariable removes a repository from an organization variable.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/variables#remove-selected-repository-from-an-organization-variable // GitHub API docs: https://docs.github.com/rest/actions/variables#remove-selected-repository-from-an-organization-variable
//
//meta:operation DELETE /orgs/{org}/actions/variables/{name}/repositories/{repository_id}
func (s *ActionsService) RemoveSelectedRepoFromOrgVariable(ctx context.Context, org, name string, repo *Repository) (*Response, error) { func (s *ActionsService) RemoveSelectedRepoFromOrgVariable(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories/%v", org, name, *repo.ID) url := fmt.Sprintf("orgs/%v/actions/variables/%v/repositories/%v", org, name, *repo.ID)
return s.removeSelectedRepoFromVariable(ctx, url) return s.removeSelectedRepoFromVariable(ctx, url)

View file

@ -70,7 +70,9 @@ type ListWorkflowJobsOptions struct {
// ListWorkflowJobs lists all jobs for a workflow run. // ListWorkflowJobs lists all jobs for a workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run // GitHub API docs: https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs
func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) { 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 := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -94,7 +96,9 @@ func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo strin
// GetWorkflowJobByID gets a specific job in a workflow run by ID. // GetWorkflowJobByID gets a specific job in a workflow run by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run // GitHub API docs: https://docs.github.com/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run
//
//meta:operation GET /repos/{owner}/{repo}/actions/jobs/{job_id}
func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID)
@ -114,11 +118,13 @@ 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. // 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/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run // GitHub API docs: https://docs.github.com/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) { //
//meta:operation GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs
func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID) u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -14,39 +14,40 @@ import (
// WorkflowRun represents a repository action workflow run. // WorkflowRun represents a repository action workflow run.
type WorkflowRun struct { type WorkflowRun struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
NodeID *string `json:"node_id,omitempty"` NodeID *string `json:"node_id,omitempty"`
HeadBranch *string `json:"head_branch,omitempty"` HeadBranch *string `json:"head_branch,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"` HeadSHA *string `json:"head_sha,omitempty"`
RunNumber *int `json:"run_number,omitempty"` RunNumber *int `json:"run_number,omitempty"`
RunAttempt *int `json:"run_attempt,omitempty"` RunAttempt *int `json:"run_attempt,omitempty"`
Event *string `json:"event,omitempty"` Event *string `json:"event,omitempty"`
DisplayTitle *string `json:"display_title,omitempty"` DisplayTitle *string `json:"display_title,omitempty"`
Status *string `json:"status,omitempty"` Status *string `json:"status,omitempty"`
Conclusion *string `json:"conclusion,omitempty"` Conclusion *string `json:"conclusion,omitempty"`
WorkflowID *int64 `json:"workflow_id,omitempty"` WorkflowID *int64 `json:"workflow_id,omitempty"`
CheckSuiteID *int64 `json:"check_suite_id,omitempty"` CheckSuiteID *int64 `json:"check_suite_id,omitempty"`
CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"` CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"`
URL *string `json:"url,omitempty"` URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"` HTMLURL *string `json:"html_url,omitempty"`
PullRequests []*PullRequest `json:"pull_requests,omitempty"` PullRequests []*PullRequest `json:"pull_requests,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"`
RunStartedAt *Timestamp `json:"run_started_at,omitempty"` RunStartedAt *Timestamp `json:"run_started_at,omitempty"`
JobsURL *string `json:"jobs_url,omitempty"` JobsURL *string `json:"jobs_url,omitempty"`
LogsURL *string `json:"logs_url,omitempty"` LogsURL *string `json:"logs_url,omitempty"`
CheckSuiteURL *string `json:"check_suite_url,omitempty"` CheckSuiteURL *string `json:"check_suite_url,omitempty"`
ArtifactsURL *string `json:"artifacts_url,omitempty"` ArtifactsURL *string `json:"artifacts_url,omitempty"`
CancelURL *string `json:"cancel_url,omitempty"` CancelURL *string `json:"cancel_url,omitempty"`
RerunURL *string `json:"rerun_url,omitempty"` RerunURL *string `json:"rerun_url,omitempty"`
PreviousAttemptURL *string `json:"previous_attempt_url,omitempty"` PreviousAttemptURL *string `json:"previous_attempt_url,omitempty"`
HeadCommit *HeadCommit `json:"head_commit,omitempty"` HeadCommit *HeadCommit `json:"head_commit,omitempty"`
WorkflowURL *string `json:"workflow_url,omitempty"` WorkflowURL *string `json:"workflow_url,omitempty"`
Repository *Repository `json:"repository,omitempty"` Repository *Repository `json:"repository,omitempty"`
HeadRepository *Repository `json:"head_repository,omitempty"` HeadRepository *Repository `json:"head_repository,omitempty"`
Actor *User `json:"actor,omitempty"` Actor *User `json:"actor,omitempty"`
TriggeringActor *User `json:"triggering_actor,omitempty"` TriggeringActor *User `json:"triggering_actor,omitempty"`
ReferencedWorkflows []*ReferencedWorkflow `json:"referenced_workflows,omitempty"`
} }
// WorkflowRuns represents a slice of repository action workflow run. // WorkflowRuns represents a slice of repository action workflow run.
@ -104,6 +105,12 @@ type PendingDeploymentsRequest struct {
Comment string `json:"comment"` Comment string `json:"comment"`
} }
type ReferencedWorkflow struct {
Path *string `json:"path,omitempty"`
SHA *string `json:"sha,omitempty"`
Ref *string `json:"ref,omitempty"`
}
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
u, err := addOptions(endpoint, opts) u, err := addOptions(endpoint, opts)
if err != nil { if err != nil {
@ -126,7 +133,9 @@ func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string,
// ListWorkflowRunsByID lists all workflow runs by workflow ID. // ListWorkflowRunsByID lists all workflow runs by workflow ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-workflow
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs
func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { 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) u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowID)
return s.listWorkflowRuns(ctx, u, opts) return s.listWorkflowRuns(ctx, u, opts)
@ -134,7 +143,9 @@ func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo s
// ListWorkflowRunsByFileName lists all workflow runs by workflow file name. // ListWorkflowRunsByFileName lists all workflow runs by workflow file name.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-workflow
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs
func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { 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) u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowFileName)
return s.listWorkflowRuns(ctx, u, opts) return s.listWorkflowRuns(ctx, u, opts)
@ -142,7 +153,9 @@ func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner,
// ListRepositoryWorkflowRuns lists all workflow runs for a repository. // ListRepositoryWorkflowRuns lists all workflow runs for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs
func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { 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 := fmt.Sprintf("repos/%s/%s/actions/runs", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -166,7 +179,9 @@ func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner,
// GetWorkflowRunByID gets a specific workflow run by ID. // GetWorkflowRunByID gets a specific workflow run by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}
func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
@ -186,7 +201,9 @@ func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo str
// GetWorkflowRunAttempt gets a specific workflow run attempt. // GetWorkflowRunAttempt gets a specific workflow run attempt.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run-attempt // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run-attempt
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}
func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo string, runID int64, attemptNumber int, opts *WorkflowRunAttemptOptions) (*WorkflowRun, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v", owner, repo, runID, attemptNumber)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -210,11 +227,13 @@ func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo
// GetWorkflowRunAttemptLogs gets a redirect URL to download a plain text file of logs for a workflow run for attempt number. // GetWorkflowRunAttemptLogs gets a redirect URL to download a plain text file of logs for a workflow run for attempt number.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#download-workflow-run-attempt-logs // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#download-workflow-run-attempt-logs
func (s *ActionsService) GetWorkflowRunAttemptLogs(ctx context.Context, owner, repo string, runID int64, attemptNumber int, followRedirects bool) (*url.URL, *Response, error) { //
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/logs
func (s *ActionsService) GetWorkflowRunAttemptLogs(ctx context.Context, owner, repo string, runID int64, attemptNumber int, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v/logs", owner, repo, runID, attemptNumber) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v/logs", owner, repo, runID, attemptNumber)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -230,7 +249,9 @@ func (s *ActionsService) GetWorkflowRunAttemptLogs(ctx context.Context, owner, r
// RerunWorkflowByID re-runs a workflow by ID. // RerunWorkflowByID re-runs a workflow by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#re-run-a-workflow
//
//meta:operation POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun
func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun", owner, repo, runID)
@ -244,7 +265,9 @@ func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo stri
// RerunFailedJobsByID re-runs all of the failed jobs and their dependent jobs in a workflow run by ID. // 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 // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#re-run-failed-jobs-from-a-workflow-run
//
//meta:operation POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs
func (s *ActionsService) RerunFailedJobsByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun-failed-jobs", owner, repo, runID)
@ -258,7 +281,9 @@ func (s *ActionsService) RerunFailedJobsByID(ctx context.Context, owner, repo st
// RerunJobByID re-runs a job and its dependent jobs in a workflow run by ID. // 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 // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run
//
//meta:operation POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun
func (s *ActionsService) RerunJobByID(ctx context.Context, owner, repo string, jobID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/rerun", owner, repo, jobID)
@ -272,7 +297,9 @@ func (s *ActionsService) RerunJobByID(ctx context.Context, owner, repo string, j
// CancelWorkflowRunByID cancels a workflow run by ID. // CancelWorkflowRunByID cancels a workflow run by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#cancel-a-workflow-run // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#cancel-a-workflow-run
//
//meta:operation POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel
func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/cancel", owner, repo, runID)
@ -286,11 +313,13 @@ 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. // 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/rest/actions/workflow-runs#download-workflow-run-logs // GitHub API docs: https://docs.github.com/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) { //
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs
func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, maxRedirects int) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -306,7 +335,9 @@ func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo str
// DeleteWorkflowRun deletes a workflow run by ID. // DeleteWorkflowRun deletes a workflow run by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-a-workflow-run // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/runs/{run_id}
func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo string, runID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
@ -320,7 +351,9 @@ func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo stri
// DeleteWorkflowRunLogs deletes all logs for a workflow run. // DeleteWorkflowRunLogs deletes all logs for a workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-workflow-run-logs // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#delete-workflow-run-logs
//
//meta:operation DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs
func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
@ -334,7 +367,9 @@ 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. // GetWorkflowRunUsageByID gets a specific workflow usage run by run ID in the unit of billable milliseconds.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-workflow-run-usage // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#get-workflow-run-usage
//
//meta:operation GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing
func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRunUsage, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/timing", owner, repo, runID)
@ -354,7 +389,9 @@ func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, rep
// PendingDeployments approve or reject pending deployments that are waiting on approval by a required reviewer. // 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 // GitHub API docs: https://docs.github.com/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run
//
//meta:operation POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments
func (s *ActionsService) PendingDeployments(ctx context.Context, owner, repo string, runID int64, request *PendingDeploymentsRequest) ([]*Deployment, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/pending_deployments", owner, repo, runID)

View file

@ -58,7 +58,9 @@ type CreateWorkflowDispatchEventRequest struct {
// ListWorkflows lists all workflows in a repository. // ListWorkflows lists all workflows in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#list-repository-workflows // GitHub API docs: https://docs.github.com/rest/actions/workflows#list-repository-workflows
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows
func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) { 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 := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -82,7 +84,9 @@ func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string,
// GetWorkflowByID gets a specific workflow by ID. // GetWorkflowByID gets a specific workflow by ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#get-a-workflow
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}
func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowID)
@ -91,7 +95,9 @@ func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string
// GetWorkflowByFileName gets a specific workflow by file name. // GetWorkflowByFileName gets a specific workflow by file name.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#get-a-workflow
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}
func (s *ActionsService) GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowFileName)
@ -115,7 +121,9 @@ func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow
// GetWorkflowUsageByID gets a specific workflow usage by ID in the unit of billable milliseconds. // GetWorkflowUsageByID gets a specific workflow usage by ID in the unit of billable milliseconds.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage // GitHub API docs: https://docs.github.com/rest/actions/workflows#get-workflow-usage
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing
func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo string, workflowID int64) (*WorkflowUsage, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowID)
@ -124,7 +132,9 @@ 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. // GetWorkflowUsageByFileName gets a specific workflow usage by file name in the unit of billable milliseconds.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage // GitHub API docs: https://docs.github.com/rest/actions/workflows#get-workflow-usage
//
//meta:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing
func (s *ActionsService) GetWorkflowUsageByFileName(ctx context.Context, owner, repo, workflowFileName string) (*WorkflowUsage, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowFileName)
@ -148,7 +158,9 @@ func (s *ActionsService) getWorkflowUsage(ctx context.Context, url string) (*Wor
// CreateWorkflowDispatchEventByID manually triggers a GitHub Actions workflow run. // CreateWorkflowDispatchEventByID manually triggers a GitHub Actions workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event // GitHub API docs: https://docs.github.com/rest/actions/workflows#create-a-workflow-dispatch-event
//
//meta:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowID)
@ -157,7 +169,9 @@ func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, ow
// CreateWorkflowDispatchEventByFileName manually triggers a GitHub Actions workflow run. // CreateWorkflowDispatchEventByFileName manually triggers a GitHub Actions workflow run.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event // GitHub API docs: https://docs.github.com/rest/actions/workflows#create-a-workflow-dispatch-event
//
//meta:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
func (s *ActionsService) CreateWorkflowDispatchEventByFileName(ctx context.Context, owner, repo, workflowFileName string, event CreateWorkflowDispatchEventRequest) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowFileName)
@ -175,7 +189,9 @@ func (s *ActionsService) createWorkflowDispatchEvent(ctx context.Context, url st
// EnableWorkflowByID enables a workflow and sets the state of the workflow to "active". // EnableWorkflowByID enables a workflow and sets the state of the workflow to "active".
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#enable-a-workflow
//
//meta:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable
func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowID)
return s.doNewPutRequest(ctx, u) return s.doNewPutRequest(ctx, u)
@ -183,7 +199,9 @@ func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo str
// EnableWorkflowByFileName enables a workflow and sets the state of the workflow to "active". // EnableWorkflowByFileName enables a workflow and sets the state of the workflow to "active".
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#enable-a-workflow
//
//meta:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable
func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowFileName)
return s.doNewPutRequest(ctx, u) return s.doNewPutRequest(ctx, u)
@ -191,7 +209,9 @@ func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, re
// DisableWorkflowByID disables a workflow and sets the state of the workflow to "disabled_manually". // DisableWorkflowByID disables a workflow and sets the state of the workflow to "disabled_manually".
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#disable-a-workflow
//
//meta:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable
func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowID)
return s.doNewPutRequest(ctx, u) return s.doNewPutRequest(ctx, u)
@ -199,7 +219,9 @@ func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo st
// DisableWorkflowByFileName disables a workflow and sets the state of the workflow to "disabled_manually". // DisableWorkflowByFileName disables a workflow and sets the state of the workflow to "disabled_manually".
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow // GitHub API docs: https://docs.github.com/rest/actions/workflows#disable-a-workflow
//
//meta:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable
func (s *ActionsService) DisableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowFileName)
return s.doNewPutRequest(ctx, u) return s.doNewPutRequest(ctx, u)

View file

@ -10,7 +10,7 @@ import "context"
// ActivityService handles communication with the activity related // ActivityService handles communication with the activity related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/ // GitHub API docs: https://docs.github.com/rest/activity/
type ActivityService service type ActivityService service
// FeedLink represents a link to a related resource. // FeedLink represents a link to a related resource.
@ -57,6 +57,10 @@ type FeedLinks struct {
// //
// Note: Private feeds are only returned when authenticating via Basic Auth // Note: Private feeds are only returned when authenticating via Basic Auth
// since current feed URIs use the older, non revocable auth tokens. // since current feed URIs use the older, non revocable auth tokens.
//
// GitHub API docs: https://docs.github.com/rest/activity/feeds#get-feeds
//
//meta:operation GET /feeds
func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) { func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) {
req, err := s.client.NewRequest("GET", "feeds", nil) req, err := s.client.NewRequest("GET", "feeds", nil)
if err != nil { if err != nil {

View file

@ -12,7 +12,9 @@ import (
// ListEvents drinks from the firehose of all public events across GitHub. // ListEvents drinks from the firehose of all public events across GitHub.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events // GitHub API docs: https://docs.github.com/rest/activity/events#list-public-events
//
//meta:operation GET /events
func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) { func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
u, err := addOptions("events", opts) u, err := addOptions("events", opts)
if err != nil { if err != nil {
@ -35,7 +37,9 @@ func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]
// ListRepositoryEvents lists events for a repository. // ListRepositoryEvents lists events for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-repository-events // GitHub API docs: https://docs.github.com/rest/activity/events#list-repository-events
//
//meta:operation GET /repos/{owner}/{repo}/events
func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/events", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -59,7 +63,9 @@ func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo
// ListIssueEventsForRepository lists issue events for a repository. // ListIssueEventsForRepository lists issue events for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository // GitHub API docs: https://docs.github.com/rest/issues/events#list-issue-events-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/issues/events
func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -83,7 +89,9 @@ func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owne
// ListEventsForRepoNetwork lists public events for a network of repositories. // ListEventsForRepoNetwork lists 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 // GitHub API docs: https://docs.github.com/rest/activity/events#list-public-events-for-a-network-of-repositories
//
//meta:operation GET /networks/{owner}/{repo}/events
func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) { 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 := fmt.Sprintf("networks/%v/%v/events", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -107,7 +115,9 @@ func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, r
// ListEventsForOrganization lists public events for an organization. // ListEventsForOrganization lists public events for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-organization-events // GitHub API docs: https://docs.github.com/rest/activity/events#list-public-organization-events
//
//meta:operation GET /orgs/{org}/events
func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) { func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) {
u := fmt.Sprintf("orgs/%v/events", org) u := fmt.Sprintf("orgs/%v/events", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -132,8 +142,11 @@ func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org str
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is // ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
// true, only public events will be returned. // true, only public events will be returned.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-for-the-authenticated-user // GitHub API docs: https://docs.github.com/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 // GitHub API docs: https://docs.github.com/rest/activity/events#list-public-events-for-a-user
//
//meta:operation GET /users/{username}/events
//meta:operation GET /users/{username}/events/public
func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) { func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
var u string var u string
if publicOnly { if publicOnly {
@ -163,8 +176,11 @@ func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user st
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is // ListEventsReceivedByUser lists the events received by a user. If publicOnly is
// true, only public events will be returned. // true, only public events will be returned.
// //
// 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/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 // GitHub API docs: https://docs.github.com/rest/activity/events#list-public-events-received-by-a-user
//
//meta:operation GET /users/{username}/received_events
//meta:operation GET /users/{username}/received_events/public
func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) { func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
var u string var u string
if publicOnly { if publicOnly {
@ -194,7 +210,9 @@ func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user str
// ListUserEventsForOrganization provides the users organization dashboard. You // ListUserEventsForOrganization provides the users organization dashboard. You
// must be authenticated as the user to view this. // must be authenticated as the user to view this.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-organization-events-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/events#list-organization-events-for-the-authenticated-user
//
//meta:operation GET /users/{username}/events/orgs/{org}
func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) { 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 := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)

View file

@ -19,7 +19,7 @@ type Notification struct {
// Reason identifies the event that triggered the notification. // Reason identifies the event that triggered the notification.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity#notification-reasons // GitHub API docs: https://docs.github.com/rest/activity#notification-reasons
Reason *string `json:"reason,omitempty"` Reason *string `json:"reason,omitempty"`
Unread *bool `json:"unread,omitempty"` Unread *bool `json:"unread,omitempty"`
@ -49,7 +49,9 @@ type NotificationListOptions struct {
// ListNotifications lists all notifications for the authenticated user. // ListNotifications lists all notifications for the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user
//
//meta:operation GET /notifications
func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) { func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) {
u := "notifications" u := "notifications"
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -74,7 +76,9 @@ func (s *ActivityService) ListNotifications(ctx context.Context, opts *Notificat
// ListRepositoryNotifications lists all notifications in a given repository // ListRepositoryNotifications lists all notifications in a given repository
// for the authenticated user. // for the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user
//
//meta:operation GET /repos/{owner}/{repo}/notifications
func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) { func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -102,7 +106,9 @@ type markReadOptions struct {
// MarkNotificationsRead marks all notifications up to lastRead as read. // MarkNotificationsRead marks all notifications up to lastRead as read.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read // GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-notifications-as-read
//
//meta:operation PUT /notifications
func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Timestamp) (*Response, error) { func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Timestamp) (*Response, error) {
opts := &markReadOptions{ opts := &markReadOptions{
LastReadAt: lastRead, LastReadAt: lastRead,
@ -118,7 +124,9 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Ti
// MarkRepositoryNotificationsRead marks all notifications up to lastRead in // MarkRepositoryNotificationsRead marks all notifications up to lastRead in
// the specified repository as read. // the specified repository as read.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read // GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-repository-notifications-as-read
//
//meta:operation PUT /repos/{owner}/{repo}/notifications
func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead Timestamp) (*Response, error) { func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead Timestamp) (*Response, error) {
opts := &markReadOptions{ opts := &markReadOptions{
LastReadAt: lastRead, LastReadAt: lastRead,
@ -134,7 +142,9 @@ func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, o
// GetThread gets the specified notification thread. // GetThread gets the specified notification thread.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread // GitHub API docs: https://docs.github.com/rest/activity/notifications#get-a-thread
//
//meta:operation GET /notifications/threads/{thread_id}
func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) { func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) {
u := fmt.Sprintf("notifications/threads/%v", id) u := fmt.Sprintf("notifications/threads/%v", id)
@ -154,7 +164,9 @@ func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notificati
// MarkThreadRead marks the specified thread as read. // MarkThreadRead marks the specified thread as read.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-a-thread-as-read // GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-a-thread-as-read
//
//meta:operation PATCH /notifications/threads/{thread_id}
func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) { func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) {
u := fmt.Sprintf("notifications/threads/%v", id) u := fmt.Sprintf("notifications/threads/%v", id)
@ -169,7 +181,9 @@ func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Respo
// GetThreadSubscription checks to see if the authenticated user is subscribed // GetThreadSubscription checks to see if the authenticated user is subscribed
// to a thread. // to a thread.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user
//
//meta:operation GET /notifications/threads/{thread_id}/subscription
func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) { func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) {
u := fmt.Sprintf("notifications/threads/%v/subscription", id) u := fmt.Sprintf("notifications/threads/%v/subscription", id)
@ -190,7 +204,9 @@ func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string)
// SetThreadSubscription sets the subscription for the specified thread for the // SetThreadSubscription sets the subscription for the specified thread for the
// authenticated user. // authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#set-a-thread-subscription // GitHub API docs: https://docs.github.com/rest/activity/notifications#set-a-thread-subscription
//
//meta:operation PUT /notifications/threads/{thread_id}/subscription
func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) { func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) {
u := fmt.Sprintf("notifications/threads/%v/subscription", id) u := fmt.Sprintf("notifications/threads/%v/subscription", id)
@ -211,7 +227,9 @@ func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string,
// DeleteThreadSubscription deletes the subscription for the specified thread // DeleteThreadSubscription deletes the subscription for the specified thread
// for the authenticated user. // for the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#delete-a-thread-subscription // GitHub API docs: https://docs.github.com/rest/activity/notifications#delete-a-thread-subscription
//
//meta:operation DELETE /notifications/threads/{thread_id}/subscription
func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) { func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) {
u := fmt.Sprintf("notifications/threads/%v/subscription", id) u := fmt.Sprintf("notifications/threads/%v/subscription", id)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -25,7 +25,9 @@ type Stargazer struct {
// ListStargazers lists people who have starred the specified repo. // ListStargazers lists people who have starred the specified repo.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-stargazers // GitHub API docs: https://docs.github.com/rest/activity/starring#list-stargazers
//
//meta:operation GET /repos/{owner}/{repo}/stargazers
func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) { 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 := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -67,8 +69,11 @@ type ActivityListStarredOptions struct {
// ListStarred lists all the repos starred by a user. Passing the empty string // ListStarred lists all the repos starred by a user. Passing the empty string
// will list the starred repositories for the authenticated user. // will list the starred repositories for the authenticated 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/rest/activity/starring#list-repositories-starred-by-a-user
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-a-user // GitHub API docs: https://docs.github.com/rest/activity/starring#list-repositories-starred-by-the-authenticated-user
//
//meta:operation GET /user/starred
//meta:operation GET /users/{username}/starred
func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) { func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) {
var u string var u string
if user != "" { if user != "" {
@ -101,7 +106,9 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *Ac
// IsStarred checks if a repository is starred by authenticated user. // IsStarred checks if a repository is starred by authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#check-if-a-repository-is-starred-by-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/starring#check-if-a-repository-is-starred-by-the-authenticated-user
//
//meta:operation GET /user/starred/{owner}/{repo}
func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) { func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) {
u := fmt.Sprintf("user/starred/%v/%v", owner, repo) u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -116,7 +123,9 @@ func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bo
// Star a repository as the authenticated user. // Star a repository as the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#star-a-repository-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/starring#star-a-repository-for-the-authenticated-user
//
//meta:operation PUT /user/starred/{owner}/{repo}
func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Response, error) { func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Response, error) {
u := fmt.Sprintf("user/starred/%v/%v", owner, repo) u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
req, err := s.client.NewRequest("PUT", u, nil) req, err := s.client.NewRequest("PUT", u, nil)
@ -129,7 +138,9 @@ func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Respon
// Unstar a repository as the authenticated user. // Unstar a repository as the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#unstar-a-repository-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/starring#unstar-a-repository-for-the-authenticated-user
//
//meta:operation DELETE /user/starred/{owner}/{repo}
func (s *ActivityService) Unstar(ctx context.Context, owner, repo string) (*Response, error) { func (s *ActivityService) Unstar(ctx context.Context, owner, repo string) (*Response, error) {
u := fmt.Sprintf("user/starred/%v/%v", owner, repo) u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -27,7 +27,9 @@ type Subscription struct {
// ListWatchers lists watchers of a particular repo. // ListWatchers lists watchers of a particular repo.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-watchers // GitHub API docs: https://docs.github.com/rest/activity/watching#list-watchers
//
//meta:operation GET /repos/{owner}/{repo}/subscribers
func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo) u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -52,8 +54,11 @@ func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string,
// ListWatched lists the repositories the specified user is watching. Passing // ListWatched lists the repositories the specified user is watching. Passing
// the empty string will fetch watched repos for the authenticated user. // the empty string will fetch watched repos for the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/activity/watching#list-repositories-watched-by-a-user
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-a-user // GitHub API docs: https://docs.github.com/rest/activity/watching#list-repositories-watched-by-the-authenticated-user
//
//meta:operation GET /user/subscriptions
//meta:operation GET /users/{username}/subscriptions
func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) { func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) {
var u string var u string
if user != "" { if user != "" {
@ -84,7 +89,9 @@ func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *Li
// repository for the authenticated user. If the authenticated user is not // repository for the authenticated user. If the authenticated user is not
// watching the repository, a nil Subscription is returned. // watching the repository, a nil Subscription is returned.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#get-a-repository-subscription // GitHub API docs: https://docs.github.com/rest/activity/watching#get-a-repository-subscription
//
//meta:operation GET /repos/{owner}/{repo}/subscription
func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) { func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
@ -111,7 +118,9 @@ func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner,
// To ignore notifications made within a repository, set subscription.Ignored to true. // To ignore notifications made within a repository, set subscription.Ignored to true.
// To stop watching a repository, use DeleteRepositorySubscription. // To stop watching a repository, use DeleteRepositorySubscription.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#set-a-repository-subscription // GitHub API docs: https://docs.github.com/rest/activity/watching#set-a-repository-subscription
//
//meta:operation PUT /repos/{owner}/{repo}/subscription
func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) { func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
@ -135,7 +144,9 @@ func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner,
// This is used to stop watching a repository. To control whether or not to // This is used to stop watching a repository. To control whether or not to
// receive notifications from a repository, use SetRepositorySubscription. // receive notifications from a repository, use SetRepositorySubscription.
// //
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#delete-a-repository-subscription // GitHub API docs: https://docs.github.com/rest/activity/watching#delete-a-repository-subscription
//
//meta:operation DELETE /repos/{owner}/{repo}/subscription
func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) { func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) {
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -14,7 +14,7 @@ import (
// GitHub API. These API routes are normally only accessible for GitHub // GitHub API. These API routes are normally only accessible for GitHub
// Enterprise installations. // Enterprise installations.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin // GitHub API docs: https://docs.github.com/rest/enterprise-admin
type AdminService service type AdminService service
// TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group. // TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group.
@ -82,7 +82,9 @@ func (m Enterprise) String() string {
// UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user. // UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-server/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
//
//meta:operation PATCH /admin/ldap/users/{username}/mapping
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) { func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/users/%v/mapping", user) u := fmt.Sprintf("admin/ldap/users/%v/mapping", user)
req, err := s.client.NewRequest("PATCH", u, mapping) req, err := s.client.NewRequest("PATCH", u, mapping)
@ -101,7 +103,9 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group. // UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise/ldap/#update-ldap-mapping-for-a-team // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-team
//
//meta:operation PATCH /admin/ldap/teams/{team_id}/mapping
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) { func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team) u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
req, err := s.client.NewRequest("PATCH", u, mapping) req, err := s.client.NewRequest("PATCH", u, mapping)

View file

@ -22,7 +22,9 @@ type createOrgRequest struct {
// Note that only a subset of the org fields are used and org must // Note that only a subset of the org fields are used and org must
// not be nil. // not be nil.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#create-an-organization // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/orgs#create-an-organization
//
//meta:operation POST /admin/organizations
func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) { func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) {
u := "admin/organizations" u := "admin/organizations"
@ -59,14 +61,18 @@ type RenameOrgResponse struct {
// RenameOrg renames an organization in GitHub Enterprise. // RenameOrg renames an organization in GitHub Enterprise.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/orgs#update-an-organization-name
//
//meta:operation PATCH /admin/organizations/{org}
func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) { func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) {
return s.RenameOrgByName(ctx, *org.Login, newName) return s.RenameOrgByName(ctx, *org.Login, newName)
} }
// RenameOrgByName renames an organization in GitHub Enterprise using its current name. // RenameOrgByName renames an organization in GitHub Enterprise using its current name.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/orgs#update-an-organization-name
//
//meta:operation PATCH /admin/organizations/{org}
func (s *AdminService) RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) { func (s *AdminService) RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) {
u := fmt.Sprintf("admin/organizations/%v", org) u := fmt.Sprintf("admin/organizations/%v", org)

View file

@ -152,7 +152,9 @@ func (s RepoStats) String() string {
// Please note that this is only available to site administrators, // Please note that this is only available to site administrators,
// otherwise it will error with a 404 not found (instead of 401 or 403). // otherwise it will error with a 404 not found (instead of 401 or 403).
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/admin_stats/ // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/admin-stats#get-all-statistics
//
//meta:operation GET /enterprise/stats/all
func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) { func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
u := "enterprise/stats/all" u := "enterprise/stats/all"
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)

View file

@ -19,7 +19,9 @@ type createUserRequest struct {
// CreateUser creates a new user in GitHub Enterprise. // CreateUser creates a new user in GitHub Enterprise.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-a-new-user // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#create-a-user
//
//meta:operation POST /admin/users
func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*User, *Response, error) { func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*User, *Response, error) {
u := "admin/users" u := "admin/users"
@ -44,7 +46,9 @@ func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*Us
// DeleteUser deletes a user in GitHub Enterprise. // DeleteUser deletes a user in GitHub Enterprise.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-user // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#delete-a-user
//
//meta:operation DELETE /admin/users/{username}
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) { func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) {
u := "admin/users/" + username u := "admin/users/" + username
@ -95,7 +99,9 @@ type UserAuthorization struct {
// CreateUserImpersonation creates an impersonation OAuth token. // CreateUserImpersonation creates an impersonation OAuth token.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#create-an-impersonation-oauth-token
//
//meta:operation POST /admin/users/{username}/authorizations
func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) { func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) {
u := fmt.Sprintf("admin/users/%s/authorizations", username) u := fmt.Sprintf("admin/users/%s/authorizations", username)
@ -115,7 +121,9 @@ func (s *AdminService) CreateUserImpersonation(ctx context.Context, username str
// DeleteUserImpersonation deletes an impersonation OAuth token. // DeleteUserImpersonation deletes an impersonation OAuth token.
// //
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
//
//meta:operation DELETE /admin/users/{username}/authorizations
func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) { func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) {
u := fmt.Sprintf("admin/users/%s/authorizations", username) u := fmt.Sprintf("admin/users/%s/authorizations", username)

View file

@ -13,7 +13,7 @@ import (
// AppsService provides access to the installation related functions // AppsService provides access to the installation related functions
// in the GitHub API. // in the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/ // GitHub API docs: https://docs.github.com/rest/apps/
type AppsService service type AppsService service
// App represents a GitHub App. // App represents a GitHub App.
@ -60,8 +60,8 @@ type InstallationTokenOptions struct {
// //
// Permission names taken from: // Permission names taken from:
// //
// https://docs.github.com/en/enterprise-server@3.0/rest/apps#create-an-installation-access-token-for-an-app // https://docs.github.com/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 // https://docs.github.com/rest/apps#create-an-installation-access-token-for-an-app
type InstallationPermissions struct { type InstallationPermissions struct {
Actions *string `json:"actions,omitempty"` Actions *string `json:"actions,omitempty"`
Administration *string `json:"administration,omitempty"` Administration *string `json:"administration,omitempty"`
@ -102,6 +102,15 @@ type InstallationPermissions struct {
Workflows *string `json:"workflows,omitempty"` Workflows *string `json:"workflows,omitempty"`
} }
// InstallationRequest represents a pending GitHub App installation request.
type InstallationRequest struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Account *User `json:"account,omitempty"`
Requester *User `json:"requester,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}
// Installation represents a GitHub Apps installation. // Installation represents a GitHub Apps installation.
type Installation struct { type Installation struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
@ -151,8 +160,11 @@ func (i Installation) String() string {
// You can find this on the settings page for your GitHub App // You can find this on the settings page for your GitHub App
// (e.g., https://github.com/settings/apps/:app_slug). // (e.g., https://github.com/settings/apps/:app_slug).
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-an-app
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-the-authenticated-app
//
//meta:operation GET /app
//meta:operation GET /apps/{app_slug}
func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) { func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) {
var u string var u string
if appSlug != "" { if appSlug != "" {
@ -175,9 +187,36 @@ func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response,
return app, resp, nil return app, resp, nil
} }
// ListInstallationRequests lists the pending installation requests that the current GitHub App has.
//
// GitHub API docs: https://docs.github.com/rest/apps/apps#list-installation-requests-for-the-authenticated-app
//
//meta:operation GET /app/installation-requests
func (s *AppsService) ListInstallationRequests(ctx context.Context, opts *ListOptions) ([]*InstallationRequest, *Response, error) {
u, err := addOptions("app/installation-requests", opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var i []*InstallationRequest
resp, err := s.client.Do(ctx, req, &i)
if err != nil {
return nil, resp, err
}
return i, resp, nil
}
// ListInstallations lists the installations that the current GitHub App has. // ListInstallations lists the installations that the current GitHub App has.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#list-installations-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app
//
//meta:operation GET /app/installations
func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) { func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("app/installations", opts) u, err := addOptions("app/installations", opts)
if err != nil { if err != nil {
@ -200,14 +239,18 @@ func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions)
// GetInstallation returns the specified installation. // GetInstallation returns the specified installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-installation-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-an-installation-for-the-authenticated-app
//
//meta:operation GET /app/installations/{installation_id}
func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) { func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) {
return s.getInstallation(ctx, fmt.Sprintf("app/installations/%v", id)) return s.getInstallation(ctx, fmt.Sprintf("app/installations/%v", id))
} }
// ListUserInstallations lists installations that are accessible to the authenticated user. // ListUserInstallations lists installations that are accessible to the authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-app-installations-accessible-to-the-user-access-token // GitHub API docs: https://docs.github.com/rest/apps/installations#list-app-installations-accessible-to-the-user-access-token
//
//meta:operation GET /user/installations
func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) { func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
u, err := addOptions("user/installations", opts) u, err := addOptions("user/installations", opts)
if err != nil { if err != nil {
@ -232,7 +275,9 @@ func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptio
// SuspendInstallation suspends the specified installation. // SuspendInstallation suspends the specified installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#suspend-an-app-installation // GitHub API docs: https://docs.github.com/rest/apps/apps#suspend-an-app-installation
//
//meta:operation PUT /app/installations/{installation_id}/suspended
func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) { func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) {
u := fmt.Sprintf("app/installations/%v/suspended", id) u := fmt.Sprintf("app/installations/%v/suspended", id)
@ -246,7 +291,9 @@ func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Respo
// UnsuspendInstallation unsuspends the specified installation. // UnsuspendInstallation unsuspends the specified installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#unsuspend-an-app-installation // GitHub API docs: https://docs.github.com/rest/apps/apps#unsuspend-an-app-installation
//
//meta:operation DELETE /app/installations/{installation_id}/suspended
func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) { func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) {
u := fmt.Sprintf("app/installations/%v/suspended", id) u := fmt.Sprintf("app/installations/%v/suspended", id)
@ -260,7 +307,9 @@ func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Res
// DeleteInstallation deletes the specified installation. // DeleteInstallation deletes the specified installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#delete-an-installation-for-the-authenticated-app
//
//meta:operation DELETE /app/installations/{installation_id}
func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error) { func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error) {
u := fmt.Sprintf("app/installations/%v", id) u := fmt.Sprintf("app/installations/%v", id)
@ -274,7 +323,9 @@ func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Respon
// CreateInstallationToken creates a new installation token. // CreateInstallationToken creates a new installation token.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app // GitHub API docs: https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app
//
//meta:operation POST /app/installations/{installation_id}/access_tokens
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) { func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) {
u := fmt.Sprintf("app/installations/%v/access_tokens", id) u := fmt.Sprintf("app/installations/%v/access_tokens", id)
@ -294,7 +345,9 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt
// CreateAttachment creates a new attachment on user comment containing a url. // CreateAttachment creates a new attachment on user comment containing a url.
// //
// TODO: Find GitHub API docs. // GitHub API docs: https://docs.github.com/enterprise-server@3.3/rest/reference/apps#create-a-content-attachment
//
//meta:operation POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments
func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) { func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) {
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID) u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
payload := &Attachment{Title: String(title), Body: String(body)} payload := &Attachment{Title: String(title), Body: String(body)}
@ -317,28 +370,36 @@ func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID i
// FindOrganizationInstallation finds the organization's installation information. // FindOrganizationInstallation finds the organization's installation information.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app
//
//meta:operation GET /orgs/{org}/installation
func (s *AppsService) FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) { func (s *AppsService) FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) {
return s.getInstallation(ctx, fmt.Sprintf("orgs/%v/installation", org)) return s.getInstallation(ctx, fmt.Sprintf("orgs/%v/installation", org))
} }
// FindRepositoryInstallation finds the repository's installation information. // FindRepositoryInstallation finds the repository's installation information.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
//
//meta:operation GET /repos/{owner}/{repo}/installation
func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, repo string) (*Installation, *Response, error) { 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)) return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo))
} }
// FindRepositoryInstallationByID finds the repository's installation information. // FindRepositoryInstallationByID finds the repository's installation information.
// //
// Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint /repositories/:id/installation. // Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint "GET /repositories/{repository_id}/installation".
//
//meta:operation GET /repositories/{repository_id}/installation
func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) { func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) {
return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id)) return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id))
} }
// FindUserInstallation finds the user's installation information. // FindUserInstallation finds the user's installation information.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app // GitHub API docs: https://docs.github.com/rest/apps/apps#get-a-user-installation-for-the-authenticated-app
//
//meta:operation GET /users/{username}/installation
func (s *AppsService) FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) { func (s *AppsService) FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) {
return s.getInstallation(ctx, fmt.Sprintf("users/%v/installation", user)) return s.getInstallation(ctx, fmt.Sprintf("users/%v/installation", user))
} }

View file

@ -12,7 +12,9 @@ import (
// GetHookConfig returns the webhook configuration for a GitHub App. // GetHookConfig returns the webhook configuration for a GitHub App.
// The underlying transport must be authenticated as an app. // The underlying transport must be authenticated as an app.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-webhook-configuration-for-an-app // GitHub API docs: https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app
//
//meta:operation GET /app/hook/config
func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) { func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) {
req, err := s.client.NewRequest("GET", "app/hook/config", nil) req, err := s.client.NewRequest("GET", "app/hook/config", nil)
if err != nil { if err != nil {
@ -31,7 +33,9 @@ func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response
// UpdateHookConfig updates the webhook configuration for a GitHub App. // UpdateHookConfig updates the webhook configuration for a GitHub App.
// The underlying transport must be authenticated as an app. // The underlying transport must be authenticated as an app.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#update-a-webhook-configuration-for-an-app // GitHub API docs: https://docs.github.com/rest/apps/webhooks#update-a-webhook-configuration-for-an-app
//
//meta:operation PATCH /app/hook/config
func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) { func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) {
req, err := s.client.NewRequest("PATCH", "app/hook/config", config) req, err := s.client.NewRequest("PATCH", "app/hook/config", config)
if err != nil { if err != nil {

View file

@ -12,7 +12,9 @@ import (
// ListHookDeliveries lists deliveries of an App webhook. // ListHookDeliveries lists deliveries of an App webhook.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook // GitHub API docs: https://docs.github.com/rest/apps/webhooks#list-deliveries-for-an-app-webhook
//
//meta:operation GET /app/hook/deliveries
func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) { func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) {
u, err := addOptions("app/hook/deliveries", opts) u, err := addOptions("app/hook/deliveries", opts)
if err != nil { if err != nil {
@ -35,7 +37,9 @@ func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOp
// GetHookDelivery returns the App webhook delivery with the specified ID. // GetHookDelivery returns the App webhook delivery with the specified ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook // GitHub API docs: https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook
//
//meta:operation GET /app/hook/deliveries/{delivery_id}
func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) { func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
u := fmt.Sprintf("app/hook/deliveries/%v", deliveryID) u := fmt.Sprintf("app/hook/deliveries/%v", deliveryID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -54,7 +58,9 @@ func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*H
// RedeliverHookDelivery redelivers a delivery for an App webhook. // RedeliverHookDelivery redelivers a delivery for an App webhook.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook // GitHub API docs: https://docs.github.com/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook
//
//meta:operation POST /app/hook/deliveries/{delivery_id}/attempts
func (s *AppsService) RedeliverHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) { func (s *AppsService) RedeliverHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
u := fmt.Sprintf("app/hook/deliveries/%v/attempts", deliveryID) u := fmt.Sprintf("app/hook/deliveries/%v/attempts", deliveryID)
req, err := s.client.NewRequest("POST", u, nil) req, err := s.client.NewRequest("POST", u, nil)

View file

@ -19,7 +19,9 @@ type ListRepositories struct {
// ListRepos lists the repositories that are accessible to the authenticated installation. // ListRepos lists the repositories that are accessible to the authenticated installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-app-installation // GitHub API docs: https://docs.github.com/rest/apps/installations#list-repositories-accessible-to-the-app-installation
//
//meta:operation GET /installation/repositories
func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) { func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) {
u, err := addOptions("installation/repositories", opts) u, err := addOptions("installation/repositories", opts)
if err != nil { if err != nil {
@ -52,7 +54,9 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe
// ListUserRepos lists repositories that are accessible // ListUserRepos lists repositories that are accessible
// to the authenticated user for an installation. // to the authenticated user for an installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-user-access-token // GitHub API docs: https://docs.github.com/rest/apps/installations#list-repositories-accessible-to-the-user-access-token
//
//meta:operation GET /user/installations/{installation_id}/repositories
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) { func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) {
u := fmt.Sprintf("user/installations/%v/repositories", id) u := fmt.Sprintf("user/installations/%v/repositories", id)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -84,7 +88,9 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt
// AddRepository adds a single repository to an installation. // AddRepository adds a single repository to an installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#add-a-repository-to-an-app-installation // GitHub API docs: https://docs.github.com/rest/apps/installations#add-a-repository-to-an-app-installation
//
//meta:operation PUT /user/installations/{installation_id}/repositories/{repository_id}
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) { func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) {
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID) u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
req, err := s.client.NewRequest("PUT", u, nil) req, err := s.client.NewRequest("PUT", u, nil)
@ -103,7 +109,9 @@ func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (
// RemoveRepository removes a single repository from an installation. // RemoveRepository removes a single repository from an installation.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#remove-a-repository-from-an-app-installation // GitHub API docs: https://docs.github.com/rest/apps/installations#remove-a-repository-from-an-app-installation
//
//meta:operation DELETE /user/installations/{installation_id}/repositories/{repository_id}
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) { func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) {
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID) u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -116,7 +124,9 @@ func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64
// RevokeInstallationToken revokes an installation token. // RevokeInstallationToken revokes an installation token.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#revoke-an-installation-access-token // GitHub API docs: https://docs.github.com/rest/apps/installations#revoke-an-installation-access-token
//
//meta:operation DELETE /installation/token
func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, error) { func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, error) {
u := "installation/token" u := "installation/token"
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -31,7 +31,9 @@ type AppConfig struct {
// CompleteAppManifest completes the App manifest handshake flow for the given // CompleteAppManifest completes the App manifest handshake flow for the given
// code. // code.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-a-github-app-from-a-manifest // GitHub API docs: https://docs.github.com/rest/apps/apps#create-a-github-app-from-a-manifest
//
//meta:operation POST /app-manifests/{code}/conversions
func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) { func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) {
u := fmt.Sprintf("app-manifests/%s/conversions", code) u := fmt.Sprintf("app-manifests/%s/conversions", code)
req, err := s.client.NewRequest("POST", u, nil) req, err := s.client.NewRequest("POST", u, nil)

View file

@ -13,7 +13,7 @@ import (
// MarketplaceService handles communication with the marketplace related // MarketplaceService handles communication with the marketplace related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#marketplace // GitHub API docs: https://docs.github.com/rest/apps#marketplace
type MarketplaceService struct { type MarketplaceService struct {
client *Client client *Client
// Stubbed controls whether endpoints that return stubbed data are used // 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 // for testing your GitHub Apps. Stubbed data is hard-coded and will not
// change based on actual subscriptions. // change based on actual subscriptions.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#testing-with-stubbed-endpoints // GitHub API docs: https://docs.github.com/rest/apps#testing-with-stubbed-endpoints
Stubbed bool Stubbed bool
} }
@ -89,7 +89,11 @@ type MarketplacePurchaseAccount struct {
// ListPlans lists all plans for your Marketplace listing. // ListPlans lists all plans for your Marketplace listing.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#list-plans // GitHub API docs: https://docs.github.com/rest/apps/marketplace#list-plans
// GitHub API docs: https://docs.github.com/rest/apps/marketplace#list-plans-stubbed
//
//meta:operation GET /marketplace_listing/plans
//meta:operation GET /marketplace_listing/stubbed/plans
func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) { func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) {
uri := s.marketplaceURI("plans") uri := s.marketplaceURI("plans")
u, err := addOptions(uri, opts) u, err := addOptions(uri, opts)
@ -113,7 +117,11 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) (
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan. // ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#list-accounts-for-a-plan // GitHub API docs: https://docs.github.com/rest/apps/marketplace#list-accounts-for-a-plan
// GitHub API docs: https://docs.github.com/rest/apps/marketplace#list-accounts-for-a-plan-stubbed
//
//meta:operation GET /marketplace_listing/plans/{plan_id}/accounts
//meta:operation GET /marketplace_listing/stubbed/plans/{plan_id}/accounts
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) { func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID)) uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID))
u, err := addOptions(uri, opts) u, err := addOptions(uri, opts)
@ -137,7 +145,11 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID
// GetPlanAccountForAccount get GitHub account (user or organization) associated with an account. // GetPlanAccountForAccount get GitHub account (user or organization) associated with an account.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-subscription-plan-for-an-account // GitHub API docs: https://docs.github.com/rest/apps/marketplace#get-a-subscription-plan-for-an-account
// GitHub API docs: https://docs.github.com/rest/apps/marketplace#get-a-subscription-plan-for-an-account-stubbed
//
//meta:operation GET /marketplace_listing/accounts/{account_id}
//meta:operation GET /marketplace_listing/stubbed/accounts/{account_id}
func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) { func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) {
uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID)) uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID))
@ -157,8 +169,11 @@ func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accou
// ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user. // ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a 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/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user
// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user-stubbed
//
//meta:operation GET /user/marketplace_purchases
//meta:operation GET /user/marketplace_purchases/stubbed
func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) { func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) {
uri := "user/marketplace_purchases" uri := "user/marketplace_purchases"
if s.Stubbed { if s.Stubbed {

View file

@ -12,7 +12,7 @@ import (
// Scope models a GitHub authorization scope. // Scope models a GitHub authorization scope.
// //
// GitHub API docs: https://docs.github.com/en/rest/oauth/#scopes // GitHub API docs: https://docs.github.com/rest/oauth/#scopes
type Scope string type Scope string
// This is the set of scopes for GitHub API V3 // 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 // This service requires HTTP Basic Authentication; it cannot be accessed using
// an OAuth token. // an OAuth token.
// //
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations // GitHub API docs: https://docs.github.com/rest/oauth-authorizations
type AuthorizationsService service type AuthorizationsService service
// Authorization represents an individual GitHub authorization. // 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 // fields. That is, you may provide only one of "Scopes", or "AddScopes", or
// "RemoveScopes". // "RemoveScopes".
// //
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations#update-an-existing-authorization // GitHub API docs: https://docs.github.com/rest/oauth-authorizations#update-an-existing-authorization
type AuthorizationUpdateRequest struct { type AuthorizationUpdateRequest struct {
Scopes []string `json:"scopes,omitempty"` Scopes []string `json:"scopes,omitempty"`
AddScopes []string `json:"add_scopes,omitempty"` AddScopes []string `json:"add_scopes,omitempty"`
@ -143,7 +143,9 @@ func (a AuthorizationUpdateRequest) String() string {
// //
// The returned Authorization.User field will be populated. // The returned Authorization.User field will be populated.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#check-a-token // GitHub API docs: https://docs.github.com/rest/apps/oauth-applications#check-a-token
//
//meta:operation POST /applications/{client_id}/token
func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) { func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
u := fmt.Sprintf("applications/%v/token", clientID) u := fmt.Sprintf("applications/%v/token", clientID)
@ -176,7 +178,9 @@ func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken
// //
// The returned Authorization.User field will be populated. // The returned Authorization.User field will be populated.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#reset-a-token // GitHub API docs: https://docs.github.com/rest/apps/oauth-applications#reset-a-token
//
//meta:operation PATCH /applications/{client_id}/token
func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) { func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
u := fmt.Sprintf("applications/%v/token", clientID) u := fmt.Sprintf("applications/%v/token", clientID)
@ -205,7 +209,9 @@ func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken
// username is the OAuth application clientID, and the password is its // username is the OAuth application clientID, and the password is its
// clientSecret. Invalid tokens will return a 404 Not Found. // clientSecret. Invalid tokens will return a 404 Not Found.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-token // GitHub API docs: https://docs.github.com/rest/apps/oauth-applications#delete-an-app-token
//
//meta:operation DELETE /applications/{client_id}/token
func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) { func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) {
u := fmt.Sprintf("applications/%v/token", clientID) u := fmt.Sprintf("applications/%v/token", clientID)
@ -226,7 +232,9 @@ func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToke
// grant will also delete all OAuth tokens associated with the application for // grant will also delete all OAuth tokens associated with the application for
// the user. // the user.
// //
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-authorization // GitHub API docs: https://docs.github.com/rest/apps/oauth-applications#delete-an-app-authorization
//
//meta:operation DELETE /applications/{client_id}/grant
func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) { func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) {
u := fmt.Sprintf("applications/%v/grant", clientID) u := fmt.Sprintf("applications/%v/grant", clientID)
@ -249,7 +257,9 @@ func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, acces
// you can e.g. create or delete a user's public SSH key. NOTE: creating a // you can e.g. create or delete a user's public SSH key. NOTE: creating a
// new token automatically revokes an existing one. // new token automatically revokes an existing one.
// //
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#create-an-impersonation-oauth-token
//
//meta:operation POST /admin/users/{username}/authorizations
func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) { func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) {
u := fmt.Sprintf("admin/users/%v/authorizations", username) u := fmt.Sprintf("admin/users/%v/authorizations", username)
req, err := s.client.NewRequest("POST", u, authReq) req, err := s.client.NewRequest("POST", u, authReq)
@ -269,7 +279,9 @@ func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, usernam
// //
// NOTE: there can be only one at a time. // NOTE: there can be only one at a time.
// //
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token // GitHub API docs: https://docs.github.com/enterprise-server@3.10/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
//
//meta:operation DELETE /admin/users/{username}/authorizations
func (s *AuthorizationsService) DeleteImpersonation(ctx context.Context, username string) (*Response, error) { func (s *AuthorizationsService) DeleteImpersonation(ctx context.Context, username string) (*Response, error) {
u := fmt.Sprintf("admin/users/%v/authorizations", username) u := fmt.Sprintf("admin/users/%v/authorizations", username)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -13,7 +13,7 @@ import (
// BillingService provides access to the billing related functions // BillingService provides access to the billing related functions
// in the GitHub API. // in the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/billing // GitHub API docs: https://docs.github.com/rest/billing
type BillingService service type BillingService service
// ActionBilling represents a GitHub Action billing. // ActionBilling represents a GitHub Action billing.
@ -62,7 +62,9 @@ type AdvancedSecurityCommittersBreakdown struct {
// GetActionsBillingOrg returns the summary of the free and paid GitHub Actions minutes used for an Org. // 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/billing#get-github-actions-billing-for-an-organization // GitHub API docs: https://docs.github.com/rest/billing/billing#get-github-actions-billing-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/billing/actions
func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) { func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) {
u := fmt.Sprintf("orgs/%v/settings/billing/actions", org) u := fmt.Sprintf("orgs/%v/settings/billing/actions", org)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -81,7 +83,9 @@ func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (
// GetPackagesBillingOrg returns the free and paid storage used for GitHub Packages in gigabytes for an Org. // 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/billing#get-github-packages-billing-for-an-organization // GitHub API docs: https://docs.github.com/rest/billing/billing#get-github-packages-billing-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/billing/packages
func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) { func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) {
u := fmt.Sprintf("orgs/%v/settings/billing/packages", org) u := fmt.Sprintf("orgs/%v/settings/billing/packages", org)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -101,7 +105,9 @@ func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string)
// GetStorageBillingOrg returns the estimated paid and estimated total storage used for GitHub Actions // GetStorageBillingOrg returns the estimated paid and estimated total storage used for GitHub Actions
// and GitHub Packages in gigabytes for an Org. // and GitHub Packages in gigabytes for an Org.
// //
// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-an-organization // GitHub API docs: https://docs.github.com/rest/billing/billing#get-shared-storage-billing-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/billing/shared-storage
func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) { func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) {
u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org) u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -120,7 +126,9 @@ func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (
// GetAdvancedSecurityActiveCommittersOrg returns the GitHub Advanced Security active committers for an organization per repository. // GetAdvancedSecurityActiveCommittersOrg returns the GitHub Advanced Security active committers for an organization per repository.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/billing?apiVersion=2022-11-28#get-github-advanced-security-active-committers-for-an-organization // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/billing/billing#get-github-advanced-security-active-committers-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/billing/advanced-security
func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string, opts *ListOptions) (*ActiveCommitters, *Response, error) { func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string, opts *ListOptions) (*ActiveCommitters, *Response, error) {
u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org) u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -144,7 +152,9 @@ func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Cont
// GetActionsBillingUser returns the summary of the free and paid GitHub Actions minutes used for a user. // 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/billing#get-github-actions-billing-for-a-user // GitHub API docs: https://docs.github.com/rest/billing/billing#get-github-actions-billing-for-a-user
//
//meta:operation GET /users/{username}/settings/billing/actions
func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) { func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) {
u := fmt.Sprintf("users/%v/settings/billing/actions", user) u := fmt.Sprintf("users/%v/settings/billing/actions", user)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -163,7 +173,9 @@ func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string)
// GetPackagesBillingUser returns the free and paid storage used for GitHub Packages in gigabytes for a user. // 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/billing#get-github-packages-billing-for-a-user // GitHub API docs: https://docs.github.com/rest/billing/billing#get-github-packages-billing-for-a-user
//
//meta:operation GET /users/{username}/settings/billing/packages
func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) { func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) {
u := fmt.Sprintf("users/%v/settings/billing/packages", user) u := fmt.Sprintf("users/%v/settings/billing/packages", user)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -183,7 +195,9 @@ func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string
// GetStorageBillingUser returns the estimated paid and estimated total storage used for GitHub Actions // GetStorageBillingUser returns the estimated paid and estimated total storage used for GitHub Actions
// and GitHub Packages in gigabytes for a user. // and GitHub Packages in gigabytes for a user.
// //
// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-a-user // GitHub API docs: https://docs.github.com/rest/billing/billing#get-shared-storage-billing-for-a-user
//
//meta:operation GET /users/{username}/settings/billing/shared-storage
func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) { func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) {
u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user) u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)

View file

@ -13,7 +13,7 @@ import (
// ChecksService provides access to the Checks API in the // ChecksService provides access to the Checks API in the
// GitHub API. // GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/ // GitHub API docs: https://docs.github.com/rest/checks/
type ChecksService service type ChecksService service
// CheckRun represents a GitHub check run on a repository associated with a GitHub app. // CheckRun represents a GitHub check run on a repository associated with a GitHub app.
@ -98,7 +98,9 @@ func (c CheckSuite) String() string {
// GetCheckRun gets a check-run for a repository. // GetCheckRun gets a check-run for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#get-a-check-run // GitHub API docs: https://docs.github.com/rest/checks/runs#get-a-check-run
//
//meta:operation GET /repos/{owner}/{repo}/check-runs/{check_run_id}
func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -119,7 +121,9 @@ func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, che
// GetCheckSuite gets a single check suite. // GetCheckSuite gets a single check suite.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#get-a-check-suite // GitHub API docs: https://docs.github.com/rest/checks/suites#get-a-check-suite
//
//meta:operation GET /repos/{owner}/{repo}/check-suites/{check_suite_id}
func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-suites/%v", owner, repo, checkSuiteID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -161,7 +165,9 @@ type CheckRunAction struct {
// CreateCheckRun creates a check run for repository. // CreateCheckRun creates a check run for repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#create-a-check-run // GitHub API docs: https://docs.github.com/rest/checks/runs#create-a-check-run
//
//meta:operation POST /repos/{owner}/{repo}/check-runs
func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-runs", owner, repo)
req, err := s.client.NewRequest("POST", u, opts) req, err := s.client.NewRequest("POST", u, opts)
@ -194,7 +200,9 @@ type UpdateCheckRunOptions struct {
// UpdateCheckRun updates a check run for a specific commit in a repository. // UpdateCheckRun updates a check run for a specific commit in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#update-a-check-run // GitHub API docs: https://docs.github.com/rest/checks/runs#update-a-check-run
//
//meta:operation PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}
func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
req, err := s.client.NewRequest("PATCH", u, opts) req, err := s.client.NewRequest("PATCH", u, opts)
@ -215,7 +223,9 @@ func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string,
// ListCheckRunAnnotations lists the annotations for a check run. // ListCheckRunAnnotations lists the annotations for a check run.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-run-annotations // GitHub API docs: https://docs.github.com/rest/checks/runs#list-check-run-annotations
//
//meta:operation GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations
func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/check-runs/%v/annotations", owner, repo, checkRunID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -257,7 +267,9 @@ type ListCheckRunsResults struct {
// ListCheckRunsForRef lists check runs for a specific ref. // ListCheckRunsForRef lists check runs for a specific ref.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-for-a-git-reference // GitHub API docs: https://docs.github.com/rest/checks/runs#list-check-runs-for-a-git-reference
//
//meta:operation GET /repos/{owner}/{repo}/commits/{ref}/check-runs
func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, refURLEscape(ref))
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -283,7 +295,9 @@ func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, re
// ListCheckRunsCheckSuite lists check runs for a check suite. // ListCheckRunsCheckSuite lists check runs for a check suite.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-in-a-check-suite // GitHub API docs: https://docs.github.com/rest/checks/runs#list-check-runs-in-a-check-suite
//
//meta:operation GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs
func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/check-suites/%v/check-runs", owner, repo, checkSuiteID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -309,7 +323,9 @@ func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo
// ReRequestCheckRun triggers GitHub to rerequest an existing check run. // ReRequestCheckRun triggers GitHub to rerequest an existing check run.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#rerequest-a-check-run // GitHub API docs: https://docs.github.com/rest/checks/runs#rerequest-a-check-run
//
//meta:operation POST /repos/{owner}/{repo}/check-runs/{check_run_id}/rerequest
func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-runs/%v/rerequest", owner, repo, checkRunID)
@ -339,7 +355,9 @@ type ListCheckSuiteResults struct {
// ListCheckSuitesForRef lists check suite for a specific ref. // ListCheckSuitesForRef lists check suite for a specific ref.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#list-check-suites-for-a-git-reference // GitHub API docs: https://docs.github.com/rest/checks/suites#list-check-suites-for-a-git-reference
//
//meta:operation GET /repos/{owner}/{repo}/commits/{ref}/check-suites
func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, refURLEscape(ref))
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -387,7 +405,9 @@ type PreferenceList struct {
// SetCheckSuitePreferences changes the default automatic flow when creating check suites. // SetCheckSuitePreferences changes the default automatic flow when creating check suites.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#update-repository-preferences-for-check-suites // GitHub API docs: https://docs.github.com/rest/checks/suites#update-repository-preferences-for-check-suites
//
//meta:operation PATCH /repos/{owner}/{repo}/check-suites/preferences
func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, repo string, opts CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-suites/preferences", owner, repo)
req, err := s.client.NewRequest("PATCH", u, opts) req, err := s.client.NewRequest("PATCH", u, opts)
@ -414,7 +434,9 @@ type CreateCheckSuiteOptions struct {
// CreateCheckSuite manually creates a check suite for a repository. // CreateCheckSuite manually creates a check suite for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#create-a-check-suite // GitHub API docs: https://docs.github.com/rest/checks/suites#create-a-check-suite
//
//meta:operation POST /repos/{owner}/{repo}/check-suites
func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-suites", owner, repo)
req, err := s.client.NewRequest("POST", u, opts) req, err := s.client.NewRequest("POST", u, opts)
@ -435,7 +457,9 @@ 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. // ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#rerequest-a-check-suite // GitHub API docs: https://docs.github.com/rest/checks/suites#rerequest-a-check-suite
//
//meta:operation POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest
func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID)

View file

@ -15,7 +15,7 @@ import (
// CodeScanningService handles communication with the code scanning related // CodeScanningService handles communication with the code scanning related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type CodeScanningService service type CodeScanningService service
// Rule represents the complete details of GitHub Code Scanning alert type. // Rule represents the complete details of GitHub Code Scanning alert type.
@ -67,7 +67,7 @@ type Tool struct {
// Alert represents an individual GitHub Code Scanning Alert on a single repository. // Alert represents an individual GitHub Code Scanning Alert on a single repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type Alert struct { type Alert struct {
Number *int `json:"number,omitempty"` Number *int `json:"number,omitempty"`
Repository *Repository `json:"repository,omitempty"` Repository *Repository `json:"repository,omitempty"`
@ -160,7 +160,7 @@ type AnalysesListOptions struct {
// CodeQLDatabase represents a metadata about the CodeQL database. // CodeQLDatabase represents a metadata about the CodeQL database.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type CodeQLDatabase struct { type CodeQLDatabase struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
@ -175,7 +175,7 @@ type CodeQLDatabase struct {
// ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository. // ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type ScanningAnalysis struct { type ScanningAnalysis struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
Ref *string `json:"ref,omitempty"` Ref *string `json:"ref,omitempty"`
@ -196,7 +196,7 @@ type ScanningAnalysis struct {
// SarifAnalysis specifies the results of a code scanning job. // SarifAnalysis specifies the results of a code scanning job.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type SarifAnalysis struct { type SarifAnalysis struct {
CommitSHA *string `json:"commit_sha,omitempty"` CommitSHA *string `json:"commit_sha,omitempty"`
Ref *string `json:"ref,omitempty"` Ref *string `json:"ref,omitempty"`
@ -208,7 +208,7 @@ type SarifAnalysis struct {
// CodeScanningAlertState specifies the state of a code scanning alert. // CodeScanningAlertState specifies the state of a code scanning alert.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type CodeScanningAlertState struct { type CodeScanningAlertState struct {
// State sets the state of the code scanning alert and is a required field. // State sets the state of the code scanning alert and is a required field.
// You must also provide DismissedReason when you set the state to "dismissed". // You must also provide DismissedReason when you set the state to "dismissed".
@ -224,7 +224,7 @@ type CodeScanningAlertState struct {
// SarifID identifies a sarif analysis upload. // SarifID identifies a sarif analysis upload.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning // GitHub API docs: https://docs.github.com/rest/code-scanning
type SarifID struct { type SarifID struct {
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
URL *string `json:"url,omitempty"` URL *string `json:"url,omitempty"`
@ -235,7 +235,9 @@ type SarifID struct {
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events // 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. // read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization
//
//meta:operation GET /orgs/{org}/code-scanning/alerts
func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *AlertListOptions) ([]*Alert, *Response, error) { func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *AlertListOptions) ([]*Alert, *Response, error) {
u := fmt.Sprintf("orgs/%v/code-scanning/alerts", org) u := fmt.Sprintf("orgs/%v/code-scanning/alerts", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -263,7 +265,9 @@ func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string,
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events // 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. // read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/alerts
func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *AlertListOptions) ([]*Alert, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/code-scanning/alerts", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -292,7 +296,9 @@ 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. // The security alert_id is the number at the end of the security alert's URL.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-alert // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-alert
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string, id int64) (*Alert, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id)
@ -317,7 +323,9 @@ func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string,
// //
// The security alert_id is the number at the end of the security alert's URL. // The security alert_id is the number at the end of the security alert's URL.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning?apiVersion=2022-11-28#update-a-code-scanning-alert // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#update-a-code-scanning-alert
//
//meta:operation PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
func (s *CodeScanningService) UpdateAlert(ctx context.Context, owner, repo string, id int64, stateInfo *CodeScanningAlertState) (*Alert, *Response, error) { func (s *CodeScanningService) UpdateAlert(ctx context.Context, owner, repo string, id int64, stateInfo *CodeScanningAlertState) (*Alert, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id) u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id)
@ -340,7 +348,9 @@ func (s *CodeScanningService) UpdateAlert(ctx context.Context, owner, repo strin
// You must use an access token with the security_events scope to use this endpoint. // 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 Apps must have the security_events read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#list-instances-of-a-code-scanning-alert // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#list-instances-of-a-code-scanning-alert
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances
func (s *CodeScanningService) ListAlertInstances(ctx context.Context, owner, repo string, id int64, opts *AlertInstancesListOptions) ([]*MostRecentInstance, *Response, error) { func (s *CodeScanningService) ListAlertInstances(ctx context.Context, owner, repo string, id int64, opts *AlertInstancesListOptions) ([]*MostRecentInstance, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v/instances", owner, repo, id) u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v/instances", owner, repo, id)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -368,7 +378,9 @@ func (s *CodeScanningService) ListAlertInstances(ctx context.Context, owner, rep
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events // 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. // write permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#upload-an-analysis-as-sarif-data // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#upload-an-analysis-as-sarif-data
//
//meta:operation POST /repos/{owner}/{repo}/code-scanning/sarifs
func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, sarif *SarifAnalysis) (*SarifID, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs", owner, repo)
@ -400,7 +412,9 @@ type SARIFUpload struct {
// You must use an access token with the security_events scope to use this endpoint. // 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 Apps must have the security_events read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#get-information-about-a-sarif-upload // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#get-information-about-a-sarif-upload
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}
func (s *CodeScanningService) GetSARIF(ctx context.Context, owner, repo, sarifID string) (*SARIFUpload, *Response, error) { func (s *CodeScanningService) GetSARIF(ctx context.Context, owner, repo, sarifID string) (*SARIFUpload, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs/%v", owner, repo, sarifID) u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs/%v", owner, repo, sarifID)
@ -424,7 +438,9 @@ func (s *CodeScanningService) GetSARIF(ctx context.Context, owner, repo, sarifID
// You must use an access token with the security_events scope to use this endpoint. // 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 Apps must have the security_events read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-analyses-for-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#list-code-scanning-analyses-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/analyses
func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*ScanningAnalysis, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -453,7 +469,9 @@ 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. // 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/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}
func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*ScanningAnalysis, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id)
@ -486,7 +504,9 @@ type DeleteAnalysis struct {
// //
// The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation. // 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/code-scanning/code-scanning#delete-a-code-scanning-analysis-from-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#delete-a-code-scanning-analysis-from-a-repository
//
//meta:operation DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}
func (s *CodeScanningService) DeleteAnalysis(ctx context.Context, owner, repo string, id int64) (*DeleteAnalysis, *Response, error) { func (s *CodeScanningService) DeleteAnalysis(ctx context.Context, owner, repo string, id int64) (*DeleteAnalysis, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id) u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id)
@ -509,7 +529,9 @@ func (s *CodeScanningService) DeleteAnalysis(ctx context.Context, owner, repo st
// You must use an access token with the security_events scope to use this endpoint. // You must use an access token with the security_events scope to use this endpoint.
// GitHub Apps must have the contents read permission to use this endpoint. // GitHub Apps must have the contents read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/codeql/databases
func (s *CodeScanningService) ListCodeQLDatabases(ctx context.Context, owner, repo string) ([]*CodeQLDatabase, *Response, error) { func (s *CodeScanningService) ListCodeQLDatabases(ctx context.Context, owner, repo string) ([]*CodeQLDatabase, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/codeql/databases", owner, repo) u := fmt.Sprintf("repos/%v/%v/code-scanning/codeql/databases", owner, repo)
@ -532,7 +554,9 @@ func (s *CodeScanningService) ListCodeQLDatabases(ctx context.Context, owner, re
// You must use an access token with the security_events scope to use this endpoint. // You must use an access token with the security_events scope to use this endpoint.
// GitHub Apps must have the contents read permission to use this endpoint. // GitHub Apps must have the contents read permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}
func (s *CodeScanningService) GetCodeQLDatabase(ctx context.Context, owner, repo, language string) (*CodeQLDatabase, *Response, error) { func (s *CodeScanningService) GetCodeQLDatabase(ctx context.Context, owner, repo, language string) (*CodeQLDatabase, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/code-scanning/codeql/databases/%v", owner, repo, language) u := fmt.Sprintf("repos/%v/%v/code-scanning/codeql/databases/%v", owner, repo, language)
@ -564,7 +588,9 @@ type DefaultSetupConfiguration struct {
// endpoint with private repos or the public_repo scope for public repos. GitHub Apps must have the repo write // endpoint with private repos or the public_repo scope for public repos. GitHub Apps must have the repo write
// permission to use this endpoint. // permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-default-setup-configuration // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-default-setup-configuration
//
//meta:operation GET /repos/{owner}/{repo}/code-scanning/default-setup
func (s *CodeScanningService) GetDefaultSetupConfiguration(ctx context.Context, owner, repo string) (*DefaultSetupConfiguration, *Response, error) { func (s *CodeScanningService) GetDefaultSetupConfiguration(ctx context.Context, owner, repo string) (*DefaultSetupConfiguration, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo) u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo)
@ -605,7 +631,9 @@ type UpdateDefaultSetupConfigurationResponse struct {
// This method might return an AcceptedError and a status code of 202. This is because this is the status that GitHub // This method might return an AcceptedError and a status code of 202. This is because this is the status that GitHub
// returns to signify that it has now scheduled the update of the pull request branch in a background task. // returns to signify that it has now scheduled the update of the pull request branch in a background task.
// //
// GitHub API docs: https://docs.github.com/en/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration
//
//meta:operation PATCH /repos/{owner}/{repo}/code-scanning/default-setup
func (s *CodeScanningService) UpdateDefaultSetupConfiguration(ctx context.Context, owner, repo string, options *UpdateDefaultSetupConfigurationOptions) (*UpdateDefaultSetupConfigurationResponse, *Response, error) { func (s *CodeScanningService) UpdateDefaultSetupConfiguration(ctx context.Context, owner, repo string, options *UpdateDefaultSetupConfigurationOptions) (*UpdateDefaultSetupConfigurationResponse, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo) u := fmt.Sprintf("repos/%s/%s/code-scanning/default-setup", owner, repo)

View file

@ -0,0 +1,87 @@
// Copyright 2023 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"
)
// CodesOfConductService provides access to code-of-conduct-related functions in the GitHub API.
type CodesOfConductService service
// CodeOfConduct represents a code of conduct.
type CodeOfConduct struct {
Name *string `json:"name,omitempty"`
Key *string `json:"key,omitempty"`
URL *string `json:"url,omitempty"`
Body *string `json:"body,omitempty"`
}
func (c *CodeOfConduct) String() string {
return Stringify(c)
}
// List returns all codes of conduct.
//
// GitHub API docs: https://docs.github.com/rest/codes-of-conduct/codes-of-conduct#get-all-codes-of-conduct
//
//meta:operation GET /codes_of_conduct
func (s *CodesOfConductService) List(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
req, err := s.client.NewRequest("GET", "codes_of_conduct", nil)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
var cs []*CodeOfConduct
resp, err := s.client.Do(ctx, req, &cs)
if err != nil {
return nil, resp, err
}
return cs, resp, nil
}
// ListCodesOfConduct returns all codes of conduct.
//
// Deprecated: Use CodesOfConductService.List instead
func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
return c.CodesOfConduct.List(ctx)
}
// Get returns an individual code of conduct.
//
// GitHub API docs: https://docs.github.com/rest/codes-of-conduct/codes-of-conduct#get-a-code-of-conduct
//
//meta:operation GET /codes_of_conduct/{key}
func (s *CodesOfConductService) Get(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
u := fmt.Sprintf("codes_of_conduct/%s", key)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
coc := new(CodeOfConduct)
resp, err := s.client.Do(ctx, req, coc)
if err != nil {
return nil, resp, err
}
return coc, resp, nil
}
// GetCodeOfConduct returns an individual code of conduct.
//
// Deprecated: Use CodesOfConductService.Get instead
func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
return c.CodesOfConduct.Get(ctx, key)
}

View file

@ -13,12 +13,12 @@ import (
// CodespacesService handles communication with the Codespaces related // CodespacesService handles communication with the Codespaces related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/ // GitHub API docs: https://docs.github.com/rest/codespaces/
type CodespacesService service type CodespacesService service
// Codespace represents a codespace. // Codespace represents a codespace.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces // GitHub API docs: https://docs.github.com/rest/codespaces
type Codespace struct { type Codespace struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
@ -90,7 +90,9 @@ type ListCodespaces struct {
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have read access to the codespaces repository permission to use this endpoint. // GitHub Apps must have read access to the codespaces repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#list-codespaces-in-a-repository-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#list-codespaces-in-a-repository-for-the-authenticated-user
//
//meta:operation GET /repos/{owner}/{repo}/codespaces
func (s *CodespacesService) ListInRepo(ctx context.Context, owner, repo string, opts *ListOptions) (*ListCodespaces, *Response, error) { func (s *CodespacesService) ListInRepo(ctx context.Context, owner, repo string, opts *ListOptions) (*ListCodespaces, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces", owner, repo) u := fmt.Sprintf("repos/%v/%v/codespaces", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -112,7 +114,7 @@ func (s *CodespacesService) ListInRepo(ctx context.Context, owner, repo string,
return codespaces, resp, nil return codespaces, resp, nil
} }
// ListOptions represents the options for listing codespaces for a user. // ListCodespacesOptions represents the options for listing codespaces for a user.
type ListCodespacesOptions struct { type ListCodespacesOptions struct {
ListOptions ListOptions
RepositoryID int64 `url:"repository_id,omitempty"` RepositoryID int64 `url:"repository_id,omitempty"`
@ -124,7 +126,9 @@ type ListCodespacesOptions struct {
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have read access to the codespaces repository permission to use this endpoint. // GitHub Apps must have read access to the codespaces repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#list-codespaces-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#list-codespaces-for-the-authenticated-user
//
//meta:operation GET /user/codespaces
func (s *CodespacesService) List(ctx context.Context, opts *ListCodespacesOptions) (*ListCodespaces, *Response, error) { func (s *CodespacesService) List(ctx context.Context, opts *ListCodespacesOptions) (*ListCodespaces, *Response, error) {
u := "user/codespaces" u := "user/codespaces"
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -172,7 +176,9 @@ type CreateCodespaceOptions struct {
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have write access to the codespaces repository permission to use this endpoint. // GitHub Apps must have write access to the codespaces repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#create-a-codespace-in-a-repository // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-in-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/codespaces
func (s *CodespacesService) CreateInRepo(ctx context.Context, owner, repo string, request *CreateCodespaceOptions) (*Codespace, *Response, error) { func (s *CodespacesService) CreateInRepo(ctx context.Context, owner, repo string, request *CreateCodespaceOptions) (*Codespace, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces", owner, repo) u := fmt.Sprintf("repos/%v/%v/codespaces", owner, repo)
@ -195,7 +201,9 @@ func (s *CodespacesService) CreateInRepo(ctx context.Context, owner, repo string
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint. // GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#start-a-codespace-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#start-a-codespace-for-the-authenticated-user
//
//meta:operation POST /user/codespaces/{codespace_name}/start
func (s *CodespacesService) Start(ctx context.Context, codespaceName string) (*Codespace, *Response, error) { func (s *CodespacesService) Start(ctx context.Context, codespaceName string) (*Codespace, *Response, error) {
u := fmt.Sprintf("user/codespaces/%v/start", codespaceName) u := fmt.Sprintf("user/codespaces/%v/start", codespaceName)
@ -218,7 +226,9 @@ func (s *CodespacesService) Start(ctx context.Context, codespaceName string) (*C
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint. // GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#stop-a-codespace-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#stop-a-codespace-for-the-authenticated-user
//
//meta:operation POST /user/codespaces/{codespace_name}/stop
func (s *CodespacesService) Stop(ctx context.Context, codespaceName string) (*Codespace, *Response, error) { func (s *CodespacesService) Stop(ctx context.Context, codespaceName string) (*Codespace, *Response, error) {
u := fmt.Sprintf("user/codespaces/%v/stop", codespaceName) u := fmt.Sprintf("user/codespaces/%v/stop", codespaceName)
@ -241,7 +251,9 @@ func (s *CodespacesService) Stop(ctx context.Context, codespaceName string) (*Co
// You must authenticate using an access token with the codespace scope to use this endpoint. // You must authenticate using an access token with the codespace scope to use this endpoint.
// GitHub Apps must have write access to the codespaces repository permission to use this endpoint. // GitHub Apps must have write access to the codespaces repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/codespaces?apiVersion=2022-11-28#delete-a-codespace-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#delete-a-codespace-for-the-authenticated-user
//
//meta:operation DELETE /user/codespaces/{codespace_name}
func (s *CodespacesService) Delete(ctx context.Context, codespaceName string) (*Response, error) { func (s *CodespacesService) Delete(ctx context.Context, codespaceName string) (*Response, error) {
u := fmt.Sprintf("user/codespaces/%v", codespaceName) u := fmt.Sprintf("user/codespaces/%v", codespaceName)

View file

@ -16,7 +16,9 @@ import (
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint
// GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint. // GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#list-secrets-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#list-secrets-for-the-authenticated-user
//
//meta:operation GET /user/codespaces/secrets
func (s *CodespacesService) ListUserSecrets(ctx context.Context, opts *ListOptions) (*Secrets, *Response, error) { func (s *CodespacesService) ListUserSecrets(ctx context.Context, opts *ListOptions) (*Secrets, *Response, error) {
u, err := addOptions("user/codespaces/secrets", opts) u, err := addOptions("user/codespaces/secrets", opts)
if err != nil { if err != nil {
@ -29,7 +31,9 @@ func (s *CodespacesService) ListUserSecrets(ctx context.Context, opts *ListOptio
// //
// Lists all Codespaces secrets available at the organization-level without revealing their encrypted values. You must authenticate using an access token with the admin:org scope to use this endpoint. // Lists all Codespaces secrets available at the organization-level without revealing their encrypted values. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#list-organization-secrets // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#list-organization-secrets
//
//meta:operation GET /orgs/{org}/codespaces/secrets
func (s *CodespacesService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) { func (s *CodespacesService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets", org) u := fmt.Sprintf("orgs/%v/codespaces/secrets", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -43,7 +47,9 @@ func (s *CodespacesService) ListOrgSecrets(ctx context.Context, org string, opts
// //
// Lists all secrets available in a repository without revealing their encrypted values. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint. // Lists all secrets available in a repository without revealing their encrypted values. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#list-repository-secrets // GitHub API docs: https://docs.github.com/rest/codespaces/repository-secrets#list-repository-secrets
//
//meta:operation GET /repos/{owner}/{repo}/codespaces/secrets
func (s *CodespacesService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) { func (s *CodespacesService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces/secrets", owner, repo) u := fmt.Sprintf("repos/%v/%v/codespaces/secrets", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -74,7 +80,9 @@ func (s *CodespacesService) listSecrets(ctx context.Context, url string) (*Secre
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint.
// GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint. // GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#get-public-key-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#get-public-key-for-the-authenticated-user
//
//meta:operation GET /user/codespaces/secrets/public-key
func (s *CodespacesService) GetUserPublicKey(ctx context.Context) (*PublicKey, *Response, error) { func (s *CodespacesService) GetUserPublicKey(ctx context.Context) (*PublicKey, *Response, error) {
return s.getPublicKey(ctx, "user/codespaces/secrets/public-key") return s.getPublicKey(ctx, "user/codespaces/secrets/public-key")
} }
@ -83,7 +91,9 @@ func (s *CodespacesService) GetUserPublicKey(ctx context.Context) (*PublicKey, *
// //
// Gets a public key for an organization, which is required in order to encrypt secrets. You need to encrypt the value of a secret before you can create or update secrets. You must authenticate using an access token with the admin:org scope to use this endpoint. // Gets a public key for an organization, which is required in order to encrypt secrets. You need to encrypt the value of a secret before you can create or update secrets. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-public-key
//
//meta:operation GET /orgs/{org}/codespaces/secrets/public-key
func (s *CodespacesService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) { func (s *CodespacesService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
return s.getPublicKey(ctx, fmt.Sprintf("orgs/%v/codespaces/secrets/public-key", org)) return s.getPublicKey(ctx, fmt.Sprintf("orgs/%v/codespaces/secrets/public-key", org))
} }
@ -92,7 +102,9 @@ func (s *CodespacesService) GetOrgPublicKey(ctx context.Context, org string) (*P
// //
// Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint. // Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#get-a-repository-public-key // GitHub API docs: https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-public-key
//
//meta:operation GET /repos/{owner}/{repo}/codespaces/secrets/public-key
func (s *CodespacesService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) { func (s *CodespacesService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
return s.getPublicKey(ctx, fmt.Sprintf("repos/%v/%v/codespaces/secrets/public-key", owner, repo)) return s.getPublicKey(ctx, fmt.Sprintf("repos/%v/%v/codespaces/secrets/public-key", owner, repo))
} }
@ -118,7 +130,9 @@ func (s *CodespacesService) getPublicKey(ctx context.Context, url string) (*Publ
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint.
// GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint. // GitHub Apps must have read access to the codespaces_user_secrets user permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#get-a-secret-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#get-a-secret-for-the-authenticated-user
//
//meta:operation GET /user/codespaces/secrets/{secret_name}
func (s *CodespacesService) GetUserSecret(ctx context.Context, name string) (*Secret, *Response, error) { func (s *CodespacesService) GetUserSecret(ctx context.Context, name string) (*Secret, *Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v", name) u := fmt.Sprintf("user/codespaces/secrets/%v", name)
return s.getSecret(ctx, u) return s.getSecret(ctx, u)
@ -128,7 +142,9 @@ func (s *CodespacesService) GetUserSecret(ctx context.Context, name string) (*Se
// //
// Gets an organization secret without revealing its encrypted value. You must authenticate using an access token with the admin:org scope to use this endpoint. // Gets an organization secret without revealing its encrypted value. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-secret
//
//meta:operation GET /orgs/{org}/codespaces/secrets/{secret_name}
func (s *CodespacesService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) { func (s *CodespacesService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, name) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, name)
return s.getSecret(ctx, u) return s.getSecret(ctx, u)
@ -138,7 +154,9 @@ func (s *CodespacesService) GetOrgSecret(ctx context.Context, org, name string)
// //
// Gets a single repository secret without revealing its encrypted value. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint. // Gets a single repository secret without revealing its encrypted value. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret // GitHub API docs: https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-secret
//
//meta:operation GET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
func (s *CodespacesService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) { func (s *CodespacesService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, name) u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, name)
return s.getSecret(ctx, u) return s.getSecret(ctx, u)
@ -165,7 +183,9 @@ func (s *CodespacesService) getSecret(ctx context.Context, url string) (*Secret,
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must also have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must also have Codespaces access to use this endpoint.
// GitHub Apps must have write access to the codespaces_user_secrets user permission and codespaces_secrets repository permission on all referenced repositories to use this endpoint. // GitHub Apps must have write access to the codespaces_user_secrets user permission and codespaces_secrets repository permission on all referenced repositories to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#create-or-update-a-secret-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#create-or-update-a-secret-for-the-authenticated-user
//
//meta:operation PUT /user/codespaces/secrets/{secret_name}
func (s *CodespacesService) CreateOrUpdateUserSecret(ctx context.Context, eSecret *EncryptedSecret) (*Response, error) { func (s *CodespacesService) CreateOrUpdateUserSecret(ctx context.Context, eSecret *EncryptedSecret) (*Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v", eSecret.Name) u := fmt.Sprintf("user/codespaces/secrets/%v", eSecret.Name)
return s.createOrUpdateSecret(ctx, u, eSecret) return s.createOrUpdateSecret(ctx, u, eSecret)
@ -175,7 +195,9 @@ func (s *CodespacesService) CreateOrUpdateUserSecret(ctx context.Context, eSecre
// //
// Creates or updates an organization secret with an encrypted value. Encrypt your secret using LibSodium. You must authenticate using an access token with the admin:org scope to use this endpoint. // Creates or updates an organization secret with an encrypted value. Encrypt your secret using LibSodium. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret
//
//meta:operation PUT /orgs/{org}/codespaces/secrets/{secret_name}
func (s *CodespacesService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) { func (s *CodespacesService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, eSecret.Name) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, eSecret.Name)
return s.createOrUpdateSecret(ctx, u, eSecret) return s.createOrUpdateSecret(ctx, u, eSecret)
@ -185,7 +207,9 @@ func (s *CodespacesService) CreateOrUpdateOrgSecret(ctx context.Context, org str
// //
// Creates or updates a repository secret with an encrypted value. Encrypt your secret using LibSodium. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint. // Creates or updates a repository secret with an encrypted value. Encrypt your secret using LibSodium. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret // GitHub API docs: https://docs.github.com/rest/codespaces/repository-secrets#create-or-update-a-repository-secret
//
//meta:operation PUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
func (s *CodespacesService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) { func (s *CodespacesService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, eSecret.Name) u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, eSecret.Name)
return s.createOrUpdateSecret(ctx, u, eSecret) return s.createOrUpdateSecret(ctx, u, eSecret)
@ -211,7 +235,9 @@ func (s *CodespacesService) createOrUpdateSecret(ctx context.Context, url string
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint.
// GitHub Apps must have write access to the codespaces_user_secrets user permission to use this endpoint. // GitHub Apps must have write access to the codespaces_user_secrets user permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#delete-a-secret-for-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#delete-a-secret-for-the-authenticated-user
//
//meta:operation DELETE /user/codespaces/secrets/{secret_name}
func (s *CodespacesService) DeleteUserSecret(ctx context.Context, name string) (*Response, error) { func (s *CodespacesService) DeleteUserSecret(ctx context.Context, name string) (*Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v", name) u := fmt.Sprintf("user/codespaces/secrets/%v", name)
return s.deleteSecret(ctx, u) return s.deleteSecret(ctx, u)
@ -221,7 +247,9 @@ func (s *CodespacesService) DeleteUserSecret(ctx context.Context, name string) (
// //
// Deletes an organization secret using the secret name. You must authenticate using an access token with the admin:org scope to use this endpoint. // Deletes an organization secret using the secret name. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#delete-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/codespaces/secrets/{secret_name}
func (s *CodespacesService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) { func (s *CodespacesService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, name) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v", org, name)
return s.deleteSecret(ctx, u) return s.deleteSecret(ctx, u)
@ -231,7 +259,9 @@ func (s *CodespacesService) DeleteOrgSecret(ctx context.Context, org, name strin
// //
// Deletes a secret in a repository using the secret name. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint. // Deletes a secret in a repository using the secret name. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets repository permission to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret // GitHub API docs: https://docs.github.com/rest/codespaces/repository-secrets#delete-a-repository-secret
//
//meta:operation DELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
func (s *CodespacesService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) { func (s *CodespacesService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, name) u := fmt.Sprintf("repos/%v/%v/codespaces/secrets/%v", owner, repo, name)
return s.deleteSecret(ctx, u) return s.deleteSecret(ctx, u)
@ -256,7 +286,9 @@ func (s *CodespacesService) deleteSecret(ctx context.Context, url string) (*Resp
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint.
// GitHub Apps must have read access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on all referenced repositories to use this endpoint. // GitHub Apps must have read access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on all referenced repositories to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#list-selected-repositories-for-a-user-secret // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#list-selected-repositories-for-a-user-secret
//
//meta:operation GET /user/codespaces/secrets/{secret_name}/repositories
func (s *CodespacesService) ListSelectedReposForUserSecret(ctx context.Context, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { func (s *CodespacesService) ListSelectedReposForUserSecret(ctx context.Context, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v/repositories", name) u := fmt.Sprintf("user/codespaces/secrets/%v/repositories", name)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -271,7 +303,9 @@ func (s *CodespacesService) ListSelectedReposForUserSecret(ctx context.Context,
// //
// Lists all repositories that have been selected when the visibility for repository access to a secret is set to selected. You must authenticate using an access token with the admin:org scope to use this endpoint. // Lists all repositories that have been selected when the visibility for repository access to a secret is set to selected. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// GitHub API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#list-selected-repositories-for-an-organization-secret
//
//meta:operation GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories
func (s *CodespacesService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { func (s *CodespacesService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories", org, name) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories", org, name)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -302,7 +336,9 @@ func (s *CodespacesService) listSelectedReposForSecret(ctx context.Context, url
// You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. // You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint.
// GitHub Apps must have write access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on all referenced repositories to use this endpoint. // GitHub Apps must have write access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on all referenced repositories to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#set-selected-repositories-for-a-user-secret // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#set-selected-repositories-for-a-user-secret
//
//meta:operation PUT /user/codespaces/secrets/{secret_name}/repositories
func (s *CodespacesService) SetSelectedReposForUserSecret(ctx context.Context, name string, ids SelectedRepoIDs) (*Response, error) { func (s *CodespacesService) SetSelectedReposForUserSecret(ctx context.Context, name string, ids SelectedRepoIDs) (*Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v/repositories", name) u := fmt.Sprintf("user/codespaces/secrets/%v/repositories", name)
return s.setSelectedRepoForSecret(ctx, u, ids) return s.setSelectedRepoForSecret(ctx, u, ids)
@ -312,7 +348,9 @@ func (s *CodespacesService) SetSelectedReposForUserSecret(ctx context.Context, n
// //
// Replaces all repositories for an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint. // Replaces all repositories for an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#set-selected-repositories-for-a-user-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#set-selected-repositories-for-an-organization-secret
//
//meta:operation PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories
func (s *CodespacesService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) { func (s *CodespacesService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories", org, name) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories", org, name)
return s.setSelectedRepoForSecret(ctx, u, ids) return s.setSelectedRepoForSecret(ctx, u, ids)
@ -340,7 +378,9 @@ func (s *CodespacesService) setSelectedRepoForSecret(ctx context.Context, url st
// //
// Adds a repository to the selected repositories for a user's codespace secret. You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. GitHub Apps must have write access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on the referenced repository to use this endpoint. // Adds a repository to the selected repositories for a user's codespace secret. You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. GitHub Apps must have write access to the codespaces_user_secrets user permission and write access to the codespaces_secrets repository permission on the referenced repository to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#add-a-selected-repository-to-a-user-secret // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#add-a-selected-repository-to-a-user-secret
//
//meta:operation PUT /user/codespaces/secrets/{secret_name}/repositories/{repository_id}
func (s *CodespacesService) AddSelectedRepoToUserSecret(ctx context.Context, name string, repo *Repository) (*Response, error) { func (s *CodespacesService) AddSelectedRepoToUserSecret(ctx context.Context, name string, repo *Repository) (*Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v/repositories/%v", name, *repo.ID) u := fmt.Sprintf("user/codespaces/secrets/%v/repositories/%v", name, *repo.ID)
return s.addSelectedRepoToSecret(ctx, u) return s.addSelectedRepoToSecret(ctx, u)
@ -350,7 +390,9 @@ func (s *CodespacesService) AddSelectedRepoToUserSecret(ctx context.Context, nam
// //
// Adds a repository to an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint. // Adds a repository to an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#add-selected-repository-to-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#add-selected-repository-to-an-organization-secret
//
//meta:operation PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}
func (s *CodespacesService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { func (s *CodespacesService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories/%v", org, name, *repo.ID) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories/%v", org, name, *repo.ID)
return s.addSelectedRepoToSecret(ctx, u) return s.addSelectedRepoToSecret(ctx, u)
@ -374,7 +416,9 @@ func (s *CodespacesService) addSelectedRepoToSecret(ctx context.Context, url str
// //
// Removes a repository from the selected repositories for a user's codespace secret. You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. GitHub Apps must have write access to the codespaces_user_secrets user permission to use this endpoint. // Removes a repository from the selected repositories for a user's codespace secret. You must authenticate using an access token with the codespace or codespace:secrets scope to use this endpoint. User must have Codespaces access to use this endpoint. GitHub Apps must have write access to the codespaces_user_secrets user permission to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/secrets?apiVersion=2022-11-28#remove-a-selected-repository-from-a-user-secret // GitHub API docs: https://docs.github.com/rest/codespaces/secrets#remove-a-selected-repository-from-a-user-secret
//
//meta:operation DELETE /user/codespaces/secrets/{secret_name}/repositories/{repository_id}
func (s *CodespacesService) RemoveSelectedRepoFromUserSecret(ctx context.Context, name string, repo *Repository) (*Response, error) { func (s *CodespacesService) RemoveSelectedRepoFromUserSecret(ctx context.Context, name string, repo *Repository) (*Response, error) {
u := fmt.Sprintf("user/codespaces/secrets/%v/repositories/%v", name, *repo.ID) u := fmt.Sprintf("user/codespaces/secrets/%v/repositories/%v", name, *repo.ID)
return s.removeSelectedRepoFromSecret(ctx, u) return s.removeSelectedRepoFromSecret(ctx, u)
@ -384,7 +428,9 @@ func (s *CodespacesService) RemoveSelectedRepoFromUserSecret(ctx context.Context
// //
// Removes a repository from an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint. // Removes a repository from an organization secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret. You must authenticate using an access token with the admin:org scope to use this endpoint.
// //
// Github API docs: https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-secret // GitHub API docs: https://docs.github.com/rest/codespaces/organization-secrets#remove-selected-repository-from-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}
func (s *CodespacesService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { func (s *CodespacesService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories/%v", org, name, *repo.ID) u := fmt.Sprintf("orgs/%v/codespaces/secrets/%v/repositories/%v", org, name, *repo.ID)
return s.removeSelectedRepoFromSecret(ctx, u) return s.removeSelectedRepoFromSecret(ctx, u)

View file

@ -8,5 +8,5 @@ package github
// DependabotService handles communication with the Dependabot related // DependabotService handles communication with the Dependabot related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/ // GitHub API docs: https://docs.github.com/rest/dependabot/
type DependabotService service type DependabotService service

View file

@ -67,6 +67,17 @@ type DependabotAlert struct {
Repository *Repository `json:"repository,omitempty"` Repository *Repository `json:"repository,omitempty"`
} }
// DependabotAlertState represents the state of a Dependabot alert to update.
type DependabotAlertState struct {
// The state of the Dependabot alert. A dismissed_reason must be provided when setting the state to dismissed.
State string `json:"state"`
// Required when state is dismissed. A reason for dismissing the alert.
// Can be one of: fix_started, inaccurate, no_bandwidth, not_used, tolerable_risk
DismissedReason *string `json:"dismissed_reason,omitempty"`
// An optional comment associated with dismissing the alert.
DismissedComment *string `json:"dismissed_comment,omitempty"`
}
// ListAlertsOptions specifies the optional parameters to the DependabotService.ListRepoAlerts // ListAlertsOptions specifies the optional parameters to the DependabotService.ListRepoAlerts
// and DependabotService.ListOrgAlerts methods. // and DependabotService.ListOrgAlerts methods.
type ListAlertsOptions struct { type ListAlertsOptions struct {
@ -104,7 +115,9 @@ func (s *DependabotService) listAlerts(ctx context.Context, url string, opts *Li
// ListRepoAlerts lists all Dependabot alerts of a repository. // ListRepoAlerts lists all Dependabot alerts of a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository // GitHub API docs: https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/alerts
func (s *DependabotService) ListRepoAlerts(ctx context.Context, owner, repo string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) { func (s *DependabotService) ListRepoAlerts(ctx context.Context, owner, repo string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/dependabot/alerts", owner, repo) url := fmt.Sprintf("repos/%v/%v/dependabot/alerts", owner, repo)
return s.listAlerts(ctx, url, opts) return s.listAlerts(ctx, url, opts)
@ -112,7 +125,9 @@ func (s *DependabotService) ListRepoAlerts(ctx context.Context, owner, repo stri
// ListOrgAlerts lists all Dependabot alerts of an organization. // ListOrgAlerts lists all Dependabot alerts of an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#list-dependabot-alerts-for-an-organization // GitHub API docs: https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-organization
//
//meta:operation GET /orgs/{org}/dependabot/alerts
func (s *DependabotService) ListOrgAlerts(ctx context.Context, org string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) { func (s *DependabotService) ListOrgAlerts(ctx context.Context, org string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) {
url := fmt.Sprintf("orgs/%v/dependabot/alerts", org) url := fmt.Sprintf("orgs/%v/dependabot/alerts", org)
return s.listAlerts(ctx, url, opts) return s.listAlerts(ctx, url, opts)
@ -120,7 +135,9 @@ func (s *DependabotService) ListOrgAlerts(ctx context.Context, org string, opts
// GetRepoAlert gets a single repository Dependabot alert. // GetRepoAlert gets a single repository Dependabot alert.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#get-a-dependabot-alert // GitHub API docs: https://docs.github.com/rest/dependabot/alerts#get-a-dependabot-alert
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/alerts/{alert_number}
func (s *DependabotService) GetRepoAlert(ctx context.Context, owner, repo string, number int) (*DependabotAlert, *Response, error) { func (s *DependabotService) GetRepoAlert(ctx context.Context, owner, repo string, number int) (*DependabotAlert, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/dependabot/alerts/%v", owner, repo, number) url := fmt.Sprintf("repos/%v/%v/dependabot/alerts/%v", owner, repo, number)
req, err := s.client.NewRequest("GET", url, nil) req, err := s.client.NewRequest("GET", url, nil)
@ -136,3 +153,24 @@ func (s *DependabotService) GetRepoAlert(ctx context.Context, owner, repo string
return alert, resp, nil return alert, resp, nil
} }
// UpdateAlert updates a Dependabot alert.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/alerts#update-a-dependabot-alert
//
//meta:operation PATCH /repos/{owner}/{repo}/dependabot/alerts/{alert_number}
func (s *DependabotService) UpdateAlert(ctx context.Context, owner, repo string, number int, stateInfo *DependabotAlertState) (*DependabotAlert, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/dependabot/alerts/%v", owner, repo, number)
req, err := s.client.NewRequest("PATCH", url, stateInfo)
if err != nil {
return nil, nil, err
}
alert := new(DependabotAlert)
resp, err := s.client.Do(ctx, req, alert)
if err != nil {
return nil, resp, err
}
return alert, resp, nil
}

View file

@ -27,7 +27,9 @@ func (s *DependabotService) getPublicKey(ctx context.Context, url string) (*Publ
// GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption. // GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-public-key // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-a-repository-public-key
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets/public-key
func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/public-key", owner, repo)
return s.getPublicKey(ctx, url) return s.getPublicKey(ctx, url)
@ -35,7 +37,9 @@ func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo st
// GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption. // GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-public-key // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-an-organization-public-key
//
//meta:operation GET /orgs/{org}/dependabot/secrets/public-key
func (s *DependabotService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) { func (s *DependabotService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
url := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", org) url := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", org)
return s.getPublicKey(ctx, url) return s.getPublicKey(ctx, url)
@ -64,7 +68,9 @@ func (s *DependabotService) listSecrets(ctx context.Context, url string, opts *L
// ListRepoSecrets lists all Dependabot secrets available in a repository // ListRepoSecrets lists all Dependabot secrets available in a repository
// without revealing their encrypted values. // without revealing their encrypted values.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-repository-secrets // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-repository-secrets
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets
func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/dependabot/secrets", owner, repo)
return s.listSecrets(ctx, url, opts) return s.listSecrets(ctx, url, opts)
@ -73,7 +79,9 @@ func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo str
// ListOrgSecrets lists all Dependabot secrets available in an organization // ListOrgSecrets lists all Dependabot secrets available in an organization
// without revealing their encrypted values. // without revealing their encrypted values.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-organization-secrets // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-organization-secrets
//
//meta:operation GET /orgs/{org}/dependabot/secrets
func (s *DependabotService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) { func (s *DependabotService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
url := fmt.Sprintf("orgs/%v/dependabot/secrets", org) url := fmt.Sprintf("orgs/%v/dependabot/secrets", org)
return s.listSecrets(ctx, url, opts) return s.listSecrets(ctx, url, opts)
@ -96,7 +104,9 @@ func (s *DependabotService) getSecret(ctx context.Context, url string) (*Secret,
// GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value. // GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-a-repository-secret
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
return s.getSecret(ctx, url) return s.getSecret(ctx, url)
@ -104,7 +114,9 @@ func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name
// GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value. // GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret
//
//meta:operation GET /orgs/{org}/dependabot/secrets/{secret_name}
func (s *DependabotService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) { func (s *DependabotService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
return s.getSecret(ctx, url) return s.getSecret(ctx, url)
@ -134,7 +146,9 @@ func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *
// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value. // CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#create-or-update-a-repository-secret
//
//meta:operation PUT /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name)
return s.putSecret(ctx, url, eSecret) return s.putSecret(ctx, url, eSecret)
@ -142,7 +156,9 @@ func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner,
// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value. // CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) { func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs)) repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs))
for i, secret := range eSecret.SelectedRepositoryIDs { for i, secret := range eSecret.SelectedRepositoryIDs {
@ -176,7 +192,9 @@ func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Resp
// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name. // DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret
//
//meta:operation DELETE /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) { 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) url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
return s.deleteSecret(ctx, url) return s.deleteSecret(ctx, url)
@ -184,7 +202,9 @@ func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, n
// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name. // DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#delete-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/dependabot/secrets/{secret_name}
func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) { func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
return s.deleteSecret(ctx, url) return s.deleteSecret(ctx, url)
@ -192,7 +212,9 @@ func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name strin
// ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret. // ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret
//
//meta:operation GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories
func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { 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) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
u, err := addOptions(url, opts) u, err := addOptions(url, opts)
@ -219,7 +241,9 @@ type DependabotSecretsSelectedRepoIDs []int64
// SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret. // SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories
func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids DependabotSecretsSelectedRepoIDs) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
type repoIDs struct { type repoIDs struct {
@ -236,7 +260,9 @@ func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, or
// AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret. // AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}
func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
req, err := s.client.NewRequest("PUT", url, nil) req, err := s.client.NewRequest("PUT", url, nil)
@ -249,7 +275,9 @@ func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org,
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret. // RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret // GitHub API docs: https://docs.github.com/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}
func (s *DependabotService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { 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) url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
req, err := s.client.NewRequest("DELETE", url, nil) req, err := s.client.NewRequest("DELETE", url, nil)

View file

@ -61,7 +61,9 @@ func (s SBOM) String() string {
// GetSBOM fetches the software bill of materials for a repository. // GetSBOM fetches the software bill of materials for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/dependency-graph/sboms // GitHub API docs: https://docs.github.com/rest/dependency-graph/sboms#export-a-software-bill-of-materials-sbom-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/dependency-graph/sbom
func (s *DependencyGraphService) GetSBOM(ctx context.Context, owner, repo string) (*SBOM, *Response, error) { func (s *DependencyGraphService) GetSBOM(ctx context.Context, owner, repo string) (*SBOM, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/dependency-graph/sbom", owner, repo) u := fmt.Sprintf("repos/%v/%v/dependency-graph/sbom", owner, repo)

View file

@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API.
Usage: Usage:
import "github.com/google/go-github/v55/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) import "github.com/google/go-github/v57/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/google/go-github/github" // with go modules disabled 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 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 services of a client divide the API into logical chunks and correspond to
the structure of the GitHub API documentation at the structure of the GitHub API documentation at
https://docs.github.com/en/rest . https://docs.github.com/rest .
NOTE: Using the https://godoc.org/context package, one can easily NOTE: Using the https://godoc.org/context package, one can easily
pass cancelation signals and deadlines to various services of the client for pass cancelation signals and deadlines to various services of the client for
@ -119,7 +119,7 @@ For secondary rate limits, you can check if its type is *github.AbuseRateLimitEr
} }
Learn more about GitHub rate limiting at Learn more about GitHub rate limiting at
https://docs.github.com/en/rest/rate-limit . https://docs.github.com/rest/rate-limit .
# Accepted Status # Accepted Status
@ -145,7 +145,7 @@ instead designed to work with a caching http.Transport. We recommend using
https://github.com/gregjones/httpcache for that. https://github.com/gregjones/httpcache for that.
Learn more about GitHub conditional requests at Learn more about GitHub conditional requests at
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests. https://docs.github.com/rest/overview/resources-in-the-rest-api#conditional-requests.
# Creating and Updating Resources # Creating and Updating Resources

View file

@ -0,0 +1,40 @@
// Copyright 2023 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"
)
// EmojisService provides access to emoji-related functions in the GitHub API.
type EmojisService service
// List returns the emojis available to use on GitHub.
//
// GitHub API docs: https://docs.github.com/rest/emojis/emojis#get-emojis
//
//meta:operation GET /emojis
func (s *EmojisService) List(ctx context.Context) (map[string]string, *Response, error) {
req, err := s.client.NewRequest("GET", "emojis", nil)
if err != nil {
return nil, nil, err
}
var emoji map[string]string
resp, err := s.client.Do(ctx, req, &emoji)
if err != nil {
return nil, resp, err
}
return emoji, resp, nil
}
// ListEmojis returns the emojis available to use on GitHub.
//
// Deprecated: Use EmojisService.List instead
func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
return c.Emojis.List(ctx)
}

View file

@ -8,5 +8,5 @@ package github
// EnterpriseService provides access to the enterprise related functions // EnterpriseService provides access to the enterprise related functions
// in the GitHub API. // in the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/ // GitHub API docs: https://docs.github.com/rest/enterprise-admin/
type EnterpriseService service type EnterpriseService service

View file

@ -79,7 +79,9 @@ type ListEnterpriseRunnerGroupOptions struct {
// ListRunnerGroups lists all self-hosted runner groups configured in an enterprise. // ListRunnerGroups lists all self-hosted runner groups configured in an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runner-groups
func (s *EnterpriseService) ListRunnerGroups(ctx context.Context, enterprise string, opts *ListEnterpriseRunnerGroupOptions) (*EnterpriseRunnerGroups, *Response, error) { func (s *EnterpriseService) ListRunnerGroups(ctx context.Context, enterprise string, opts *ListEnterpriseRunnerGroupOptions) (*EnterpriseRunnerGroups, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runner-groups", enterprise)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -103,7 +105,9 @@ func (s *EnterpriseService) ListRunnerGroups(ctx context.Context, enterprise str
// GetEnterpriseRunnerGroup gets a specific self-hosted runner group for an enterprise using its RunnerGroup ID. // GetEnterpriseRunnerGroup gets a specific self-hosted runner group for an enterprise using its RunnerGroup ID.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}
func (s *EnterpriseService) GetEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64) (*EnterpriseRunnerGroup, *Response, error) { func (s *EnterpriseService) GetEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64) (*EnterpriseRunnerGroup, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -122,7 +126,9 @@ func (s *EnterpriseService) GetEnterpriseRunnerGroup(ctx context.Context, enterp
// DeleteEnterpriseRunnerGroup deletes a self-hosted runner group from an enterprise. // DeleteEnterpriseRunnerGroup deletes a self-hosted runner group from an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#delete-a-self-hosted-runner-group-from-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}
func (s *EnterpriseService) DeleteEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64) (*Response, error) { func (s *EnterpriseService) DeleteEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID)
@ -136,7 +142,9 @@ func (s *EnterpriseService) DeleteEnterpriseRunnerGroup(ctx context.Context, ent
// CreateEnterpriseRunnerGroup creates a new self-hosted runner group for an enterprise. // CreateEnterpriseRunnerGroup creates a new self-hosted runner group for an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#create-a-self-hosted-runner-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/runner-groups
func (s *EnterpriseService) CreateEnterpriseRunnerGroup(ctx context.Context, enterprise string, createReq CreateEnterpriseRunnerGroupRequest) (*EnterpriseRunnerGroup, *Response, error) { func (s *EnterpriseService) CreateEnterpriseRunnerGroup(ctx context.Context, enterprise string, createReq CreateEnterpriseRunnerGroupRequest) (*EnterpriseRunnerGroup, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runner-groups", enterprise)
req, err := s.client.NewRequest("POST", u, createReq) req, err := s.client.NewRequest("POST", u, createReq)
@ -155,7 +163,9 @@ func (s *EnterpriseService) CreateEnterpriseRunnerGroup(ctx context.Context, ent
// UpdateEnterpriseRunnerGroup updates a self-hosted runner group for an enterprise. // UpdateEnterpriseRunnerGroup updates a self-hosted runner group for an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#update-a-self-hosted-runner-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-enterprise
//
//meta:operation PATCH /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}
func (s *EnterpriseService) UpdateEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64, updateReq UpdateEnterpriseRunnerGroupRequest) (*EnterpriseRunnerGroup, *Response, error) { func (s *EnterpriseService) UpdateEnterpriseRunnerGroup(ctx context.Context, enterprise string, groupID int64, updateReq UpdateEnterpriseRunnerGroupRequest) (*EnterpriseRunnerGroup, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v", enterprise, groupID)
req, err := s.client.NewRequest("PATCH", u, updateReq) req, err := s.client.NewRequest("PATCH", u, updateReq)
@ -174,7 +184,9 @@ func (s *EnterpriseService) UpdateEnterpriseRunnerGroup(ctx context.Context, ent
// ListOrganizationAccessRunnerGroup lists the organizations with access to a self-hosted runner group configured in an enterprise. // ListOrganizationAccessRunnerGroup lists the organizations with access to a self-hosted runner group configured in an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations
func (s *EnterpriseService) ListOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID int64, opts *ListOptions) (*ListOrganizations, *Response, error) { func (s *EnterpriseService) ListOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID int64, opts *ListOptions) (*ListOrganizations, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations", enterprise, groupID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -199,7 +211,9 @@ func (s *EnterpriseService) ListOrganizationAccessRunnerGroup(ctx context.Contex
// SetOrganizationAccessRunnerGroup replaces the list of organizations that have access to a self-hosted runner group configured in an enterprise // SetOrganizationAccessRunnerGroup replaces the list of organizations that have access to a self-hosted runner group configured in an enterprise
// with a new List of organizations. // with a new List of organizations.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#set-organization-access-for-a-self-hosted-runner-group-in-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#set-organization-access-for-a-self-hosted-runner-group-in-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations
func (s *EnterpriseService) SetOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID int64, ids SetOrgAccessRunnerGroupRequest) (*Response, error) { func (s *EnterpriseService) SetOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID int64, ids SetOrgAccessRunnerGroupRequest) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations", enterprise, groupID)
@ -214,7 +228,9 @@ func (s *EnterpriseService) SetOrganizationAccessRunnerGroup(ctx context.Context
// AddOrganizationAccessRunnerGroup adds an organization to the list of selected organizations that can access a self-hosted runner group. // AddOrganizationAccessRunnerGroup adds an organization to the list of selected organizations that can access a self-hosted runner group.
// The runner group must have visibility set to 'selected'. // The runner group must have visibility set to 'selected'.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#add-organization-access-to-a-self-hosted-runner-group-in-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#add-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations/{org_id}
func (s *EnterpriseService) AddOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID, orgID int64) (*Response, error) { func (s *EnterpriseService) AddOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID, orgID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations/%v", enterprise, groupID, orgID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations/%v", enterprise, groupID, orgID)
@ -229,7 +245,9 @@ func (s *EnterpriseService) AddOrganizationAccessRunnerGroup(ctx context.Context
// RemoveOrganizationAccessRunnerGroup removes an organization from the list of selected organizations that can access a self-hosted runner group. // RemoveOrganizationAccessRunnerGroup removes an organization from the list of selected organizations that can access a self-hosted runner group.
// The runner group must have visibility set to 'selected'. // The runner group must have visibility set to 'selected'.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#remove-organization-access-to-a-self-hosted-runner-group-in-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#remove-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations/{org_id}
func (s *EnterpriseService) RemoveOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID, orgID int64) (*Response, error) { func (s *EnterpriseService) RemoveOrganizationAccessRunnerGroup(ctx context.Context, enterprise string, groupID, orgID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations/%v", enterprise, groupID, orgID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/organizations/%v", enterprise, groupID, orgID)
@ -243,7 +261,9 @@ func (s *EnterpriseService) RemoveOrganizationAccessRunnerGroup(ctx context.Cont
// ListRunnerGroupRunners lists self-hosted runners that are in a specific enterprise group. // ListRunnerGroupRunners lists self-hosted runners that are in a specific enterprise group.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners
func (s *EnterpriseService) ListRunnerGroupRunners(ctx context.Context, enterprise string, groupID int64, opts *ListOptions) (*Runners, *Response, error) { func (s *EnterpriseService) ListRunnerGroupRunners(ctx context.Context, enterprise string, groupID int64, opts *ListOptions) (*Runners, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners", enterprise, groupID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -268,7 +288,9 @@ func (s *EnterpriseService) ListRunnerGroupRunners(ctx context.Context, enterpri
// SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an enterprise runner group // SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an enterprise runner group
// with a new list of runners. // with a new list of runners.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#set-self-hosted-runners-in-a-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners
func (s *EnterpriseService) SetRunnerGroupRunners(ctx context.Context, enterprise string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) { func (s *EnterpriseService) SetRunnerGroupRunners(ctx context.Context, enterprise string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners", enterprise, groupID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners", enterprise, groupID)
@ -282,7 +304,9 @@ func (s *EnterpriseService) SetRunnerGroupRunners(ctx context.Context, enterpris
// AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an enterprise. // AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#add-a-self-hosted-runner-to-a-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#add-a-self-hosted-runner-to-a-group-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners/{runner_id}
func (s *EnterpriseService) AddRunnerGroupRunners(ctx context.Context, enterprise string, groupID, runnerID int64) (*Response, error) { func (s *EnterpriseService) AddRunnerGroupRunners(ctx context.Context, enterprise string, groupID, runnerID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners/%v", enterprise, groupID, runnerID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners/%v", enterprise, groupID, runnerID)
@ -297,7 +321,9 @@ func (s *EnterpriseService) AddRunnerGroupRunners(ctx context.Context, enterpris
// RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an enterprise. // RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an enterprise.
// The runner is then returned to the default group. // The runner is then returned to the default group.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#remove-a-self-hosted-runner-from-a-group-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners/{runner_id}
func (s *EnterpriseService) RemoveRunnerGroupRunners(ctx context.Context, enterprise string, groupID, runnerID int64) (*Response, error) { func (s *EnterpriseService) RemoveRunnerGroupRunners(ctx context.Context, enterprise string, groupID, runnerID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners/%v", enterprise, groupID, runnerID) u := fmt.Sprintf("enterprises/%v/actions/runner-groups/%v/runners/%v", enterprise, groupID, runnerID)

View file

@ -12,7 +12,9 @@ import (
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // 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-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#list-runner-applications-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runners/downloads
func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) { func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -31,7 +33,9 @@ func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context,
// GenerateEnterpriseJITConfig generates a just-in-time configuration for an enterprise. // GenerateEnterpriseJITConfig generates a just-in-time configuration for an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/runners/generate-jitconfig
func (s *EnterpriseService) GenerateEnterpriseJITConfig(ctx context.Context, enterprise string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) { func (s *EnterpriseService) GenerateEnterpriseJITConfig(ctx context.Context, enterprise string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners/generate-jitconfig", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runners/generate-jitconfig", enterprise)
@ -51,7 +55,9 @@ func (s *EnterpriseService) GenerateEnterpriseJITConfig(ctx context.Context, ent
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner. // CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#create-a-registration-token-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/runners/registration-token
func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) { func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners/registration-token", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runners/registration-token", enterprise)
@ -71,7 +77,9 @@ func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterpr
// ListRunners lists all the self-hosted runners for a enterprise. // ListRunners lists all the self-hosted runners for a enterprise.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runners
func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) { func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise) u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -95,7 +103,9 @@ 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. // RemoveRunner forces the removal of a self-hosted runner from an enterprise using the runner id.
// //
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/runners/{runner_id}
func (s *EnterpriseService) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) { func (s *EnterpriseService) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners/%v", enterprise, runnerID) u := fmt.Sprintf("enterprises/%v/actions/runners/%v", enterprise, runnerID)

View file

@ -12,7 +12,9 @@ import (
// GetAuditLog gets the audit-log entries for an organization. // GetAuditLog gets the audit-log entries for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/audit-log
func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) { func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) {
u := fmt.Sprintf("enterprises/%v/audit-log", enterprise) u := fmt.Sprintf("enterprises/%v/audit-log", enterprise)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)

View file

@ -20,7 +20,9 @@ type EnterpriseSecurityAnalysisSettings struct {
// GetCodeSecurityAndAnalysis gets code security and analysis features for an enterprise. // GetCodeSecurityAndAnalysis gets code security and analysis features for an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/code-security-and-analysis?apiVersion=2022-11-28#get-code-security-and-analysis-features-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/code-security-and-analysis#get-code-security-and-analysis-features-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/code_security_and_analysis
func (s *EnterpriseService) GetCodeSecurityAndAnalysis(ctx context.Context, enterprise string) (*EnterpriseSecurityAnalysisSettings, *Response, error) { func (s *EnterpriseService) GetCodeSecurityAndAnalysis(ctx context.Context, enterprise string) (*EnterpriseSecurityAnalysisSettings, *Response, error) {
u := fmt.Sprintf("enterprises/%v/code_security_and_analysis", enterprise) u := fmt.Sprintf("enterprises/%v/code_security_and_analysis", enterprise)
@ -40,7 +42,9 @@ func (s *EnterpriseService) GetCodeSecurityAndAnalysis(ctx context.Context, ente
// UpdateCodeSecurityAndAnalysis updates code security and analysis features for new repositories in an enterprise. // UpdateCodeSecurityAndAnalysis updates code security and analysis features for new repositories in an enterprise.
// //
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/code-security-and-analysis?apiVersion=2022-11-28#update-code-security-and-analysis-features-for-an-enterprise // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/code-security-and-analysis#update-code-security-and-analysis-features-for-an-enterprise
//
//meta:operation PATCH /enterprises/{enterprise}/code_security_and_analysis
func (s *EnterpriseService) UpdateCodeSecurityAndAnalysis(ctx context.Context, enterprise string, settings *EnterpriseSecurityAnalysisSettings) (*Response, error) { func (s *EnterpriseService) UpdateCodeSecurityAndAnalysis(ctx context.Context, enterprise string, settings *EnterpriseSecurityAnalysisSettings) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/code_security_and_analysis", enterprise) u := fmt.Sprintf("enterprises/%v/code_security_and_analysis", enterprise)
req, err := s.client.NewRequest("PATCH", u, settings) req, err := s.client.NewRequest("PATCH", u, settings)
@ -61,7 +65,9 @@ func (s *EnterpriseService) UpdateCodeSecurityAndAnalysis(ctx context.Context, e
// Valid values for securityProduct: "advanced_security", "secret_scanning", "secret_scanning_push_protection". // Valid values for securityProduct: "advanced_security", "secret_scanning", "secret_scanning_push_protection".
// Valid values for enablement: "enable_all", "disable_all". // Valid values for enablement: "enable_all", "disable_all".
// //
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/code-security-and-analysis?apiVersion=2022-11-28#enable-or-disable-a-security-feature // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/code-security-and-analysis#enable-or-disable-a-security-feature
//
//meta:operation POST /enterprises/{enterprise}/{security_product}/{enablement}
func (s *EnterpriseService) EnableDisableSecurityFeature(ctx context.Context, enterprise, securityProduct, enablement string) (*Response, error) { func (s *EnterpriseService) EnableDisableSecurityFeature(ctx context.Context, enterprise, securityProduct, enablement string) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/%v/%v", enterprise, securityProduct, enablement) u := fmt.Sprintf("enterprises/%v/%v/%v", enterprise, securityProduct, enablement)
req, err := s.client.NewRequest("POST", u, nil) req, err := s.client.NewRequest("POST", u, nil)

View file

@ -18,7 +18,7 @@ type RequestedAction struct {
// BranchProtectionRuleEvent triggered when a check suite is "created", "edited", or "deleted". // BranchProtectionRuleEvent triggered when a check suite is "created", "edited", or "deleted".
// The Webhook event name is "branch_protection_rule". // The Webhook event name is "branch_protection_rule".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule
type BranchProtectionRuleEvent struct { type BranchProtectionRuleEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Rule *BranchProtectionRule `json:"rule,omitempty"` Rule *BranchProtectionRule `json:"rule,omitempty"`
@ -32,7 +32,7 @@ type BranchProtectionRuleEvent struct {
// CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested". // CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested".
// The Webhook event name is "check_run". // The Webhook event name is "check_run".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#check_run // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#check_run
type CheckRunEvent struct { type CheckRunEvent struct {
CheckRun *CheckRun `json:"check_run,omitempty"` CheckRun *CheckRun `json:"check_run,omitempty"`
// The action performed. Possible values are: "created", "completed", "rerequested" or "requested_action". // The action performed. Possible values are: "created", "completed", "rerequested" or "requested_action".
@ -51,7 +51,7 @@ type CheckRunEvent struct {
// CheckSuiteEvent is triggered when a check suite is "completed", "requested", or "rerequested". // CheckSuiteEvent is triggered when a check suite is "completed", "requested", or "rerequested".
// The Webhook event name is "check_suite". // The Webhook event name is "check_suite".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#check_suite // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#check_suite
type CheckSuiteEvent struct { type CheckSuiteEvent struct {
CheckSuite *CheckSuite `json:"check_suite,omitempty"` CheckSuite *CheckSuite `json:"check_suite,omitempty"`
// The action performed. Possible values are: "completed", "requested" or "rerequested". // The action performed. Possible values are: "completed", "requested" or "rerequested".
@ -67,7 +67,7 @@ type CheckSuiteEvent struct {
// CommitCommentEvent is triggered when a commit comment is created. // CommitCommentEvent is triggered when a commit comment is created.
// The Webhook event name is "commit_comment". // The Webhook event name is "commit_comment".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#commit_comment // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#commit_comment
type CommitCommentEvent struct { type CommitCommentEvent struct {
Comment *RepositoryComment `json:"comment,omitempty"` Comment *RepositoryComment `json:"comment,omitempty"`
@ -76,6 +76,10 @@ type CommitCommentEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// ContentReferenceEvent is triggered when the body or comment of an issue or // ContentReferenceEvent is triggered when the body or comment of an issue or
@ -99,7 +103,7 @@ type ContentReferenceEvent struct {
// Additionally, webhooks will not receive this event for tags if more // Additionally, webhooks will not receive this event for tags if more
// than three tags are pushed at once. // than three tags are pushed at once.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/github-event-types#createevent // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/github-event-types#createevent
type CreateEvent struct { type CreateEvent struct {
Ref *string `json:"ref,omitempty"` Ref *string `json:"ref,omitempty"`
// RefType is the object that was created. Possible values are: "repository", "branch", "tag". // RefType is the object that was created. Possible values are: "repository", "branch", "tag".
@ -121,7 +125,7 @@ type CreateEvent struct {
// Note: webhooks will not receive this event for tags if more than three tags // Note: webhooks will not receive this event for tags if more than three tags
// are deleted at once. // are deleted at once.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/github-event-types#deleteevent // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/github-event-types#deleteevent
type DeleteEvent struct { type DeleteEvent struct {
Ref *string `json:"ref,omitempty"` Ref *string `json:"ref,omitempty"`
// RefType is the object that was deleted. Possible values are: "branch", "tag". // RefType is the object that was deleted. Possible values are: "branch", "tag".
@ -132,12 +136,16 @@ type DeleteEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// DependabotAlertEvent is triggered when there is activity relating to Dependabot alerts. // DependabotAlertEvent is triggered when there is activity relating to Dependabot alerts.
// The Webhook event name is "dependabot_alert". // The Webhook event name is "dependabot_alert".
// //
// GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#dependabot_alert // GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#dependabot_alert
type DependabotAlertEvent struct { type DependabotAlertEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Alert *DependabotAlert `json:"alert,omitempty"` Alert *DependabotAlert `json:"alert,omitempty"`
@ -156,7 +164,7 @@ type DependabotAlertEvent struct {
// DeployKeyEvent is triggered when a deploy key is added or removed from a repository. // DeployKeyEvent is triggered when a deploy key is added or removed from a repository.
// The Webhook event name is "deploy_key". // The Webhook event name is "deploy_key".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deploy_key // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#deploy_key
type DeployKeyEvent struct { type DeployKeyEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "created" or "deleted". // "created" or "deleted".
@ -182,7 +190,7 @@ type DeployKeyEvent struct {
// //
// Events of this type are not visible in timelines, they are only used to trigger hooks. // Events of this type are not visible in timelines, they are only used to trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deployment // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#deployment
type DeploymentEvent struct { type DeploymentEvent struct {
Deployment *Deployment `json:"deployment,omitempty"` Deployment *Deployment `json:"deployment,omitempty"`
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
@ -192,6 +200,10 @@ type DeploymentEvent struct {
// The following fields are only populated by Webhook events. // The following fields are only populated by Webhook events.
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// DeploymentProtectionRuleEvent represents a deployment protection rule event. // DeploymentProtectionRuleEvent represents a deployment protection rule event.
@ -218,7 +230,7 @@ type DeploymentProtectionRuleEvent struct {
// //
// Events of this type are not visible in timelines, they are only used to trigger hooks. // Events of this type are not visible in timelines, they are only used to trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deployment_status // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#deployment_status
type DeploymentStatusEvent struct { type DeploymentStatusEvent struct {
Deployment *Deployment `json:"deployment,omitempty"` Deployment *Deployment `json:"deployment,omitempty"`
DeploymentStatus *DeploymentStatus `json:"deployment_status,omitempty"` DeploymentStatus *DeploymentStatus `json:"deployment_status,omitempty"`
@ -227,6 +239,10 @@ type DeploymentStatusEvent struct {
// The following fields are only populated by Webhook events. // The following fields are only populated by Webhook events.
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// DiscussionCommentEvent represents a webhook event for a comment on discussion. // DiscussionCommentEvent represents a webhook event for a comment on discussion.
@ -265,7 +281,7 @@ type CommentDiscussion struct {
// DiscussionEvent represents a webhook event for a discussion. // DiscussionEvent represents a webhook event for a discussion.
// The Webhook event name is "discussion". // The Webhook event name is "discussion".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion
type DiscussionEvent struct { type DiscussionEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// created, edited, deleted, pinned, unpinned, locked, unlocked, // created, edited, deleted, pinned, unpinned, locked, unlocked,
@ -318,7 +334,7 @@ type DiscussionCategory struct {
// ForkEvent is triggered when a user forks a repository. // ForkEvent is triggered when a user forks a repository.
// The Webhook event name is "fork". // The Webhook event name is "fork".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#fork // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#fork
type ForkEvent struct { type ForkEvent struct {
// Forkee is the created repository. // Forkee is the created repository.
Forkee *Repository `json:"forkee,omitempty"` Forkee *Repository `json:"forkee,omitempty"`
@ -332,7 +348,7 @@ type ForkEvent struct {
// GitHubAppAuthorizationEvent is triggered when a user's authorization for a // GitHubAppAuthorizationEvent is triggered when a user's authorization for a
// GitHub Application is revoked. // GitHub Application is revoked.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#github_app_authorization // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#github_app_authorization
type GitHubAppAuthorizationEvent struct { type GitHubAppAuthorizationEvent struct {
// The action performed. Possible value is: "revoked". // The action performed. Possible value is: "revoked".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -355,7 +371,7 @@ type Page struct {
// GollumEvent is triggered when a Wiki page is created or updated. // GollumEvent is triggered when a Wiki page is created or updated.
// The Webhook event name is "gollum". // The Webhook event name is "gollum".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#gollum // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#gollum
type GollumEvent struct { type GollumEvent struct {
Pages []*Page `json:"pages,omitempty"` Pages []*Page `json:"pages,omitempty"`
@ -363,16 +379,21 @@ type GollumEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// EditChange represents the changes when an issue, pull request, comment, // EditChange represents the changes when an issue, pull request, comment,
// or repository has been edited. // or repository has been edited.
type EditChange struct { type EditChange struct {
Title *EditTitle `json:"title,omitempty"` Title *EditTitle `json:"title,omitempty"`
Body *EditBody `json:"body,omitempty"` Body *EditBody `json:"body,omitempty"`
Base *EditBase `json:"base,omitempty"` Base *EditBase `json:"base,omitempty"`
Repo *EditRepo `json:"repository,omitempty"` Repo *EditRepo `json:"repository,omitempty"`
Owner *EditOwner `json:"owner,omitempty"` Owner *EditOwner `json:"owner,omitempty"`
DefaultBranch *EditDefaultBranch `json:"default_branch,omitempty"`
} }
// EditTitle represents a pull-request title change. // EditTitle represents a pull-request title change.
@ -422,6 +443,11 @@ type EditSHA struct {
From *string `json:"from,omitempty"` From *string `json:"from,omitempty"`
} }
// EditDefaultBranch represents a change of repository's default branch name.
type EditDefaultBranch struct {
From *string `json:"from,omitempty"`
}
// ProjectChange represents the changes when a project has been edited. // ProjectChange represents the changes when a project has been edited.
type ProjectChange struct { type ProjectChange struct {
Name *ProjectName `json:"name,omitempty"` Name *ProjectName `json:"name,omitempty"`
@ -502,7 +528,7 @@ type TeamPermissionsFrom struct {
// or new permissions have been accepted. // or new permissions have been accepted.
// The Webhook event name is "installation". // The Webhook event name is "installation".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#installation // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#installation
type InstallationEvent struct { type InstallationEvent struct {
// The action that was performed. Can be either "created", "deleted", "suspend", "unsuspend" or "new_permissions_accepted". // The action that was performed. Can be either "created", "deleted", "suspend", "unsuspend" or "new_permissions_accepted".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -510,12 +536,16 @@ type InstallationEvent struct {
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
Requester *User `json:"requester,omitempty"` Requester *User `json:"requester,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// InstallationRepositoriesEvent is triggered when a repository is added or // InstallationRepositoriesEvent is triggered when a repository is added or
// removed from an installation. The Webhook event name is "installation_repositories". // removed from an installation. The Webhook event name is "installation_repositories".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#installation_repositories // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#installation_repositories
type InstallationRepositoriesEvent struct { type InstallationRepositoriesEvent struct {
// The action that was performed. Can be either "added" or "removed". // The action that was performed. Can be either "added" or "removed".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -524,6 +554,10 @@ type InstallationRepositoriesEvent struct {
RepositorySelection *string `json:"repository_selection,omitempty"` RepositorySelection *string `json:"repository_selection,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// InstallationLoginChange represents a change in login on an installation. // InstallationLoginChange represents a change in login on an installation.
@ -545,7 +579,7 @@ type InstallationChanges struct {
// InstallationTargetEvent is triggered when there is activity on an installation from a user or organization account. // InstallationTargetEvent is triggered when there is activity on an installation from a user or organization account.
// The Webhook event name is "installation_target". // The Webhook event name is "installation_target".
// //
// GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target // GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target
type InstallationTargetEvent struct { type InstallationTargetEvent struct {
Account *User `json:"account,omitempty"` Account *User `json:"account,omitempty"`
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -562,7 +596,7 @@ type InstallationTargetEvent struct {
// or pull request. // or pull request.
// The Webhook event name is "issue_comment". // The Webhook event name is "issue_comment".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#issue_comment // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#issue_comment
type IssueCommentEvent struct { type IssueCommentEvent struct {
// Action is the action that was performed on the comment. // Action is the action that was performed on the comment.
// Possible values are: "created", "edited", "deleted". // Possible values are: "created", "edited", "deleted".
@ -586,7 +620,7 @@ type IssueCommentEvent struct {
// locked, unlocked, milestoned, or demilestoned. // locked, unlocked, milestoned, or demilestoned.
// The Webhook event name is "issues". // The Webhook event name is "issues".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#issues // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#issues
type IssuesEvent struct { type IssuesEvent struct {
// Action is the action that was performed. Possible values are: "opened", // Action is the action that was performed. Possible values are: "opened",
// "edited", "deleted", "transferred", "pinned", "unpinned", "closed", "reopened", // "edited", "deleted", "transferred", "pinned", "unpinned", "closed", "reopened",
@ -603,12 +637,16 @@ type IssuesEvent struct {
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
Milestone *Milestone `json:"milestone,omitempty"` Milestone *Milestone `json:"milestone,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// LabelEvent is triggered when a repository's label is created, edited, or deleted. // LabelEvent is triggered when a repository's label is created, edited, or deleted.
// The Webhook event name is "label" // The Webhook event name is "label"
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#label // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#label
type LabelEvent struct { type LabelEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "created", "edited", "deleted" // "created", "edited", "deleted"
@ -627,7 +665,7 @@ type LabelEvent struct {
// their GitHub Marketplace plan. // their GitHub Marketplace plan.
// Webhook event name "marketplace_purchase". // Webhook event name "marketplace_purchase".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#marketplace_purchase // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#marketplace_purchase
type MarketplacePurchaseEvent struct { type MarketplacePurchaseEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "purchased", "cancelled", "pending_change", "pending_change_cancelled", "changed". // "purchased", "cancelled", "pending_change", "pending_change_cancelled", "changed".
@ -639,12 +677,16 @@ type MarketplacePurchaseEvent struct {
PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase,omitempty"` PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// MemberEvent is triggered when a user is added as a collaborator to a repository. // MemberEvent is triggered when a user is added as a collaborator to a repository.
// The Webhook event name is "member". // The Webhook event name is "member".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#member // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#member
type MemberEvent struct { type MemberEvent struct {
// Action is the action that was performed. Possible value is: "added". // Action is the action that was performed. Possible value is: "added".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -654,6 +696,10 @@ type MemberEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// MembershipEvent is triggered when a user is added or removed from a team. // MembershipEvent is triggered when a user is added or removed from a team.
@ -662,7 +708,7 @@ type MemberEvent struct {
// Events of this type are not visible in timelines, they are only used to // Events of this type are not visible in timelines, they are only used to
// trigger organization webhooks. // trigger organization webhooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#membership // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#membership
type MembershipEvent struct { type MembershipEvent struct {
// Action is the action that was performed. Possible values are: "added", "removed". // Action is the action that was performed. Possible values are: "added", "removed".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -694,7 +740,7 @@ type MergeGroup struct {
// MergeGroupEvent represents activity related to merge groups in a merge queue. The type of activity is specified // MergeGroupEvent represents activity related to merge groups in a merge queue. The type of activity is specified
// in the action property of the payload object. // in the action property of the payload object.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#merge_group // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#merge_group
type MergeGroupEvent struct { type MergeGroupEvent struct {
// The action that was performed. Currently, can only be checks_requested. // The action that was performed. Currently, can only be checks_requested.
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -713,7 +759,7 @@ type MergeGroupEvent struct {
// Therefore, it must be selected for each hook that you'd like to receive meta events for. // Therefore, it must be selected for each hook that you'd like to receive meta events for.
// The Webhook event name is "meta". // The Webhook event name is "meta".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#meta // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#meta
type MetaEvent struct { type MetaEvent struct {
// Action is the action that was performed. Possible value is: "deleted". // Action is the action that was performed. Possible value is: "deleted".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -734,7 +780,7 @@ type MetaEvent struct {
// MilestoneEvent is triggered when a milestone is created, closed, opened, edited, or deleted. // MilestoneEvent is triggered when a milestone is created, closed, opened, edited, or deleted.
// The Webhook event name is "milestone". // The Webhook event name is "milestone".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#milestone // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#milestone
type MilestoneEvent struct { type MilestoneEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "created", "closed", "opened", "edited", "deleted" // "created", "closed", "opened", "edited", "deleted"
@ -754,7 +800,7 @@ type MilestoneEvent struct {
// Events of this type are not visible in timelines. These events are only used to trigger organization hooks. // Events of this type are not visible in timelines. These events are only used to trigger organization hooks.
// Webhook event name is "organization". // Webhook event name is "organization".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#organization // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#organization
type OrganizationEvent struct { type OrganizationEvent struct {
// Action is the action that was performed. // Action is the action that was performed.
// Possible values are: "deleted", "renamed", "member_added", "member_removed", or "member_invited". // Possible values are: "deleted", "renamed", "member_added", "member_removed", or "member_invited".
@ -775,7 +821,7 @@ type OrganizationEvent struct {
// OrgBlockEvent is triggered when an organization blocks or unblocks a user. // OrgBlockEvent is triggered when an organization blocks or unblocks a user.
// The Webhook event name is "org_block". // The Webhook event name is "org_block".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#org_block // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#org_block
type OrgBlockEvent struct { type OrgBlockEvent struct {
// Action is the action that was performed. // Action is the action that was performed.
// Can be "blocked" or "unblocked". // Can be "blocked" or "unblocked".
@ -816,7 +862,7 @@ type PackageEvent struct {
// //
// Events of this type are not visible in timelines, they are only used to trigger hooks. // Events of this type are not visible in timelines, they are only used to trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#page_build // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#page_build
type PageBuildEvent struct { type PageBuildEvent struct {
Build *PagesBuild `json:"build,omitempty"` Build *PagesBuild `json:"build,omitempty"`
@ -825,6 +871,10 @@ type PageBuildEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// PersonalAccessTokenRequestEvent occurs when there is activity relating to a // PersonalAccessTokenRequestEvent occurs when there is activity relating to a
@ -832,7 +882,7 @@ type PageBuildEvent struct {
// belong to a resource owner that requires approval for token access. // belong to a resource owner that requires approval for token access.
// The webhook event name is "personal_access_token_request". // The webhook event name is "personal_access_token_request".
// //
// GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#personal_access_token_request // GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#personal_access_token_request
type PersonalAccessTokenRequestEvent struct { type PersonalAccessTokenRequestEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "approved", "cancelled", "created" or "denied" // "approved", "cancelled", "created" or "denied"
@ -885,6 +935,10 @@ type PersonalAccessTokenRequest struct {
// Date and time when the associated fine-grained personal access token was last used for authentication. // Date and time when the associated fine-grained personal access token was last used for authentication.
TokenLastUsedAt *Timestamp `json:"token_last_used_at,omitempty"` TokenLastUsedAt *Timestamp `json:"token_last_used_at,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// PersonalAccessTokenPermissions represents the original or newly requested // PersonalAccessTokenPermissions represents the original or newly requested
@ -916,7 +970,7 @@ type PingEvent struct {
// ProjectEvent is triggered when project is created, modified or deleted. // ProjectEvent is triggered when project is created, modified or deleted.
// The webhook event name is "project". // The webhook event name is "project".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#project // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project
type ProjectEvent struct { type ProjectEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Changes *ProjectChange `json:"changes,omitempty"` Changes *ProjectChange `json:"changes,omitempty"`
@ -932,7 +986,7 @@ type ProjectEvent struct {
// ProjectCardEvent is triggered when a project card is created, updated, moved, converted to an issue, or deleted. // ProjectCardEvent is triggered when a project card is created, updated, moved, converted to an issue, or deleted.
// The webhook event name is "project_card". // The webhook event name is "project_card".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#project_card // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_card
type ProjectCardEvent struct { type ProjectCardEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Changes *ProjectCardChange `json:"changes,omitempty"` Changes *ProjectCardChange `json:"changes,omitempty"`
@ -949,7 +1003,7 @@ type ProjectCardEvent struct {
// ProjectColumnEvent is triggered when a project column is created, updated, moved, or deleted. // ProjectColumnEvent is triggered when a project column is created, updated, moved, or deleted.
// The webhook event name is "project_column". // The webhook event name is "project_column".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#project_column // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_column
type ProjectColumnEvent struct { type ProjectColumnEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Changes *ProjectColumnChange `json:"changes,omitempty"` Changes *ProjectColumnChange `json:"changes,omitempty"`
@ -966,7 +1020,7 @@ type ProjectColumnEvent struct {
// ProjectV2Event is triggered when there is activity relating to an organization-level project. // ProjectV2Event is triggered when there is activity relating to an organization-level project.
// The Webhook event name is "projects_v2". // The Webhook event name is "projects_v2".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2
type ProjectV2Event struct { type ProjectV2Event struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
ProjectsV2 *ProjectsV2 `json:"projects_v2,omitempty"` ProjectsV2 *ProjectsV2 `json:"projects_v2,omitempty"`
@ -998,7 +1052,7 @@ type ProjectsV2 struct {
// ProjectV2ItemEvent is triggered when there is activity relating to an item on an organization-level project. // ProjectV2ItemEvent is triggered when there is activity relating to an item on an organization-level project.
// The Webhook event name is "projects_v2_item". // The Webhook event name is "projects_v2_item".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2_item // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2_item
type ProjectV2ItemEvent struct { type ProjectV2ItemEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Changes *ProjectV2ItemChange `json:"changes,omitempty"` Changes *ProjectV2ItemChange `json:"changes,omitempty"`
@ -1021,7 +1075,7 @@ type ArchivedAt struct {
To *Timestamp `json:"to,omitempty"` To *Timestamp `json:"to,omitempty"`
} }
// ProjectsV2 represents an item belonging to a project. // ProjectV2Item represents an item belonging to a project.
type ProjectV2Item struct { type ProjectV2Item struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"` NodeID *string `json:"node_id,omitempty"`
@ -1038,12 +1092,16 @@ type ProjectV2Item struct {
// According to GitHub: "Without a doubt: the best GitHub event." // According to GitHub: "Without a doubt: the best GitHub event."
// The Webhook event name is "public". // The Webhook event name is "public".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#public // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#public
type PublicEvent struct { type PublicEvent struct {
// The following fields are only populated by Webhook events. // The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// PullRequestEvent is triggered when a pull request is assigned, unassigned, labeled, // PullRequestEvent is triggered when a pull request is assigned, unassigned, labeled,
@ -1051,7 +1109,7 @@ type PublicEvent struct {
// locked, unlocked, a pull request review is requested, or a review request is removed. // locked, unlocked, a pull request review is requested, or a review request is removed.
// The Webhook event name is "pull_request". // The Webhook event name is "pull_request".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/github-event-types#pullrequestevent // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/github-event-types#pullrequestevent
type PullRequestEvent struct { type PullRequestEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "assigned", "unassigned", "review_requested", "review_request_removed", "labeled", "unlabeled", // "assigned", "unassigned", "review_requested", "review_request_removed", "labeled", "unlabeled",
@ -1086,13 +1144,16 @@ type PullRequestEvent struct {
// The following fields are only populated when the Action is "synchronize". // The following fields are only populated when the Action is "synchronize".
Before *string `json:"before,omitempty"` Before *string `json:"before,omitempty"`
After *string `json:"after,omitempty"` After *string `json:"after,omitempty"`
// The following will be populated if the event was performed by an App
PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"`
} }
// PullRequestReviewEvent is triggered when a review is submitted on a pull // PullRequestReviewEvent is triggered when a review is submitted on a pull
// request. // request.
// The Webhook event name is "pull_request_review". // The Webhook event name is "pull_request_review".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review
type PullRequestReviewEvent struct { type PullRequestReviewEvent struct {
// Action is always "submitted". // Action is always "submitted".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1113,7 +1174,7 @@ type PullRequestReviewEvent struct {
// portion of the unified diff of a pull request. // portion of the unified diff of a pull request.
// The Webhook event name is "pull_request_review_comment". // The Webhook event name is "pull_request_review_comment".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_comment // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_comment
type PullRequestReviewCommentEvent struct { type PullRequestReviewCommentEvent struct {
// Action is the action that was performed on the comment. // Action is the action that was performed on the comment.
// Possible values are: "created", "edited", "deleted". // Possible values are: "created", "edited", "deleted".
@ -1126,13 +1187,17 @@ type PullRequestReviewCommentEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// PullRequestReviewThreadEvent is triggered when a comment made as part of a // PullRequestReviewThreadEvent is triggered when a comment made as part of a
// review of a pull request is marked resolved or unresolved. // review of a pull request is marked resolved or unresolved.
// The Webhook event name is "pull_request_review_thread". // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_thread
type PullRequestReviewThreadEvent struct { type PullRequestReviewThreadEvent struct {
// Action is the action that was performed on the comment. // Action is the action that was performed on the comment.
// Possible values are: "resolved", "unresolved". // Possible values are: "resolved", "unresolved".
@ -1144,6 +1209,10 @@ type PullRequestReviewThreadEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled, // PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled,
@ -1151,7 +1220,7 @@ type PullRequestReviewThreadEvent struct {
// locked, unlocked, a pull request review is requested, or a review request is removed. // locked, unlocked, a pull request review is requested, or a review request is removed.
// The Webhook event name is "pull_request_target". // The Webhook event name is "pull_request_target".
// //
// GitHub API docs: https://docs.github.com/en/actions/events-that-trigger-workflows#pull_request_target // GitHub API docs: https://docs.github.com/actions/events-that-trigger-workflows#pull_request_target
type PullRequestTargetEvent struct { type PullRequestTargetEvent struct {
// Action is the action that was performed. Possible values are: // Action is the action that was performed. Possible values are:
// "assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened", // "assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened",
@ -1186,11 +1255,14 @@ type PullRequestTargetEvent struct {
// The following fields are only populated when the Action is "synchronize". // The following fields are only populated when the Action is "synchronize".
Before *string `json:"before,omitempty"` Before *string `json:"before,omitempty"`
After *string `json:"after,omitempty"` After *string `json:"after,omitempty"`
// The following will be populated if the event was performed by an App
PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"`
} }
// PushEvent represents a git push to a GitHub repository. // PushEvent represents a git push to a GitHub repository.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#push // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#push
type PushEvent struct { type PushEvent struct {
PushID *int64 `json:"push_id,omitempty"` PushID *int64 `json:"push_id,omitempty"`
Head *string `json:"head,omitempty"` Head *string `json:"head,omitempty"`
@ -1210,7 +1282,7 @@ type PushEvent struct {
Compare *string `json:"compare,omitempty"` Compare *string `json:"compare,omitempty"`
Repo *PushEventRepository `json:"repository,omitempty"` Repo *PushEventRepository `json:"repository,omitempty"`
HeadCommit *HeadCommit `json:"head_commit,omitempty"` HeadCommit *HeadCommit `json:"head_commit,omitempty"`
Pusher *User `json:"pusher,omitempty"` Pusher *CommitAuthor `json:"pusher,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
@ -1298,7 +1370,7 @@ type PushEventRepoOwner struct {
// edited, deleted, or prereleased. // edited, deleted, or prereleased.
// The Webhook event name is "release". // The Webhook event name is "release".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#release // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#release
type ReleaseEvent struct { type ReleaseEvent struct {
// Action is the action that was performed. Possible values are: "published", "unpublished", // Action is the action that was performed. Possible values are: "published", "unpublished",
// "created", "edited", "deleted", or "prereleased". // "created", "edited", "deleted", or "prereleased".
@ -1309,6 +1381,10 @@ type ReleaseEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// RepositoryEvent is triggered when a repository is created, archived, unarchived, // RepositoryEvent is triggered when a repository is created, archived, unarchived,
@ -1319,7 +1395,7 @@ type ReleaseEvent struct {
// Events of this type are not visible in timelines, they are only used to // Events of this type are not visible in timelines, they are only used to
// trigger organization webhooks. // trigger organization webhooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#repository
type RepositoryEvent struct { type RepositoryEvent struct {
// Action is the action that was performed. Possible values are: "created", // Action is the action that was performed. Possible values are: "created",
// "deleted" (organization hooks only), "archived", "unarchived", "edited", "renamed", // "deleted" (organization hooks only), "archived", "unarchived", "edited", "renamed",
@ -1336,7 +1412,7 @@ type RepositoryEvent struct {
// RepositoryDispatchEvent is triggered when a client sends a POST request to the repository dispatch event endpoint. // RepositoryDispatchEvent is triggered when a client sends a POST request to the repository dispatch event endpoint.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository_dispatch // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#repository_dispatch
type RepositoryDispatchEvent struct { type RepositoryDispatchEvent struct {
// Action is the event_type that submitted with the repository dispatch payload. Value can be any string. // Action is the event_type that submitted with the repository dispatch payload. Value can be any string.
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1352,7 +1428,7 @@ type RepositoryDispatchEvent struct {
// RepositoryImportEvent represents the activity related to a repository being imported to GitHub. // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import
type RepositoryImportEvent struct { type RepositoryImportEvent struct {
// Status represents the final state of the import. This can be one of "success", "cancelled", or "failure". // Status represents the final state of the import. This can be one of "success", "cancelled", or "failure".
Status *string `json:"status,omitempty"` Status *string `json:"status,omitempty"`
@ -1363,7 +1439,7 @@ type RepositoryImportEvent struct {
// RepositoryVulnerabilityAlertEvent is triggered when a security alert is created, dismissed, or resolved. // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#repository_vulnerability_alert
type RepositoryVulnerabilityAlertEvent struct { type RepositoryVulnerabilityAlertEvent struct {
// Action is the action that was performed. Possible values are: "create", "dismiss", "resolve". // Action is the action that was performed. Possible values are: "create", "dismiss", "resolve".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1379,6 +1455,10 @@ type RepositoryVulnerabilityAlertEvent struct {
// The user that triggered the event. // The user that triggered the event.
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// RepositoryVulnerabilityAlert represents a repository security alert. // RepositoryVulnerabilityAlert represents a repository security alert.
@ -1400,7 +1480,7 @@ type RepositoryVulnerabilityAlert struct {
// SecretScanningAlertEvent is triggered when a secret scanning alert occurs in a repository. // SecretScanningAlertEvent is triggered when a secret scanning alert occurs in a repository.
// The Webhook name is secret_scanning_alert. // The Webhook name is secret_scanning_alert.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#secret_scanning_alert // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#secret_scanning_alert
type SecretScanningAlertEvent struct { type SecretScanningAlertEvent struct {
// Action is the action that was performed. Possible values are: "created", "resolved", or "reopened". // Action is the action that was performed. Possible values are: "created", "resolved", or "reopened".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1420,7 +1500,7 @@ type SecretScanningAlertEvent struct {
// SecurityAndAnalysisEvent is triggered when code security and analysis features // SecurityAndAnalysisEvent is triggered when code security and analysis features
// are enabled or disabled for a repository. // are enabled or disabled for a repository.
// //
// GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#security_and_analysis // GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#security_and_analysis
type SecurityAndAnalysisEvent struct { type SecurityAndAnalysisEvent struct {
Changes *SecurityAndAnalysisChange `json:"changes,omitempty"` Changes *SecurityAndAnalysisChange `json:"changes,omitempty"`
Enterprise *Enterprise `json:"enterprise,omitempty"` Enterprise *Enterprise `json:"enterprise,omitempty"`
@ -1445,7 +1525,7 @@ type SecurityAndAnalysisChangeFrom struct {
// StarEvent is triggered when a star is added or removed from a repository. // StarEvent is triggered when a star is added or removed from a repository.
// The Webhook event name is "star". // The Webhook event name is "star".
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#star // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#star
type StarEvent struct { type StarEvent struct {
// Action is the action that was performed. Possible values are: "created" or "deleted". // Action is the action that was performed. Possible values are: "created" or "deleted".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1466,7 +1546,7 @@ type StarEvent struct {
// Events of this type are not visible in timelines, they are only used to // Events of this type are not visible in timelines, they are only used to
// trigger hooks. // trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#status // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#status
type StatusEvent struct { type StatusEvent struct {
SHA *string `json:"sha,omitempty"` SHA *string `json:"sha,omitempty"`
// State is the new state. Possible values are: "pending", "success", "failure", "error". // State is the new state. Possible values are: "pending", "success", "failure", "error".
@ -1485,6 +1565,10 @@ type StatusEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// TeamEvent is triggered when an organization's team is created, modified or deleted. // TeamEvent is triggered when an organization's team is created, modified or deleted.
@ -1493,7 +1577,7 @@ type StatusEvent struct {
// Events of this type are not visible in timelines. These events are only used // Events of this type are not visible in timelines. These events are only used
// to trigger hooks. // to trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#team // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#team
type TeamEvent struct { type TeamEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Team *Team `json:"team,omitempty"` Team *Team `json:"team,omitempty"`
@ -1512,7 +1596,7 @@ type TeamEvent struct {
// Events of this type are not visible in timelines. These events are only used // Events of this type are not visible in timelines. These events are only used
// to trigger hooks. // to trigger hooks.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#team_add // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#team_add
type TeamAddEvent struct { type TeamAddEvent struct {
Team *Team `json:"team,omitempty"` Team *Team `json:"team,omitempty"`
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
@ -1546,7 +1630,7 @@ type UserEvent struct {
// The events actor is the user who starred a repository, and the events // The events actor is the user who starred a repository, and the events
// repository is the repository that was starred. // repository is the repository that was starred.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#watch // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#watch
type WatchEvent struct { type WatchEvent struct {
// Action is the action that was performed. Possible value is: "started". // Action is the action that was performed. Possible value is: "started".
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
@ -1555,12 +1639,16 @@ type WatchEvent struct {
Repo *Repository `json:"repository,omitempty"` Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"` Installation *Installation `json:"installation,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Org *Organization `json:"organization,omitempty"`
} }
// WorkflowDispatchEvent is triggered when someone triggers a workflow run on GitHub or // WorkflowDispatchEvent is triggered when someone triggers a workflow run on GitHub or
// sends a POST request to the create a workflow dispatch event endpoint. // sends a POST request to the create a workflow dispatch event endpoint.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_dispatch // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#workflow_dispatch
type WorkflowDispatchEvent struct { type WorkflowDispatchEvent struct {
Inputs json.RawMessage `json:"inputs,omitempty"` Inputs json.RawMessage `json:"inputs,omitempty"`
Ref *string `json:"ref,omitempty"` Ref *string `json:"ref,omitempty"`
@ -1575,7 +1663,7 @@ type WorkflowDispatchEvent struct {
// WorkflowJobEvent is triggered when a job is queued, started or completed. // WorkflowJobEvent is triggered when a job is queued, started or completed.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job
type WorkflowJobEvent struct { type WorkflowJobEvent struct {
WorkflowJob *WorkflowJob `json:"workflow_job,omitempty"` WorkflowJob *WorkflowJob `json:"workflow_job,omitempty"`
@ -1593,7 +1681,7 @@ type WorkflowJobEvent struct {
// WorkflowRunEvent is triggered when a GitHub Actions workflow run is requested or completed. // WorkflowRunEvent is triggered when a GitHub Actions workflow run is requested or completed.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_run // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#workflow_run
type WorkflowRunEvent struct { type WorkflowRunEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Workflow *Workflow `json:"workflow,omitempty"` Workflow *Workflow `json:"workflow,omitempty"`
@ -1608,20 +1696,35 @@ type WorkflowRunEvent struct {
// SecurityAdvisory represents the advisory object in SecurityAdvisoryEvent payload. // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory
type SecurityAdvisory struct { type SecurityAdvisory struct {
CVSS *AdvisoryCVSS `json:"cvss,omitempty"` CVSS *AdvisoryCVSS `json:"cvss,omitempty"`
CWEs []*AdvisoryCWEs `json:"cwes,omitempty"` CWEs []*AdvisoryCWEs `json:"cwes,omitempty"`
GHSAID *string `json:"ghsa_id,omitempty"` GHSAID *string `json:"ghsa_id,omitempty"`
Summary *string `json:"summary,omitempty"` Summary *string `json:"summary,omitempty"`
Description *string `json:"description,omitempty"` Description *string `json:"description,omitempty"`
Severity *string `json:"severity,omitempty"` Severity *string `json:"severity,omitempty"`
Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"` Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"`
References []*AdvisoryReference `json:"references,omitempty"` References []*AdvisoryReference `json:"references,omitempty"`
PublishedAt *Timestamp `json:"published_at,omitempty"` PublishedAt *Timestamp `json:"published_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"`
WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"` WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"`
Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"` Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"`
CVEID *string `json:"cve_id,omitempty"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
Author *User `json:"author,omitempty"`
Publisher *User `json:"publisher,omitempty"`
State *string `json:"state,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
ClosedAt *Timestamp `json:"closed_at,omitempty"`
Submission *SecurityAdvisorySubmission `json:"submission,omitempty"`
CWEIDs []string `json:"cwe_ids,omitempty"`
Credits []*RepoAdvisoryCredit `json:"credits,omitempty"`
CreditsDetailed []*RepoAdvisoryCreditDetailed `json:"credits_detailed,omitempty"`
CollaboratingUsers []*User `json:"collaborating_users,omitempty"`
CollaboratingTeams []*Team `json:"collaborating_teams,omitempty"`
PrivateFork *Repository `json:"private_fork,omitempty"`
} }
// AdvisoryIdentifier represents the identifier for a Security Advisory. // AdvisoryIdentifier represents the identifier for a Security Advisory.
@ -1641,6 +1744,12 @@ type AdvisoryVulnerability struct {
Severity *string `json:"severity,omitempty"` Severity *string `json:"severity,omitempty"`
VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"` VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"`
FirstPatchedVersion *FirstPatchedVersion `json:"first_patched_version,omitempty"` FirstPatchedVersion *FirstPatchedVersion `json:"first_patched_version,omitempty"`
// PatchedVersions and VulnerableFunctions are used in the following APIs:
// - https://docs.github.com/rest/security-advisories/repository-advisories#list-repository-security-advisories-for-an-organization
// - https://docs.github.com/rest/security-advisories/repository-advisories#list-repository-security-advisories
PatchedVersions *string `json:"patched_versions,omitempty"`
VulnerableFunctions []string `json:"vulnerable_functions,omitempty"`
} }
// VulnerabilityPackage represents the package object for an Advisory Vulnerability. // VulnerabilityPackage represents the package object for an Advisory Vulnerability.
@ -1656,7 +1765,7 @@ type FirstPatchedVersion struct {
// SecurityAdvisoryEvent is triggered when a security-related vulnerability is found in software on GitHub. // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory
type SecurityAdvisoryEvent struct { type SecurityAdvisoryEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
SecurityAdvisory *SecurityAdvisory `json:"security_advisory,omitempty"` SecurityAdvisory *SecurityAdvisory `json:"security_advisory,omitempty"`
@ -1671,7 +1780,7 @@ type SecurityAdvisoryEvent struct {
// CodeScanningAlertEvent is triggered when a code scanning finds a potential vulnerability or error in your code. // 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 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert
type CodeScanningAlertEvent struct { type CodeScanningAlertEvent struct {
Action *string `json:"action,omitempty"` Action *string `json:"action,omitempty"`
Alert *Alert `json:"alert,omitempty"` Alert *Alert `json:"alert,omitempty"`

View file

@ -14,7 +14,7 @@ import (
// GistsService handles communication with the Gist related // GistsService handles communication with the Gist related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists // GitHub API docs: https://docs.github.com/rest/gists
type GistsService service type GistsService service
// Gist represents a GitHub's gist. // Gist represents a GitHub's gist.
@ -96,8 +96,11 @@ type GistListOptions struct {
// is authenticated, it will returns all gists for the authenticated // is authenticated, it will returns all gists for the authenticated
// user. // 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/rest/gists/gists#list-gists-for-a-user
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-a-user // GitHub API docs: https://docs.github.com/rest/gists/gists#list-gists-for-the-authenticated-user
//
//meta:operation GET /gists
//meta:operation GET /users/{username}/gists
func (s *GistsService) List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) { func (s *GistsService) List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) {
var u string var u string
if user != "" { if user != "" {
@ -126,7 +129,9 @@ func (s *GistsService) List(ctx context.Context, user string, opts *GistListOpti
// ListAll lists all public gists. // ListAll lists all public gists.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-public-gists // GitHub API docs: https://docs.github.com/rest/gists/gists#list-public-gists
//
//meta:operation GET /gists/public
func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) { func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
u, err := addOptions("gists/public", opts) u, err := addOptions("gists/public", opts)
if err != nil { if err != nil {
@ -149,7 +154,9 @@ func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*G
// ListStarred lists starred gists of authenticated user. // ListStarred lists starred gists of authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-starred-gists // GitHub API docs: https://docs.github.com/rest/gists/gists#list-starred-gists
//
//meta:operation GET /gists/starred
func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) { func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
u, err := addOptions("gists/starred", opts) u, err := addOptions("gists/starred", opts)
if err != nil { if err != nil {
@ -172,7 +179,9 @@ func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) (
// Get a single gist. // Get a single gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#get-a-gist
//
//meta:operation GET /gists/{gist_id}
func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, error) { func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, error) {
u := fmt.Sprintf("gists/%v", id) u := fmt.Sprintf("gists/%v", id)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -191,7 +200,9 @@ func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, er
// GetRevision gets a specific revision of a gist. // GetRevision gets a specific revision of a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist-revision // GitHub API docs: https://docs.github.com/rest/gists/gists#get-a-gist-revision
//
//meta:operation GET /gists/{gist_id}/{sha}
func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) { func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) {
u := fmt.Sprintf("gists/%v/%v", id, sha) u := fmt.Sprintf("gists/%v/%v", id, sha)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -210,7 +221,9 @@ func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist,
// Create a gist for authenticated user. // Create a gist for authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#create-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#create-a-gist
//
//meta:operation POST /gists
func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) { func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) {
u := "gists" u := "gists"
req, err := s.client.NewRequest("POST", u, gist) req, err := s.client.NewRequest("POST", u, gist)
@ -229,7 +242,9 @@ func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response
// Edit a gist. // Edit a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#update-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#update-a-gist
//
//meta:operation PATCH /gists/{gist_id}
func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) { func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) {
u := fmt.Sprintf("gists/%v", id) u := fmt.Sprintf("gists/%v", id)
req, err := s.client.NewRequest("PATCH", u, gist) req, err := s.client.NewRequest("PATCH", u, gist)
@ -248,7 +263,9 @@ func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist,
// ListCommits lists commits of a gist. // ListCommits lists commits of a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-commits // GitHub API docs: https://docs.github.com/rest/gists/gists#list-gist-commits
//
//meta:operation GET /gists/{gist_id}/commits
func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) { func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) {
u := fmt.Sprintf("gists/%v/commits", id) u := fmt.Sprintf("gists/%v/commits", id)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -272,7 +289,9 @@ func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOpt
// Delete a gist. // Delete a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#delete-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#delete-a-gist
//
//meta:operation DELETE /gists/{gist_id}
func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error) { func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error) {
u := fmt.Sprintf("gists/%v", id) u := fmt.Sprintf("gists/%v", id)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -285,7 +304,9 @@ func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error)
// Star a gist on behalf of authenticated user. // Star a gist on behalf of authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#star-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#star-a-gist
//
//meta:operation PUT /gists/{gist_id}/star
func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) { func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) {
u := fmt.Sprintf("gists/%v/star", id) u := fmt.Sprintf("gists/%v/star", id)
req, err := s.client.NewRequest("PUT", u, nil) req, err := s.client.NewRequest("PUT", u, nil)
@ -298,7 +319,9 @@ func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) {
// Unstar a gist on a behalf of authenticated user. // Unstar a gist on a behalf of authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#unstar-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#unstar-a-gist
//
//meta:operation DELETE /gists/{gist_id}/star
func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error) { func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error) {
u := fmt.Sprintf("gists/%v/star", id) u := fmt.Sprintf("gists/%v/star", id)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -311,7 +334,9 @@ func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error)
// IsStarred checks if a gist is starred by authenticated user. // IsStarred checks if a gist is starred by authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#check-if-a-gist-is-starred // GitHub API docs: https://docs.github.com/rest/gists/gists#check-if-a-gist-is-starred
//
//meta:operation GET /gists/{gist_id}/star
func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Response, error) { func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Response, error) {
u := fmt.Sprintf("gists/%v/star", id) u := fmt.Sprintf("gists/%v/star", id)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -326,7 +351,9 @@ func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Respons
// Fork a gist. // Fork a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#fork-a-gist // GitHub API docs: https://docs.github.com/rest/gists/gists#fork-a-gist
//
//meta:operation POST /gists/{gist_id}/forks
func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, error) { func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, error) {
u := fmt.Sprintf("gists/%v/forks", id) u := fmt.Sprintf("gists/%v/forks", id)
req, err := s.client.NewRequest("POST", u, nil) req, err := s.client.NewRequest("POST", u, nil)
@ -345,7 +372,9 @@ func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, e
// ListForks lists forks of a gist. // ListForks lists forks of a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-forks // GitHub API docs: https://docs.github.com/rest/gists/gists#list-gist-forks
//
//meta:operation GET /gists/{gist_id}/forks
func (s *GistsService) ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) { func (s *GistsService) ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) {
u := fmt.Sprintf("gists/%v/forks", id) u := fmt.Sprintf("gists/%v/forks", id)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)

View file

@ -25,7 +25,9 @@ func (g GistComment) String() string {
// ListComments lists all comments for a gist. // ListComments lists all comments for a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#list-gist-comments // GitHub API docs: https://docs.github.com/rest/gists/comments#list-gist-comments
//
//meta:operation GET /gists/{gist_id}/comments
func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) { func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) {
u := fmt.Sprintf("gists/%v/comments", gistID) u := fmt.Sprintf("gists/%v/comments", gistID)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -49,7 +51,9 @@ func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *Li
// GetComment retrieves a single comment from a gist. // GetComment retrieves a single comment from a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#get-a-gist-comment // GitHub API docs: https://docs.github.com/rest/gists/comments#get-a-gist-comment
//
//meta:operation GET /gists/{gist_id}/comments/{comment_id}
func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) { func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) {
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -68,7 +72,9 @@ func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID
// CreateComment creates a comment for a gist. // CreateComment creates a comment for a gist.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#create-a-gist-comment // GitHub API docs: https://docs.github.com/rest/gists/comments#create-a-gist-comment
//
//meta:operation POST /gists/{gist_id}/comments
func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) { func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) {
u := fmt.Sprintf("gists/%v/comments", gistID) u := fmt.Sprintf("gists/%v/comments", gistID)
req, err := s.client.NewRequest("POST", u, comment) req, err := s.client.NewRequest("POST", u, comment)
@ -87,7 +93,9 @@ func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment
// EditComment edits an existing gist comment. // EditComment edits an existing gist comment.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#update-a-gist-comment // GitHub API docs: https://docs.github.com/rest/gists/comments#update-a-gist-comment
//
//meta:operation PATCH /gists/{gist_id}/comments/{comment_id}
func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) { func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) {
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
req, err := s.client.NewRequest("PATCH", u, comment) req, err := s.client.NewRequest("PATCH", u, comment)
@ -106,7 +114,9 @@ func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID
// DeleteComment deletes a gist comment. // DeleteComment deletes a gist comment.
// //
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#delete-a-gist-comment // GitHub API docs: https://docs.github.com/rest/gists/comments#delete-a-gist-comment
//
//meta:operation DELETE /gists/{gist_id}/comments/{comment_id}
func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) { func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) {
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -8,5 +8,5 @@ package github
// GitService handles communication with the git data related // GitService handles communication with the git data related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/ // GitHub API docs: https://docs.github.com/rest/git/
type GitService service type GitService service

View file

@ -23,7 +23,9 @@ type Blob struct {
// GetBlob fetches a blob from a repo given a SHA. // GetBlob fetches a blob from a repo given a SHA.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob // GitHub API docs: https://docs.github.com/rest/git/blobs#get-a-blob
//
//meta:operation GET /repos/{owner}/{repo}/git/blobs/{file_sha}
func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -43,7 +45,9 @@ func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha
// GetBlobRaw fetches a blob's contents from a repo. // GetBlobRaw fetches a blob's contents from a repo.
// Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data. // Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob // GitHub API docs: https://docs.github.com/rest/git/blobs#get-a-blob
//
//meta:operation GET /repos/{owner}/{repo}/git/blobs/{file_sha}
func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -64,7 +68,9 @@ func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([
// CreateBlob creates a blob object. // CreateBlob creates a blob object.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#create-a-blob // GitHub API docs: https://docs.github.com/rest/git/blobs#create-a-blob
//
//meta:operation POST /repos/{owner}/{repo}/git/blobs
func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo)
req, err := s.client.NewRequest("POST", u, blob) req, err := s.client.NewRequest("POST", u, blob)

View file

@ -82,7 +82,9 @@ func (c CommitAuthor) String() string {
// GetCommit fetches the Commit object for a given SHA. // GetCommit fetches the Commit object for a given SHA.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/commits#get-a-commit // GitHub API docs: https://docs.github.com/rest/git/commits#get-a-commit-object
//
//meta:operation GET /repos/{owner}/{repo}/git/commits/{commit_sha}
func (s *GitService) GetCommit(ctx context.Context, owner string, repo string, sha string) (*Commit, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/commits/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -122,7 +124,9 @@ type CreateCommitOptions struct {
// data if omitted. If the commit.Author is omitted, it will be filled in with // data if omitted. If the commit.Author is omitted, it will be filled in with
// the authenticated users information and the current date. // the authenticated users information and the current date.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/commits#create-a-commit // GitHub API docs: https://docs.github.com/rest/git/commits#create-a-commit
//
//meta:operation POST /repos/{owner}/{repo}/git/commits
func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit, opts *CreateCommitOptions) (*Commit, *Response, error) { func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit, opts *CreateCommitOptions) (*Commit, *Response, error) {
if commit == nil { if commit == nil {
return nil, nil, fmt.Errorf("commit must be provided") return nil, nil, fmt.Errorf("commit must be provided")

View file

@ -49,7 +49,9 @@ type updateRefRequest struct {
// GetRef fetches a single reference in a repository. // GetRef fetches a single reference in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/refs#get-a-reference // GitHub API docs: https://docs.github.com/rest/git/refs#get-a-reference
//
//meta:operation GET /repos/{owner}/{repo}/git/ref/{ref}
func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) { func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) {
ref = strings.TrimPrefix(ref, "refs/") ref = strings.TrimPrefix(ref, "refs/")
u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref)) u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref))
@ -88,7 +90,9 @@ type ReferenceListOptions struct {
// ListMatchingRefs lists references in a repository that match a supplied ref. // ListMatchingRefs lists references in a repository that match a supplied ref.
// Use an empty ref to list all references. // Use an empty ref to list all references.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/refs#list-matching-references // GitHub API docs: https://docs.github.com/rest/git/refs#list-matching-references
//
//meta:operation GET /repos/{owner}/{repo}/git/matching-refs/{ref}
func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) { func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) {
var ref string var ref string
if opts != nil { if opts != nil {
@ -116,7 +120,9 @@ func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, o
// CreateRef creates a new ref in a repository. // CreateRef creates a new ref in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/refs#create-a-reference // GitHub API docs: https://docs.github.com/rest/git/refs#create-a-reference
//
//meta:operation POST /repos/{owner}/{repo}/git/refs
func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) { func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo) u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
req, err := s.client.NewRequest("POST", u, &createRefRequest{ req, err := s.client.NewRequest("POST", u, &createRefRequest{
@ -139,7 +145,9 @@ func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, r
// UpdateRef updates an existing ref in a repository. // UpdateRef updates an existing ref in a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/refs#update-a-reference // GitHub API docs: https://docs.github.com/rest/git/refs#update-a-reference
//
//meta:operation PATCH /repos/{owner}/{repo}/git/refs/{ref}
func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) { func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) {
refPath := strings.TrimPrefix(*ref.Ref, "refs/") refPath := strings.TrimPrefix(*ref.Ref, "refs/")
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(refPath)) u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(refPath))
@ -162,7 +170,9 @@ func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, r
// DeleteRef deletes a ref from a repository. // DeleteRef deletes a ref from a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/refs#delete-a-reference // GitHub API docs: https://docs.github.com/rest/git/refs#delete-a-reference
//
//meta:operation DELETE /repos/{owner}/{repo}/git/refs/{ref}
func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) { func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) {
ref = strings.TrimPrefix(ref, "refs/") ref = strings.TrimPrefix(ref, "refs/")
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref)) u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref))

View file

@ -35,7 +35,9 @@ type createTagRequest struct {
// GetTag fetches a tag from a repo given a SHA. // GetTag fetches a tag from a repo given a SHA.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/tags#get-a-tag // GitHub API docs: https://docs.github.com/rest/git/tags#get-a-tag
//
//meta:operation GET /repos/{owner}/{repo}/git/tags/{tag_sha}
func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) { func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha) u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -54,7 +56,9 @@ func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha
// CreateTag creates a tag object. // CreateTag creates a tag object.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/tags#create-a-tag-object // GitHub API docs: https://docs.github.com/rest/git/tags#create-a-tag-object
//
//meta:operation POST /repos/{owner}/{repo}/git/tags
func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) { func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo) u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo)

View file

@ -93,7 +93,9 @@ func (t *TreeEntry) MarshalJSON() ([]byte, error) {
// GetTree fetches the Tree object for a given sha hash from a repository. // GetTree fetches the Tree object for a given sha hash from a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/trees#get-a-tree // GitHub API docs: https://docs.github.com/rest/git/trees#get-a-tree
//
//meta:operation GET /repos/{owner}/{repo}/git/trees/{tree_sha}
func (s *GitService) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha)
if recursive { if recursive {
@ -124,7 +126,9 @@ type createTree struct {
// path modifying that tree are specified, it will overwrite the contents of // 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. // that tree with the new path contents and write a new tree out.
// //
// GitHub API docs: https://docs.github.com/en/rest/git/trees#create-a-tree // GitHub API docs: https://docs.github.com/rest/git/trees#create-a-tree
//
//meta:operation POST /repos/{owner}/{repo}/git/trees
func (s *GitService) CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo)

View file

@ -5,6 +5,7 @@
//go:generate go run gen-accessors.go //go:generate go run gen-accessors.go
//go:generate go run gen-stringify-test.go //go:generate go run gen-stringify-test.go
//go:generate ../script/metadata.sh update-go
package github package github
@ -27,7 +28,7 @@ import (
) )
const ( const (
Version = "v55.0.0" Version = "v57.0.0"
defaultAPIVersion = "2022-11-28" defaultAPIVersion = "2022-11-28"
defaultBaseURL = "https://api.github.com/" defaultBaseURL = "https://api.github.com/"
@ -131,10 +132,10 @@ const (
// https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/ // https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/
mediaTypeListPullsOrBranchesForCommitPreview = "application/vnd.github.groot-preview+json" mediaTypeListPullsOrBranchesForCommitPreview = "application/vnd.github.groot-preview+json"
// https://docs.github.com/en/rest/previews/#repository-creation-permissions // https://docs.github.com/rest/previews/#repository-creation-permissions
mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json" mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json"
// https://docs.github.com/en/rest/previews/#create-and-use-repository-templates // https://docs.github.com/rest/previews/#create-and-use-repository-templates
mediaTypeRepositoryTemplatePreview = "application/vnd.github.baptiste-preview+json" mediaTypeRepositoryTemplatePreview = "application/vnd.github.baptiste-preview+json"
// https://developer.github.com/changes/2019-10-03-multi-line-comments/ // https://developer.github.com/changes/2019-10-03-multi-line-comments/
@ -183,9 +184,11 @@ type Client struct {
Billing *BillingService Billing *BillingService
Checks *ChecksService Checks *ChecksService
CodeScanning *CodeScanningService CodeScanning *CodeScanningService
CodesOfConduct *CodesOfConductService
Codespaces *CodespacesService Codespaces *CodespacesService
Dependabot *DependabotService Dependabot *DependabotService
DependencyGraph *DependencyGraphService DependencyGraph *DependencyGraphService
Emojis *EmojisService
Enterprise *EnterpriseService Enterprise *EnterpriseService
Gists *GistsService Gists *GistsService
Git *GitService Git *GitService
@ -194,11 +197,14 @@ type Client struct {
IssueImport *IssueImportService IssueImport *IssueImportService
Issues *IssuesService Issues *IssuesService
Licenses *LicensesService Licenses *LicensesService
Markdown *MarkdownService
Marketplace *MarketplaceService Marketplace *MarketplaceService
Meta *MetaService
Migrations *MigrationService Migrations *MigrationService
Organizations *OrganizationsService Organizations *OrganizationsService
Projects *ProjectsService Projects *ProjectsService
PullRequests *PullRequestsService PullRequests *PullRequestsService
RateLimit *RateLimitService
Reactions *ReactionsService Reactions *ReactionsService
Repositories *RepositoriesService Repositories *RepositoriesService
SCIM *SCIMService SCIM *SCIMService
@ -401,8 +407,10 @@ func (c *Client) initialize() {
c.Checks = (*ChecksService)(&c.common) c.Checks = (*ChecksService)(&c.common)
c.CodeScanning = (*CodeScanningService)(&c.common) c.CodeScanning = (*CodeScanningService)(&c.common)
c.Codespaces = (*CodespacesService)(&c.common) c.Codespaces = (*CodespacesService)(&c.common)
c.CodesOfConduct = (*CodesOfConductService)(&c.common)
c.Dependabot = (*DependabotService)(&c.common) c.Dependabot = (*DependabotService)(&c.common)
c.DependencyGraph = (*DependencyGraphService)(&c.common) c.DependencyGraph = (*DependencyGraphService)(&c.common)
c.Emojis = (*EmojisService)(&c.common)
c.Enterprise = (*EnterpriseService)(&c.common) c.Enterprise = (*EnterpriseService)(&c.common)
c.Gists = (*GistsService)(&c.common) c.Gists = (*GistsService)(&c.common)
c.Git = (*GitService)(&c.common) c.Git = (*GitService)(&c.common)
@ -411,11 +419,14 @@ func (c *Client) initialize() {
c.IssueImport = (*IssueImportService)(&c.common) c.IssueImport = (*IssueImportService)(&c.common)
c.Issues = (*IssuesService)(&c.common) c.Issues = (*IssuesService)(&c.common)
c.Licenses = (*LicensesService)(&c.common) c.Licenses = (*LicensesService)(&c.common)
c.Markdown = (*MarkdownService)(&c.common)
c.Marketplace = &MarketplaceService{client: c} c.Marketplace = &MarketplaceService{client: c}
c.Meta = (*MetaService)(&c.common)
c.Migrations = (*MigrationService)(&c.common) c.Migrations = (*MigrationService)(&c.common)
c.Organizations = (*OrganizationsService)(&c.common) c.Organizations = (*OrganizationsService)(&c.common)
c.Projects = (*ProjectsService)(&c.common) c.Projects = (*ProjectsService)(&c.common)
c.PullRequests = (*PullRequestsService)(&c.common) c.PullRequests = (*PullRequestsService)(&c.common)
c.RateLimit = (*RateLimitService)(&c.common)
c.Reactions = (*ReactionsService)(&c.common) c.Reactions = (*ReactionsService)(&c.common)
c.Repositories = (*RepositoriesService)(&c.common) c.Repositories = (*RepositoriesService)(&c.common)
c.SCIM = (*SCIMService)(&c.common) c.SCIM = (*SCIMService)(&c.common)
@ -984,7 +995,7 @@ func compareHTTPResponse(r1, r2 *http.Response) bool {
/* /*
An ErrorResponse reports one or more errors caused by an API request. An ErrorResponse reports one or more errors caused by an API request.
GitHub API docs: https://docs.github.com/en/rest/#client-errors GitHub API docs: https://docs.github.com/rest/#client-errors
*/ */
type ErrorResponse struct { type ErrorResponse struct {
Response *http.Response `json:"-"` // HTTP response that caused this error Response *http.Response `json:"-"` // HTTP response that caused this error
@ -994,7 +1005,7 @@ type ErrorResponse struct {
Block *ErrorBlock `json:"block,omitempty"` Block *ErrorBlock `json:"block,omitempty"`
// Most errors will also include a documentation_url field pointing // Most errors will also include a documentation_url field pointing
// to some content that might help you resolve the error, see // to some content that might help you resolve the error, see
// https://docs.github.com/en/rest/#client-errors // https://docs.github.com/rest/#client-errors
DocumentationURL string `json:"documentation_url,omitempty"` DocumentationURL string `json:"documentation_url,omitempty"`
} }
@ -1007,9 +1018,17 @@ type ErrorBlock struct {
} }
func (r *ErrorResponse) Error() string { func (r *ErrorResponse) Error() string {
return fmt.Sprintf("%v %v: %d %v %+v", if r.Response != nil && r.Response.Request != nil {
r.Response.Request.Method, sanitizeURL(r.Response.Request.URL), return fmt.Sprintf("%v %v: %d %v %+v",
r.Response.StatusCode, r.Message, r.Errors) r.Response.Request.Method, sanitizeURL(r.Response.Request.URL),
r.Response.StatusCode, r.Message, r.Errors)
}
if r.Response != nil {
return fmt.Sprintf("%d %v %+v", r.Response.StatusCode, r.Message, r.Errors)
}
return fmt.Sprintf("%v %+v", r.Message, r.Errors)
} }
// Is returns whether the provided error equals this error. // Is returns whether the provided error equals this error.
@ -1114,7 +1133,7 @@ func (ae *AcceptedError) Is(target error) bool {
} }
// AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the // AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the
// "documentation_url" field value equal to "https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits". // "documentation_url" field value equal to "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits".
type AbuseRateLimitError struct { type AbuseRateLimitError struct {
Response *http.Response // HTTP response that caused this error Response *http.Response // HTTP response that caused this error
Message string `json:"message"` // error message Message string `json:"message"` // error message
@ -1177,7 +1196,7 @@ GitHub error responses structure are often undocumented and inconsistent.
Sometimes error is just a simple string (Issue #540). Sometimes error is just a simple string (Issue #540).
In such cases, Message represents an error message as a workaround. In such cases, Message represents an error message as a workaround.
GitHub API docs: https://docs.github.com/en/rest/#client-errors GitHub API docs: https://docs.github.com/rest/#client-errors
*/ */
type Error struct { type Error struct {
Resource string `json:"resource"` // resource on which the error occurred Resource string `json:"resource"` // resource on which the error occurred
@ -1240,7 +1259,7 @@ func CheckResponse(r *http.Response) error {
} }
case r.StatusCode == http.StatusForbidden && case r.StatusCode == http.StatusForbidden &&
(strings.HasSuffix(errorResponse.DocumentationURL, "#abuse-rate-limits") || (strings.HasSuffix(errorResponse.DocumentationURL, "#abuse-rate-limits") ||
strings.HasSuffix(errorResponse.DocumentationURL, "#secondary-rate-limits")): strings.HasSuffix(errorResponse.DocumentationURL, "secondary-rate-limits")):
abuseRateLimitError := &AbuseRateLimitError{ abuseRateLimitError := &AbuseRateLimitError{
Response: errorResponse.Response, Response: errorResponse.Response,
Message: errorResponse.Message, Message: errorResponse.Message,
@ -1273,54 +1292,6 @@ func parseBoolResponse(err error) (bool, error) {
return false, err return false, err
} }
// Rate represents the rate limit for the current client.
type Rate struct {
// The number of requests per hour the client is currently limited to.
Limit int `json:"limit"`
// The number of remaining requests the client can make this hour.
Remaining int `json:"remaining"`
// The time at which the current rate limit will reset.
Reset Timestamp `json:"reset"`
}
func (r Rate) String() string {
return Stringify(r)
}
// RateLimits represents the rate limits for the current client.
type RateLimits struct {
// The rate limit for non-search API requests. Unauthenticated
// requests are limited to 60 per hour. Authenticated requests are
// limited to 5,000 per hour.
//
// 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/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 {
return Stringify(r)
}
type rateLimitCategory uint8 type rateLimitCategory uint8
const ( const (
@ -1339,7 +1310,7 @@ const (
// category returns the rate limit category of the endpoint, determined by HTTP method and Request.URL.Path. // category returns the rate limit category of the endpoint, determined by HTTP method and Request.URL.Path.
func category(method, path string) rateLimitCategory { func category(method, path string) rateLimitCategory {
switch { switch {
// https://docs.github.com/en/rest/rate-limit#about-rate-limits // https://docs.github.com/rest/rate-limit#about-rate-limits
default: default:
// NOTE: coreCategory is returned for actionsRunnerRegistrationCategory too, // NOTE: coreCategory is returned for actionsRunnerRegistrationCategory too,
// because no API found for this category. // because no API found for this category.
@ -1353,70 +1324,27 @@ func category(method, path string) rateLimitCategory {
method == http.MethodPost: method == http.MethodPost:
return integrationManifestCategory return integrationManifestCategory
// https://docs.github.com/en/rest/migrations/source-imports#start-an-import // https://docs.github.com/rest/migrations/source-imports#start-an-import
case strings.HasPrefix(path, "/repos/") && case strings.HasPrefix(path, "/repos/") &&
strings.HasSuffix(path, "/import") && strings.HasSuffix(path, "/import") &&
method == http.MethodPut: method == http.MethodPut:
return sourceImportCategory return sourceImportCategory
// https://docs.github.com/en/rest/code-scanning#upload-an-analysis-as-sarif-data // https://docs.github.com/rest/code-scanning#upload-an-analysis-as-sarif-data
case strings.HasSuffix(path, "/code-scanning/sarifs"): case strings.HasSuffix(path, "/code-scanning/sarifs"):
return codeScanningUploadCategory return codeScanningUploadCategory
// https://docs.github.com/en/enterprise-cloud@latest/rest/scim // https://docs.github.com/enterprise-cloud@latest/rest/scim
case strings.HasPrefix(path, "/scim/"): case strings.HasPrefix(path, "/scim/"):
return scimCategory return scimCategory
} }
} }
// RateLimits returns the rate limits for the current client. // RateLimits returns the rate limits for the current client.
//
// Deprecated: Use RateLimitService.Get instead.
func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error) { func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error) {
req, err := c.NewRequest("GET", "rate_limit", nil) return c.RateLimit.Get(ctx)
if err != nil {
return nil, nil, err
}
response := new(struct {
Resources *RateLimits `json:"resources"`
})
// This resource is not subject to rate limits.
ctx = context.WithValue(ctx, bypassRateLimitCheck, true)
resp, err := c.Do(ctx, req, response)
if err != nil {
return nil, resp, err
}
if response.Resources != nil {
c.rateMu.Lock()
if response.Resources.Core != nil {
c.rateLimits[coreCategory] = *response.Resources.Core
}
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()
}
return response.Resources, resp, nil
} }
func setCredentialsAsHeaders(req *http.Request, id, secret string) *http.Request { func setCredentialsAsHeaders(req *http.Request, id, secret string) *http.Request {
@ -1450,7 +1378,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 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. ClientID:ClientSecret and apply it as an "Authorization": "Basic" header.
See https://docs.github.com/en/rest/#unauthenticated-rate-limited-requests for See https://docs.github.com/rest/#unauthenticated-rate-limited-requests for
more information. more information.
*/ */
type UnauthenticatedRateLimitedTransport struct { type UnauthenticatedRateLimitedTransport struct {
@ -1558,7 +1486,7 @@ func formatRateReset(d time.Duration) string {
// When using roundTripWithOptionalFollowRedirect, note that it // When using roundTripWithOptionalFollowRedirect, note that it
// is the responsibility of the caller to close the response body. // is the responsibility of the caller to close the response body.
func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, followRedirects bool, opts ...RequestOption) (*http.Response, error) { func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, maxRedirects int, opts ...RequestOption) (*http.Response, error) {
req, err := c.NewRequest("GET", u, nil, opts...) req, err := c.NewRequest("GET", u, nil, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -1577,10 +1505,10 @@ func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u stri
} }
// If redirect response is returned, follow it // If redirect response is returned, follow it
if followRedirects && resp.StatusCode == http.StatusMovedPermanently { if maxRedirects > 0 && resp.StatusCode == http.StatusMovedPermanently {
_ = resp.Body.Close() _ = resp.Body.Close()
u = resp.Header.Get("Location") u = resp.Header.Get("Location")
resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, false, opts...) resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects-1, opts...)
} }
return resp, err return resp, err
} }

View file

@ -13,7 +13,7 @@ import (
// GitignoresService provides access to the gitignore related functions in the // GitignoresService provides access to the gitignore related functions in the
// GitHub API. // GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/gitignore/ // GitHub API docs: https://docs.github.com/rest/gitignore/
type GitignoresService service type GitignoresService service
// Gitignore represents a .gitignore file as returned by the GitHub API. // Gitignore represents a .gitignore file as returned by the GitHub API.
@ -28,7 +28,9 @@ func (g Gitignore) String() string {
// List all available Gitignore templates. // List all available Gitignore templates.
// //
// GitHub API docs: https://docs.github.com/en/rest/gitignore/#listing-available-templates // GitHub API docs: https://docs.github.com/rest/gitignore/gitignore#get-all-gitignore-templates
//
//meta:operation GET /gitignore/templates
func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) { func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) {
req, err := s.client.NewRequest("GET", "gitignore/templates", nil) req, err := s.client.NewRequest("GET", "gitignore/templates", nil)
if err != nil { if err != nil {
@ -46,7 +48,9 @@ func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, erro
// Get a Gitignore by name. // Get a Gitignore by name.
// //
// GitHub API docs: https://docs.github.com/en/rest/gitignore#get-a-gitignore-template // GitHub API docs: https://docs.github.com/rest/gitignore/gitignore#get-a-gitignore-template
//
//meta:operation GET /gitignore/templates/{name}
func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) { func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) {
u := fmt.Sprintf("gitignore/templates/%v", name) u := fmt.Sprintf("gitignore/templates/%v", name)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)

View file

@ -8,7 +8,7 @@ package github
// InteractionsService handles communication with the repository and organization related // InteractionsService handles communication with the repository and organization related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/ // GitHub API docs: https://docs.github.com/rest/interactions/
type InteractionsService service type InteractionsService service
// InteractionRestriction represents the interaction restrictions for repository and organization. // InteractionRestriction represents the interaction restrictions for repository and organization.

View file

@ -12,7 +12,9 @@ import (
// GetRestrictionsForOrg fetches the interaction restrictions for an organization. // GetRestrictionsForOrg fetches the interaction restrictions for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#get-interaction-restrictions-for-an-organization // GitHub API docs: https://docs.github.com/rest/interactions/orgs#get-interaction-restrictions-for-an-organization
//
//meta:operation GET /orgs/{org}/interaction-limits
func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) { func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("orgs/%v/interaction-limits", organization) u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -39,7 +41,9 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
// in public repositories for the given organization. // in public repositories for the given organization.
// Possible values are: "existing_users", "contributors_only", "collaborators_only". // Possible values are: "existing_users", "contributors_only", "collaborators_only".
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#set-interaction-restrictions-for-an-organization // GitHub API docs: https://docs.github.com/rest/interactions/orgs#set-interaction-restrictions-for-an-organization
//
//meta:operation PUT /orgs/{org}/interaction-limits
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) { func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("orgs/%v/interaction-limits", organization) u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
@ -65,7 +69,9 @@ func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, orga
// RemoveRestrictionsFromOrg removes the interaction restrictions for an organization. // RemoveRestrictionsFromOrg removes the interaction restrictions for an organization.
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization // GitHub API docs: https://docs.github.com/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization
//
//meta:operation DELETE /orgs/{org}/interaction-limits
func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) { func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) {
u := fmt.Sprintf("orgs/%v/interaction-limits", organization) u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -12,7 +12,9 @@ import (
// GetRestrictionsForRepo fetches the interaction restrictions for a repository. // GetRestrictionsForRepo fetches the interaction restrictions for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#get-interaction-restrictions-for-a-repository // GitHub API docs: https://docs.github.com/rest/interactions/repos#get-interaction-restrictions-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/interaction-limits
func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) { func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -39,7 +41,9 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
// for the given repository. // for the given repository.
// Possible values are: "existing_users", "contributors_only", "collaborators_only". // Possible values are: "existing_users", "contributors_only", "collaborators_only".
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#set-interaction-restrictions-for-a-repository // GitHub API docs: https://docs.github.com/rest/interactions/repos#set-interaction-restrictions-for-a-repository
//
//meta:operation PUT /repos/{owner}/{repo}/interaction-limits
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) { func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
@ -65,7 +69,9 @@ func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, own
// RemoveRestrictionsFromRepo removes the interaction restrictions for a repository. // RemoveRestrictionsFromRepo removes the interaction restrictions for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#remove-interaction-restrictions-for-a-repository // GitHub API docs: https://docs.github.com/rest/interactions/repos#remove-interaction-restrictions-for-a-repository
//
//meta:operation DELETE /repos/{owner}/{repo}/interaction-limits
func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) { func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -70,7 +70,9 @@ type IssueImportError struct {
// Create a new imported issue on the specified repository. // Create a new imported issue on the specified repository.
// //
// https://gist.github.com/jonmagic/5282384165e0f86ef105#start-an-issue-import // GitHub API docs: https://gist.github.com/jonmagic/5282384165e0f86ef105#start-an-issue-import
//
//meta:operation POST /repos/{owner}/{repo}/import/issues
func (s *IssueImportService) Create(ctx context.Context, owner, repo string, issue *IssueImportRequest) (*IssueImportResponse, *Response, error) { func (s *IssueImportService) Create(ctx context.Context, owner, repo string, issue *IssueImportRequest) (*IssueImportResponse, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import/issues", owner, repo) u := fmt.Sprintf("repos/%v/%v/import/issues", owner, repo)
req, err := s.client.NewRequest("POST", u, issue) req, err := s.client.NewRequest("POST", u, issue)
@ -99,7 +101,9 @@ func (s *IssueImportService) Create(ctx context.Context, owner, repo string, iss
// CheckStatus checks the status of an imported issue. // CheckStatus checks the status of an imported issue.
// //
// https://gist.github.com/jonmagic/5282384165e0f86ef105#import-status-request // GitHub API docs: https://gist.github.com/jonmagic/5282384165e0f86ef105#import-status-request
//
//meta:operation GET /repos/{owner}/{repo}/import/issues/{issue_number}
func (s *IssueImportService) CheckStatus(ctx context.Context, owner, repo string, issueID int64) (*IssueImportResponse, *Response, error) { func (s *IssueImportService) CheckStatus(ctx context.Context, owner, repo string, issueID int64) (*IssueImportResponse, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import/issues/%v", owner, repo, issueID) u := fmt.Sprintf("repos/%v/%v/import/issues/%v", owner, repo, issueID)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -121,7 +125,9 @@ func (s *IssueImportService) CheckStatus(ctx context.Context, owner, repo string
// CheckStatusSince checks the status of multiple imported issues since a given date. // CheckStatusSince checks the status of multiple imported issues since a given date.
// //
// https://gist.github.com/jonmagic/5282384165e0f86ef105#check-status-of-multiple-issues // GitHub API docs: https://gist.github.com/jonmagic/5282384165e0f86ef105#check-status-of-multiple-issues
//
//meta:operation GET /repos/{owner}/{repo}/import/issues
func (s *IssueImportService) CheckStatusSince(ctx context.Context, owner, repo string, since Timestamp) ([]*IssueImportResponse, *Response, error) { func (s *IssueImportService) CheckStatusSince(ctx context.Context, owner, repo string, since Timestamp) ([]*IssueImportResponse, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import/issues?since=%v", owner, repo, since.Format("2006-01-02")) u := fmt.Sprintf("repos/%v/%v/import/issues?since=%v", owner, repo, since.Format("2006-01-02"))
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)

View file

@ -14,7 +14,7 @@ import (
// IssuesService handles communication with the issue related // IssuesService handles communication with the issue related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/ // GitHub API docs: https://docs.github.com/rest/issues/
type IssuesService service type IssuesService service
// Issue represents a GitHub issue on a repository. // Issue represents a GitHub issue on a repository.
@ -54,9 +54,10 @@ type Issue struct {
Reactions *Reactions `json:"reactions,omitempty"` Reactions *Reactions `json:"reactions,omitempty"`
Assignees []*User `json:"assignees,omitempty"` Assignees []*User `json:"assignees,omitempty"`
NodeID *string `json:"node_id,omitempty"` NodeID *string `json:"node_id,omitempty"`
Draft *bool `json:"draft,omitempty"`
// TextMatches is only populated from search results that request text matches // TextMatches is only populated from search results that request text matches
// See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata // See: search.go and https://docs.github.com/rest/search/#text-match-metadata
TextMatches []*TextMatch `json:"text_matches,omitempty"` TextMatches []*TextMatch `json:"text_matches,omitempty"`
// ActiveLockReason is populated only when LockReason is provided while locking the issue. // ActiveLockReason is populated only when LockReason is provided while locking the issue.
@ -132,8 +133,11 @@ type PullRequestLinks struct {
// organization repositories; if false, list only owned and member // organization repositories; if false, list only owned and member
// repositories. // repositories.
// //
// 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/rest/issues/issues#list-issues-assigned-to-the-authenticated-user
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-issues-assigned-to-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user
//
//meta:operation GET /issues
//meta:operation GET /user/issues
func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) { func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) {
var u string var u string
if all { if all {
@ -147,7 +151,9 @@ func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptio
// ListByOrg fetches the issues in the specified organization for the // ListByOrg fetches the issues in the specified organization for the
// authenticated user. // authenticated user.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user // GitHub API docs: https://docs.github.com/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user
//
//meta:operation GET /orgs/{org}/issues
func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) { func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) {
u := fmt.Sprintf("orgs/%v/issues", org) u := fmt.Sprintf("orgs/%v/issues", org)
return s.listIssues(ctx, u, opts) return s.listIssues(ctx, u, opts)
@ -218,7 +224,9 @@ type IssueListByRepoOptions struct {
// ListByRepo lists the issues for the specified repository. // ListByRepo lists the issues for the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-repository-issues // GitHub API docs: https://docs.github.com/rest/issues/issues#list-repository-issues
//
//meta:operation GET /repos/{owner}/{repo}/issues
func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -245,7 +253,9 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo strin
// Get a single issue. // Get a single issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#get-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#get-an-issue
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}
func (s *IssuesService) Get(ctx context.Context, owner string, repo string, number int) (*Issue, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -267,7 +277,9 @@ func (s *IssuesService) Get(ctx context.Context, owner string, repo string, numb
// Create a new issue on the specified repository. // Create a new issue on the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#create-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#create-an-issue
//
//meta:operation POST /repos/{owner}/{repo}/issues
func (s *IssuesService) Create(ctx context.Context, owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
req, err := s.client.NewRequest("POST", u, issue) req, err := s.client.NewRequest("POST", u, issue)
@ -286,7 +298,9 @@ func (s *IssuesService) Create(ctx context.Context, owner string, repo string, i
// Edit (update) an issue. // Edit (update) an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#update-an-issue
//
//meta:operation PATCH /repos/{owner}/{repo}/issues/{issue_number}
func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
req, err := s.client.NewRequest("PATCH", u, issue) req, err := s.client.NewRequest("PATCH", u, issue)
@ -303,11 +317,13 @@ func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, num
return i, resp, nil return i, resp, nil
} }
// Remove a milestone from an issue. // RemoveMilestone removes a milestone from an issue.
// //
// This is a helper method to explicitly update an issue with a `null` milestone, thereby removing it. // 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/rest/issues/issues#update-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#update-an-issue
//
//meta:operation PATCH /repos/{owner}/{repo}/issues/{issue_number}
func (s *IssuesService) RemoveMilestone(ctx context.Context, owner, repo string, issueNumber int) (*Issue, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, issueNumber)
req, err := s.client.NewRequest("PATCH", u, &struct { req, err := s.client.NewRequest("PATCH", u, &struct {
@ -337,7 +353,9 @@ type LockIssueOptions struct {
// Lock an issue's conversation. // Lock an issue's conversation.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#lock-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#lock-an-issue
//
//meta:operation PUT /repos/{owner}/{repo}/issues/{issue_number}/lock
func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int, opts *LockIssueOptions) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
req, err := s.client.NewRequest("PUT", u, opts) req, err := s.client.NewRequest("PUT", u, opts)
@ -350,7 +368,9 @@ func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, num
// Unlock an issue's conversation. // Unlock an issue's conversation.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#unlock-an-issue // GitHub API docs: https://docs.github.com/rest/issues/issues#unlock-an-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock
func (s *IssuesService) Unlock(ctx context.Context, owner string, repo string, number int) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -13,7 +13,9 @@ import (
// ListAssignees fetches all available assignees (owners and collaborators) to // ListAssignees fetches all available assignees (owners and collaborators) to
// which issues may be assigned. // which issues may be assigned.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#list-assignees // GitHub API docs: https://docs.github.com/rest/issues/assignees#list-assignees
//
//meta:operation GET /repos/{owner}/{repo}/assignees
func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -37,7 +39,9 @@ func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, o
// IsAssignee checks if a user is an assignee for the specified repository. // IsAssignee checks if a user is an assignee for the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#check-if-a-user-can-be-assigned // GitHub API docs: https://docs.github.com/rest/issues/assignees#check-if-a-user-can-be-assigned
//
//meta:operation GET /repos/{owner}/{repo}/assignees/{assignee}
func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -52,7 +56,9 @@ func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string
// AddAssignees adds the provided GitHub users as assignees to the issue. // AddAssignees adds the provided GitHub users as assignees to the issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#add-assignees-to-an-issue // GitHub API docs: https://docs.github.com/rest/issues/assignees#add-assignees-to-an-issue
//
//meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/assignees
func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
users := &struct { users := &struct {
Assignees []string `json:"assignees,omitempty"` Assignees []string `json:"assignees,omitempty"`
@ -74,7 +80,9 @@ func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, nu
// RemoveAssignees removes the provided GitHub users as assignees from the issue. // RemoveAssignees removes the provided GitHub users as assignees from the issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#remove-assignees-from-an-issue // GitHub API docs: https://docs.github.com/rest/issues/assignees#remove-assignees-from-an-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees
func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
users := &struct { users := &struct {
Assignees []string `json:"assignees,omitempty"` Assignees []string `json:"assignees,omitempty"`

View file

@ -50,8 +50,11 @@ type IssueListCommentsOptions struct {
// ListComments lists all comments on the specified issue. Specifying an issue // ListComments lists all comments on the specified issue. Specifying an issue
// number of 0 will return all comments on all issues for the repository. // number of 0 will return all comments on all issues for the repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments // GitHub API docs: https://docs.github.com/rest/issues/comments#list-issue-comments
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments-for-a-repository // GitHub API docs: https://docs.github.com/rest/issues/comments#list-issue-comments-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/issues/comments
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/comments
func (s *IssuesService) ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) { func (s *IssuesService) ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) {
var u string var u string
if number == 0 { if number == 0 {
@ -83,7 +86,9 @@ func (s *IssuesService) ListComments(ctx context.Context, owner string, repo str
// GetComment fetches the specified issue comment. // GetComment fetches the specified issue comment.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#get-an-issue-comment // GitHub API docs: https://docs.github.com/rest/issues/comments#get-an-issue-comment
//
//meta:operation GET /repos/{owner}/{repo}/issues/comments/{comment_id}
func (s *IssuesService) GetComment(ctx context.Context, owner string, repo string, commentID int64) (*IssueComment, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
@ -106,7 +111,9 @@ func (s *IssuesService) GetComment(ctx context.Context, owner string, repo strin
// CreateComment creates a new comment on the specified issue. // CreateComment creates a new comment on the specified issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#create-an-issue-comment // GitHub API docs: https://docs.github.com/rest/issues/comments#create-an-issue-comment
//
//meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/comments
func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
req, err := s.client.NewRequest("POST", u, comment) req, err := s.client.NewRequest("POST", u, comment)
@ -125,7 +132,9 @@ func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo st
// EditComment updates an issue comment. // EditComment updates an issue comment.
// A non-nil comment.Body must be provided. Other comment fields should be left nil. // A non-nil comment.Body must be provided. Other comment fields should be left nil.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#update-an-issue-comment // GitHub API docs: https://docs.github.com/rest/issues/comments#update-an-issue-comment
//
//meta:operation PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}
func (s *IssuesService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
req, err := s.client.NewRequest("PATCH", u, comment) req, err := s.client.NewRequest("PATCH", u, comment)
@ -143,7 +152,9 @@ func (s *IssuesService) EditComment(ctx context.Context, owner string, repo stri
// DeleteComment deletes an issue comment. // DeleteComment deletes an issue comment.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#delete-an-issue-comment // GitHub API docs: https://docs.github.com/rest/issues/comments#delete-an-issue-comment
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}
func (s *IssuesService) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -66,7 +66,7 @@ type IssueEvent struct {
// //
// review_requested, review_request_removed // review_requested, review_request_removed
// The Actor requested or removed the request for a review. // The Actor requested or removed the request for a review.
// RequestedReviewer and ReviewRequester will be populated below. // RequestedReviewer or RequestedTeam, and ReviewRequester will be populated below.
// //
Event *string `json:"event,omitempty"` Event *string `json:"event,omitempty"`
@ -74,17 +74,19 @@ type IssueEvent struct {
Issue *Issue `json:"issue,omitempty"` Issue *Issue `json:"issue,omitempty"`
// Only present on certain events; see above. // Only present on certain events; see above.
Assignee *User `json:"assignee,omitempty"` Assignee *User `json:"assignee,omitempty"`
Assigner *User `json:"assigner,omitempty"` Assigner *User `json:"assigner,omitempty"`
CommitID *string `json:"commit_id,omitempty"` CommitID *string `json:"commit_id,omitempty"`
Milestone *Milestone `json:"milestone,omitempty"` Milestone *Milestone `json:"milestone,omitempty"`
Label *Label `json:"label,omitempty"` Label *Label `json:"label,omitempty"`
Rename *Rename `json:"rename,omitempty"` Rename *Rename `json:"rename,omitempty"`
LockReason *string `json:"lock_reason,omitempty"` LockReason *string `json:"lock_reason,omitempty"`
ProjectCard *ProjectCard `json:"project_card,omitempty"` ProjectCard *ProjectCard `json:"project_card,omitempty"`
DismissedReview *DismissedReview `json:"dismissed_review,omitempty"` DismissedReview *DismissedReview `json:"dismissed_review,omitempty"`
RequestedReviewer *User `json:"requested_reviewer,omitempty"` RequestedReviewer *User `json:"requested_reviewer,omitempty"`
ReviewRequester *User `json:"review_requester,omitempty"` RequestedTeam *Team `json:"requested_team,omitempty"`
ReviewRequester *User `json:"review_requester,omitempty"`
PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"`
} }
// DismissedReview represents details for 'dismissed_review' events. // DismissedReview represents details for 'dismissed_review' events.
@ -99,7 +101,9 @@ type DismissedReview struct {
// ListIssueEvents lists events for the specified issue. // ListIssueEvents lists events for the specified issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events // GitHub API docs: https://docs.github.com/rest/issues/events#list-issue-events
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/events
func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*IssueEvent, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -125,7 +129,9 @@ func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string,
// ListRepositoryEvents lists events for the specified repository. // ListRepositoryEvents lists events for the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository // GitHub API docs: https://docs.github.com/rest/issues/events#list-issue-events-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/issues/events
func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -149,7 +155,9 @@ func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo st
// GetEvent returns the specified issue event. // GetEvent returns the specified issue event.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/events#get-an-issue-event // GitHub API docs: https://docs.github.com/rest/issues/events#get-an-issue-event
//
//meta:operation GET /repos/{owner}/{repo}/issues/events/{event_id}
func (s *IssuesService) GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id)

View file

@ -27,7 +27,9 @@ func (l Label) String() string {
// ListLabels lists all labels for a repository. // ListLabels lists all labels for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-a-repository // GitHub API docs: https://docs.github.com/rest/issues/labels#list-labels-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/labels
func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Label, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -51,7 +53,9 @@ func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo strin
// GetLabel gets a single label. // GetLabel gets a single label.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#get-a-label // GitHub API docs: https://docs.github.com/rest/issues/labels#get-a-label
//
//meta:operation GET /repos/{owner}/{repo}/labels/{name}
func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, name string) (*Label, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -70,7 +74,9 @@ func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string,
// CreateLabel creates a new label on the specified repository. // CreateLabel creates a new label on the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#create-a-label // GitHub API docs: https://docs.github.com/rest/issues/labels#create-a-label
//
//meta:operation POST /repos/{owner}/{repo}/labels
func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo string, label *Label) (*Label, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
req, err := s.client.NewRequest("POST", u, label) req, err := s.client.NewRequest("POST", u, label)
@ -89,7 +95,9 @@ func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo stri
// EditLabel edits a label. // EditLabel edits a label.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#update-a-label // GitHub API docs: https://docs.github.com/rest/issues/labels#update-a-label
//
//meta:operation PATCH /repos/{owner}/{repo}/labels/{name}
func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string, name string, label *Label) (*Label, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
req, err := s.client.NewRequest("PATCH", u, label) req, err := s.client.NewRequest("PATCH", u, label)
@ -108,7 +116,9 @@ func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string
// DeleteLabel deletes a label. // DeleteLabel deletes a label.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#delete-a-label // GitHub API docs: https://docs.github.com/rest/issues/labels#delete-a-label
//
//meta:operation DELETE /repos/{owner}/{repo}/labels/{name}
func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo string, name string) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -120,7 +130,9 @@ func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo stri
// ListLabelsByIssue lists all labels for an issue. // ListLabelsByIssue lists all labels for an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-an-issue // GitHub API docs: https://docs.github.com/rest/issues/labels#list-labels-for-an-issue
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/labels
func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -144,7 +156,9 @@ func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, rep
// AddLabelsToIssue adds labels to an issue. // AddLabelsToIssue adds labels to an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#add-labels-to-an-issue // GitHub API docs: https://docs.github.com/rest/issues/labels#add-labels-to-an-issue
//
//meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/labels
func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
req, err := s.client.NewRequest("POST", u, labels) req, err := s.client.NewRequest("POST", u, labels)
@ -163,7 +177,9 @@ func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo
// RemoveLabelForIssue removes a label for an issue. // RemoveLabelForIssue removes a label for an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-a-label-from-an-issue // GitHub API docs: https://docs.github.com/rest/issues/labels#remove-a-label-from-an-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}
func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -176,7 +192,9 @@ func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, r
// ReplaceLabelsForIssue replaces all labels for an issue. // ReplaceLabelsForIssue replaces all labels for an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#set-labels-for-an-issue // GitHub API docs: https://docs.github.com/rest/issues/labels#set-labels-for-an-issue
//
//meta:operation PUT /repos/{owner}/{repo}/issues/{issue_number}/labels
func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
req, err := s.client.NewRequest("PUT", u, labels) req, err := s.client.NewRequest("PUT", u, labels)
@ -195,7 +213,9 @@ func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string,
// RemoveLabelsForIssue removes all labels for an issue. // RemoveLabelsForIssue removes all labels for an issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-all-labels-from-an-issue // GitHub API docs: https://docs.github.com/rest/issues/labels#remove-all-labels-from-an-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels
func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string, repo string, number int) (*Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)
@ -208,7 +228,9 @@ func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string,
// ListLabelsForMilestone lists labels for every issue in a milestone. // ListLabelsForMilestone lists labels for every issue in a milestone.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-issues-in-a-milestone // GitHub API docs: https://docs.github.com/rest/issues/labels#list-labels-for-issues-in-a-milestone
//
//meta:operation GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels
func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)

View file

@ -54,7 +54,9 @@ type MilestoneListOptions struct {
// ListMilestones lists all milestones for a repository. // ListMilestones lists all milestones for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#list-milestones // GitHub API docs: https://docs.github.com/rest/issues/milestones#list-milestones
//
//meta:operation GET /repos/{owner}/{repo}/milestones
func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) { func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo) u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -78,7 +80,9 @@ func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo s
// GetMilestone gets a single milestone. // GetMilestone gets a single milestone.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#get-a-milestone // GitHub API docs: https://docs.github.com/rest/issues/milestones#get-a-milestone
//
//meta:operation GET /repos/{owner}/{repo}/milestones/{milestone_number}
func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) { func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -97,7 +101,9 @@ func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo str
// CreateMilestone creates a new milestone on the specified repository. // CreateMilestone creates a new milestone on the specified repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#create-a-milestone // GitHub API docs: https://docs.github.com/rest/issues/milestones#create-a-milestone
//
//meta:operation POST /repos/{owner}/{repo}/milestones
func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) { func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo) u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
req, err := s.client.NewRequest("POST", u, milestone) req, err := s.client.NewRequest("POST", u, milestone)
@ -116,7 +122,9 @@ func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo
// EditMilestone edits a milestone. // EditMilestone edits a milestone.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#update-a-milestone // GitHub API docs: https://docs.github.com/rest/issues/milestones#update-a-milestone
//
//meta:operation PATCH /repos/{owner}/{repo}/milestones/{milestone_number}
func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) { func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
req, err := s.client.NewRequest("PATCH", u, milestone) req, err := s.client.NewRequest("PATCH", u, milestone)
@ -135,7 +143,9 @@ func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo st
// DeleteMilestone deletes a milestone. // DeleteMilestone deletes a milestone.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#delete-a-milestone // GitHub API docs: https://docs.github.com/rest/issues/milestones#delete-a-milestone
//
//meta:operation DELETE /repos/{owner}/{repo}/milestones/{milestone_number}
func (s *IssuesService) DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) { func (s *IssuesService) DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

View file

@ -14,7 +14,7 @@ import (
// Timeline represents an event that occurred around an Issue or Pull Request. // Timeline represents an event that occurred around an Issue or Pull Request.
// //
// It is similar to an IssueEvent but may contain more information. // It is similar to an IssueEvent but may contain more information.
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/events/issue-event-types
type Timeline struct { type Timeline struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
URL *string `json:"url,omitempty"` URL *string `json:"url,omitempty"`
@ -151,6 +151,8 @@ type Timeline struct {
// The review summary text. // The review summary text.
Body *string `json:"body,omitempty"` Body *string `json:"body,omitempty"`
SubmittedAt *Timestamp `json:"submitted_at,omitempty"` SubmittedAt *Timestamp `json:"submitted_at,omitempty"`
PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"`
} }
// Source represents a reference's source. // Source represents a reference's source.
@ -164,7 +166,9 @@ type Source struct {
// ListIssueTimeline lists events for the specified issue. // ListIssueTimeline lists events for the specified issue.
// //
// GitHub API docs: https://docs.github.com/en/rest/issues/timeline#list-timeline-events-for-an-issue // GitHub API docs: https://docs.github.com/rest/issues/timeline#list-timeline-events-for-an-issue
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/timeline
func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) { 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 := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)

View file

@ -13,7 +13,7 @@ import (
// LicensesService handles communication with the license related // LicensesService handles communication with the license related
// methods of the GitHub API. // methods of the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/licenses/ // GitHub API docs: https://docs.github.com/rest/licenses/
type LicensesService service type LicensesService service
// RepositoryLicense represents the license for a repository. // RepositoryLicense represents the license for a repository.
@ -60,7 +60,9 @@ func (l License) String() string {
// List popular open source licenses. // List popular open source licenses.
// //
// GitHub API docs: https://docs.github.com/en/rest/licenses/#list-all-licenses // GitHub API docs: https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses
//
//meta:operation GET /licenses
func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) { func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) {
req, err := s.client.NewRequest("GET", "licenses", nil) req, err := s.client.NewRequest("GET", "licenses", nil)
if err != nil { if err != nil {
@ -78,7 +80,9 @@ func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, erro
// Get extended metadata for one license. // Get extended metadata for one license.
// //
// GitHub API docs: https://docs.github.com/en/rest/licenses#get-a-license // GitHub API docs: https://docs.github.com/rest/licenses/licenses#get-a-license
//
//meta:operation GET /licenses/{license}
func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) { func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) {
u := fmt.Sprintf("licenses/%s", licenseName) u := fmt.Sprintf("licenses/%s", licenseName)

View file

@ -0,0 +1,69 @@
// Copyright 2023 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"bytes"
"context"
)
// MarkdownService provides access to markdown-related functions in the GitHub API.
type MarkdownService service
// MarkdownOptions specifies optional parameters to the Render method.
type MarkdownOptions struct {
// Mode identifies the rendering mode. Possible values are:
// markdown - render a document as plain Render, just like
// README files are rendered.
//
// gfm - to render a document as user-content, e.g. like user
// comments or issues are rendered. In GFM mode, hard line breaks are
// always taken into account, and issue and user mentions are linked
// accordingly.
//
// Default is "markdown".
Mode string
// Context identifies the repository context. Only taken into account
// when rendering as "gfm".
Context string
}
type markdownRenderRequest struct {
Text *string `json:"text,omitempty"`
Mode *string `json:"mode,omitempty"`
Context *string `json:"context,omitempty"`
}
// Render renders an arbitrary Render document.
//
// GitHub API docs: https://docs.github.com/rest/markdown/markdown#render-a-markdown-document
//
//meta:operation POST /markdown
func (s *MarkdownService) Render(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
request := &markdownRenderRequest{Text: String(text)}
if opts != nil {
if opts.Mode != "" {
request.Mode = String(opts.Mode)
}
if opts.Context != "" {
request.Context = String(opts.Context)
}
}
req, err := s.client.NewRequest("POST", "markdown", request)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := s.client.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}

View file

@ -281,14 +281,14 @@ func ValidateSignature(signature string, payload, secretToken []byte) error {
// WebHookType returns the event type of webhook request r. // WebHookType returns the event type of webhook request r.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/events/github-event-types
func WebHookType(r *http.Request) string { func WebHookType(r *http.Request) string {
return r.Header.Get(EventTypeHeader) return r.Header.Get(EventTypeHeader)
} }
// DeliveryID returns the unique delivery ID of webhook request r. // DeliveryID returns the unique delivery ID of webhook request r.
// //
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/events/github-event-types
func DeliveryID(r *http.Request) string { func DeliveryID(r *http.Request) string {
return r.Header.Get(DeliveryIDHeader) return r.Header.Get(DeliveryIDHeader)
} }
@ -326,7 +326,7 @@ func ParseWebHook(messageType string, payload []byte) (interface{}, error) {
return event.ParsePayload() return event.ParsePayload()
} }
// WebhookTypes returns a sorted list of all the known GitHub event type strings // MessageTypes returns a sorted list of all the known GitHub event type strings
// supported by go-github. // supported by go-github.
func MessageTypes() []string { func MessageTypes() []string {
types := make([]string, 0, len(eventTypeMapping)) types := make([]string, 0, len(eventTypeMapping))

160
vendor/github.com/google/go-github/v57/github/meta.go generated vendored Normal file
View file

@ -0,0 +1,160 @@
// 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 (
"bytes"
"context"
"fmt"
"net/url"
)
// MetaService provides access to functions in the GitHub API that GitHub categorizes as "meta".
type MetaService service
// APIMeta represents metadata about the GitHub API.
type APIMeta struct {
// An Array of IP addresses in CIDR format specifying the addresses
// that incoming service hooks will originate from on GitHub.com.
Hooks []string `json:"hooks,omitempty"`
// An Array of IP addresses in CIDR format specifying the Git servers
// for GitHub.com.
Git []string `json:"git,omitempty"`
// Whether authentication with username and password is supported.
// (GitHub Enterprise instances using CAS or OAuth for authentication
// will return false. Features like Basic Authentication with a
// username and password, sudo mode, and two-factor authentication are
// not supported on these servers.)
VerifiablePasswordAuthentication *bool `json:"verifiable_password_authentication,omitempty"`
// An array of IP addresses in CIDR format specifying the addresses
// which serve GitHub Packages.
Packages []string `json:"packages,omitempty"`
// An array of IP addresses in CIDR format specifying the addresses
// which serve GitHub Pages websites.
Pages []string `json:"pages,omitempty"`
// An Array of IP addresses specifying the addresses that source imports
// will originate from on GitHub.com.
Importer []string `json:"importer,omitempty"`
// An array of IP addresses in CIDR format specifying the IP addresses
// GitHub Actions will originate from.
Actions []string `json:"actions,omitempty"`
// An array of IP addresses in CIDR format specifying the IP addresses
// Dependabot will originate from.
Dependabot []string `json:"dependabot,omitempty"`
// A map of algorithms to SSH key fingerprints.
SSHKeyFingerprints map[string]string `json:"ssh_key_fingerprints,omitempty"`
// 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"`
}
// Get returns information about GitHub.com, the service. Or, if you access
// this endpoint on your organizations GitHub Enterprise installation, this
// endpoint provides information about that installation.
//
// GitHub API docs: https://docs.github.com/rest/meta/meta#get-github-meta-information
//
//meta:operation GET /meta
func (s *MetaService) Get(ctx context.Context) (*APIMeta, *Response, error) {
req, err := s.client.NewRequest("GET", "meta", nil)
if err != nil {
return nil, nil, err
}
meta := new(APIMeta)
resp, err := s.client.Do(ctx, req, meta)
if err != nil {
return nil, resp, err
}
return meta, resp, nil
}
// APIMeta returns information about GitHub.com.
//
// Deprecated: Use MetaService.Get instead.
func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) {
return c.Meta.Get(ctx)
}
// Octocat returns an ASCII art octocat with the specified message in a speech
// bubble. If message is empty, a random zen phrase is used.
//
// GitHub API docs: https://docs.github.com/rest/meta/meta#get-octocat
//
//meta:operation GET /octocat
func (s *MetaService) Octocat(ctx context.Context, message string) (string, *Response, error) {
u := "octocat"
if message != "" {
u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message))
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := s.client.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}
// Octocat returns an ASCII art octocat with the specified message in a speech
// bubble. If message is empty, a random zen phrase is used.
//
// Deprecated: Use MetaService.Octocat instead.
func (c *Client) Octocat(ctx context.Context, message string) (string, *Response, error) {
return c.Meta.Octocat(ctx, message)
}
// Zen returns a random line from The Zen of GitHub.
//
// See also: http://warpspire.com/posts/taste/
//
// GitHub API docs: https://docs.github.com/rest/meta/meta#get-the-zen-of-github
//
//meta:operation GET /zen
func (s *MetaService) Zen(ctx context.Context) (string, *Response, error) {
req, err := s.client.NewRequest("GET", "zen", nil)
if err != nil {
return "", nil, err
}
buf := new(bytes.Buffer)
resp, err := s.client.Do(ctx, req, buf)
if err != nil {
return "", resp, err
}
return buf.String(), resp, nil
}
// Zen returns a random line from The Zen of GitHub.
//
// Deprecated: Use MetaService.Zen instead.
func (c *Client) Zen(ctx context.Context) (string, *Response, error) {
return c.Meta.Zen(ctx)
}

View file

@ -16,7 +16,7 @@ import (
// MigrationService provides access to the migration related functions // MigrationService provides access to the migration related functions
// in the GitHub API. // in the GitHub API.
// //
// GitHub API docs: https://docs.github.com/en/rest/migration/ // GitHub API docs: https://docs.github.com/rest/migration/
type MigrationService service type MigrationService service
// Migration represents a GitHub migration (archival). // Migration represents a GitHub migration (archival).
@ -74,7 +74,9 @@ type startMigration struct {
// StartMigration starts the generation of a migration archive. // StartMigration starts the generation of a migration archive.
// repos is a slice of repository names to migrate. // repos is a slice of repository names to migrate.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#start-an-organization-migration // GitHub API docs: https://docs.github.com/rest/migrations/orgs#start-an-organization-migration
//
//meta:operation POST /orgs/{org}/migrations
func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) { func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations", org) u := fmt.Sprintf("orgs/%v/migrations", org)
@ -103,7 +105,9 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos
// ListMigrations lists the most recent migrations. // ListMigrations lists the most recent migrations.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#list-organization-migrations // GitHub API docs: https://docs.github.com/rest/migrations/orgs#list-organization-migrations
//
//meta:operation GET /orgs/{org}/migrations
func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) { func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations", org) u := fmt.Sprintf("orgs/%v/migrations", org)
u, err := addOptions(u, opts) u, err := addOptions(u, opts)
@ -131,7 +135,9 @@ func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts
// MigrationStatus gets the status of a specific migration archive. // MigrationStatus gets the status of a specific migration archive.
// id is the migration ID. // id is the migration ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#get-an-organization-migration-status // GitHub API docs: https://docs.github.com/rest/migrations/orgs#get-an-organization-migration-status
//
//meta:operation GET /orgs/{org}/migrations/{migration_id}
func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) { func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations/%v", org, id) u := fmt.Sprintf("orgs/%v/migrations/%v", org, id)
@ -155,7 +161,9 @@ func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id i
// MigrationArchiveURL fetches a migration archive URL. // MigrationArchiveURL fetches a migration archive URL.
// id is the migration ID. // id is the migration ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#download-an-organization-migration-archive // GitHub API docs: https://docs.github.com/rest/migrations/orgs#download-an-organization-migration-archive
//
//meta:operation GET /orgs/{org}/migrations/{migration_id}/archive
func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) { 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) u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
@ -192,7 +200,9 @@ func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string,
// DeleteMigration deletes a previous migration archive. // DeleteMigration deletes a previous migration archive.
// id is the migration ID. // id is the migration ID.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#delete-an-organization-migration-archive // GitHub API docs: https://docs.github.com/rest/migrations/orgs#delete-an-organization-migration-archive
//
//meta:operation DELETE /orgs/{org}/migrations/{migration_id}/archive
func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) { func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id) u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
@ -212,7 +222,9 @@ func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id i
// You should unlock each migrated repository and delete them when the migration // You should unlock each migrated repository and delete them when the migration
// is complete and you no longer need the source data. // is complete and you no longer need the source data.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#unlock-an-organization-repository // GitHub API docs: https://docs.github.com/rest/migrations/orgs#unlock-an-organization-repository
//
//meta:operation DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock
func (s *MigrationService) UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) { 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) u := fmt.Sprintf("orgs/%v/migrations/%v/repos/%v/lock", org, id, repo)

View file

@ -115,7 +115,7 @@ func (i Import) String() string {
// SourceImportAuthor identifies an author imported from a source repository. // SourceImportAuthor identifies an author imported from a source repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-commit-authors // GitHub API docs: https://docs.github.com/rest/migration/source_imports/#get-commit-authors
type SourceImportAuthor struct { type SourceImportAuthor struct {
ID *int64 `json:"id,omitempty"` ID *int64 `json:"id,omitempty"`
RemoteID *string `json:"remote_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. // LargeFile identifies a file larger than 100MB found during a repository import.
// //
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-large-files // GitHub API docs: https://docs.github.com/rest/migration/source_imports/#get-large-files
type LargeFile struct { type LargeFile struct {
RefName *string `json:"ref_name,omitempty"` RefName *string `json:"ref_name,omitempty"`
Path *string `json:"path,omitempty"` Path *string `json:"path,omitempty"`
@ -146,7 +146,9 @@ func (f LargeFile) String() string {
// StartImport initiates a repository import. // StartImport initiates a repository import.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#start-an-import // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#start-an-import
//
//meta:operation PUT /repos/{owner}/{repo}/import
func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import", owner, repo) u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
req, err := s.client.NewRequest("PUT", u, in) req, err := s.client.NewRequest("PUT", u, in)
@ -165,7 +167,9 @@ func (s *MigrationService) StartImport(ctx context.Context, owner, repo string,
// ImportProgress queries for the status and progress of an ongoing repository import. // ImportProgress queries for the status and progress of an ongoing repository import.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-an-import-status // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#get-an-import-status
//
//meta:operation GET /repos/{owner}/{repo}/import
func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) { func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import", owner, repo) u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -184,7 +188,9 @@ func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo strin
// UpdateImport initiates a repository import. // UpdateImport initiates a repository import.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-an-import // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#update-an-import
//
//meta:operation PATCH /repos/{owner}/{repo}/import
func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import", owner, repo) u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
req, err := s.client.NewRequest("PATCH", u, in) req, err := s.client.NewRequest("PATCH", u, in)
@ -213,7 +219,9 @@ func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string,
// This method and MapCommitAuthor allow you to provide correct Git author // This method and MapCommitAuthor allow you to provide correct Git author
// information. // information.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-commit-authors // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#get-commit-authors
//
//meta:operation GET /repos/{owner}/{repo}/import/authors
func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) { func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo) u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -234,7 +242,9 @@ func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string
// application can continue updating authors any time before you push new // application can continue updating authors any time before you push new
// commits to the repository. // commits to the repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#map-a-commit-author // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#map-a-commit-author
//
//meta:operation PATCH /repos/{owner}/{repo}/import/authors/{author_id}
func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo string, id int64, author *SourceImportAuthor) (*SourceImportAuthor, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/import/authors/%v", owner, repo, id)
req, err := s.client.NewRequest("PATCH", u, author) req, err := s.client.NewRequest("PATCH", u, author)
@ -255,7 +265,9 @@ func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo stri
// files larger than 100MB. Only the UseLFS field on the provided Import is // files larger than 100MB. Only the UseLFS field on the provided Import is
// used. // used.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-git-lfs-preference // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#update-git-lfs-preference
//
//meta:operation PATCH /repos/{owner}/{repo}/import/lfs
func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { 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) u := fmt.Sprintf("repos/%v/%v/import/lfs", owner, repo)
req, err := s.client.NewRequest("PATCH", u, in) req, err := s.client.NewRequest("PATCH", u, in)
@ -274,7 +286,9 @@ func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo str
// LargeFiles lists files larger than 100MB found during the import. // LargeFiles lists files larger than 100MB found during the import.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-large-files // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#get-large-files
//
//meta:operation GET /repos/{owner}/{repo}/import/large_files
func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) { func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo) u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo)
req, err := s.client.NewRequest("GET", u, nil) req, err := s.client.NewRequest("GET", u, nil)
@ -293,7 +307,9 @@ func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) (
// CancelImport stops an import for a repository. // CancelImport stops an import for a repository.
// //
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#cancel-an-import // GitHub API docs: https://docs.github.com/rest/migrations/source-imports#cancel-an-import
//
//meta:operation DELETE /repos/{owner}/{repo}/import
func (s *MigrationService) CancelImport(ctx context.Context, owner, repo string) (*Response, error) { func (s *MigrationService) CancelImport(ctx context.Context, owner, repo string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/import", owner, repo) u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
req, err := s.client.NewRequest("DELETE", u, nil) req, err := s.client.NewRequest("DELETE", u, nil)

Some files were not shown because too many files have changed in this diff Show more