Bump github.com/bradleyfalzon/ghinstallation/v2 from 2.12.0 to 2.13.0
Bumps [github.com/bradleyfalzon/ghinstallation/v2](https://github.com/bradleyfalzon/ghinstallation) from 2.12.0 to 2.13.0. - [Release notes](https://github.com/bradleyfalzon/ghinstallation/releases) - [Commits](https://github.com/bradleyfalzon/ghinstallation/compare/v2.12.0...v2.13.0) --- updated-dependencies: - dependency-name: github.com/bradleyfalzon/ghinstallation/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
f43f797883
commit
5d6ace6a2c
176 changed files with 3390 additions and 2102 deletions
4
go.mod
4
go.mod
|
|
@ -6,7 +6,7 @@ toolchain go1.23.0
|
|||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.4.0
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.12.0
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.13.0
|
||||
github.com/cloudbase/garm-provider-common v0.1.4
|
||||
github.com/felixge/httpsnoop v1.0.4
|
||||
github.com/go-openapi/errors v0.22.0
|
||||
|
|
@ -56,7 +56,7 @@ require (
|
|||
github.com/go-openapi/validate v0.24.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
|
||||
github.com/google/go-github/v66 v66.0.0 // indirect
|
||||
github.com/google/go-github/v68 v68.0.0 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -6,8 +6,8 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3d
|
|||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.12.0 h1:k8oVjGhZel2qmCUsYwSE34jPNT9DL2wCBOtugsHv26g=
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.12.0/go.mod h1:V4gJcNyAftH0rXpRp1SUVUuh+ACxOH1xOk/ZzkRHltg=
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.13.0 h1:5FhjW93/YLQJDmPdeyMPw7IjAPzqsr+0jHPfrPz0sZI=
|
||||
github.com/bradleyfalzon/ghinstallation/v2 v2.13.0/go.mod h1:EJ6fgedVEHa2kUyBTTvslJCXJafS/mhJNNKEOCspZXQ=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
|
|
@ -68,8 +68,8 @@ 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-github/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs=
|
||||
github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw=
|
||||
github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M=
|
||||
github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4=
|
||||
github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s=
|
||||
github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68=
|
||||
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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
|
|
|
|||
2
vendor/github.com/bradleyfalzon/ghinstallation/v2/transport.go
generated
vendored
2
vendor/github.com/bradleyfalzon/ghinstallation/v2/transport.go
generated
vendored
|
|
@ -13,7 +13,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v66/github"
|
||||
"github.com/google/go-github/v68/github"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
315
vendor/github.com/google/go-github/v66/github/copilot.go
generated
vendored
315
vendor/github.com/google/go-github/v66/github/copilot.go
generated
vendored
|
|
@ -1,315 +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"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CopilotService provides access to the Copilot-related functions
|
||||
// in the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/copilot/
|
||||
type CopilotService service
|
||||
|
||||
// CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription.
|
||||
type CopilotOrganizationDetails struct {
|
||||
SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"`
|
||||
PublicCodeSuggestions string `json:"public_code_suggestions"`
|
||||
CopilotChat string `json:"copilot_chat"`
|
||||
SeatManagementSetting string `json:"seat_management_setting"`
|
||||
}
|
||||
|
||||
// CopilotSeatBreakdown represents the breakdown of Copilot for Business seats for the organization.
|
||||
type CopilotSeatBreakdown struct {
|
||||
Total int `json:"total"`
|
||||
AddedThisCycle int `json:"added_this_cycle"`
|
||||
PendingCancellation int `json:"pending_cancellation"`
|
||||
PendingInvitation int `json:"pending_invitation"`
|
||||
ActiveThisCycle int `json:"active_this_cycle"`
|
||||
InactiveThisCycle int `json:"inactive_this_cycle"`
|
||||
}
|
||||
|
||||
// ListCopilotSeatsResponse represents the Copilot for Business seat assignments for an organization.
|
||||
type ListCopilotSeatsResponse struct {
|
||||
TotalSeats int64 `json:"total_seats"`
|
||||
Seats []*CopilotSeatDetails `json:"seats"`
|
||||
}
|
||||
|
||||
// CopilotSeatDetails represents the details of a Copilot for Business seat.
|
||||
type CopilotSeatDetails struct {
|
||||
// Assignee can either be a User, Team, or Organization.
|
||||
Assignee interface{} `json:"assignee"`
|
||||
AssigningTeam *Team `json:"assigning_team,omitempty"`
|
||||
PendingCancellationDate *string `json:"pending_cancellation_date,omitempty"`
|
||||
LastActivityAt *Timestamp `json:"last_activity_at,omitempty"`
|
||||
LastActivityEditor *string `json:"last_activity_editor,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
// SeatAssignments represents the number of seats assigned.
|
||||
type SeatAssignments struct {
|
||||
SeatsCreated int `json:"seats_created"`
|
||||
}
|
||||
|
||||
// SeatCancellations represents the number of seats cancelled.
|
||||
type SeatCancellations struct {
|
||||
SeatsCancelled int `json:"seats_cancelled"`
|
||||
}
|
||||
|
||||
func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error {
|
||||
// Using an alias to avoid infinite recursion when calling json.Unmarshal
|
||||
type alias CopilotSeatDetails
|
||||
var seatDetail alias
|
||||
|
||||
if err := json.Unmarshal(data, &seatDetail); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cp.AssigningTeam = seatDetail.AssigningTeam
|
||||
cp.PendingCancellationDate = seatDetail.PendingCancellationDate
|
||||
cp.LastActivityAt = seatDetail.LastActivityAt
|
||||
cp.LastActivityEditor = seatDetail.LastActivityEditor
|
||||
cp.CreatedAt = seatDetail.CreatedAt
|
||||
cp.UpdatedAt = seatDetail.UpdatedAt
|
||||
|
||||
switch v := seatDetail.Assignee.(type) {
|
||||
case map[string]interface{}:
|
||||
jsonData, err := json.Marshal(seatDetail.Assignee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if v["type"] == nil {
|
||||
return fmt.Errorf("assignee type field is not set")
|
||||
}
|
||||
|
||||
if t, ok := v["type"].(string); ok && t == "User" {
|
||||
user := &User{}
|
||||
if err := json.Unmarshal(jsonData, user); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = user
|
||||
} else if t, ok := v["type"].(string); ok && t == "Team" {
|
||||
team := &Team{}
|
||||
if err := json.Unmarshal(jsonData, team); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = team
|
||||
} else if t, ok := v["type"].(string); ok && t == "Organization" {
|
||||
organization := &Organization{}
|
||||
if err := json.Unmarshal(jsonData, organization); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = organization
|
||||
} else {
|
||||
return fmt.Errorf("unsupported assignee type %v", v["type"])
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported assignee type %T", v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUser gets the User from the CopilotSeatDetails if the assignee is a user.
|
||||
func (cp *CopilotSeatDetails) GetUser() (*User, bool) { u, ok := cp.Assignee.(*User); return u, ok }
|
||||
|
||||
// GetTeam gets the Team from the CopilotSeatDetails if the assignee is a team.
|
||||
func (cp *CopilotSeatDetails) GetTeam() (*Team, bool) { t, ok := cp.Assignee.(*Team); return t, ok }
|
||||
|
||||
// GetOrganization gets the Organization from the CopilotSeatDetails if the assignee is an organization.
|
||||
func (cp *CopilotSeatDetails) GetOrganization() (*Organization, bool) {
|
||||
o, ok := cp.Assignee.(*Organization)
|
||||
return o, ok
|
||||
}
|
||||
|
||||
// GetCopilotBilling gets Copilot for Business billing information and settings for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-information-and-settings-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/copilot/billing
|
||||
func (s *CopilotService) GetCopilotBilling(ctx context.Context, org string) (*CopilotOrganizationDetails, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing", org)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var copilotDetails *CopilotOrganizationDetails
|
||||
resp, err := s.client.Do(ctx, req, &copilotDetails)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return copilotDetails, resp, nil
|
||||
}
|
||||
|
||||
// ListCopilotSeats lists Copilot for Business seat assignments for an organization.
|
||||
//
|
||||
// To paginate through all seats, populate 'Page' with the number of the last page.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/copilot/billing/seats
|
||||
func (s *CopilotService) ListCopilotSeats(ctx context.Context, org string, opts *ListOptions) (*ListCopilotSeatsResponse, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/seats", 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 copilotSeats *ListCopilotSeatsResponse
|
||||
resp, err := s.client.Do(ctx, req, &copilotSeats)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return copilotSeats, resp, nil
|
||||
}
|
||||
|
||||
// AddCopilotTeams adds teams to the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#add-teams-to-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/copilot/billing/selected_teams
|
||||
func (s *CopilotService) AddCopilotTeams(ctx context.Context, org string, teamNames []string) (*SeatAssignments, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_teams", org)
|
||||
|
||||
body := struct {
|
||||
SelectedTeams []string `json:"selected_teams"`
|
||||
}{
|
||||
SelectedTeams: teamNames,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatAssignments *SeatAssignments
|
||||
resp, err := s.client.Do(ctx, req, &seatAssignments)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatAssignments, resp, nil
|
||||
}
|
||||
|
||||
// RemoveCopilotTeams removes teams from the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#remove-teams-from-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/copilot/billing/selected_teams
|
||||
func (s *CopilotService) RemoveCopilotTeams(ctx context.Context, org string, teamNames []string) (*SeatCancellations, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_teams", org)
|
||||
|
||||
body := struct {
|
||||
SelectedTeams []string `json:"selected_teams"`
|
||||
}{
|
||||
SelectedTeams: teamNames,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatCancellations *SeatCancellations
|
||||
resp, err := s.client.Do(ctx, req, &seatCancellations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatCancellations, resp, nil
|
||||
}
|
||||
|
||||
// AddCopilotUsers adds users to the Copilot for Business subscription for an organization
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#add-users-to-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/copilot/billing/selected_users
|
||||
func (s *CopilotService) AddCopilotUsers(ctx context.Context, org string, users []string) (*SeatAssignments, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org)
|
||||
|
||||
body := struct {
|
||||
SelectedUsernames []string `json:"selected_usernames"`
|
||||
}{
|
||||
SelectedUsernames: users,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatAssignments *SeatAssignments
|
||||
resp, err := s.client.Do(ctx, req, &seatAssignments)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatAssignments, resp, nil
|
||||
}
|
||||
|
||||
// RemoveCopilotUsers removes users from the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#remove-users-from-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/copilot/billing/selected_users
|
||||
func (s *CopilotService) RemoveCopilotUsers(ctx context.Context, org string, users []string) (*SeatCancellations, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org)
|
||||
|
||||
body := struct {
|
||||
SelectedUsernames []string `json:"selected_usernames"`
|
||||
}{
|
||||
SelectedUsernames: users,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatCancellations *SeatCancellations
|
||||
resp, err := s.client.Do(ctx, req, &seatCancellations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatCancellations, resp, nil
|
||||
}
|
||||
|
||||
// GetSeatDetails gets Copilot for Business seat assignment details for a user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-assignment-details-for-a-user
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/members/{username}/copilot
|
||||
func (s *CopilotService) GetSeatDetails(ctx context.Context, org, user string) (*CopilotSeatDetails, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/members/%v/copilot", org, user)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatDetails *CopilotSeatDetails
|
||||
resp, err := s.client.Do(ctx, req, &seatDetails)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatDetails, resp, nil
|
||||
}
|
||||
64
vendor/github.com/google/go-github/v66/github/orgs_projects.go
generated
vendored
64
vendor/github.com/google/go-github/v66/github/orgs_projects.go
generated
vendored
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ListProjects lists the projects for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#list-organization-projects
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/projects
|
||||
func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/projects", org)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
var projects []*Project
|
||||
resp, err := s.client.Do(ctx, req, &projects)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return projects, resp, nil
|
||||
}
|
||||
|
||||
// CreateProject creates a GitHub Project for the specified organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#create-an-organization-project
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/projects
|
||||
func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/projects", org)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
project := &Project{}
|
||||
resp, err := s.client.Do(ctx, req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
634
vendor/github.com/google/go-github/v66/github/projects.go
generated
vendored
634
vendor/github.com/google/go-github/v66/github/projects.go
generated
vendored
|
|
@ -1,634 +0,0 @@
|
|||
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ProjectsService provides access to the projects functions in the
|
||||
// GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects
|
||||
type ProjectsService service
|
||||
|
||||
// Project represents a GitHub Project.
|
||||
type Project struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
ColumnsURL *string `json:"columns_url,omitempty"`
|
||||
OwnerURL *string `json:"owner_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Number *int `json:"number,omitempty"`
|
||||
State *string `json:"state,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
OrganizationPermission *string `json:"organization_permission,omitempty"`
|
||||
Private *bool `json:"private,omitempty"`
|
||||
|
||||
// The User object that generated the project.
|
||||
Creator *User `json:"creator,omitempty"`
|
||||
}
|
||||
|
||||
func (p Project) String() string {
|
||||
return Stringify(p)
|
||||
}
|
||||
|
||||
// GetProject gets a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#get-a-project
|
||||
//
|
||||
//meta:operation GET /projects/{project_id}
|
||||
func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
project := &Project{}
|
||||
resp, err := s.client.Do(ctx, req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
|
||||
// ProjectOptions specifies the parameters to the
|
||||
// RepositoriesService.CreateProject and
|
||||
// ProjectsService.UpdateProject methods.
|
||||
type ProjectOptions struct {
|
||||
// The name of the project. (Required for creation; optional for update.)
|
||||
Name *string `json:"name,omitempty"`
|
||||
// The body of the project. (Optional.)
|
||||
Body *string `json:"body,omitempty"`
|
||||
|
||||
// The following field(s) are only applicable for update.
|
||||
// They should be left with zero values for creation.
|
||||
|
||||
// State of the project. Either "open" or "closed". (Optional.)
|
||||
State *string `json:"state,omitempty"`
|
||||
// The permission level that all members of the project's organization
|
||||
// will have on this project.
|
||||
// Setting the organization permission is only available
|
||||
// for organization projects. (Optional.)
|
||||
OrganizationPermission *string `json:"organization_permission,omitempty"`
|
||||
// Sets visibility of the project within the organization.
|
||||
// Setting visibility is only available
|
||||
// for organization projects.(Optional.)
|
||||
Private *bool `json:"private,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateProject updates a repository project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#update-a-project
|
||||
//
|
||||
//meta:operation PATCH /projects/{project_id}
|
||||
func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *ProjectOptions) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
project := &Project{}
|
||||
resp, err := s.client.Do(ctx, req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
|
||||
// DeleteProject deletes a GitHub Project from a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#delete-a-project
|
||||
//
|
||||
//meta:operation DELETE /projects/{project_id}
|
||||
func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v", id)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ProjectColumn represents a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/repos/projects/
|
||||
type ProjectColumn struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
ProjectURL *string `json:"project_url,omitempty"`
|
||||
CardsURL *string `json:"cards_url,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
}
|
||||
|
||||
// ListProjectColumns lists the columns of a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#list-project-columns
|
||||
//
|
||||
//meta:operation GET /projects/{project_id}/columns
|
||||
func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int64, opts *ListOptions) ([]*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/columns", projectID)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
columns := []*ProjectColumn{}
|
||||
resp, err := s.client.Do(ctx, req, &columns)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return columns, resp, nil
|
||||
}
|
||||
|
||||
// GetProjectColumn gets a column of a GitHub Project for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#get-a-project-column
|
||||
//
|
||||
//meta:operation GET /projects/columns/{column_id}
|
||||
func (s *ProjectsService) GetProjectColumn(ctx context.Context, id int64) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
column := &ProjectColumn{}
|
||||
resp, err := s.client.Do(ctx, req, column)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return column, resp, nil
|
||||
}
|
||||
|
||||
// ProjectColumnOptions specifies the parameters to the
|
||||
// ProjectsService.CreateProjectColumn and
|
||||
// ProjectsService.UpdateProjectColumn methods.
|
||||
type ProjectColumnOptions struct {
|
||||
// The name of the project column. (Required for creation and update.)
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// CreateProjectColumn creates a column for the specified (by number) project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#create-a-project-column
|
||||
//
|
||||
//meta:operation POST /projects/{project_id}/columns
|
||||
func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/columns", projectID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
column := &ProjectColumn{}
|
||||
resp, err := s.client.Do(ctx, req, column)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return column, resp, nil
|
||||
}
|
||||
|
||||
// UpdateProjectColumn updates a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#update-an-existing-project-column
|
||||
//
|
||||
//meta:operation PATCH /projects/columns/{column_id}
|
||||
func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", columnID)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
column := &ProjectColumn{}
|
||||
resp, err := s.client.Do(ctx, req, column)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return column, resp, nil
|
||||
}
|
||||
|
||||
// DeleteProjectColumn deletes a column from a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#delete-a-project-column
|
||||
//
|
||||
//meta:operation DELETE /projects/columns/{column_id}
|
||||
func (s *ProjectsService) DeleteProjectColumn(ctx context.Context, columnID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v", columnID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ProjectColumnMoveOptions specifies the parameters to the
|
||||
// ProjectsService.MoveProjectColumn method.
|
||||
type ProjectColumnMoveOptions struct {
|
||||
// Position can be one of "first", "last", or "after:<column-id>", where
|
||||
// <column-id> is the ID of a column in the same project. (Required.)
|
||||
Position string `json:"position"`
|
||||
}
|
||||
|
||||
// MoveProjectColumn moves a column within a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/columns#move-a-project-column
|
||||
//
|
||||
//meta:operation POST /projects/columns/{column_id}/moves
|
||||
func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnMoveOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/moves", columnID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ProjectCard represents a card in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards/#get-a-project-card
|
||||
type ProjectCard struct {
|
||||
URL *string `json:"url,omitempty"`
|
||||
ColumnURL *string `json:"column_url,omitempty"`
|
||||
ContentURL *string `json:"content_url,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Note *string `json:"note,omitempty"`
|
||||
Creator *User `json:"creator,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
ColumnID *int64 `json:"column_id,omitempty"`
|
||||
|
||||
// The following fields are only populated by Events API.
|
||||
ProjectID *int64 `json:"project_id,omitempty"`
|
||||
ProjectURL *string `json:"project_url,omitempty"`
|
||||
ColumnName *string `json:"column_name,omitempty"`
|
||||
PreviousColumnName *string `json:"previous_column_name,omitempty"` // Populated in "moved_columns_in_project" event deliveries.
|
||||
}
|
||||
|
||||
// ProjectCardListOptions specifies the optional parameters to the
|
||||
// ProjectsService.ListProjectCards method.
|
||||
type ProjectCardListOptions struct {
|
||||
// ArchivedState is used to list all, archived, or not_archived project cards.
|
||||
// Defaults to not_archived when you omit this parameter.
|
||||
ArchivedState *string `url:"archived_state,omitempty"`
|
||||
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListProjectCards lists the cards in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#list-project-cards
|
||||
//
|
||||
//meta:operation GET /projects/columns/{column_id}/cards
|
||||
func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opts *ProjectCardListOptions) ([]*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/cards", columnID)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
cards := []*ProjectCard{}
|
||||
resp, err := s.client.Do(ctx, req, &cards)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return cards, resp, nil
|
||||
}
|
||||
|
||||
// GetProjectCard gets a card in a column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#get-a-project-card
|
||||
//
|
||||
//meta:operation GET /projects/columns/cards/{card_id}
|
||||
func (s *ProjectsService) GetProjectCard(ctx context.Context, cardID int64) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
card := &ProjectCard{}
|
||||
resp, err := s.client.Do(ctx, req, card)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return card, resp, nil
|
||||
}
|
||||
|
||||
// ProjectCardOptions specifies the parameters to the
|
||||
// ProjectsService.CreateProjectCard and
|
||||
// ProjectsService.UpdateProjectCard methods.
|
||||
type ProjectCardOptions struct {
|
||||
// The note of the card. Note and ContentID are mutually exclusive.
|
||||
Note string `json:"note,omitempty"`
|
||||
// The ID (not Number) of the Issue to associate with this card.
|
||||
// Note and ContentID are mutually exclusive.
|
||||
ContentID int64 `json:"content_id,omitempty"`
|
||||
// The type of content to associate with this card. Possible values are: "Issue" and "PullRequest".
|
||||
ContentType string `json:"content_type,omitempty"`
|
||||
// Use true to archive a project card.
|
||||
// Specify false if you need to restore a previously archived project card.
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
}
|
||||
|
||||
// CreateProjectCard creates a card in the specified column of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#create-a-project-card
|
||||
//
|
||||
//meta:operation POST /projects/columns/{column_id}/cards
|
||||
func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/%v/cards", columnID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
card := &ProjectCard{}
|
||||
resp, err := s.client.Do(ctx, req, card)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return card, resp, nil
|
||||
}
|
||||
|
||||
// UpdateProjectCard updates a card of a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#update-an-existing-project-card
|
||||
//
|
||||
//meta:operation PATCH /projects/columns/cards/{card_id}
|
||||
func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
card := &ProjectCard{}
|
||||
resp, err := s.client.Do(ctx, req, card)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return card, resp, nil
|
||||
}
|
||||
|
||||
// DeleteProjectCard deletes a card from a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#delete-a-project-card
|
||||
//
|
||||
//meta:operation DELETE /projects/columns/cards/{card_id}
|
||||
func (s *ProjectsService) DeleteProjectCard(ctx context.Context, cardID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v", cardID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ProjectCardMoveOptions specifies the parameters to the
|
||||
// ProjectsService.MoveProjectCard method.
|
||||
type ProjectCardMoveOptions struct {
|
||||
// Position can be one of "top", "bottom", or "after:<card-id>", where
|
||||
// <card-id> is the ID of a card in the same project.
|
||||
Position string `json:"position"`
|
||||
// ColumnID is the ID of a column in the same project. Note that ColumnID
|
||||
// is required when using Position "after:<card-id>" when that card is in
|
||||
// another column; otherwise it is optional.
|
||||
ColumnID int64 `json:"column_id,omitempty"`
|
||||
}
|
||||
|
||||
// MoveProjectCard moves a card within a GitHub Project.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/cards#move-a-project-card
|
||||
//
|
||||
//meta:operation POST /projects/columns/cards/{card_id}/moves
|
||||
func (s *ProjectsService) MoveProjectCard(ctx context.Context, cardID int64, opts *ProjectCardMoveOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/columns/cards/%v/moves", cardID)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ProjectCollaboratorOptions specifies the optional parameters to the
|
||||
// ProjectsService.AddProjectCollaborator method.
|
||||
type ProjectCollaboratorOptions struct {
|
||||
// Permission specifies the permission to grant to the collaborator.
|
||||
// Possible values are:
|
||||
// "read" - can read, but not write to or administer this project.
|
||||
// "write" - can read and write, but not administer this project.
|
||||
// "admin" - can read, write and administer this project.
|
||||
//
|
||||
// Default value is "write"
|
||||
Permission *string `json:"permission,omitempty"`
|
||||
}
|
||||
|
||||
// AddProjectCollaborator adds a collaborator to an organization project and sets
|
||||
// their permission level. You must be an organization owner or a project admin to add a collaborator.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/collaborators#add-project-collaborator
|
||||
//
|
||||
//meta:operation PUT /projects/{project_id}/collaborators/{username}
|
||||
func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64, username string, opts *ProjectCollaboratorOptions) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v", id, username)
|
||||
req, err := s.client.NewRequest("PUT", u, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// RemoveProjectCollaborator removes a collaborator from an organization project.
|
||||
// You must be an organization owner or a project admin to remove a collaborator.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/collaborators#remove-user-as-a-collaborator
|
||||
//
|
||||
//meta:operation DELETE /projects/{project_id}/collaborators/{username}
|
||||
func (s *ProjectsService) RemoveProjectCollaborator(ctx context.Context, id int64, username string) (*Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v", id, username)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ListCollaboratorOptions specifies the optional parameters to the
|
||||
// ProjectsService.ListProjectCollaborators method.
|
||||
type ListCollaboratorOptions struct {
|
||||
// Affiliation specifies how collaborators should be filtered by their affiliation.
|
||||
// Possible values are:
|
||||
// "outside" - All outside collaborators of an organization-owned repository
|
||||
// "direct" - All collaborators with permissions to an organization-owned repository,
|
||||
// regardless of organization membership status
|
||||
// "all" - All collaborators the authenticated user can see
|
||||
//
|
||||
// Default value is "all".
|
||||
Affiliation *string `url:"affiliation,omitempty"`
|
||||
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListProjectCollaborators lists the collaborators for an organization project. For a project,
|
||||
// the list of collaborators includes outside collaborators, organization members that are direct
|
||||
// collaborators, organization members with access through team memberships, organization members
|
||||
// with access through default organization permissions, and organization owners. You must be an
|
||||
// organization owner or a project admin to list collaborators.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/collaborators#list-project-collaborators
|
||||
//
|
||||
//meta:operation GET /projects/{project_id}/collaborators
|
||||
func (s *ProjectsService) ListProjectCollaborators(ctx context.Context, id int64, opts *ListCollaboratorOptions) ([]*User, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators", id)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
var users []*User
|
||||
resp, err := s.client.Do(ctx, req, &users)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return users, resp, nil
|
||||
}
|
||||
|
||||
// ProjectPermissionLevel represents the permission level an organization
|
||||
// member has for a given project.
|
||||
type ProjectPermissionLevel struct {
|
||||
// Possible values: "admin", "write", "read", "none"
|
||||
Permission *string `json:"permission,omitempty"`
|
||||
|
||||
User *User `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// ReviewProjectCollaboratorPermission returns the collaborator's permission level for an organization
|
||||
// project. Possible values for the permission key: "admin", "write", "read", "none".
|
||||
// You must be an organization owner or a project admin to review a user's permission level.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/collaborators#get-project-permission-for-a-user
|
||||
//
|
||||
//meta:operation GET /projects/{project_id}/collaborators/{username}/permission
|
||||
func (s *ProjectsService) ReviewProjectCollaboratorPermission(ctx context.Context, id int64, username string) (*ProjectPermissionLevel, *Response, error) {
|
||||
u := fmt.Sprintf("projects/%v/collaborators/%v/permission", id, username)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
ppl := new(ProjectPermissionLevel)
|
||||
resp, err := s.client.Do(ctx, req, ppl)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return ppl, resp, nil
|
||||
}
|
||||
73
vendor/github.com/google/go-github/v66/github/repos_projects.go
generated
vendored
73
vendor/github.com/google/go-github/v66/github/repos_projects.go
generated
vendored
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ProjectListOptions specifies the optional parameters to the
|
||||
// OrganizationsService.ListProjects and RepositoriesService.ListProjects methods.
|
||||
type ProjectListOptions struct {
|
||||
// Indicates the state of the projects to return. Can be either open, closed, or all. Default: open
|
||||
State string `url:"state,omitempty"`
|
||||
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListProjects lists the projects for a repo.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#list-repository-projects
|
||||
//
|
||||
//meta:operation GET /repos/{owner}/{repo}/projects
|
||||
func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opts *ProjectListOptions) ([]*Project, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/projects", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
var projects []*Project
|
||||
resp, err := s.client.Do(ctx, req, &projects)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return projects, resp, nil
|
||||
}
|
||||
|
||||
// CreateProject creates a GitHub Project for the specified repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#create-a-repository-project
|
||||
//
|
||||
//meta:operation POST /repos/{owner}/{repo}/projects
|
||||
func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo string, opts *ProjectOptions) (*Project, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/projects", owner, repo)
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
project := &Project{}
|
||||
resp, err := s.client.Do(ctx, req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
72
vendor/github.com/google/go-github/v66/github/users_projects.go
generated
vendored
72
vendor/github.com/google/go-github/v66/github/users_projects.go
generated
vendored
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright 2019 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ListProjects lists the projects for the specified user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#list-user-projects
|
||||
//
|
||||
//meta:operation GET /users/{username}/projects
|
||||
func (s *UsersService) ListProjects(ctx context.Context, user string, opts *ProjectListOptions) ([]*Project, *Response, error) {
|
||||
u := fmt.Sprintf("users/%v/projects", user)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
var projects []*Project
|
||||
resp, err := s.client.Do(ctx, req, &projects)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return projects, resp, nil
|
||||
}
|
||||
|
||||
// CreateUserProjectOptions specifies the parameters to the UsersService.CreateProject method.
|
||||
type CreateUserProjectOptions struct {
|
||||
// The name of the project. (Required.)
|
||||
Name string `json:"name"`
|
||||
// The description of the project. (Optional.)
|
||||
Body *string `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// CreateProject creates a GitHub Project for the current user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/projects/projects#create-a-user-project
|
||||
//
|
||||
//meta:operation POST /user/projects
|
||||
func (s *UsersService) CreateProject(ctx context.Context, opts *CreateUserProjectOptions) (*Project, *Response, error) {
|
||||
u := "user/projects"
|
||||
req, err := s.client.NewRequest("POST", u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeProjectsPreview)
|
||||
|
||||
project := &Project{}
|
||||
resp, err := s.client.Do(ctx, req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ Abhishek Sharma <abhishekbiyala@gmail.com>
|
|||
Abhishek Veeramalla <abhishek.veeramalla@gmail.com>
|
||||
aboy <b1011211@gmail.com>
|
||||
Adam Kohring <ajkohring@gmail.com>
|
||||
Aditya Mahendrakar <a.mahendrakar@yahoo.com>
|
||||
adrienzieba <adrien.zieba@appdirect.com>
|
||||
afdesk <work@afdesk.com>
|
||||
Ahmad Nurus S <ahmadnurus.sh@gmail.com>
|
||||
|
|
@ -39,6 +40,7 @@ Alex Su <alexsu@17.media>
|
|||
Alex Unger <zyxancf@gmail.com>
|
||||
Alexander Harkness <me@bearbin.net>
|
||||
Alexey Alekhin <laughedelic@gmail.com>
|
||||
Alexis Couvreur <alexiscouvreur.pro@gmail.com>
|
||||
Alexis Gauthiez <alexis.gauthiez@gmail.com>
|
||||
Ali Farooq <ali.farooq0@pm.me>
|
||||
Alin Balutoiu <alinbalutoiu@gmail.com>
|
||||
|
|
@ -48,6 +50,7 @@ Amey Sakhadeo <me@ameyms.com>
|
|||
Anders Janmyr <anders@janmyr.com>
|
||||
Andreas Deininger <andreas@deininger.net>
|
||||
Andreas Garnæs <https://github.com/andreas>
|
||||
Andrew Gillis <gillis.andrew@gmail.com>
|
||||
Andrew Ryabchun <aryabchun@mail.ua>
|
||||
Andrew Svoboda <svoboda.andrew@gmail.com>
|
||||
Andriyun <andriy.yun@gmail.com>
|
||||
|
|
@ -110,6 +113,7 @@ chandresh-pancholi <chandreshpancholi007@gmail.com>
|
|||
Charles Fenwick Elliott <Charles@FenwickElliott.io>
|
||||
Charlie Yan <charlieyan08@gmail.com>
|
||||
Chmouel Boudjnah <chmouel@chmouel.com>
|
||||
Chris Allen Lane <chris@chris-allen-lane.com>
|
||||
Chris King <chriskingnet@gmail.com>
|
||||
Chris Mc <prince.chrismc@gmail.com>
|
||||
Chris Raborg <craborg57@gmail.com>
|
||||
|
|
@ -170,6 +174,7 @@ eperm <staffordworrell@gmail.com>
|
|||
Erick Fejta <erick@fejta.com>
|
||||
Erik Elkins <erik.elkins@outlook.com>
|
||||
Erik Nobel <hendrik.nobel@transferwise.com>
|
||||
Erwan Finot <finot.erwan@gmail.com>
|
||||
erwinvaneyk <erwinvaneyk@gmail.com>
|
||||
Evan Anderson <evan.k.anderson@gmail.com>
|
||||
Evan Elias <evanjelias@gmail.com>
|
||||
|
|
@ -207,6 +212,7 @@ Hari haran <hariharan.uno@gmail.com>
|
|||
Harikesh00 <prajapatiharikesh16@gmail.com>
|
||||
haya14busa <haya14busa@gmail.com>
|
||||
haya14busa <hayabusa1419@gmail.com>
|
||||
Henrik Lundström <henrik94lundstrom@gmail.com>
|
||||
Hiroki Ito <hiroki.ito.dev@gmail.com>
|
||||
Hubot Jr <rreichel3@github.com>
|
||||
Huy Tr <kingbazoka@gmail.com>
|
||||
|
|
@ -219,6 +225,7 @@ Ioannis Georgoulas <igeorgoulas21@gmail.com>
|
|||
Isao Jonas <isao.jonas@gmail.com>
|
||||
ishan upadhyay <ishanupadhyay412@gmail.com>
|
||||
isqua <isqua@isqua.ru>
|
||||
Ivan Martos <martos.ivan@gmail.com>
|
||||
Jacob Valdemar <jan@lunar.app>
|
||||
Jake Krammer <jake.krammer1@gmail.com>
|
||||
Jake Scaltreto <jake.scaltreto@circle.com>
|
||||
|
|
@ -343,6 +350,7 @@ Michał Glapa <michal.glapa@gmail.com>
|
|||
Michelangelo Morrillo <michelangelo@morrillo.it>
|
||||
Miguel Elias dos Santos <migueleliasweb@gmail.com>
|
||||
Mike Chen <mchen300@gmail.com>
|
||||
Miles Crabill <miles@milescrabill.com>
|
||||
Mishin Nikolai <sanduku.default@gmail.com>
|
||||
mohammad ali <2018cs92@student.uet.edu.pk>
|
||||
Mohammed AlDujaili <avainer11@gmail.com>
|
||||
|
|
@ -373,6 +381,7 @@ ns-cweber <cweber@narrativescience.com>
|
|||
nxya <nathacutlan@gmail.com>
|
||||
Ole Orhagen <ole.orhagen@northern.tech>
|
||||
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||
Oleksandr Redko <oleksandr.red+github@gmail.com>
|
||||
Ondřej Kupka <ondra.cap@gmail.com>
|
||||
Ori Talmor <talmorori@gmail.com>
|
||||
Osama Faqhruldin <onfaqhru@gmail.com>
|
||||
|
|
@ -472,6 +481,7 @@ SoundCloud, Ltd.
|
|||
Sridhar Mocherla <srmocher@microsoft.com>
|
||||
SriVignessh Pss <sriknowledge@gmail.com>
|
||||
Stefan Sedich <stefan.sedich@gmail.com>
|
||||
Steve Hipwell <steve.hipwell@gmail.com>
|
||||
Steve Teuber <github@steveteuber.com>
|
||||
Stian Eikeland <stian@eikeland.se>
|
||||
Suhaib Mujahid <suhaibmujahid@gmail.com>
|
||||
|
|
@ -50,12 +50,22 @@ type ArtifactList struct {
|
|||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
}
|
||||
|
||||
// ListArtifactsOptions specifies the optional parameters to the
|
||||
// ActionsService.ListArtifacts method.
|
||||
type ListArtifactsOptions struct {
|
||||
// Name represents the name field of an artifact.
|
||||
// When specified, only artifacts with this name will be returned.
|
||||
Name *string `url:"name,omitempty"`
|
||||
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListArtifacts lists all artifacts that belong to 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 *ListArtifactsOptions) (*ArtifactList, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
|
|
@ -80,7 +80,7 @@ type ListOrgRunnerGroupOptions struct {
|
|||
|
||||
// ListOrganizationRunnerGroups lists all self-hosted runner groups configured in 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
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -106,7 +106,7 @@ func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org s
|
|||
|
||||
// GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -127,7 +127,7 @@ func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org str
|
|||
|
||||
// DeleteOrganizationRunnerGroup deletes a self-hosted runner group from an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -143,7 +143,7 @@ func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// CreateOrganizationRunnerGroup creates a new self-hosted runner group for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -164,7 +164,7 @@ func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// UpdateOrganizationRunnerGroup updates a self-hosted runner group for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -185,7 +185,7 @@ func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org
|
|||
|
||||
// ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/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/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) {
|
||||
|
|
@ -212,7 +212,7 @@ func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, or
|
|||
// SetRepositoryAccessRunnerGroup replaces the list of repositories that have access to a self-hosted runner group configured in an organization
|
||||
// with a new List of repositories.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/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/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) {
|
||||
|
|
@ -229,7 +229,7 @@ func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org
|
|||
// AddRepositoryAccessRunnerGroup adds a repository to the list of selected repositories that can access a self-hosted runner group.
|
||||
// The runner group must have visibility set to 'selected'.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/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/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) {
|
||||
|
|
@ -246,7 +246,7 @@ func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org
|
|||
// RemoveRepositoryAccessRunnerGroup removes a repository from the list of selected repositories that can access a self-hosted runner group.
|
||||
// The runner group must have visibility set to 'selected'.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/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/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) {
|
||||
|
|
@ -262,7 +262,7 @@ func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context,
|
|||
|
||||
// ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -289,7 +289,7 @@ func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string,
|
|||
// SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an organization runner group
|
||||
// with a new list of runners.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -305,7 +305,7 @@ func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string,
|
|||
|
||||
// AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#add-a-self-hosted-runner-to-a-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -322,7 +322,7 @@ func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string,
|
|||
// RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization.
|
||||
// The runner is then returned to the default group.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization
|
||||
// GitHub API docs: https://docs.github.com/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) {
|
||||
|
|
@ -39,7 +39,7 @@ func (p *PublicKey) UnmarshalJSON(data []byte) error {
|
|||
case string:
|
||||
p.KeyID = &v
|
||||
case float64:
|
||||
p.KeyID = String(strconv.FormatFloat(v, 'f', -1, 64))
|
||||
p.KeyID = Ptr(strconv.FormatFloat(v, 'f', -1, 64))
|
||||
default:
|
||||
return fmt.Errorf("unable to unmarshal %T as a string", v)
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func (m Enterprise) String() string {
|
|||
|
||||
// UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -103,7 +103,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m
|
|||
|
||||
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-team
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -22,7 +22,7 @@ type createOrgRequest struct {
|
|||
// Note that only a subset of the org fields are used and org must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#create-an-organization
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -61,7 +61,7 @@ type RenameOrgResponse struct {
|
|||
|
||||
// RenameOrg renames an organization in GitHub Enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#update-an-organization-name
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -70,7 +70,7 @@ func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName
|
|||
|
||||
// RenameOrgByName renames an organization in GitHub Enterprise using its current name.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#update-an-organization-name
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -152,7 +152,7 @@ func (s RepoStats) String() string {
|
|||
// Please note that this is only available to site administrators,
|
||||
// otherwise it will error with a 404 not found (instead of 401 or 403).
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/admin-stats#get-all-statistics
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/admin-stats#get-all-statistics
|
||||
//
|
||||
//meta:operation GET /enterprise/stats/all
|
||||
func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
|
||||
|
|
@ -20,7 +20,7 @@ type CreateUserRequest struct {
|
|||
|
||||
// CreateUser creates a new user in GitHub Enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#create-a-user
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/users#create-a-user
|
||||
//
|
||||
//meta:operation POST /admin/users
|
||||
func (s *AdminService) CreateUser(ctx context.Context, userReq CreateUserRequest) (*User, *Response, error) {
|
||||
|
|
@ -42,7 +42,7 @@ func (s *AdminService) CreateUser(ctx context.Context, userReq CreateUserRequest
|
|||
|
||||
// DeleteUser deletes a user in GitHub Enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#delete-a-user
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/users#delete-a-user
|
||||
//
|
||||
//meta:operation DELETE /admin/users/{username}
|
||||
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) {
|
||||
|
|
@ -95,7 +95,7 @@ type UserAuthorization struct {
|
|||
|
||||
// CreateUserImpersonation creates an impersonation OAuth token.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#create-an-impersonation-oauth-token
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -117,7 +117,7 @@ func (s *AdminService) CreateUserImpersonation(ctx context.Context, username str
|
|||
|
||||
// DeleteUserImpersonation deletes an impersonation OAuth token.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -80,22 +80,47 @@ type InstallationPermissions struct {
|
|||
Actions *string `json:"actions,omitempty"`
|
||||
ActionsVariables *string `json:"actions_variables,omitempty"`
|
||||
Administration *string `json:"administration,omitempty"`
|
||||
Attestations *string `json:"attestations,omitempty"`
|
||||
Blocking *string `json:"blocking,omitempty"`
|
||||
Checks *string `json:"checks,omitempty"`
|
||||
Codespaces *string `json:"codespaces,omitempty"`
|
||||
CodespacesLifecycleAdmin *string `json:"codespaces_lifecycle_admin,omitempty"`
|
||||
CodespacesMetadata *string `json:"codespaces_metadata,omitempty"`
|
||||
CodespacesSecrets *string `json:"codespaces_secrets,omitempty"`
|
||||
CodespacesUserSecrets *string `json:"codespaces_user_secrets,omitempty"`
|
||||
Contents *string `json:"contents,omitempty"`
|
||||
ContentReferences *string `json:"content_references,omitempty"`
|
||||
CopilotMessages *string `json:"copilot_messages,omitempty"`
|
||||
DependabotSecrets *string `json:"dependabot_secrets,omitempty"`
|
||||
Deployments *string `json:"deployments,omitempty"`
|
||||
Discussions *string `json:"discussions,omitempty"`
|
||||
Emails *string `json:"emails,omitempty"`
|
||||
Environments *string `json:"environments,omitempty"`
|
||||
Followers *string `json:"followers,omitempty"`
|
||||
Gists *string `json:"gists,omitempty"`
|
||||
GitSigningSSHPublicKeys *string `json:"git_signing_ssh_public_keys,omitempty"`
|
||||
GPGKeys *string `json:"gpg_keys,omitempty"`
|
||||
InteractionLimits *string `json:"interaction_limits,omitempty"`
|
||||
Issues *string `json:"issues,omitempty"`
|
||||
Keys *string `json:"keys,omitempty"`
|
||||
Metadata *string `json:"metadata,omitempty"`
|
||||
Members *string `json:"members,omitempty"`
|
||||
MergeQueues *string `json:"merge_queues,omitempty"`
|
||||
OrganizationActionsVariables *string `json:"organization_actions_variables,omitempty"`
|
||||
OrganizationAdministration *string `json:"organization_administration,omitempty"`
|
||||
OrganizationAnnouncementBanners *string `json:"organization_announcement_banners,omitempty"`
|
||||
OrganizationAPIInsights *string `json:"organization_api_insights,omitempty"`
|
||||
OrganizationCodespaces *string `json:"organization_codespaces,omitempty"`
|
||||
OrganizationCodespacesSecrets *string `json:"organization_codespaces_secrets,omitempty"`
|
||||
OrganizationCodespacesSettings *string `json:"organization_codespaces_settings,omitempty"`
|
||||
OrganizationCopilotSeatManagement *string `json:"organization_copilot_seat_management,omitempty"`
|
||||
OrganizationCustomProperties *string `json:"organization_custom_properties,omitempty"`
|
||||
OrganizationCustomRoles *string `json:"organization_custom_roles,omitempty"`
|
||||
OrganizationCustomOrgRoles *string `json:"organization_custom_org_roles,omitempty"`
|
||||
OrganizationDependabotSecrets *string `json:"organization_dependabot_secrets,omitempty"`
|
||||
OrganizationEvents *string `json:"organization_events,omitempty"`
|
||||
OrganizationHooks *string `json:"organization_hooks,omitempty"`
|
||||
OrganizationKnowledgeBases *string `json:"organization_knowledge_bases,omitempty"`
|
||||
OrganizationPackages *string `json:"organization_packages,omitempty"`
|
||||
OrganizationPersonalAccessTokens *string `json:"organization_personal_access_tokens,omitempty"`
|
||||
OrganizationPersonalAccessTokenRequests *string `json:"organization_personal_access_token_requests,omitempty"`
|
||||
|
|
@ -107,7 +132,11 @@ type InstallationPermissions struct {
|
|||
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
|
||||
Packages *string `json:"packages,omitempty"`
|
||||
Pages *string `json:"pages,omitempty"`
|
||||
Plan *string `json:"plan,omitempty"`
|
||||
Profile *string `json:"profile,omitempty"`
|
||||
PullRequests *string `json:"pull_requests,omitempty"`
|
||||
RepositoryAdvisories *string `json:"repository_advisories,omitempty"`
|
||||
RepositoryCustomProperties *string `json:"repository_custom_properties,omitempty"`
|
||||
RepositoryHooks *string `json:"repository_hooks,omitempty"`
|
||||
RepositoryProjects *string `json:"repository_projects,omitempty"`
|
||||
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
|
||||
|
|
@ -115,9 +144,12 @@ type InstallationPermissions struct {
|
|||
SecretScanningAlerts *string `json:"secret_scanning_alerts,omitempty"`
|
||||
SecurityEvents *string `json:"security_events,omitempty"`
|
||||
SingleFile *string `json:"single_file,omitempty"`
|
||||
Starring *string `json:"starring,omitempty"`
|
||||
Statuses *string `json:"statuses,omitempty"`
|
||||
TeamDiscussions *string `json:"team_discussions,omitempty"`
|
||||
UserEvents *string `json:"user_events,omitempty"`
|
||||
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
|
||||
Watching *string `json:"watching,omitempty"`
|
||||
Workflows *string `json:"workflows,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +425,7 @@ func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id i
|
|||
//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) {
|
||||
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
|
||||
payload := &Attachment{Title: String(title), Body: String(body)}
|
||||
payload := &Attachment{Title: Ptr(title), Body: Ptr(body)}
|
||||
req, err := s.client.NewRequest("POST", u, payload)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
27
vendor/github.com/google/go-github/v68/github/attestations.go
generated
vendored
Normal file
27
vendor/github.com/google/go-github/v68/github/attestations.go
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2024 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Attestation represents an artifact attestation associated with a repository.
|
||||
// The provided bundle can be used to verify the provenance of artifacts.
|
||||
//
|
||||
// https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds
|
||||
type Attestation struct {
|
||||
// The attestation's Sigstore Bundle.
|
||||
// Refer to the sigstore bundle specification for more info:
|
||||
// https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_bundle.proto
|
||||
Bundle json.RawMessage `json:"bundle"`
|
||||
RepositoryID int64 `json:"repository_id"`
|
||||
}
|
||||
|
||||
// AttestationsResponse represents a collection of artifact attestations.
|
||||
type AttestationsResponse struct {
|
||||
Attestations []*Attestation `json:"attestations"`
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
// GitHub API docs: https://docs.github.com/rest/oauth/#scopes
|
||||
type Scope string
|
||||
|
||||
// This is the set of scopes for GitHub API V3
|
||||
// This is the set of scopes for GitHub API V3.
|
||||
const (
|
||||
ScopeNone Scope = "(no scope)" // REVISIT: is this actually returned, or just a documentation artifact?
|
||||
ScopeUser Scope = "user"
|
||||
|
|
@ -257,7 +257,7 @@ 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
|
||||
// new token automatically revokes an existing one.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#create-an-impersonation-oauth-token
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -279,7 +279,7 @@ func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, usernam
|
|||
//
|
||||
// NOTE: there can be only one at a time.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
|
||||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/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) {
|
||||
|
|
@ -401,7 +401,7 @@ type CheckSuitePreferenceResults struct {
|
|||
Repository *Repository `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// PreferenceList represents a list of auto trigger checks for repository
|
||||
// PreferenceList represents a list of auto trigger checks for repository.
|
||||
type PreferenceList struct {
|
||||
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
|
||||
}
|
||||
|
|
@ -429,7 +429,7 @@ func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, rep
|
|||
return checkSuitePrefResults, resp, nil
|
||||
}
|
||||
|
||||
// CreateCheckSuiteOptions sets up parameters to manually create a check suites
|
||||
// CreateCheckSuiteOptions sets up parameters to manually create a check suites.
|
||||
type CreateCheckSuiteOptions struct {
|
||||
HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.)
|
||||
HeadBranch *string `json:"head_branch,omitempty"` // The name of the head branch where the code changes are implemented.
|
||||
|
|
@ -50,7 +50,7 @@ func (s *CodesOfConductService) List(ctx context.Context) ([]*CodeOfConduct, *Re
|
|||
|
||||
// ListCodesOfConduct returns all codes of conduct.
|
||||
//
|
||||
// Deprecated: Use CodesOfConductService.List instead
|
||||
// Deprecated: Use CodesOfConductService.List instead.
|
||||
func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
|
||||
return c.CodesOfConduct.List(ctx)
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ func (s *CodesOfConductService) Get(ctx context.Context, key string) (*CodeOfCon
|
|||
|
||||
// GetCodeOfConduct returns an individual code of conduct.
|
||||
//
|
||||
// Deprecated: Use CodesOfConductService.Get instead
|
||||
// Deprecated: Use CodesOfConductService.Get instead.
|
||||
func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
|
||||
return c.CodesOfConduct.Get(ctx, key)
|
||||
}
|
||||
570
vendor/github.com/google/go-github/v68/github/copilot.go
generated
vendored
Normal file
570
vendor/github.com/google/go-github/v68/github/copilot.go
generated
vendored
Normal file
|
|
@ -0,0 +1,570 @@
|
|||
// 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"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CopilotService provides access to the Copilot-related functions
|
||||
// in the GitHub API.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/rest/copilot/
|
||||
type CopilotService service
|
||||
|
||||
// CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription.
|
||||
type CopilotOrganizationDetails struct {
|
||||
SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"`
|
||||
PublicCodeSuggestions string `json:"public_code_suggestions"`
|
||||
CopilotChat string `json:"copilot_chat"`
|
||||
SeatManagementSetting string `json:"seat_management_setting"`
|
||||
}
|
||||
|
||||
// CopilotSeatBreakdown represents the breakdown of Copilot for Business seats for the organization.
|
||||
type CopilotSeatBreakdown struct {
|
||||
Total int `json:"total"`
|
||||
AddedThisCycle int `json:"added_this_cycle"`
|
||||
PendingCancellation int `json:"pending_cancellation"`
|
||||
PendingInvitation int `json:"pending_invitation"`
|
||||
ActiveThisCycle int `json:"active_this_cycle"`
|
||||
InactiveThisCycle int `json:"inactive_this_cycle"`
|
||||
}
|
||||
|
||||
// ListCopilotSeatsResponse represents the Copilot for Business seat assignments for an organization.
|
||||
type ListCopilotSeatsResponse struct {
|
||||
TotalSeats int64 `json:"total_seats"`
|
||||
Seats []*CopilotSeatDetails `json:"seats"`
|
||||
}
|
||||
|
||||
// CopilotSeatDetails represents the details of a Copilot for Business seat.
|
||||
type CopilotSeatDetails struct {
|
||||
// Assignee can either be a User, Team, or Organization.
|
||||
Assignee interface{} `json:"assignee"`
|
||||
AssigningTeam *Team `json:"assigning_team,omitempty"`
|
||||
PendingCancellationDate *string `json:"pending_cancellation_date,omitempty"`
|
||||
LastActivityAt *Timestamp `json:"last_activity_at,omitempty"`
|
||||
LastActivityEditor *string `json:"last_activity_editor,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
PlanType *string `json:"plan_type,omitempty"`
|
||||
}
|
||||
|
||||
// SeatAssignments represents the number of seats assigned.
|
||||
type SeatAssignments struct {
|
||||
SeatsCreated int `json:"seats_created"`
|
||||
}
|
||||
|
||||
// SeatCancellations represents the number of seats cancelled.
|
||||
type SeatCancellations struct {
|
||||
SeatsCancelled int `json:"seats_cancelled"`
|
||||
}
|
||||
|
||||
// CopilotMetricsListOptions represents the optional parameters to the CopilotService get metrics methods.
|
||||
type CopilotMetricsListOptions struct {
|
||||
Since *time.Time `url:"since,omitempty"`
|
||||
Until *time.Time `url:"until,omitempty"`
|
||||
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// CopilotIDECodeCompletionsLanguage represents Copilot usage metrics for completions in the IDE for a language.
|
||||
type CopilotIDECodeCompletionsLanguage struct {
|
||||
Name string `json:"name"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
}
|
||||
|
||||
// CopilotIDECodeCompletionsModelLanguage represents Copilot usage metrics for completions in the IDE for a model and language.
|
||||
type CopilotIDECodeCompletionsModelLanguage struct {
|
||||
Name string `json:"name"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
TotalCodeSuggestions int `json:"total_code_suggestions"`
|
||||
TotalCodeAcceptances int `json:"total_code_acceptances"`
|
||||
TotalCodeLinesSuggested int `json:"total_code_lines_suggested"`
|
||||
TotalCodeLinesAccepted int `json:"total_code_lines_accepted"`
|
||||
}
|
||||
|
||||
// CopilotIDECodeCompletionsModel represents Copilot usage metrics for completions in the IDE for a model.
|
||||
type CopilotIDECodeCompletionsModel struct {
|
||||
Name string `json:"name"`
|
||||
IsCustomModel bool `json:"is_custom_model"`
|
||||
CustomModelTrainingDate *string `json:"custom_model_training_date,omitempty"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Languages []*CopilotIDECodeCompletionsModelLanguage `json:"languages"`
|
||||
}
|
||||
|
||||
// CopilotIDECodeCompletionsEditor represents Copilot usage metrics for completions in the IDE for an editor.
|
||||
type CopilotIDECodeCompletionsEditor struct {
|
||||
Name string `json:"name"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Models []*CopilotIDECodeCompletionsModel `json:"models"`
|
||||
}
|
||||
|
||||
// CopilotIDECodeCompletions represents Copilot usage metrics for Copilot code completions in the IDE, categorized by editor, model and language.
|
||||
type CopilotIDECodeCompletions struct {
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Languages []*CopilotIDECodeCompletionsLanguage `json:"languages"`
|
||||
Editors []*CopilotIDECodeCompletionsEditor `json:"editors"`
|
||||
}
|
||||
|
||||
// CopilotIDEChatModel represents Copilot usage metrics for chatting with a model in the IDE.
|
||||
type CopilotIDEChatModel struct {
|
||||
Name string `json:"name"`
|
||||
IsCustomModel bool `json:"is_custom_model"`
|
||||
CustomModelTrainingDate *string `json:"custom_model_training_date,omitempty"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
TotalChats int `json:"total_chats"`
|
||||
TotalChatInsertionEvents int `json:"total_chat_insertion_events"`
|
||||
TotalChatCopyEvents int `json:"total_chat_copy_events"`
|
||||
}
|
||||
|
||||
// CopilotIDEChatEditor represents Copilot usage metrics for chatting with a model in the IDE, categorized by editor and model.
|
||||
type CopilotIDEChatEditor struct {
|
||||
Name string `json:"name"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Models []*CopilotIDEChatModel `json:"models"`
|
||||
}
|
||||
|
||||
// CopilotIDEChat represents Copilot usage metrics for Copilot Chat in the IDE, categorized by editor and model.
|
||||
type CopilotIDEChat struct {
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Editors []*CopilotIDEChatEditor `json:"editors"`
|
||||
}
|
||||
|
||||
// CopilotDotcomChatModel represents Copilot usage metrics for chatting with a model in the webbrowser.
|
||||
type CopilotDotcomChatModel struct {
|
||||
Name string `json:"name"`
|
||||
IsCustomModel bool `json:"is_custom_model"`
|
||||
CustomModelTrainingDate *string `json:"custom_model_training_date,omitempty"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
TotalChats int `json:"total_chats"`
|
||||
}
|
||||
|
||||
// CopilotDotcomChat represents Copilot usage metrics for Copilot Chat in the webbrowser, categorized by model.
|
||||
type CopilotDotcomChat struct {
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Models []*CopilotDotcomChatModel `json:"models"`
|
||||
}
|
||||
|
||||
// CopilotDotcomPullRequestsModel represents Copilot usage metrics for pull requests in the webbrowser, categorized by model.
|
||||
type CopilotDotcomPullRequestsModel struct {
|
||||
Name string `json:"name"`
|
||||
IsCustomModel bool `json:"is_custom_model"`
|
||||
CustomModelTrainingDate *string `json:"custom_model_training_date,omitempty"`
|
||||
TotalPRSummariesCreated int `json:"total_pr_summaries_created"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
}
|
||||
|
||||
// CopilotDotcomPullRequestsRepository represents Copilot usage metrics for pull requests in the webbrowser, categorized by repository.
|
||||
type CopilotDotcomPullRequestsRepository struct {
|
||||
Name string `json:"name"`
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Models []*CopilotDotcomPullRequestsModel `json:"models"`
|
||||
}
|
||||
|
||||
// CopilotDotcomPullRequests represents Copilot usage metrics for pull requests in the webbrowser, categorized by repository and model.
|
||||
type CopilotDotcomPullRequests struct {
|
||||
TotalEngagedUsers int `json:"total_engaged_users"`
|
||||
Repositories []*CopilotDotcomPullRequestsRepository `json:"repositories"`
|
||||
}
|
||||
|
||||
// CopilotMetrics represents Copilot usage metrics for a given day.
|
||||
type CopilotMetrics struct {
|
||||
Date string `json:"date"`
|
||||
TotalActiveUsers *int `json:"total_active_users,omitempty"`
|
||||
TotalEngagedUsers *int `json:"total_engaged_users,omitempty"`
|
||||
CopilotIDECodeCompletions *CopilotIDECodeCompletions `json:"copilot_ide_code_completions,omitempty"`
|
||||
CopilotIDEChat *CopilotIDEChat `json:"copilot_ide_chat,omitempty"`
|
||||
CopilotDotcomChat *CopilotDotcomChat `json:"copilot_dotcom_chat,omitempty"`
|
||||
CopilotDotcomPullRequests *CopilotDotcomPullRequests `json:"copilot_dotcom_pull_requests,omitempty"`
|
||||
}
|
||||
|
||||
func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error {
|
||||
// Using an alias to avoid infinite recursion when calling json.Unmarshal
|
||||
type alias CopilotSeatDetails
|
||||
var seatDetail alias
|
||||
|
||||
if err := json.Unmarshal(data, &seatDetail); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cp.AssigningTeam = seatDetail.AssigningTeam
|
||||
cp.PendingCancellationDate = seatDetail.PendingCancellationDate
|
||||
cp.LastActivityAt = seatDetail.LastActivityAt
|
||||
cp.LastActivityEditor = seatDetail.LastActivityEditor
|
||||
cp.CreatedAt = seatDetail.CreatedAt
|
||||
cp.UpdatedAt = seatDetail.UpdatedAt
|
||||
cp.PlanType = seatDetail.PlanType
|
||||
|
||||
switch v := seatDetail.Assignee.(type) {
|
||||
case map[string]interface{}:
|
||||
jsonData, err := json.Marshal(seatDetail.Assignee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if v["type"] == nil {
|
||||
return errors.New("assignee type field is not set")
|
||||
}
|
||||
|
||||
if t, ok := v["type"].(string); ok && t == "User" {
|
||||
user := &User{}
|
||||
if err := json.Unmarshal(jsonData, user); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = user
|
||||
} else if t, ok := v["type"].(string); ok && t == "Team" {
|
||||
team := &Team{}
|
||||
if err := json.Unmarshal(jsonData, team); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = team
|
||||
} else if t, ok := v["type"].(string); ok && t == "Organization" {
|
||||
organization := &Organization{}
|
||||
if err := json.Unmarshal(jsonData, organization); err != nil {
|
||||
return err
|
||||
}
|
||||
cp.Assignee = organization
|
||||
} else {
|
||||
return fmt.Errorf("unsupported assignee type %v", v["type"])
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported assignee type %T", v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUser gets the User from the CopilotSeatDetails if the assignee is a user.
|
||||
func (cp *CopilotSeatDetails) GetUser() (*User, bool) { u, ok := cp.Assignee.(*User); return u, ok }
|
||||
|
||||
// GetTeam gets the Team from the CopilotSeatDetails if the assignee is a team.
|
||||
func (cp *CopilotSeatDetails) GetTeam() (*Team, bool) { t, ok := cp.Assignee.(*Team); return t, ok }
|
||||
|
||||
// GetOrganization gets the Organization from the CopilotSeatDetails if the assignee is an organization.
|
||||
func (cp *CopilotSeatDetails) GetOrganization() (*Organization, bool) {
|
||||
o, ok := cp.Assignee.(*Organization)
|
||||
return o, ok
|
||||
}
|
||||
|
||||
// GetCopilotBilling gets Copilot for Business billing information and settings for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-information-and-settings-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/copilot/billing
|
||||
func (s *CopilotService) GetCopilotBilling(ctx context.Context, org string) (*CopilotOrganizationDetails, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing", org)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var copilotDetails *CopilotOrganizationDetails
|
||||
resp, err := s.client.Do(ctx, req, &copilotDetails)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return copilotDetails, resp, nil
|
||||
}
|
||||
|
||||
// ListCopilotSeats lists Copilot for Business seat assignments for an organization.
|
||||
//
|
||||
// To paginate through all seats, populate 'Page' with the number of the last page.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/copilot/billing/seats
|
||||
func (s *CopilotService) ListCopilotSeats(ctx context.Context, org string, opts *ListOptions) (*ListCopilotSeatsResponse, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/seats", 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 copilotSeats *ListCopilotSeatsResponse
|
||||
resp, err := s.client.Do(ctx, req, &copilotSeats)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return copilotSeats, resp, nil
|
||||
}
|
||||
|
||||
// ListCopilotEnterpriseSeats lists Copilot for Business seat assignments for an enterprise.
|
||||
//
|
||||
// To paginate through all seats, populate 'Page' with the number of the last page.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-enterprise
|
||||
//
|
||||
//meta:operation GET /enterprises/{enterprise}/copilot/billing/seats
|
||||
func (s *CopilotService) ListCopilotEnterpriseSeats(ctx context.Context, enterprise string, opts *ListOptions) (*ListCopilotSeatsResponse, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/copilot/billing/seats", enterprise)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var copilotSeats *ListCopilotSeatsResponse
|
||||
resp, err := s.client.Do(ctx, req, &copilotSeats)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return copilotSeats, resp, nil
|
||||
}
|
||||
|
||||
// AddCopilotTeams adds teams to the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#add-teams-to-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/copilot/billing/selected_teams
|
||||
func (s *CopilotService) AddCopilotTeams(ctx context.Context, org string, teamNames []string) (*SeatAssignments, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_teams", org)
|
||||
|
||||
body := struct {
|
||||
SelectedTeams []string `json:"selected_teams"`
|
||||
}{
|
||||
SelectedTeams: teamNames,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatAssignments *SeatAssignments
|
||||
resp, err := s.client.Do(ctx, req, &seatAssignments)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatAssignments, resp, nil
|
||||
}
|
||||
|
||||
// RemoveCopilotTeams removes teams from the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#remove-teams-from-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/copilot/billing/selected_teams
|
||||
func (s *CopilotService) RemoveCopilotTeams(ctx context.Context, org string, teamNames []string) (*SeatCancellations, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_teams", org)
|
||||
|
||||
body := struct {
|
||||
SelectedTeams []string `json:"selected_teams"`
|
||||
}{
|
||||
SelectedTeams: teamNames,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatCancellations *SeatCancellations
|
||||
resp, err := s.client.Do(ctx, req, &seatCancellations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatCancellations, resp, nil
|
||||
}
|
||||
|
||||
// AddCopilotUsers adds users to the Copilot for Business subscription for an organization
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#add-users-to-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/copilot/billing/selected_users
|
||||
func (s *CopilotService) AddCopilotUsers(ctx context.Context, org string, users []string) (*SeatAssignments, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org)
|
||||
|
||||
body := struct {
|
||||
SelectedUsernames []string `json:"selected_usernames"`
|
||||
}{
|
||||
SelectedUsernames: users,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatAssignments *SeatAssignments
|
||||
resp, err := s.client.Do(ctx, req, &seatAssignments)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatAssignments, resp, nil
|
||||
}
|
||||
|
||||
// RemoveCopilotUsers removes users from the Copilot for Business subscription for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#remove-users-from-the-copilot-subscription-for-an-organization
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/copilot/billing/selected_users
|
||||
func (s *CopilotService) RemoveCopilotUsers(ctx context.Context, org string, users []string) (*SeatCancellations, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org)
|
||||
|
||||
body := struct {
|
||||
SelectedUsernames []string `json:"selected_usernames"`
|
||||
}{
|
||||
SelectedUsernames: users,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatCancellations *SeatCancellations
|
||||
resp, err := s.client.Do(ctx, req, &seatCancellations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatCancellations, resp, nil
|
||||
}
|
||||
|
||||
// GetSeatDetails gets Copilot for Business seat assignment details for a user.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-assignment-details-for-a-user
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/members/{username}/copilot
|
||||
func (s *CopilotService) GetSeatDetails(ctx context.Context, org, user string) (*CopilotSeatDetails, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/members/%v/copilot", org, user)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var seatDetails *CopilotSeatDetails
|
||||
resp, err := s.client.Do(ctx, req, &seatDetails)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return seatDetails, resp, nil
|
||||
}
|
||||
|
||||
// GetEnterpriseMetrics gets Copilot usage metrics for an enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-enterprise
|
||||
//
|
||||
//meta:operation GET /enterprises/{enterprise}/copilot/metrics
|
||||
func (s *CopilotService) GetEnterpriseMetrics(ctx context.Context, enterprise string, opts *CopilotMetricsListOptions) ([]*CopilotMetrics, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/copilot/metrics", enterprise)
|
||||
u, err := addOptions(u, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var metrics []*CopilotMetrics
|
||||
resp, err := s.client.Do(ctx, req, &metrics)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return metrics, resp, nil
|
||||
}
|
||||
|
||||
// GetEnterpriseTeamMetrics gets Copilot usage metrics for an enterprise team.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-enterprise-team
|
||||
//
|
||||
//meta:operation GET /enterprises/{enterprise}/team/{team_slug}/copilot/metrics
|
||||
func (s *CopilotService) GetEnterpriseTeamMetrics(ctx context.Context, enterprise, team string, opts *CopilotMetricsListOptions) ([]*CopilotMetrics, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/team/%v/copilot/metrics", enterprise, team)
|
||||
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 metrics []*CopilotMetrics
|
||||
resp, err := s.client.Do(ctx, req, &metrics)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return metrics, resp, nil
|
||||
}
|
||||
|
||||
// GetOrganizationMetrics gets Copilot usage metrics for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/copilot/metrics
|
||||
func (s *CopilotService) GetOrganizationMetrics(ctx context.Context, org string, opts *CopilotMetricsListOptions) ([]*CopilotMetrics, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/copilot/metrics", 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 metrics []*CopilotMetrics
|
||||
resp, err := s.client.Do(ctx, req, &metrics)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return metrics, resp, nil
|
||||
}
|
||||
|
||||
// GetOrganizationTeamMetrics gets Copilot usage metrics for an organization team.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-a-team
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/team/{team_slug}/copilot/metrics
|
||||
func (s *CopilotService) GetOrganizationTeamMetrics(ctx context.Context, org, team string, opts *CopilotMetricsListOptions) ([]*CopilotMetrics, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/team/%v/copilot/metrics", org, team)
|
||||
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 metrics []*CopilotMetrics
|
||||
resp, err := s.client.Do(ctx, req, &metrics)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return metrics, resp, nil
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API.
|
|||
|
||||
Usage:
|
||||
|
||||
import "github.com/google/go-github/v66/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
|
||||
import "github.com/google/go-github/v68/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
|
||||
import "github.com/google/go-github/github" // with go modules disabled
|
||||
|
||||
Construct a new GitHub client, then use the various services on the client to
|
||||
|
|
@ -156,8 +156,8 @@ bool, and int values. For example:
|
|||
|
||||
// create a new private repository named "foo"
|
||||
repo := &github.Repository{
|
||||
Name: github.String("foo"),
|
||||
Private: github.Bool(true),
|
||||
Name: github.Ptr("foo"),
|
||||
Private: github.Ptr(true),
|
||||
}
|
||||
client.Repositories.Create(ctx, "", repo)
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ func (s *EmojisService) List(ctx context.Context) (map[string]string, *Response,
|
|||
|
||||
// ListEmojis returns the emojis available to use on GitHub.
|
||||
//
|
||||
// Deprecated: Use EmojisService.List instead
|
||||
// Deprecated: Use EmojisService.List instead.
|
||||
func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
|
||||
return c.Emojis.List(ctx)
|
||||
}
|
||||
121
vendor/github.com/google/go-github/v68/github/enterprise_properties.go
generated
vendored
Normal file
121
vendor/github.com/google/go-github/v68/github/enterprise_properties.go
generated
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
// Copyright 2024 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"
|
||||
)
|
||||
|
||||
// GetAllCustomProperties gets all custom properties that are defined for the specified enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties#get-custom-properties-for-an-enterprise
|
||||
//
|
||||
//meta:operation GET /enterprises/{enterprise}/properties/schema
|
||||
func (s *EnterpriseService) GetAllCustomProperties(ctx context.Context, enterprise string) ([]*CustomProperty, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/properties/schema", enterprise)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var customProperties []*CustomProperty
|
||||
resp, err := s.client.Do(ctx, req, &customProperties)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return customProperties, resp, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateCustomProperties creates new or updates existing custom properties that are defined for the specified enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties#create-or-update-custom-properties-for-an-enterprise
|
||||
//
|
||||
//meta:operation PATCH /enterprises/{enterprise}/properties/schema
|
||||
func (s *EnterpriseService) CreateOrUpdateCustomProperties(ctx context.Context, enterprise string, properties []*CustomProperty) ([]*CustomProperty, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/properties/schema", enterprise)
|
||||
|
||||
params := struct {
|
||||
Properties []*CustomProperty `json:"properties"`
|
||||
}{
|
||||
Properties: properties,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("PATCH", u, params)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var customProperties []*CustomProperty
|
||||
resp, err := s.client.Do(ctx, req, &customProperties)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return customProperties, resp, nil
|
||||
}
|
||||
|
||||
// GetCustomProperty gets a custom property that is defined for the specified enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties#get-a-custom-property-for-an-enterprise
|
||||
//
|
||||
//meta:operation GET /enterprises/{enterprise}/properties/schema/{custom_property_name}
|
||||
func (s *EnterpriseService) GetCustomProperty(ctx context.Context, enterprise, customPropertyName string) (*CustomProperty, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/properties/schema/%v", enterprise, customPropertyName)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var customProperty *CustomProperty
|
||||
resp, err := s.client.Do(ctx, req, &customProperty)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return customProperty, resp, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateCustomProperty creates a new or updates an existing custom property that is defined for the specified enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties#create-or-update-a-custom-property-for-an-enterprise
|
||||
//
|
||||
//meta:operation PUT /enterprises/{enterprise}/properties/schema/{custom_property_name}
|
||||
func (s *EnterpriseService) CreateOrUpdateCustomProperty(ctx context.Context, enterprise, customPropertyName string, property *CustomProperty) (*CustomProperty, *Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/properties/schema/%v", enterprise, customPropertyName)
|
||||
|
||||
req, err := s.client.NewRequest("PUT", u, property)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var customProperty *CustomProperty
|
||||
resp, err := s.client.Do(ctx, req, &customProperty)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return customProperty, resp, nil
|
||||
}
|
||||
|
||||
// RemoveCustomProperty removes a custom property that is defined for the specified enterprise.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties#remove-a-custom-property-for-an-enterprise
|
||||
//
|
||||
//meta:operation DELETE /enterprises/{enterprise}/properties/schema/{custom_property_name}
|
||||
func (s *EnterpriseService) RemoveCustomProperty(ctx context.Context, enterprise, customPropertyName string) (*Response, error) {
|
||||
u := fmt.Sprintf("enterprises/%v/properties/schema/%v", enterprise, customPropertyName)
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
|
@ -29,6 +29,19 @@ type BranchProtectionRuleEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// BranchProtectionConfigurationEvent is triggered when there is a change to branch protection configurations for a repository.
|
||||
// The Webhook event name is "branch_protection_configuration".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_configuration
|
||||
type BranchProtectionConfigurationEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Enterprise *Enterprise `json:"enterprise,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// CheckRunEvent is triggered when a check run is "created", "completed", or "rerequested".
|
||||
// The Webhook event name is "check_run".
|
||||
//
|
||||
|
|
@ -119,6 +132,43 @@ type CreateEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// CustomPropertyEvent represents a created, deleted or updated custom property.
|
||||
// The Webhook event name is "custom_property".
|
||||
//
|
||||
// Note: this is related to custom property configuration at the enterprise or organization level.
|
||||
// See CustomPropertyValuesEvent for activity related to custom property values for a repository.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/webhooks/webhook-events-and-payloads#custom_property
|
||||
type CustomPropertyEvent struct {
|
||||
// Action possible values are: "created", "deleted", "updated".
|
||||
Action *string `json:"action,omitempty"`
|
||||
Definition *CustomProperty `json:"definition,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Enterprise *Enterprise `json:"enterprise,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// CustomPropertyValuesEvent represents an update to a custom property.
|
||||
// The Webhook event name is "custom_property_values".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/webhooks/webhook-events-and-payloads#custom_property_values
|
||||
type CustomPropertyValuesEvent struct {
|
||||
// Action possible values are: "updated".
|
||||
Action *string `json:"action,omitempty"`
|
||||
NewPropertyValues []*CustomPropertyValue `json:"new_property_values,omitempty"`
|
||||
OldPropertyValues []*CustomPropertyValue `json:"old_property_values,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Enterprise *Enterprise `json:"enterprise,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// DeleteEvent represents a deleted branch or tag.
|
||||
// The Webhook event name is "delete".
|
||||
//
|
||||
|
|
@ -753,8 +803,7 @@ type MemberChanges struct {
|
|||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#member
|
||||
type MemberEvent struct {
|
||||
// Action is the action that was performed. Possible values are:
|
||||
//"added", "edited", "removed".
|
||||
// Action is the action that was performed. Possible values are: "added", "edited", "removed".
|
||||
Action *string `json:"action,omitempty"`
|
||||
Member *User `json:"member,omitempty"`
|
||||
Changes *MemberChanges `json:"changes,omitempty"`
|
||||
|
|
@ -1034,63 +1083,13 @@ type PingEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectEvent is triggered when project is created, modified or deleted.
|
||||
// The webhook event name is "project".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project
|
||||
type ProjectEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Changes *ProjectChange `json:"changes,omitempty"`
|
||||
Project *Project `json:"project,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectCardEvent is triggered when a project card is created, updated, moved, converted to an issue, or deleted.
|
||||
// The webhook event name is "project_card".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_card
|
||||
type ProjectCardEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Changes *ProjectCardChange `json:"changes,omitempty"`
|
||||
AfterID *int64 `json:"after_id,omitempty"`
|
||||
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectColumnEvent is triggered when a project column is created, updated, moved, or deleted.
|
||||
// The webhook event name is "project_column".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#project_column
|
||||
type ProjectColumnEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Changes *ProjectColumnChange `json:"changes,omitempty"`
|
||||
AfterID *int64 `json:"after_id,omitempty"`
|
||||
ProjectColumn *ProjectColumn `json:"project_column,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Org *Organization `json:"organization,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectV2Event is triggered when there is activity relating to an organization-level project.
|
||||
// The Webhook event name is "projects_v2".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2
|
||||
type ProjectV2Event struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
ProjectsV2 *ProjectsV2 `json:"projects_v2,omitempty"`
|
||||
Action *string `json:"action,omitempty"`
|
||||
ProjectsV2 *ProjectV2 `json:"projects_v2,omitempty"`
|
||||
|
||||
// The following fields are only populated by Webhook events.
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
|
|
@ -1098,8 +1097,8 @@ type ProjectV2Event struct {
|
|||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectsV2 represents a projects v2 project.
|
||||
type ProjectsV2 struct {
|
||||
// ProjectV2 represents a v2 project.
|
||||
type ProjectV2 struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
|
|
@ -1114,6 +1113,17 @@ type ProjectsV2 struct {
|
|||
Number *int `json:"number,omitempty"`
|
||||
ShortDescription *string `json:"short_description,omitempty"`
|
||||
DeletedBy *User `json:"deleted_by,omitempty"`
|
||||
|
||||
// Fields migrated from the Project (classic) struct:
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
ColumnsURL *string `json:"columns_url,omitempty"`
|
||||
OwnerURL *string `json:"owner_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
State *string `json:"state,omitempty"`
|
||||
OrganizationPermission *string `json:"organization_permission,omitempty"`
|
||||
Private *bool `json:"private,omitempty"`
|
||||
}
|
||||
|
||||
// ProjectV2ItemEvent is triggered when there is activity relating to an item on an organization-level project.
|
||||
|
|
@ -1505,6 +1515,22 @@ type RepositoryImportEvent struct {
|
|||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// RepositoryRulesetEvent triggers whenever there is a change to the repository's ruleset configuration.
|
||||
//
|
||||
// This can include updates to protection rules, required status checks, code owners, or other related configurations.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/en/webhooks/webhook-events-and-payloads#repository_ruleset
|
||||
type RepositoryRulesetEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Enterprise *Enterprise `json:"enterprise,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
RepositoryRuleset *RepositoryRuleset `json:"repository_ruleset"`
|
||||
Changes *RepositoryRulesetEditedChanges `json:"changes,omitempty"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// RepositoryVulnerabilityAlertEvent is triggered when a security alert is created, dismissed, or resolved.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#repository_vulnerability_alert
|
||||
|
|
@ -1565,6 +1591,20 @@ type SecretScanningAlertEvent struct {
|
|||
Installation *Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
// SecretScanningAlertLocationEvent is triggered when there is activity relating to the locations of a secret in a secret scanning alert.
|
||||
// The Webhook event name is "secret_scanning_alert_location".
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#secret_scanning_alert_location
|
||||
type SecretScanningAlertLocationEvent struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
Alert *SecretScanningAlert `json:"alert,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Location *SecretScanningAlertLocation `json:"location,omitempty"`
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
Repo *Repository `json:"repository,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityAndAnalysisEvent is triggered when code security and analysis features
|
||||
// are enabled or disabled for a repository.
|
||||
//
|
||||
|
|
@ -1745,6 +1785,7 @@ type WorkflowJobEvent struct {
|
|||
Repo *Repository `json:"repository,omitempty"`
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Deployment *Deployment `json:"deployment,omitempty"`
|
||||
}
|
||||
|
||||
// WorkflowRunEvent is triggered when a GitHub Actions workflow run is requested or completed.
|
||||
|
|
@ -49,7 +49,6 @@ type Commit struct {
|
|||
Message *string `json:"message,omitempty"`
|
||||
Tree *Tree `json:"tree,omitempty"`
|
||||
Parents []*Commit `json:"parents,omitempty"`
|
||||
Stats *CommitStats `json:"stats,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Verification *SignatureVerification `json:"verification,omitempty"`
|
||||
|
|
@ -129,7 +128,7 @@ type CreateCommitOptions struct {
|
|||
//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) {
|
||||
if commit == nil {
|
||||
return nil, nil, fmt.Errorf("commit must be provided")
|
||||
return nil, nil, errors.New("commit must be provided")
|
||||
}
|
||||
if opts == nil {
|
||||
opts = &CreateCommitOptions{}
|
||||
|
|
@ -127,7 +127,7 @@ func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, r
|
|||
u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
|
||||
req, err := s.client.NewRequest("POST", u, &createRefRequest{
|
||||
// back-compat with previous behavior that didn't require 'refs/' prefix
|
||||
Ref: String("refs/" + strings.TrimPrefix(*ref.Ref, "refs/")),
|
||||
Ref: Ptr("refs/" + strings.TrimPrefix(*ref.Ref, "refs/")),
|
||||
SHA: ref.Object.SHA,
|
||||
})
|
||||
if err != nil {
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -28,21 +28,21 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Version = "v66.0.0"
|
||||
Version = "v68.0.0"
|
||||
|
||||
defaultAPIVersion = "2022-11-28"
|
||||
defaultBaseURL = "https://api.github.com/"
|
||||
defaultUserAgent = "go-github" + "/" + Version
|
||||
uploadBaseURL = "https://uploads.github.com/"
|
||||
|
||||
headerAPIVersion = "X-GitHub-Api-Version"
|
||||
headerRateLimit = "X-RateLimit-Limit"
|
||||
headerRateRemaining = "X-RateLimit-Remaining"
|
||||
headerRateReset = "X-RateLimit-Reset"
|
||||
headerOTP = "X-GitHub-OTP"
|
||||
headerAPIVersion = "X-Github-Api-Version"
|
||||
headerRateLimit = "X-Ratelimit-Limit"
|
||||
headerRateRemaining = "X-Ratelimit-Remaining"
|
||||
headerRateReset = "X-Ratelimit-Reset"
|
||||
headerOTP = "X-Github-Otp"
|
||||
headerRetryAfter = "Retry-After"
|
||||
|
||||
headerTokenExpiration = "GitHub-Authentication-Token-Expiration"
|
||||
headerTokenExpiration = "Github-Authentication-Token-Expiration"
|
||||
|
||||
mediaTypeV3 = "application/vnd.github.v3+json"
|
||||
defaultMediaType = "application/octet-stream"
|
||||
|
|
@ -203,7 +203,6 @@ type Client struct {
|
|||
Meta *MetaService
|
||||
Migrations *MigrationService
|
||||
Organizations *OrganizationsService
|
||||
Projects *ProjectsService
|
||||
PullRequests *PullRequestsService
|
||||
RateLimit *RateLimitService
|
||||
Reactions *ReactionsService
|
||||
|
|
@ -432,7 +431,6 @@ func (c *Client) initialize() {
|
|||
c.Meta = (*MetaService)(&c.common)
|
||||
c.Migrations = (*MigrationService)(&c.common)
|
||||
c.Organizations = (*OrganizationsService)(&c.common)
|
||||
c.Projects = (*ProjectsService)(&c.common)
|
||||
c.PullRequests = (*PullRequestsService)(&c.common)
|
||||
c.RateLimit = (*RateLimitService)(&c.common)
|
||||
c.Reactions = (*ReactionsService)(&c.common)
|
||||
|
|
@ -841,12 +839,17 @@ func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, erro
|
|||
}
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
var response *Response
|
||||
if resp != nil {
|
||||
response = newResponse(resp)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
// If we got an error, and the context has been canceled,
|
||||
// the context's error is probably more useful.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
return response, ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
|
|
@ -854,15 +857,13 @@ func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, erro
|
|||
if e, ok := err.(*url.Error); ok {
|
||||
if url, err := url.Parse(e.URL); err == nil {
|
||||
e.URL = sanitizeURL(url).String()
|
||||
return nil, e
|
||||
return response, e
|
||||
}
|
||||
}
|
||||
|
||||
return nil, err
|
||||
return response, err
|
||||
}
|
||||
|
||||
response := newResponse(resp)
|
||||
|
||||
// Don't update the rate limits if this was a cached response.
|
||||
// X-From-Cache is set by https://github.com/gregjones/httpcache
|
||||
if response.Header.Get("X-From-Cache") == "" {
|
||||
|
|
@ -1579,23 +1580,37 @@ func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u stri
|
|||
return resp, err
|
||||
}
|
||||
|
||||
// Ptr is a helper routine that allocates a new T value
|
||||
// to store v and returns a pointer to it.
|
||||
func Ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
// Bool is a helper routine that allocates a new bool value
|
||||
// to store v and returns a pointer to it.
|
||||
//
|
||||
// Deprecated: use Ptr instead.
|
||||
func Bool(v bool) *bool { return &v }
|
||||
|
||||
// Int is a helper routine that allocates a new int value
|
||||
// to store v and returns a pointer to it.
|
||||
//
|
||||
// Deprecated: use Ptr instead.
|
||||
func Int(v int) *int { return &v }
|
||||
|
||||
// Int64 is a helper routine that allocates a new int64 value
|
||||
// to store v and returns a pointer to it.
|
||||
//
|
||||
// Deprecated: use Ptr instead.
|
||||
func Int64(v int64) *int64 { return &v }
|
||||
|
||||
// String is a helper routine that allocates a new string value
|
||||
// to store v and returns a pointer to it.
|
||||
//
|
||||
// Deprecated: use Ptr instead.
|
||||
func String(v string) *string { return &v }
|
||||
|
||||
// roundTripperFunc creates a RoundTripper (transport)
|
||||
// roundTripperFunc creates a RoundTripper (transport).
|
||||
type roundTripperFunc func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (fn roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
|
|
@ -47,7 +47,7 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
|
|||
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||
|
||||
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||
interaction := &InteractionRestriction{Limit: Ptr(limit)}
|
||||
|
||||
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||
if err != nil {
|
||||
|
|
@ -47,7 +47,7 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
|
|||
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||
|
||||
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||
interaction := &InteractionRestriction{Limit: Ptr(limit)}
|
||||
|
||||
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||
if err != nil {
|
||||
|
|
@ -85,7 +85,6 @@ type IssueEvent struct {
|
|||
Label *Label `json:"label,omitempty"`
|
||||
Rename *Rename `json:"rename,omitempty"`
|
||||
LockReason *string `json:"lock_reason,omitempty"`
|
||||
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||
DismissedReview *DismissedReview `json:"dismissed_review,omitempty"`
|
||||
RequestedReviewer *User `json:"requested_reviewer,omitempty"`
|
||||
RequestedTeam *Team `json:"requested_team,omitempty"`
|
||||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// Label represents a GitHub label on an Issue
|
||||
// Label represents a GitHub label on an Issue.
|
||||
type Label struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
|
|
@ -97,6 +97,14 @@ type Timeline struct {
|
|||
// reviewed
|
||||
// The pull request was reviewed.
|
||||
//
|
||||
// review_requested
|
||||
// The actor requested a review from a user or team.
|
||||
// Reviewer and Requester/RequestedTeam will be populated.
|
||||
//
|
||||
// review_request_removed
|
||||
// The actor removed a review request from a user or team.
|
||||
// Reviewer and Requester/RequestedTeam will be populated.
|
||||
//
|
||||
// subscribed
|
||||
// The actor subscribed to receive notifications for an issue.
|
||||
//
|
||||
|
|
@ -134,8 +142,7 @@ type Timeline struct {
|
|||
Source *Source `json:"source,omitempty"`
|
||||
// An object containing rename details including 'from' and 'to' attributes.
|
||||
// Only provided for 'renamed' events.
|
||||
Rename *Rename `json:"rename,omitempty"`
|
||||
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||
Rename *Rename `json:"rename,omitempty"`
|
||||
// The state of a submitted review. Can be one of: 'commented',
|
||||
// 'changes_requested' or 'approved'.
|
||||
// Only provided for 'reviewed' events.
|
||||
|
|
@ -44,13 +44,13 @@ type markdownRenderRequest struct {
|
|||
//
|
||||
//meta:operation POST /markdown
|
||||
func (s *MarkdownService) Render(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
|
||||
request := &markdownRenderRequest{Text: String(text)}
|
||||
request := &markdownRenderRequest{Text: Ptr(text)}
|
||||
if opts != nil {
|
||||
if opts.Mode != "" {
|
||||
request.Mode = String(opts.Mode)
|
||||
request.Mode = Ptr(opts.Mode)
|
||||
}
|
||||
if opts.Context != "" {
|
||||
request.Context = String(opts.Context)
|
||||
request.Context = Ptr(opts.Context)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,77 +46,79 @@ const (
|
|||
var (
|
||||
// eventTypeMapping maps webhooks types to their corresponding go-github struct types.
|
||||
eventTypeMapping = map[string]interface{}{
|
||||
"branch_protection_rule": &BranchProtectionRuleEvent{},
|
||||
"check_run": &CheckRunEvent{},
|
||||
"check_suite": &CheckSuiteEvent{},
|
||||
"code_scanning_alert": &CodeScanningAlertEvent{},
|
||||
"commit_comment": &CommitCommentEvent{},
|
||||
"content_reference": &ContentReferenceEvent{},
|
||||
"create": &CreateEvent{},
|
||||
"delete": &DeleteEvent{},
|
||||
"dependabot_alert": &DependabotAlertEvent{},
|
||||
"deploy_key": &DeployKeyEvent{},
|
||||
"deployment": &DeploymentEvent{},
|
||||
"deployment_review": &DeploymentReviewEvent{},
|
||||
"deployment_status": &DeploymentStatusEvent{},
|
||||
"deployment_protection_rule": &DeploymentProtectionRuleEvent{},
|
||||
"discussion": &DiscussionEvent{},
|
||||
"discussion_comment": &DiscussionCommentEvent{},
|
||||
"fork": &ForkEvent{},
|
||||
"github_app_authorization": &GitHubAppAuthorizationEvent{},
|
||||
"gollum": &GollumEvent{},
|
||||
"installation": &InstallationEvent{},
|
||||
"installation_repositories": &InstallationRepositoriesEvent{},
|
||||
"installation_target": &InstallationTargetEvent{},
|
||||
"issue_comment": &IssueCommentEvent{},
|
||||
"issues": &IssuesEvent{},
|
||||
"label": &LabelEvent{},
|
||||
"marketplace_purchase": &MarketplacePurchaseEvent{},
|
||||
"member": &MemberEvent{},
|
||||
"membership": &MembershipEvent{},
|
||||
"merge_group": &MergeGroupEvent{},
|
||||
"meta": &MetaEvent{},
|
||||
"milestone": &MilestoneEvent{},
|
||||
"organization": &OrganizationEvent{},
|
||||
"org_block": &OrgBlockEvent{},
|
||||
"package": &PackageEvent{},
|
||||
"page_build": &PageBuildEvent{},
|
||||
"personal_access_token_request": &PersonalAccessTokenRequestEvent{},
|
||||
"ping": &PingEvent{},
|
||||
"project": &ProjectEvent{},
|
||||
"project_card": &ProjectCardEvent{},
|
||||
"project_column": &ProjectColumnEvent{},
|
||||
"projects_v2": &ProjectV2Event{},
|
||||
"projects_v2_item": &ProjectV2ItemEvent{},
|
||||
"public": &PublicEvent{},
|
||||
"pull_request": &PullRequestEvent{},
|
||||
"pull_request_review": &PullRequestReviewEvent{},
|
||||
"pull_request_review_comment": &PullRequestReviewCommentEvent{},
|
||||
"pull_request_review_thread": &PullRequestReviewThreadEvent{},
|
||||
"pull_request_target": &PullRequestTargetEvent{},
|
||||
"push": &PushEvent{},
|
||||
"repository": &RepositoryEvent{},
|
||||
"repository_dispatch": &RepositoryDispatchEvent{},
|
||||
"repository_import": &RepositoryImportEvent{},
|
||||
"repository_vulnerability_alert": &RepositoryVulnerabilityAlertEvent{},
|
||||
"release": &ReleaseEvent{},
|
||||
"secret_scanning_alert": &SecretScanningAlertEvent{},
|
||||
"security_advisory": &SecurityAdvisoryEvent{},
|
||||
"security_and_analysis": &SecurityAndAnalysisEvent{},
|
||||
"sponsorship": &SponsorshipEvent{},
|
||||
"star": &StarEvent{},
|
||||
"status": &StatusEvent{},
|
||||
"team": &TeamEvent{},
|
||||
"team_add": &TeamAddEvent{},
|
||||
"user": &UserEvent{},
|
||||
"watch": &WatchEvent{},
|
||||
"workflow_dispatch": &WorkflowDispatchEvent{},
|
||||
"workflow_job": &WorkflowJobEvent{},
|
||||
"workflow_run": &WorkflowRunEvent{},
|
||||
"branch_protection_configuration": &BranchProtectionConfigurationEvent{},
|
||||
"branch_protection_rule": &BranchProtectionRuleEvent{},
|
||||
"check_run": &CheckRunEvent{},
|
||||
"check_suite": &CheckSuiteEvent{},
|
||||
"code_scanning_alert": &CodeScanningAlertEvent{},
|
||||
"commit_comment": &CommitCommentEvent{},
|
||||
"content_reference": &ContentReferenceEvent{},
|
||||
"create": &CreateEvent{},
|
||||
"custom_property": &CustomPropertyEvent{},
|
||||
"custom_property_values": &CustomPropertyValuesEvent{},
|
||||
"delete": &DeleteEvent{},
|
||||
"dependabot_alert": &DependabotAlertEvent{},
|
||||
"deploy_key": &DeployKeyEvent{},
|
||||
"deployment": &DeploymentEvent{},
|
||||
"deployment_review": &DeploymentReviewEvent{},
|
||||
"deployment_status": &DeploymentStatusEvent{},
|
||||
"deployment_protection_rule": &DeploymentProtectionRuleEvent{},
|
||||
"discussion": &DiscussionEvent{},
|
||||
"discussion_comment": &DiscussionCommentEvent{},
|
||||
"fork": &ForkEvent{},
|
||||
"github_app_authorization": &GitHubAppAuthorizationEvent{},
|
||||
"gollum": &GollumEvent{},
|
||||
"installation": &InstallationEvent{},
|
||||
"installation_repositories": &InstallationRepositoriesEvent{},
|
||||
"installation_target": &InstallationTargetEvent{},
|
||||
"issue_comment": &IssueCommentEvent{},
|
||||
"issues": &IssuesEvent{},
|
||||
"label": &LabelEvent{},
|
||||
"marketplace_purchase": &MarketplacePurchaseEvent{},
|
||||
"member": &MemberEvent{},
|
||||
"membership": &MembershipEvent{},
|
||||
"merge_group": &MergeGroupEvent{},
|
||||
"meta": &MetaEvent{},
|
||||
"milestone": &MilestoneEvent{},
|
||||
"organization": &OrganizationEvent{},
|
||||
"org_block": &OrgBlockEvent{},
|
||||
"package": &PackageEvent{},
|
||||
"page_build": &PageBuildEvent{},
|
||||
"personal_access_token_request": &PersonalAccessTokenRequestEvent{},
|
||||
"ping": &PingEvent{},
|
||||
"projects_v2": &ProjectV2Event{},
|
||||
"projects_v2_item": &ProjectV2ItemEvent{},
|
||||
"public": &PublicEvent{},
|
||||
"pull_request": &PullRequestEvent{},
|
||||
"pull_request_review": &PullRequestReviewEvent{},
|
||||
"pull_request_review_comment": &PullRequestReviewCommentEvent{},
|
||||
"pull_request_review_thread": &PullRequestReviewThreadEvent{},
|
||||
"pull_request_target": &PullRequestTargetEvent{},
|
||||
"push": &PushEvent{},
|
||||
"repository": &RepositoryEvent{},
|
||||
"repository_dispatch": &RepositoryDispatchEvent{},
|
||||
"repository_import": &RepositoryImportEvent{},
|
||||
"repository_ruleset": &RepositoryRulesetEvent{},
|
||||
"repository_vulnerability_alert": &RepositoryVulnerabilityAlertEvent{},
|
||||
"release": &ReleaseEvent{},
|
||||
"secret_scanning_alert": &SecretScanningAlertEvent{},
|
||||
"secret_scanning_alert_location": &SecretScanningAlertLocationEvent{},
|
||||
"security_advisory": &SecurityAdvisoryEvent{},
|
||||
"security_and_analysis": &SecurityAndAnalysisEvent{},
|
||||
"sponsorship": &SponsorshipEvent{},
|
||||
"star": &StarEvent{},
|
||||
"status": &StatusEvent{},
|
||||
"team": &TeamEvent{},
|
||||
"team_add": &TeamAddEvent{},
|
||||
"user": &UserEvent{},
|
||||
"watch": &WatchEvent{},
|
||||
"workflow_dispatch": &WorkflowDispatchEvent{},
|
||||
"workflow_job": &WorkflowJobEvent{},
|
||||
"workflow_run": &WorkflowRunEvent{},
|
||||
}
|
||||
// forward mapping of event types to the string names of the structs
|
||||
// Forward mapping of event types to the string names of the structs.
|
||||
messageToTypeName = make(map[string]string, len(eventTypeMapping))
|
||||
// Inverse map of the above
|
||||
// Inverse map of the above.
|
||||
typeToMessageMapping = make(map[string]string, len(eventTypeMapping))
|
||||
)
|
||||
|
||||
|
|
@ -82,8 +82,8 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos
|
|||
|
||||
body := &startMigration{Repositories: repos}
|
||||
if opts != nil {
|
||||
body.LockRepositories = Bool(opts.LockRepositories)
|
||||
body.ExcludeAttachments = Bool(opts.ExcludeAttachments)
|
||||
body.LockRepositories = Ptr(opts.LockRepositories)
|
||||
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
|
|
@ -75,8 +75,8 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin
|
|||
|
||||
body := &startUserMigration{Repositories: repos}
|
||||
if opts != nil {
|
||||
body.LockRepositories = Bool(opts.LockRepositories)
|
||||
body.ExcludeAttachments = Bool(opts.ExcludeAttachments)
|
||||
body.LockRepositories = Ptr(opts.LockRepositories)
|
||||
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
40
vendor/github.com/google/go-github/v68/github/orgs_attestations.go
generated
vendored
Normal file
40
vendor/github.com/google/go-github/v68/github/orgs_attestations.go
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2024 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"
|
||||
)
|
||||
|
||||
// ListAttestations returns a collection of artifact attestations
|
||||
// with a given subject digest that are associated with repositories
|
||||
// owned by an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/orgs/orgs#list-attestations
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/attestations/{subject_digest}
|
||||
func (s *OrganizationsService) ListAttestations(ctx context.Context, org, subjectDigest string, opts *ListOptions) (*AttestationsResponse, *Response, error) {
|
||||
var u = fmt.Sprintf("orgs/%v/attestations/%v", org, subjectDigest)
|
||||
|
||||
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 attestations *AttestationsResponse
|
||||
resp, err := s.client.Do(ctx, req, &attestations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return attestations, resp, nil
|
||||
}
|
||||
284
vendor/github.com/google/go-github/v68/github/orgs_codesecurity_configurations.go
generated
vendored
Normal file
284
vendor/github.com/google/go-github/v68/github/orgs_codesecurity_configurations.go
generated
vendored
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
// Copyright 2024 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// DependencyGraphAutosubmitActionOptions represents the options for the DependencyGraphAutosubmitAction.
|
||||
type DependencyGraphAutosubmitActionOptions struct {
|
||||
LabeledRunners *bool `json:"labeled_runners,omitempty"`
|
||||
}
|
||||
|
||||
// CodeSecurityConfiguration represents a code security configuration.
|
||||
type CodeSecurityConfiguration struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
TargetType *string `json:"target_type,omitempty"`
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
AdvancedSecurity *string `json:"advanced_security,omitempty"`
|
||||
DependencyGraph *string `json:"dependency_graph,omitempty"`
|
||||
DependencyGraphAutosubmitAction *string `json:"dependency_graph_autosubmit_action,omitempty"`
|
||||
DependencyGraphAutosubmitActionOptions *DependencyGraphAutosubmitActionOptions `json:"dependency_graph_autosubmit_action_options,omitempty"`
|
||||
DependabotAlerts *string `json:"dependabot_alerts,omitempty"`
|
||||
DependabotSecurityUpdates *string `json:"dependabot_security_updates,omitempty"`
|
||||
CodeScanningDefaultSetup *string `json:"code_scanning_default_setup,omitempty"`
|
||||
SecretScanning *string `json:"secret_scanning,omitempty"`
|
||||
SecretScanningPushProtection *string `json:"secret_scanning_push_protection,omitempty"`
|
||||
SecretScanningValidityChecks *string `json:"secret_scanning_validity_checks,omitempty"`
|
||||
SecretScanningNonProviderPatterns *string `json:"secret_scanning_non_provider_patterns,omitempty"`
|
||||
PrivateVulnerabilityReporting *string `json:"private_vulnerability_reporting,omitempty"`
|
||||
Enforcement *string `json:"enforcement,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
// CodeSecurityConfigurationWithDefaultForNewRepos represents a code security configuration with default for new repos param.
|
||||
type CodeSecurityConfigurationWithDefaultForNewRepos struct {
|
||||
Configuration *CodeSecurityConfiguration `json:"configuration"`
|
||||
DefaultForNewRepos *string `json:"default_for_new_repos"`
|
||||
}
|
||||
|
||||
// RepositoryCodeSecurityConfiguration represents a code security configuration for a repository.
|
||||
type RepositoryCodeSecurityConfiguration struct {
|
||||
State *string `json:"state,omitempty"`
|
||||
Configuration *CodeSecurityConfiguration `json:"configuration,omitempty"`
|
||||
}
|
||||
|
||||
// GetCodeSecurityConfigurations gets code security configurations for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-code-security-configurations-for-an-organization
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/code-security/configurations
|
||||
func (s *OrganizationsService) GetCodeSecurityConfigurations(ctx context.Context, org string) ([]*CodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations", org)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var configurations []*CodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &configurations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return configurations, resp, nil
|
||||
}
|
||||
|
||||
// CreateCodeSecurityConfiguration creates a code security configuration for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#create-a-code-security-configuration
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/code-security/configurations
|
||||
func (s *OrganizationsService) CreateCodeSecurityConfiguration(ctx context.Context, org string, c *CodeSecurityConfiguration) (*CodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations", org)
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, c)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var configuration *CodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &configuration)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return configuration, resp, nil
|
||||
}
|
||||
|
||||
// GetDefaultCodeSecurityConfigurations gets default code security configurations for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-default-code-security-configurations
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/code-security/configurations/defaults
|
||||
func (s *OrganizationsService) GetDefaultCodeSecurityConfigurations(ctx context.Context, org string) ([]*CodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/defaults", org)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var configurations []*CodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &configurations)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return configurations, resp, nil
|
||||
}
|
||||
|
||||
// DetachCodeSecurityConfigurationsFromRepositories detaches code security configuration from an organization's repositories.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#detach-configurations-from-repositories
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/code-security/configurations/detach
|
||||
func (s *OrganizationsService) DetachCodeSecurityConfigurationsFromRepositories(ctx context.Context, org string, repoIDs []int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/detach", org)
|
||||
type selectedRepoIDs struct {
|
||||
SelectedIDs []int64 `json:"selected_repository_ids"`
|
||||
}
|
||||
req, err := s.client.NewRequest("DELETE", u, selectedRepoIDs{SelectedIDs: repoIDs})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := s.client.Do(ctx, req, nil)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetCodeSecurityConfiguration gets a code security configuration available in an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-a-code-security-configuration
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/code-security/configurations/{configuration_id}
|
||||
func (s *OrganizationsService) GetCodeSecurityConfiguration(ctx context.Context, org string, id int64) (*CodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var configuration *CodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &configuration)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return configuration, resp, nil
|
||||
}
|
||||
|
||||
// UpdateCodeSecurityConfiguration updates a code security configuration for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#update-a-code-security-configuration
|
||||
//
|
||||
//meta:operation PATCH /orgs/{org}/code-security/configurations/{configuration_id}
|
||||
func (s *OrganizationsService) UpdateCodeSecurityConfiguration(ctx context.Context, org string, id int64, c *CodeSecurityConfiguration) (*CodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
|
||||
|
||||
req, err := s.client.NewRequest("PATCH", u, c)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var configuration *CodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &configuration)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return configuration, resp, nil
|
||||
}
|
||||
|
||||
// DeleteCodeSecurityConfiguration deletes a code security configuration for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#delete-a-code-security-configuration
|
||||
//
|
||||
//meta:operation DELETE /orgs/{org}/code-security/configurations/{configuration_id}
|
||||
func (s *OrganizationsService) DeleteCodeSecurityConfiguration(ctx context.Context, org string, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// AttachCodeSecurityConfigurationsToRepositories attaches code security configurations to repositories for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#attach-a-configuration-to-repositories
|
||||
//
|
||||
//meta:operation POST /orgs/{org}/code-security/configurations/{configuration_id}/attach
|
||||
func (s *OrganizationsService) AttachCodeSecurityConfigurationsToRepositories(ctx context.Context, org string, id int64, scope string, repoIDs []int64) (*Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/attach", org, id)
|
||||
type selectedRepoIDs struct {
|
||||
Scope string `json:"scope"`
|
||||
SelectedIDs []int64 `json:"selected_repository_ids,omitempty"`
|
||||
}
|
||||
req, err := s.client.NewRequest("POST", u, selectedRepoIDs{Scope: scope, SelectedIDs: repoIDs})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := s.client.Do(ctx, req, nil)
|
||||
if err != nil && resp.StatusCode != http.StatusAccepted { // StatusAccepted(202) is the expected status code as job is queued for processing
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// SetDefaultCodeSecurityConfiguration sets a code security configuration as the default for an organization.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization
|
||||
//
|
||||
//meta:operation PUT /orgs/{org}/code-security/configurations/{configuration_id}/defaults
|
||||
func (s *OrganizationsService) SetDefaultCodeSecurityConfiguration(ctx context.Context, org string, id int64, newReposParam string) (*CodeSecurityConfigurationWithDefaultForNewRepos, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/defaults", org, id)
|
||||
type configParam struct {
|
||||
DefaultForNewRepos string `json:"default_for_new_repos"`
|
||||
}
|
||||
req, err := s.client.NewRequest("PUT", u, configParam{DefaultForNewRepos: newReposParam})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
var c *CodeSecurityConfigurationWithDefaultForNewRepos
|
||||
resp, err := s.client.Do(ctx, req, &c)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return c, resp, nil
|
||||
}
|
||||
|
||||
// GetRepositoriesForCodeSecurityConfiguration gets repositories associated with a code security configuration.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-repositories-associated-with-a-code-security-configuration
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories
|
||||
func (s *OrganizationsService) GetRepositoriesForCodeSecurityConfiguration(ctx context.Context, org string, id int64) ([]*Repository, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/repositories", org, id)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var repositories []*Repository
|
||||
resp, err := s.client.Do(ctx, req, &repositories)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return repositories, resp, nil
|
||||
}
|
||||
|
||||
// GetCodeSecurityConfigurationForRepository gets code security configuration that manages a repository's code security settings.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-the-code-security-configuration-associated-with-a-repository
|
||||
//
|
||||
//meta:operation GET /repos/{owner}/{repo}/code-security-configuration
|
||||
func (s *OrganizationsService) GetCodeSecurityConfigurationForRepository(ctx context.Context, org, repo string) (*RepositoryCodeSecurityConfiguration, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/code-security-configuration", org, repo)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
var repoConfig *RepositoryCodeSecurityConfiguration
|
||||
resp, err := s.client.Do(ctx, req, &repoConfig)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return repoConfig, resp, nil
|
||||
}
|
||||
|
|
@ -61,6 +61,29 @@ func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org stri
|
|||
return customRepoRoles, resp, nil
|
||||
}
|
||||
|
||||
// GetCustomRepoRole gets a custom repository roles available in this organization.
|
||||
// In order to see custom repository roles in an organization, the authenticated user must be an organization owner.
|
||||
//
|
||||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#get-a-custom-repository-role
|
||||
//
|
||||
//meta:operation GET /orgs/{org}/custom-repository-roles/{role_id}
|
||||
func (s *OrganizationsService) GetCustomRepoRole(ctx context.Context, org string, roleID int64) (*CustomRepoRoles, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/custom-repository-roles/%v", org, roleID)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
resultingRole := new(CustomRepoRoles)
|
||||
resp, err := s.client.Do(ctx, req, resultingRole)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return resultingRole, resp, nil
|
||||
}
|
||||
|
||||
// CreateCustomRepoRole creates a custom repository role in this organization.
|
||||
// In order to create custom repository roles in an organization, the authenticated user must be an organization owner.
|
||||
//
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue