From 84651d1d8c93c5016e4d19da00eeb38307b6c286 Mon Sep 17 00:00:00 2001 From: billnapier Date: Wed, 4 Oct 2023 08:06:36 -0700 Subject: [PATCH] Add "organization" field to more events (#2949) Fixes: #2950. --- github/event_types.go | 76 ++++++++++++++++ github/github-accessors.go | 152 ++++++++++++++++++++++++++++++++ github/github-accessors_test.go | 133 ++++++++++++++++++++++++++++ 3 files changed, 361 insertions(+) diff --git a/github/event_types.go b/github/event_types.go index 3161384f15d..b3e58b3318f 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -76,6 +76,10 @@ type CommitCommentEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // ContentReferenceEvent is triggered when the body or comment of an issue or @@ -132,6 +136,10 @@ type DeleteEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // DependabotAlertEvent is triggered when there is activity relating to Dependabot alerts. @@ -192,6 +200,10 @@ type DeploymentEvent struct { // The following fields are only populated by Webhook events. Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // DeploymentProtectionRuleEvent represents a deployment protection rule event. @@ -227,6 +239,10 @@ type DeploymentStatusEvent struct { // The following fields are only populated by Webhook events. Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // DiscussionCommentEvent represents a webhook event for a comment on discussion. @@ -363,6 +379,10 @@ type GollumEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // EditChange represents the changes when an issue, pull request, comment, @@ -510,6 +530,10 @@ type InstallationEvent struct { Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` Requester *User `json:"requester,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // InstallationRepositoriesEvent is triggered when a repository is added or @@ -524,6 +548,10 @@ type InstallationRepositoriesEvent struct { RepositorySelection *string `json:"repository_selection,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // InstallationLoginChange represents a change in login on an installation. @@ -603,6 +631,10 @@ type IssuesEvent struct { Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` Milestone *Milestone `json:"milestone,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // LabelEvent is triggered when a repository's label is created, edited, or deleted. @@ -639,6 +671,10 @@ type MarketplacePurchaseEvent struct { PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // MemberEvent is triggered when a user is added as a collaborator to a repository. @@ -654,6 +690,10 @@ type MemberEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // MembershipEvent is triggered when a user is added or removed from a team. @@ -825,6 +865,10 @@ type PageBuildEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // PersonalAccessTokenRequestEvent occurs when there is activity relating to a @@ -885,6 +929,10 @@ type PersonalAccessTokenRequest struct { // Date and time when the associated fine-grained personal access token was last used for authentication. TokenLastUsedAt *Timestamp `json:"token_last_used_at,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // PersonalAccessTokenPermissions represents the original or newly requested @@ -1044,6 +1092,10 @@ type PublicEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // PullRequestEvent is triggered when a pull request is assigned, unassigned, labeled, @@ -1129,6 +1181,10 @@ type PullRequestReviewCommentEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // PullRequestReviewThreadEvent is triggered when a comment made as part of a @@ -1147,6 +1203,10 @@ type PullRequestReviewThreadEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled, @@ -1315,6 +1375,10 @@ type ReleaseEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // RepositoryEvent is triggered when a repository is created, archived, unarchived, @@ -1385,6 +1449,10 @@ type RepositoryVulnerabilityAlertEvent struct { // The user that triggered the event. Sender *User `json:"sender,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // RepositoryVulnerabilityAlert represents a repository security alert. @@ -1491,6 +1559,10 @@ type StatusEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // TeamEvent is triggered when an organization's team is created, modified or deleted. @@ -1561,6 +1633,10 @@ type WatchEvent struct { Repo *Repository `json:"repository,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` + + // The following field is only present when the webhook is triggered on + // a repository belonging to an organization. + Org *Organization `json:"organization,omitempty"` } // WorkflowDispatchEvent is triggered when someone triggers a workflow run on GitHub or diff --git a/github/github-accessors.go b/github/github-accessors.go index 7317081668e..8519de2de9d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -3814,6 +3814,14 @@ func (c *CommitCommentEvent) GetInstallation() *Installation { return c.Installation } +// GetOrg returns the Org field. +func (c *CommitCommentEvent) GetOrg() *Organization { + if c == nil { + return nil + } + return c.Org +} + // GetRepo returns the Repo field. func (c *CommitCommentEvent) GetRepo() *Repository { if c == nil { @@ -5046,6 +5054,14 @@ func (d *DeleteEvent) GetInstallation() *Installation { return d.Installation } +// GetOrg returns the Org field. +func (d *DeleteEvent) GetOrg() *Organization { + if d == nil { + return nil + } + return d.Org +} + // GetPusherType returns the PusherType field if it's non-nil, zero value otherwise. func (d *DeleteEvent) GetPusherType() string { if d == nil || d.PusherType == nil { @@ -5582,6 +5598,14 @@ func (d *DeploymentEvent) GetInstallation() *Installation { return d.Installation } +// GetOrg returns the Org field. +func (d *DeploymentEvent) GetOrg() *Organization { + if d == nil { + return nil + } + return d.Org +} + // GetRepo returns the Repo field. func (d *DeploymentEvent) GetRepo() *Repository { if d == nil { @@ -5886,6 +5910,14 @@ func (d *DeploymentStatusEvent) GetInstallation() *Installation { return d.Installation } +// GetOrg returns the Org field. +func (d *DeploymentStatusEvent) GetOrg() *Organization { + if d == nil { + return nil + } + return d.Org +} + // GetRepo returns the Repo field. func (d *DeploymentStatusEvent) GetRepo() *Repository { if d == nil { @@ -7686,6 +7718,14 @@ func (g *GollumEvent) GetInstallation() *Installation { return g.Installation } +// GetOrg returns the Org field. +func (g *GollumEvent) GetOrg() *Organization { + if g == nil { + return nil + } + return g.Org +} + // GetRepo returns the Repo field. func (g *GollumEvent) GetRepo() *Repository { if g == nil { @@ -8558,6 +8598,14 @@ func (i *InstallationEvent) GetInstallation() *Installation { return i.Installation } +// GetOrg returns the Org field. +func (i *InstallationEvent) GetOrg() *Organization { + if i == nil { + return nil + } + return i.Org +} + // GetRequester returns the Requester field. func (i *InstallationEvent) GetRequester() *User { if i == nil { @@ -8894,6 +8942,14 @@ func (i *InstallationRepositoriesEvent) GetInstallation() *Installation { return i.Installation } +// GetOrg returns the Org field. +func (i *InstallationRepositoriesEvent) GetOrg() *Organization { + if i == nil { + return nil + } + return i.Org +} + // GetRepositorySelection returns the RepositorySelection field if it's non-nil, zero value otherwise. func (i *InstallationRepositoriesEvent) GetRepositorySelection() string { if i == nil || i.RepositorySelection == nil { @@ -9998,6 +10054,14 @@ func (i *IssuesEvent) GetMilestone() *Milestone { return i.Milestone } +// GetOrg returns the Org field. +func (i *IssuesEvent) GetOrg() *Organization { + if i == nil { + return nil + } + return i.Org +} + // GetRepo returns the Repo field. func (i *IssuesEvent) GetRepo() *Repository { if i == nil { @@ -11046,6 +11110,14 @@ func (m *MarketplacePurchaseEvent) GetMarketplacePurchase() *MarketplacePurchase return m.MarketplacePurchase } +// GetOrg returns the Org field. +func (m *MarketplacePurchaseEvent) GetOrg() *Organization { + if m == nil { + return nil + } + return m.Org +} + // GetPreviousMarketplacePurchase returns the PreviousMarketplacePurchase field. func (m *MarketplacePurchaseEvent) GetPreviousMarketplacePurchase() *MarketplacePurchase { if m == nil { @@ -11094,6 +11166,14 @@ func (m *MemberEvent) GetMember() *User { return m.Member } +// GetOrg returns the Org field. +func (m *MemberEvent) GetOrg() *Organization { + if m == nil { + return nil + } + return m.Org +} + // GetRepo returns the Repo field. func (m *MemberEvent) GetRepo() *Repository { if m == nil { @@ -13326,6 +13406,14 @@ func (p *PageBuildEvent) GetInstallation() *Installation { return p.Installation } +// GetOrg returns the Org field. +func (p *PageBuildEvent) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + // GetRepo returns the Repo field. func (p *PageBuildEvent) GetRepo() *Repository { if p == nil { @@ -13862,6 +13950,14 @@ func (p *PersonalAccessTokenRequest) GetID() int64 { return *p.ID } +// GetOrg returns the Org field. +func (p *PersonalAccessTokenRequest) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + // GetOwner returns the Owner field. func (p *PersonalAccessTokenRequest) GetOwner() *User { if p == nil { @@ -15454,6 +15550,14 @@ func (p *PublicEvent) GetInstallation() *Installation { return p.Installation } +// GetOrg returns the Org field. +func (p *PublicEvent) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + // GetRepo returns the Repo field. func (p *PublicEvent) GetRepo() *Repository { if p == nil { @@ -16430,6 +16534,14 @@ func (p *PullRequestReviewCommentEvent) GetInstallation() *Installation { return p.Installation } +// GetOrg returns the Org field. +func (p *PullRequestReviewCommentEvent) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + // GetPullRequest returns the PullRequest field. func (p *PullRequestReviewCommentEvent) GetPullRequest() *PullRequest { if p == nil { @@ -16654,6 +16766,14 @@ func (p *PullRequestReviewThreadEvent) GetInstallation() *Installation { return p.Installation } +// GetOrg returns the Org field. +func (p *PullRequestReviewThreadEvent) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + // GetPullRequest returns the PullRequest field. func (p *PullRequestReviewThreadEvent) GetPullRequest() *PullRequest { if p == nil { @@ -17686,6 +17806,14 @@ func (r *ReleaseEvent) GetInstallation() *Installation { return r.Installation } +// GetOrg returns the Org field. +func (r *ReleaseEvent) GetOrg() *Organization { + if r == nil { + return nil + } + return r.Org +} + // GetRelease returns the Release field. func (r *ReleaseEvent) GetRelease() *RepositoryRelease { if r == nil { @@ -19774,6 +19902,14 @@ func (r *RepositoryVulnerabilityAlertEvent) GetInstallation() *Installation { return r.Installation } +// GetOrg returns the Org field. +func (r *RepositoryVulnerabilityAlertEvent) GetOrg() *Organization { + if r == nil { + return nil + } + return r.Org +} + // GetRepository returns the Repository field. func (r *RepositoryVulnerabilityAlertEvent) GetRepository() *Repository { if r == nil { @@ -21622,6 +21758,14 @@ func (s *StatusEvent) GetName() string { return *s.Name } +// GetOrg returns the Org field. +func (s *StatusEvent) GetOrg() *Organization { + if s == nil { + return nil + } + return s.Org +} + // GetRepo returns the Repo field. func (s *StatusEvent) GetRepo() *Repository { if s == nil { @@ -23950,6 +24094,14 @@ func (w *WatchEvent) GetInstallation() *Installation { return w.Installation } +// GetOrg returns the Org field. +func (w *WatchEvent) GetOrg() *Organization { + if w == nil { + return nil + } + return w.Org +} + // GetRepo returns the Repo field. func (w *WatchEvent) GetRepo() *Repository { if w == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index bdb4209a270..c3e02988ae7 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4519,6 +4519,13 @@ func TestCommitCommentEvent_GetInstallation(tt *testing.T) { c.GetInstallation() } +func TestCommitCommentEvent_GetOrg(tt *testing.T) { + c := &CommitCommentEvent{} + c.GetOrg() + c = nil + c.GetOrg() +} + func TestCommitCommentEvent_GetRepo(tt *testing.T) { c := &CommitCommentEvent{} c.GetRepo() @@ -5969,6 +5976,13 @@ func TestDeleteEvent_GetInstallation(tt *testing.T) { d.GetInstallation() } +func TestDeleteEvent_GetOrg(tt *testing.T) { + d := &DeleteEvent{} + d.GetOrg() + d = nil + d.GetOrg() +} + func TestDeleteEvent_GetPusherType(tt *testing.T) { var zeroValue string d := &DeleteEvent{PusherType: &zeroValue} @@ -6570,6 +6584,13 @@ func TestDeploymentEvent_GetInstallation(tt *testing.T) { d.GetInstallation() } +func TestDeploymentEvent_GetOrg(tt *testing.T) { + d := &DeploymentEvent{} + d.GetOrg() + d = nil + d.GetOrg() +} + func TestDeploymentEvent_GetRepo(tt *testing.T) { d := &DeploymentEvent{} d.GetRepo() @@ -6911,6 +6932,13 @@ func TestDeploymentStatusEvent_GetInstallation(tt *testing.T) { d.GetInstallation() } +func TestDeploymentStatusEvent_GetOrg(tt *testing.T) { + d := &DeploymentStatusEvent{} + d.GetOrg() + d = nil + d.GetOrg() +} + func TestDeploymentStatusEvent_GetRepo(tt *testing.T) { d := &DeploymentStatusEvent{} d.GetRepo() @@ -9011,6 +9039,13 @@ func TestGollumEvent_GetInstallation(tt *testing.T) { g.GetInstallation() } +func TestGollumEvent_GetOrg(tt *testing.T) { + g := &GollumEvent{} + g.GetOrg() + g = nil + g.GetOrg() +} + func TestGollumEvent_GetRepo(tt *testing.T) { g := &GollumEvent{} g.GetRepo() @@ -10059,6 +10094,13 @@ func TestInstallationEvent_GetInstallation(tt *testing.T) { i.GetInstallation() } +func TestInstallationEvent_GetOrg(tt *testing.T) { + i := &InstallationEvent{} + i.GetOrg() + i = nil + i.GetOrg() +} + func TestInstallationEvent_GetRequester(tt *testing.T) { i := &InstallationEvent{} i.GetRequester() @@ -10470,6 +10512,13 @@ func TestInstallationRepositoriesEvent_GetInstallation(tt *testing.T) { i.GetInstallation() } +func TestInstallationRepositoriesEvent_GetOrg(tt *testing.T) { + i := &InstallationRepositoriesEvent{} + i.GetOrg() + i = nil + i.GetOrg() +} + func TestInstallationRepositoriesEvent_GetRepositorySelection(tt *testing.T) { var zeroValue string i := &InstallationRepositoriesEvent{RepositorySelection: &zeroValue} @@ -11706,6 +11755,13 @@ func TestIssuesEvent_GetMilestone(tt *testing.T) { i.GetMilestone() } +func TestIssuesEvent_GetOrg(tt *testing.T) { + i := &IssuesEvent{} + i.GetOrg() + i = nil + i.GetOrg() +} + func TestIssuesEvent_GetRepo(tt *testing.T) { i := &IssuesEvent{} i.GetRepo() @@ -12965,6 +13021,13 @@ func TestMarketplacePurchaseEvent_GetMarketplacePurchase(tt *testing.T) { m.GetMarketplacePurchase() } +func TestMarketplacePurchaseEvent_GetOrg(tt *testing.T) { + m := &MarketplacePurchaseEvent{} + m.GetOrg() + m = nil + m.GetOrg() +} + func TestMarketplacePurchaseEvent_GetPreviousMarketplacePurchase(tt *testing.T) { m := &MarketplacePurchaseEvent{} m.GetPreviousMarketplacePurchase() @@ -13013,6 +13076,13 @@ func TestMemberEvent_GetMember(tt *testing.T) { m.GetMember() } +func TestMemberEvent_GetOrg(tt *testing.T) { + m := &MemberEvent{} + m.GetOrg() + m = nil + m.GetOrg() +} + func TestMemberEvent_GetRepo(tt *testing.T) { m := &MemberEvent{} m.GetRepo() @@ -15620,6 +15690,13 @@ func TestPageBuildEvent_GetInstallation(tt *testing.T) { p.GetInstallation() } +func TestPageBuildEvent_GetOrg(tt *testing.T) { + p := &PageBuildEvent{} + p.GetOrg() + p = nil + p.GetOrg() +} + func TestPageBuildEvent_GetRepo(tt *testing.T) { p := &PageBuildEvent{} p.GetRepo() @@ -16263,6 +16340,13 @@ func TestPersonalAccessTokenRequest_GetID(tt *testing.T) { p.GetID() } +func TestPersonalAccessTokenRequest_GetOrg(tt *testing.T) { + p := &PersonalAccessTokenRequest{} + p.GetOrg() + p = nil + p.GetOrg() +} + func TestPersonalAccessTokenRequest_GetOwner(tt *testing.T) { p := &PersonalAccessTokenRequest{} p.GetOwner() @@ -17980,6 +18064,13 @@ func TestPublicEvent_GetInstallation(tt *testing.T) { p.GetInstallation() } +func TestPublicEvent_GetOrg(tt *testing.T) { + p := &PublicEvent{} + p.GetOrg() + p = nil + p.GetOrg() +} + func TestPublicEvent_GetRepo(tt *testing.T) { p := &PublicEvent{} p.GetRepo() @@ -19110,6 +19201,13 @@ func TestPullRequestReviewCommentEvent_GetInstallation(tt *testing.T) { p.GetInstallation() } +func TestPullRequestReviewCommentEvent_GetOrg(tt *testing.T) { + p := &PullRequestReviewCommentEvent{} + p.GetOrg() + p = nil + p.GetOrg() +} + func TestPullRequestReviewCommentEvent_GetPullRequest(tt *testing.T) { p := &PullRequestReviewCommentEvent{} p.GetPullRequest() @@ -19342,6 +19440,13 @@ func TestPullRequestReviewThreadEvent_GetInstallation(tt *testing.T) { p.GetInstallation() } +func TestPullRequestReviewThreadEvent_GetOrg(tt *testing.T) { + p := &PullRequestReviewThreadEvent{} + p.GetOrg() + p = nil + p.GetOrg() +} + func TestPullRequestReviewThreadEvent_GetPullRequest(tt *testing.T) { p := &PullRequestReviewThreadEvent{} p.GetPullRequest() @@ -20530,6 +20635,13 @@ func TestReleaseEvent_GetInstallation(tt *testing.T) { r.GetInstallation() } +func TestReleaseEvent_GetOrg(tt *testing.T) { + r := &ReleaseEvent{} + r.GetOrg() + r = nil + r.GetOrg() +} + func TestReleaseEvent_GetRelease(tt *testing.T) { r := &ReleaseEvent{} r.GetRelease() @@ -23011,6 +23123,13 @@ func TestRepositoryVulnerabilityAlertEvent_GetInstallation(tt *testing.T) { r.GetInstallation() } +func TestRepositoryVulnerabilityAlertEvent_GetOrg(tt *testing.T) { + r := &RepositoryVulnerabilityAlertEvent{} + r.GetOrg() + r = nil + r.GetOrg() +} + func TestRepositoryVulnerabilityAlertEvent_GetRepository(tt *testing.T) { r := &RepositoryVulnerabilityAlertEvent{} r.GetRepository() @@ -25165,6 +25284,13 @@ func TestStatusEvent_GetName(tt *testing.T) { s.GetName() } +func TestStatusEvent_GetOrg(tt *testing.T) { + s := &StatusEvent{} + s.GetOrg() + s = nil + s.GetOrg() +} + func TestStatusEvent_GetRepo(tt *testing.T) { s := &StatusEvent{} s.GetRepo() @@ -27925,6 +28051,13 @@ func TestWatchEvent_GetInstallation(tt *testing.T) { w.GetInstallation() } +func TestWatchEvent_GetOrg(tt *testing.T) { + w := &WatchEvent{} + w.GetOrg() + w = nil + w.GetOrg() +} + func TestWatchEvent_GetRepo(tt *testing.T) { w := &WatchEvent{} w.GetRepo()