diff --git a/github/event_types.go b/github/event_types.go index 1a403da9b9d..3161384f15d 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1086,6 +1086,9 @@ type PullRequestEvent struct { // The following fields are only populated when the Action is "synchronize". Before *string `json:"before,omitempty"` After *string `json:"after,omitempty"` + + // The following will be populated if the event was performed by an App + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // PullRequestReviewEvent is triggered when a review is submitted on a pull @@ -1186,6 +1189,9 @@ type PullRequestTargetEvent struct { // The following fields are only populated when the Action is "synchronize". Before *string `json:"before,omitempty"` After *string `json:"after,omitempty"` + + // The following will be populated if the event was performed by an App + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // PushEvent represents a git push to a GitHub repository. diff --git a/github/event_types_test.go b/github/event_types_test.go index 31b94479f3b..91ac291205f 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -15177,6 +15177,15 @@ func TestPullRequestEvent_Marshal(t *testing.T) { URL: String("s"), Name: String("n"), }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Slug: String("s"), + Name: String("n"), + Description: String("d"), + ExternalURL: String("e"), + HTMLURL: String("h"), + }, Organization: &Organization{ BillingEmail: String("be"), Blog: String("b"), @@ -15346,11 +15355,47 @@ func TestPullRequestEvent_Marshal(t *testing.T) { "requested_team": { "id": 1 }, + "label": { + "id": 1 + }, + "before": "before", + "after": "after", "repository": { "id": 1, "name": "n", "url": "s" }, + "performed_via_github_app": { + "id": 1, + "node_id": "n", + "slug": "s", + "name": "n", + "description": "d", + "external_url": "e", + "html_url": "h" + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, "sender": { "login": "l", "id": 1, @@ -15456,34 +15501,7 @@ func TestPullRequestEvent_Marshal(t *testing.T) { "url": "u" }, "suspended_at": ` + referenceTimeStr + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" + } }` testJSONMarshal(t, u, want) @@ -16060,6 +16078,15 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { URL: String("s"), Name: String("n"), }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Slug: String("s"), + Name: String("n"), + Description: String("d"), + ExternalURL: String("e"), + HTMLURL: String("h"), + }, Organization: &Organization{ BillingEmail: String("be"), Blog: String("b"), @@ -16229,11 +16256,47 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { "requested_team": { "id": 1 }, + "label": { + "id": 1 + }, + "before": "before", + "after": "after", "repository": { "id": 1, "name": "n", "url": "s" }, + "performed_via_github_app": { + "id": 1, + "node_id": "n", + "slug": "s", + "name": "n", + "description": "d", + "external_url": "e", + "html_url": "h" + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, "sender": { "login": "l", "id": 1, @@ -16339,34 +16402,7 @@ func TestPullRequestTargetEvent_Marshal(t *testing.T) { "url": "u" }, "suspended_at": ` + referenceTimeStr + ` - }, - "label": { - "id": 1 - }, - "organization": { - "name": "n", - "company": "c", - "blog": "b", - "location": "loc", - "email": "e", - "twitter_username": "tu", - "description": "d", - "billing_email": "be", - "is_verified": true, - "has_organization_projects": true, - "has_repository_projects": true, - "default_repository_permission": "drp", - "members_can_create_repositories": true, - "members_can_create_public_repositories": false, - "members_can_create_private_repositories": true, - "members_can_create_internal_repositories": true, - "members_allowed_repository_creation_type": "marct", - "members_can_create_pages": true, - "members_can_create_public_pages": false, - "members_can_create_private_pages": true - }, - "before": "before", - "after": "after" + } }` testJSONMarshal(t, u, want) diff --git a/github/github-accessors.go b/github/github-accessors.go index b305bfc6448..bb65af6800d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9598,6 +9598,14 @@ func (i *IssueEvent) GetMilestone() *Milestone { return i.Milestone } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (i *IssueEvent) GetPerformedViaGithubApp() *App { + if i == nil { + return nil + } + return i.PerformedViaGithubApp +} + // GetProjectCard returns the ProjectCard field. func (i *IssueEvent) GetProjectCard() *ProjectCard { if i == nil { @@ -9622,6 +9630,14 @@ func (i *IssueEvent) GetRequestedReviewer() *User { return i.RequestedReviewer } +// GetRequestedTeam returns the RequestedTeam field. +func (i *IssueEvent) GetRequestedTeam() *Team { + if i == nil { + return nil + } + return i.RequestedTeam +} + // GetReviewRequester returns the ReviewRequester field. func (i *IssueEvent) GetReviewRequester() *User { if i == nil { @@ -16158,6 +16174,14 @@ func (p *PullRequestEvent) GetOrganization() *Organization { return p.Organization } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (p *PullRequestEvent) GetPerformedViaGithubApp() *App { + if p == nil { + return nil + } + return p.PerformedViaGithubApp +} + // GetPullRequest returns the PullRequest field. func (p *PullRequestEvent) GetPullRequest() *PullRequest { if p == nil { @@ -16694,6 +16718,14 @@ func (p *PullRequestTargetEvent) GetOrganization() *Organization { return p.Organization } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (p *PullRequestTargetEvent) GetPerformedViaGithubApp() *App { + if p == nil { + return nil + } + return p.PerformedViaGithubApp +} + // GetPullRequest returns the PullRequest field. func (p *PullRequestTargetEvent) GetPullRequest() *PullRequest { if p == nil { @@ -22526,6 +22558,14 @@ func (t *Timeline) GetMilestone() *Milestone { return t.Milestone } +// GetPerformedViaGithubApp returns the PerformedViaGithubApp field. +func (t *Timeline) GetPerformedViaGithubApp() *App { + if t == nil { + return nil + } + return t.PerformedViaGithubApp +} + // GetProjectCard returns the ProjectCard field. func (t *Timeline) GetProjectCard() *ProjectCard { if t == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 962e5e8f733..0ad058b10cc 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -11248,6 +11248,13 @@ func TestIssueEvent_GetMilestone(tt *testing.T) { i.GetMilestone() } +func TestIssueEvent_GetPerformedViaGithubApp(tt *testing.T) { + i := &IssueEvent{} + i.GetPerformedViaGithubApp() + i = nil + i.GetPerformedViaGithubApp() +} + func TestIssueEvent_GetProjectCard(tt *testing.T) { i := &IssueEvent{} i.GetProjectCard() @@ -11269,6 +11276,13 @@ func TestIssueEvent_GetRequestedReviewer(tt *testing.T) { i.GetRequestedReviewer() } +func TestIssueEvent_GetRequestedTeam(tt *testing.T) { + i := &IssueEvent{} + i.GetRequestedTeam() + i = nil + i.GetRequestedTeam() +} + func TestIssueEvent_GetReviewRequester(tt *testing.T) { i := &IssueEvent{} i.GetReviewRequester() @@ -18812,6 +18826,13 @@ func TestPullRequestEvent_GetOrganization(tt *testing.T) { p.GetOrganization() } +func TestPullRequestEvent_GetPerformedViaGithubApp(tt *testing.T) { + p := &PullRequestEvent{} + p.GetPerformedViaGithubApp() + p = nil + p.GetPerformedViaGithubApp() +} + func TestPullRequestEvent_GetPullRequest(tt *testing.T) { p := &PullRequestEvent{} p.GetPullRequest() @@ -19380,6 +19401,13 @@ func TestPullRequestTargetEvent_GetOrganization(tt *testing.T) { p.GetOrganization() } +func TestPullRequestTargetEvent_GetPerformedViaGithubApp(tt *testing.T) { + p := &PullRequestTargetEvent{} + p.GetPerformedViaGithubApp() + p = nil + p.GetPerformedViaGithubApp() +} + func TestPullRequestTargetEvent_GetPullRequest(tt *testing.T) { p := &PullRequestTargetEvent{} p.GetPullRequest() @@ -26214,6 +26242,13 @@ func TestTimeline_GetMilestone(tt *testing.T) { t.GetMilestone() } +func TestTimeline_GetPerformedViaGithubApp(tt *testing.T) { + t := &Timeline{} + t.GetPerformedViaGithubApp() + t = nil + t.GetPerformedViaGithubApp() +} + func TestTimeline_GetProjectCard(tt *testing.T) { t := &Timeline{} t.GetProjectCard() diff --git a/github/issues_events.go b/github/issues_events.go index ed076591701..0305fca1168 100644 --- a/github/issues_events.go +++ b/github/issues_events.go @@ -66,7 +66,7 @@ type IssueEvent struct { // // review_requested, review_request_removed // The Actor requested or removed the request for a review. - // RequestedReviewer and ReviewRequester will be populated below. + // RequestedReviewer or RequestedTeam, and ReviewRequester will be populated below. // Event *string `json:"event,omitempty"` @@ -74,17 +74,19 @@ type IssueEvent struct { Issue *Issue `json:"issue,omitempty"` // Only present on certain events; see above. - Assignee *User `json:"assignee,omitempty"` - Assigner *User `json:"assigner,omitempty"` - CommitID *string `json:"commit_id,omitempty"` - Milestone *Milestone `json:"milestone,omitempty"` - 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"` - ReviewRequester *User `json:"review_requester,omitempty"` + Assignee *User `json:"assignee,omitempty"` + Assigner *User `json:"assigner,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + 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"` + ReviewRequester *User `json:"review_requester,omitempty"` + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // DismissedReview represents details for 'dismissed_review' events. diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 1d8d3233d19..e8118b6ddcd 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -270,6 +270,62 @@ func TestIssueEvent_Marshal(t *testing.T) { CreatedAt: &Timestamp{referenceTime}, SuspendedAt: &Timestamp{referenceTime}, }, + RequestedTeam: &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + MembersURL: String("m"), + RepositoriesURL: String("r"), + Organization: &Organization{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + AvatarURL: String("a"), + HTMLURL: String("h"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + }, + Parent: &Team{ + ID: Int64(1), + NodeID: String("n"), + Name: String("n"), + Description: String("d"), + URL: String("u"), + Slug: String("s"), + Permission: String("p"), + Privacy: String("p"), + MembersCount: Int(1), + ReposCount: Int(1), + }, + LDAPDN: String("l"), + }, + PerformedViaGithubApp: &App{ + ID: Int64(1), + NodeID: String("n"), + Owner: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + Name: String("n"), + Description: String("d"), + HTMLURL: String("h"), + ExternalURL: String("u"), + }, ReviewRequester: &User{ Login: String("l"), ID: Int64(1), @@ -401,6 +457,62 @@ func TestIssueEvent_Marshal(t *testing.T) { "suspended_at": ` + referenceTimeStr + `, "url": "u" }, + "requested_team": { + "id": 1, + "node_id": "n", + "name": "n", + "description": "d", + "url": "u", + "slug": "s", + "permission": "p", + "privacy": "p", + "members_count": 1, + "repos_count": 1, + "members_url": "m", + "repositories_url": "r", + "organization": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "html_url": "h", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e" + }, + "parent": { + "id": 1, + "node_id": "n", + "name": "n", + "description": "d", + "url": "u", + "slug": "s", + "permission": "p", + "privacy": "p", + "members_count": 1, + "repos_count": 1 + }, + "ldap_dn": "l" + }, + "performed_via_github_app": { + "id": 1, + "node_id": "n", + "owner": { + "login": "l", + "id": 1, + "node_id": "n", + "url": "u", + "repos_url": "r", + "events_url": "e", + "avatar_url": "a" + }, + "name": "n", + "description": "d", + "html_url": "h", + "external_url": "u" + }, "review_requester": { "login": "l", "id": 1, diff --git a/github/issues_timeline.go b/github/issues_timeline.go index 9c73e6176d1..8ac02ac14dc 100644 --- a/github/issues_timeline.go +++ b/github/issues_timeline.go @@ -151,6 +151,8 @@ type Timeline struct { // The review summary text. Body *string `json:"body,omitempty"` SubmittedAt *Timestamp `json:"submitted_at,omitempty"` + + PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` } // Source represents a reference's source.