From 9fb1d21feecb7f79ce3489a3cb967000ab77bf9d Mon Sep 17 00:00:00 2001 From: abhishek Date: Sun, 27 Jul 2025 01:08:58 +0530 Subject: [PATCH 1/4] feat: Implement List Repository Activities endpoint Adds support for the /repos/{owner}/{repo}/activity REST API endpoint. This implements the List Repository Activities functionality introduced in GitHub API v2022-11-28, allowing clients to retrieve detailed activity data for repositories. Includes: - New RepositoryActivity struct and related types - ListRepositoryActivitiesOptions for pagination and filtering - Implementation in RepositoriesService with tests - Documentation with examples Ref: #3649 Signed-off-by: abhishek --- github/github-accessors.go | 168 +++++++++++++++++ github/github-accessors_test.go | 228 +++++++++++++++++++++++ github/repos.go | 72 ++++++++ github/repos_test.go | 310 ++++++++++++++++++++++++++++++++ openapi_operations.yaml | 190 +++++++++++++++++--- 5 files changed, 939 insertions(+), 29 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 7edf3a4cdf0..ba65fefb3ac 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -238,6 +238,158 @@ func (a *ActionsVariable) GetVisibility() string { return *a.Visibility } +// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetAvatarURL() string { + if a == nil || a.AvatarURL == nil { + return "" + } + return *a.AvatarURL +} + +// GetEventsURL returns the EventsURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetEventsURL() string { + if a == nil || a.EventsURL == nil { + return "" + } + return *a.EventsURL +} + +// GetFollowersURL returns the FollowersURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetFollowersURL() string { + if a == nil || a.FollowersURL == nil { + return "" + } + return *a.FollowersURL +} + +// GetFollowingURL returns the FollowingURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetFollowingURL() string { + if a == nil || a.FollowingURL == nil { + return "" + } + return *a.FollowingURL +} + +// GetGistsURL returns the GistsURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetGistsURL() string { + if a == nil || a.GistsURL == nil { + return "" + } + return *a.GistsURL +} + +// GetGravatarID returns the GravatarID field if it's non-nil, zero value otherwise. +func (a *Actor) GetGravatarID() string { + if a == nil || a.GravatarID == nil { + return "" + } + return *a.GravatarID +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetHTMLURL() string { + if a == nil || a.HTMLURL == nil { + return "" + } + return *a.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *Actor) GetID() int64 { + if a == nil || a.ID == nil { + return 0 + } + return *a.ID +} + +// GetLogin returns the Login field if it's non-nil, zero value otherwise. +func (a *Actor) GetLogin() string { + if a == nil || a.Login == nil { + return "" + } + return *a.Login +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (a *Actor) GetNodeID() string { + if a == nil || a.NodeID == nil { + return "" + } + return *a.NodeID +} + +// GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetOrganizationsURL() string { + if a == nil || a.OrganizationsURL == nil { + return "" + } + return *a.OrganizationsURL +} + +// GetReceivedEventsURL returns the ReceivedEventsURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetReceivedEventsURL() string { + if a == nil || a.ReceivedEventsURL == nil { + return "" + } + return *a.ReceivedEventsURL +} + +// GetReposURL returns the ReposURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetReposURL() string { + if a == nil || a.ReposURL == nil { + return "" + } + return *a.ReposURL +} + +// GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. +func (a *Actor) GetSiteAdmin() bool { + if a == nil || a.SiteAdmin == nil { + return false + } + return *a.SiteAdmin +} + +// GetStarredURL returns the StarredURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetStarredURL() string { + if a == nil || a.StarredURL == nil { + return "" + } + return *a.StarredURL +} + +// GetSubscriptionsURL returns the SubscriptionsURL field if it's non-nil, zero value otherwise. +func (a *Actor) GetSubscriptionsURL() string { + if a == nil || a.SubscriptionsURL == nil { + return "" + } + return *a.SubscriptionsURL +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (a *Actor) GetType() string { + if a == nil || a.Type == nil { + return "" + } + return *a.Type +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (a *Actor) GetURL() string { + if a == nil || a.URL == nil { + return "" + } + return *a.URL +} + +// GetUserViewType returns the UserViewType field if it's non-nil, zero value otherwise. +func (a *Actor) GetUserViewType() string { + if a == nil || a.UserViewType == nil { + return "" + } + return *a.UserViewType +} + // GetCountryCode returns the CountryCode field if it's non-nil, zero value otherwise. func (a *ActorLocation) GetCountryCode() string { if a == nil || a.CountryCode == nil { @@ -22406,6 +22558,22 @@ func (r *RepositoryActiveCommitters) GetName() string { return *r.Name } +// GetActor returns the Actor field. +func (r *RepositoryActivity) GetActor() *Actor { + if r == nil { + return nil + } + return r.Actor +} + +// GetTimestamp returns the Timestamp field if it's non-nil, zero value otherwise. +func (r *RepositoryActivity) GetTimestamp() Timestamp { + if r == nil || r.Timestamp == nil { + return Timestamp{} + } + return *r.Timestamp +} + // GetConfiguration returns the Configuration field. func (r *RepositoryCodeSecurityConfiguration) GetConfiguration() *CodeSecurityConfiguration { if r == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 38a1fda432e..ec5b93db995 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -320,6 +320,215 @@ func TestActionsVariable_GetVisibility(tt *testing.T) { a.GetVisibility() } +func TestActor_GetAvatarURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{AvatarURL: &zeroValue} + a.GetAvatarURL() + a = &Actor{} + a.GetAvatarURL() + a = nil + a.GetAvatarURL() +} + +func TestActor_GetEventsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{EventsURL: &zeroValue} + a.GetEventsURL() + a = &Actor{} + a.GetEventsURL() + a = nil + a.GetEventsURL() +} + +func TestActor_GetFollowersURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{FollowersURL: &zeroValue} + a.GetFollowersURL() + a = &Actor{} + a.GetFollowersURL() + a = nil + a.GetFollowersURL() +} + +func TestActor_GetFollowingURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{FollowingURL: &zeroValue} + a.GetFollowingURL() + a = &Actor{} + a.GetFollowingURL() + a = nil + a.GetFollowingURL() +} + +func TestActor_GetGistsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{GistsURL: &zeroValue} + a.GetGistsURL() + a = &Actor{} + a.GetGistsURL() + a = nil + a.GetGistsURL() +} + +func TestActor_GetGravatarID(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{GravatarID: &zeroValue} + a.GetGravatarID() + a = &Actor{} + a.GetGravatarID() + a = nil + a.GetGravatarID() +} + +func TestActor_GetHTMLURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{HTMLURL: &zeroValue} + a.GetHTMLURL() + a = &Actor{} + a.GetHTMLURL() + a = nil + a.GetHTMLURL() +} + +func TestActor_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + a := &Actor{ID: &zeroValue} + a.GetID() + a = &Actor{} + a.GetID() + a = nil + a.GetID() +} + +func TestActor_GetLogin(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{Login: &zeroValue} + a.GetLogin() + a = &Actor{} + a.GetLogin() + a = nil + a.GetLogin() +} + +func TestActor_GetNodeID(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{NodeID: &zeroValue} + a.GetNodeID() + a = &Actor{} + a.GetNodeID() + a = nil + a.GetNodeID() +} + +func TestActor_GetOrganizationsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{OrganizationsURL: &zeroValue} + a.GetOrganizationsURL() + a = &Actor{} + a.GetOrganizationsURL() + a = nil + a.GetOrganizationsURL() +} + +func TestActor_GetReceivedEventsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{ReceivedEventsURL: &zeroValue} + a.GetReceivedEventsURL() + a = &Actor{} + a.GetReceivedEventsURL() + a = nil + a.GetReceivedEventsURL() +} + +func TestActor_GetReposURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{ReposURL: &zeroValue} + a.GetReposURL() + a = &Actor{} + a.GetReposURL() + a = nil + a.GetReposURL() +} + +func TestActor_GetSiteAdmin(tt *testing.T) { + tt.Parallel() + var zeroValue bool + a := &Actor{SiteAdmin: &zeroValue} + a.GetSiteAdmin() + a = &Actor{} + a.GetSiteAdmin() + a = nil + a.GetSiteAdmin() +} + +func TestActor_GetStarredURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{StarredURL: &zeroValue} + a.GetStarredURL() + a = &Actor{} + a.GetStarredURL() + a = nil + a.GetStarredURL() +} + +func TestActor_GetSubscriptionsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{SubscriptionsURL: &zeroValue} + a.GetSubscriptionsURL() + a = &Actor{} + a.GetSubscriptionsURL() + a = nil + a.GetSubscriptionsURL() +} + +func TestActor_GetType(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{Type: &zeroValue} + a.GetType() + a = &Actor{} + a.GetType() + a = nil + a.GetType() +} + +func TestActor_GetURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{URL: &zeroValue} + a.GetURL() + a = &Actor{} + a.GetURL() + a = nil + a.GetURL() +} + +func TestActor_GetUserViewType(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Actor{UserViewType: &zeroValue} + a.GetUserViewType() + a = &Actor{} + a.GetUserViewType() + a = nil + a.GetUserViewType() +} + func TestActorLocation_GetCountryCode(tt *testing.T) { tt.Parallel() var zeroValue string @@ -28938,6 +29147,25 @@ func TestRepositoryActiveCommitters_GetName(tt *testing.T) { r.GetName() } +func TestRepositoryActivity_GetActor(tt *testing.T) { + tt.Parallel() + r := &RepositoryActivity{} + r.GetActor() + r = nil + r.GetActor() +} + +func TestRepositoryActivity_GetTimestamp(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + r := &RepositoryActivity{Timestamp: &zeroValue} + r.GetTimestamp() + r = &RepositoryActivity{} + r.GetTimestamp() + r = nil + r.GetTimestamp() +} + func TestRepositoryCodeSecurityConfiguration_GetConfiguration(tt *testing.T) { tt.Parallel() r := &RepositoryCodeSecurityConfiguration{} diff --git a/github/repos.go b/github/repos.go index c8df90908e2..9ebfd1d1f9b 100644 --- a/github/repos.go +++ b/github/repos.go @@ -2438,3 +2438,75 @@ func (s *RepositoriesService) IsPrivateReportingEnabled(ctx context.Context, own resp, err := s.client.Do(ctx, req, privateReporting) return privateReporting.Enabled, resp, err } + +type RepositoryActivityOptions struct { + Direction string `url:"direction,omitempty"` + Before string `url:"before,omitempty"` + After string `url:"after,omitempty"` + Ref string `url:"ref,omitempty"` + Actor string `url:"actor,omitempty"` + TimePeriod string `url:"time_period,omitempty"` + ActivityType string `url:"activity_type,omitempty"` + + ListOptions +} + +// Actor represents a repository actor. +type Actor struct { + Login *string `json:"login,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + AvatarURL *string `json:"avatar_url,omitempty"` + GravatarID *string `json:"gravatar_id,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + FollowersURL *string `json:"followers_url,omitempty"` + FollowingURL *string `json:"following_url,omitempty"` + GistsURL *string `json:"gists_url,omitempty"` + StarredURL *string `json:"starred_url,omitempty"` + SubscriptionsURL *string `json:"subscriptions_url,omitempty"` + OrganizationsURL *string `json:"organizations_url,omitempty"` + ReposURL *string `json:"repos_url,omitempty"` + EventsURL *string `json:"events_url,omitempty"` + ReceivedEventsURL *string `json:"received_events_url,omitempty"` + Type *string `json:"type,omitempty"` + UserViewType *string `json:"user_view_type,omitempty"` + SiteAdmin *bool `json:"site_admin,omitempty"` +} + +type RepositoryActivity struct { + ID int64 `json:"id"` + NodeID string `json:"node_id"` + Before string `json:"before"` + After string `json:"after"` + Ref string `json:"ref"` + Timestamp *Timestamp `json:"timestamp"` + ActivityType string `json:"activity_type"` + Actor *Actor `json:"actor"` +} + +// ListRespositoryActivities lists the activities for a repository. +// +// GitHub API docs: https://docs.github.com/rest/repos/repos#list-repository-activities +// +//meta:operation GET /repos/{owner}/{repo}/activities +func (s *RepositoriesService) ListRespositoryActivities(ctx context.Context, owner, repo string, opts *RepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/activities", 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 + } + + var activities []*RepositoryActivity + resp, err := s.client.Do(ctx, req, &activities) + if err != nil { + return nil, resp, err + } + + return activities, resp, nil +} diff --git a/github/repos_test.go b/github/repos_test.go index 1384fb40ca7..1e80cc88a31 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4567,3 +4567,313 @@ func TestRepository_UnmarshalJSON(t *testing.T) { }) } } + +func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "per_page": "100", + }) + fmt.Fprint(w, `[ + { + "id": 123456789, + "node_id": "PSH_test123", + "before": "abc123def456", + "after": "def456ghi789", + "ref": "refs/heads/main", + "timestamp": "2023-01-01T12:00:00Z", + "activity_type": "push", + "actor": { + "login": "testuser1", + "id": 111111, + "node_id": "MDQ6VXNlcjExMTExMQ==", + "avatar_url": "https://avatars.githubusercontent.com/u/111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser1", + "html_url": "https://github.com/testuser1", + "followers_url": "https://api.github.com/users/testuser1/followers", + "following_url": "https://api.github.com/users/testuser1/following{/other_user}", + "gists_url": "https://api.github.com/users/testuser1/gists{/gist_id}", + "starred_url": "https://api.github.com/users/testuser1/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/testuser1/subscriptions", + "organizations_url": "https://api.github.com/users/testuser1/orgs", + "repos_url": "https://api.github.com/users/testuser1/repos", + "events_url": "https://api.github.com/users/testuser1/events{/privacy}", + "received_events_url": "https://api.github.com/users/testuser1/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + } + }, + { + "id": 123456788, + "node_id": "PSH_test124", + "before": "def456ghi789", + "after": "ghi789jkl012", + "ref": "refs/heads/feature", + "timestamp": "2023-01-01T11:30:00Z", + "activity_type": "branch_deletion", + "actor": { + "login": "testuser2", + "id": 222222, + "node_id": "MDQ6VXNlcjIyMjIyMg==", + "avatar_url": "https://avatars.githubusercontent.com/u/222222?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser2", + "html_url": "https://github.com/testuser2", + "followers_url": "https://api.github.com/users/testuser2/followers", + "following_url": "https://api.github.com/users/testuser2/following{/other_user}", + "gists_url": "https://api.github.com/users/testuser2/gists{/gist_id}", + "starred_url": "https://api.github.com/users/testuser2/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/testuser2/subscriptions", + "organizations_url": "https://api.github.com/users/testuser2/orgs", + "repos_url": "https://api.github.com/users/testuser2/repos", + "events_url": "https://api.github.com/users/testuser2/events{/privacy}", + "received_events_url": "https://api.github.com/users/testuser2/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + } + } + ]`) + }) + + opts := &RepositoryActivityOptions{ListOptions: ListOptions{PerPage: 100}} + ctx := context.Background() + activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + if err != nil { + t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + } + + want := []*RepositoryActivity{ + { + ID: 123456789, + NodeID: "PSH_test123", + Before: "abc123def456", + After: "def456ghi789", + Ref: "refs/heads/main", + Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, + ActivityType: "push", + Actor: &Actor{ + Login: Ptr("testuser1"), + ID: Ptr(int64(111111)), + NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), + AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), + GravatarID: Ptr(""), + URL: Ptr("https://api.github.com/users/testuser1"), + HTMLURL: Ptr("https://github.com/testuser1"), + FollowersURL: Ptr("https://api.github.com/users/testuser1/followers"), + FollowingURL: Ptr("https://api.github.com/users/testuser1/following{/other_user}"), + GistsURL: Ptr("https://api.github.com/users/testuser1/gists{/gist_id}"), + StarredURL: Ptr("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), + SubscriptionsURL: Ptr("https://api.github.com/users/testuser1/subscriptions"), + OrganizationsURL: Ptr("https://api.github.com/users/testuser1/orgs"), + ReposURL: Ptr("https://api.github.com/users/testuser1/repos"), + EventsURL: Ptr("https://api.github.com/users/testuser1/events{/privacy}"), + ReceivedEventsURL: Ptr("https://api.github.com/users/testuser1/received_events"), + Type: Ptr("User"), + UserViewType: Ptr("public"), + SiteAdmin: Ptr(false), + }, + }, + { + ID: 123456788, + NodeID: "PSH_test124", + Before: "def456ghi789", + After: "ghi789jkl012", + Ref: "refs/heads/feature", + Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 11, 30, 0, 0, time.UTC)}, + ActivityType: "branch_deletion", + Actor: &Actor{ + Login: Ptr("testuser2"), + ID: Ptr(int64(222222)), + NodeID: Ptr("MDQ6VXNlcjIyMjIyMg=="), + AvatarURL: Ptr("https://avatars.githubusercontent.com/u/222222?v=4"), + GravatarID: Ptr(""), + URL: Ptr("https://api.github.com/users/testuser2"), + HTMLURL: Ptr("https://github.com/testuser2"), + FollowersURL: Ptr("https://api.github.com/users/testuser2/followers"), + FollowingURL: Ptr("https://api.github.com/users/testuser2/following{/other_user}"), + GistsURL: Ptr("https://api.github.com/users/testuser2/gists{/gist_id}"), + StarredURL: Ptr("https://api.github.com/users/testuser2/starred{/owner}{/repo}"), + SubscriptionsURL: Ptr("https://api.github.com/users/testuser2/subscriptions"), + OrganizationsURL: Ptr("https://api.github.com/users/testuser2/orgs"), + ReposURL: Ptr("https://api.github.com/users/testuser2/repos"), + EventsURL: Ptr("https://api.github.com/users/testuser2/events{/privacy}"), + ReceivedEventsURL: Ptr("https://api.github.com/users/testuser2/received_events"), + Type: Ptr("User"), + UserViewType: Ptr("public"), + SiteAdmin: Ptr(false), + }, + }, + } + + if !cmp.Equal(activities, want) { + t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + } + + const methodName = "ListRespositoryActivities" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Repositories.ListRespositoryActivities(ctx, "\n", "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "direction": "desc", + "before": "2023-01-01T12:00:00Z", + "after": "2023-01-01T11:30:00Z", + "ref": "refs/heads/main", + "actor": "testuser1", + "time_period": "day", + "activity_type": "push", + "page": "2", + "per_page": "50", + }) + fmt.Fprint(w, `[ + { + "id": 123456789, + "node_id": "PSH_test123", + "before": "abc123def456", + "after": "def456ghi789", + "ref": "refs/heads/main", + "timestamp": "2023-01-01T12:00:00Z", + "activity_type": "push", + "actor": { + "login": "testuser1", + "id": 111111, + "node_id": "MDQ6VXNlcjExMTExMQ==", + "avatar_url": "https://avatars.githubusercontent.com/u/111111?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser1", + "html_url": "https://github.com/testuser1", + "followers_url": "https://api.github.com/users/testuser1/followers", + "following_url": "https://api.github.com/users/testuser1/following{/other_user}", + "gists_url": "https://api.github.com/users/testuser1/gists{/gist_id}", + "starred_url": "https://api.github.com/users/testuser1/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/testuser1/subscriptions", + "organizations_url": "https://api.github.com/users/testuser1/orgs", + "repos_url": "https://api.github.com/users/testuser1/repos", + "events_url": "https://api.github.com/users/testuser1/events{/privacy}", + "received_events_url": "https://api.github.com/users/testuser1/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + } + } + ]`) + }) + + opts := &RepositoryActivityOptions{ + Direction: "desc", + Before: "2023-01-01T12:00:00Z", + After: "2023-01-01T11:30:00Z", + Ref: "refs/heads/main", + Actor: "testuser1", + TimePeriod: "day", + ActivityType: "push", + ListOptions: ListOptions{Page: 2, PerPage: 50}, + } + ctx := context.Background() + activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + if err != nil { + t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + } + + want := []*RepositoryActivity{ + { + ID: 123456789, + NodeID: "PSH_test123", + Before: "abc123def456", + After: "def456ghi789", + Ref: "refs/heads/main", + Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, + ActivityType: "push", + Actor: &Actor{ + Login: Ptr("testuser1"), + ID: Ptr(int64(111111)), + NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), + AvatarURL: Ptr("https://avatars.githubusercontent.com/u/111111?v=4"), + GravatarID: Ptr(""), + URL: Ptr("https://api.github.com/users/testuser1"), + HTMLURL: Ptr("https://github.com/testuser1"), + FollowersURL: Ptr("https://api.github.com/users/testuser1/followers"), + FollowingURL: Ptr("https://api.github.com/users/testuser1/following{/other_user}"), + GistsURL: Ptr("https://api.github.com/users/testuser1/gists{/gist_id}"), + StarredURL: Ptr("https://api.github.com/users/testuser1/starred{/owner}{/repo}"), + SubscriptionsURL: Ptr("https://api.github.com/users/testuser1/subscriptions"), + OrganizationsURL: Ptr("https://api.github.com/users/testuser1/orgs"), + ReposURL: Ptr("https://api.github.com/users/testuser1/repos"), + EventsURL: Ptr("https://api.github.com/users/testuser1/events{/privacy}"), + ReceivedEventsURL: Ptr("https://api.github.com/users/testuser1/received_events"), + Type: Ptr("User"), + UserViewType: Ptr("public"), + SiteAdmin: Ptr(false), + }, + }, + } + + if !cmp.Equal(activities, want) { + t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + } +} + +func TestRepositoriesService_ListRespositoryActivities_emptyResponse(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `[]`) + }) + + ctx := context.Background() + activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", nil) + if err != nil { + t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + } + + want := []*RepositoryActivity{} + if !cmp.Equal(activities, want) { + t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + } +} + +func TestRepositoriesService_ListRespositoryActivities_invalidOwner(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := context.Background() + _, _, err := client.Repositories.ListRespositoryActivities(ctx, "%", "r", nil) + if err == nil { + t.Error("Expected error to be returned") + } +} + +func TestRepositoriesService_ListRespositoryActivities_invalidRepo(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := context.Background() + _, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "%", nil) + if err == nil { + t.Error("Expected error to be returned") + } +} diff --git a/openapi_operations.yaml b/openapi_operations.yaml index 54e1867b5c8..ff687b4b1f6 100644 --- a/openapi_operations.yaml +++ b/openapi_operations.yaml @@ -27,7 +27,7 @@ operation_overrides: documentation_url: https://docs.github.com/rest/pages/pages#request-a-github-pages-build - name: GET /repos/{owner}/{repo}/pages/builds/{build_id} documentation_url: https://docs.github.com/rest/pages/pages#get-github-pages-build -openapi_commit: 0956844c50850685dce43634d73a69f4dac7989e +openapi_commit: ecbe0df804f3f85f8a68f48d6e9711d05da6f201 openapi_operations: - name: GET / documentation_url: https://docs.github.com/rest/meta/meta#github-api-root @@ -720,6 +720,42 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/announcement-banners/enterprises#set-announcement-banner-for-enterprise openapi_files: - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/apps/installable_organizations + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-enterprise-owned-organizations-that-can-have-github-apps-installed + openapi_files: + - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/apps/installable_organizations/{org}/accessible_repositories + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-repositories-belonging-to-an-enterprise-owned-organization + openapi_files: + - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/apps/organizations/{org}/installations + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#list-github-apps-installed-on-an-enterprise-owned-organization + openapi_files: + - descriptions/ghec/ghec.json + - name: POST /enterprises/{enterprise}/apps/organizations/{org}/installations + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#install-a-github-app-on-an-enterprise-owned-organization + openapi_files: + - descriptions/ghec/ghec.json + - name: DELETE /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#uninstall-a-github-app-from-an-enterprise-owned-organization + openapi_files: + - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-the-repositories-accessible-to-a-given-github-app-installation + openapi_files: + - descriptions/ghec/ghec.json + - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#toggle-installation-repository-access-between-selected-and-all-repositories + openapi_files: + - descriptions/ghec/ghec.json + - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#grant-repository-access-to-an-organization-installation + openapi_files: + - descriptions/ghec/ghec.json + - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#remove-repository-access-from-an-organization-installation + openapi_files: + - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/audit-log documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise openapi_files: @@ -850,6 +886,10 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/license#get-a-license-sync-status openapi_files: - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/members/{username}/copilot + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/copilot/copilot-user-management#get-copilot-seat-assignment-details-for-an-enterprise-user + openapi_files: + - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/network-configurations documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/network-configurations#list-hosted-compute-network-configurations-for-an-enterprise openapi_files: @@ -941,12 +981,28 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#get-all-cost-centers-for-an-enterprise openapi_files: - descriptions/ghec/ghec.json + - name: POST /enterprises/{enterprise}/settings/billing/cost-centers + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#create-a-new-cost-center + openapi_files: + - descriptions/ghec/ghec.json + - name: DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#delete-a-cost-center + openapi_files: + - descriptions/ghec/ghec.json + - name: GET /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#get-a-cost-center-by-id + openapi_files: + - descriptions/ghec/ghec.json + - name: PATCH /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#update-a-cost-center-name + openapi_files: + - descriptions/ghec/ghec.json - name: DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#remove-users-from-a-cost-center + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#remove-resources-from-a-cost-center openapi_files: - descriptions/ghec/ghec.json - name: POST /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#add-users-to-a-cost-center + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#add-resources-to-a-cost-center openapi_files: - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/settings/billing/packages @@ -1333,6 +1389,21 @@ openapi_operations: openapi_files: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: GET /organizations/{org}/dependabot/repository-access + documentation_url: https://docs.github.com/rest/dependabot/repository-access#lists-the-repositories-dependabot-can-access-in-an-organization + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: PATCH /organizations/{org}/dependabot/repository-access + documentation_url: https://docs.github.com/rest/dependabot/repository-access#updates-dependabots-repository-access-list-for-an-organization + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: PUT /organizations/{org}/dependabot/repository-access/default-level + documentation_url: https://docs.github.com/rest/dependabot/repository-access#set-the-default-repository-access-level-for-dependabot + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json - name: GET /organizations/{org}/settings/billing/usage documentation_url: https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization openapi_files: @@ -1768,6 +1839,26 @@ openapi_operations: openapi_files: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: POST /orgs/{org}/attestations/bulk-list + documentation_url: https://docs.github.com/rest/orgs/orgs#list-attestations-by-bulk-subject-digests + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: POST /orgs/{org}/attestations/delete-request + documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-in-bulk + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: DELETE /orgs/{org}/attestations/digest/{subject_digest} + documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-by-subject-digest + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: DELETE /orgs/{org}/attestations/{attestation_id} + documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-by-id + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json - name: GET /orgs/{org}/attestations/{subject_digest} documentation_url: https://docs.github.com/rest/orgs/orgs#list-attestations openapi_files: @@ -2108,6 +2199,10 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: GET /orgs/{org}/dismissal-requests/code-scanning + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#list-dismissal-requests-for-code-scanning-alerts-for-an-organization + openapi_files: + - descriptions/ghec/ghec.json - name: GET /orgs/{org}/dismissal-requests/secret-scanning documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/secret-scanning/alert-dismissal-requests#list-alert-dismissal-requests-for-secret-scanning-for-an-org openapi_files: @@ -2646,7 +2741,6 @@ openapi_operations: openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - - descriptions/ghes-3.17/ghes-3.17.json - name: GET /orgs/{org}/private-registries/public-key documentation_url: https://docs.github.com/rest/private-registries/organization-configurations#get-private-registries-public-key-for-an-organization openapi_files: @@ -2672,13 +2766,13 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /orgs/{org}/projects - documentation_url: https://docs.github.com/rest/projects/projects#list-organization-projects + documentation_url: https://docs.github.com/rest/projects-classic/projects#list-organization-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /orgs/{org}/projects - documentation_url: https://docs.github.com/rest/projects/projects#create-an-organization-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#create-an-organization-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -3145,115 +3239,115 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects/cards#delete-a-project-card + documentation_url: https://docs.github.com/rest/projects-classic/cards#delete-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects/cards#get-a-project-card + documentation_url: https://docs.github.com/rest/projects-classic/cards#get-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects/cards#update-an-existing-project-card + documentation_url: https://docs.github.com/rest/projects-classic/cards#update-an-existing-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/cards/{card_id}/moves - documentation_url: https://docs.github.com/rest/projects/cards#move-a-project-card + documentation_url: https://docs.github.com/rest/projects-classic/cards#move-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects/columns#delete-a-project-column + documentation_url: https://docs.github.com/rest/projects-classic/columns#delete-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects/columns#get-a-project-column + documentation_url: https://docs.github.com/rest/projects-classic/columns#get-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects/columns#update-an-existing-project-column + documentation_url: https://docs.github.com/rest/projects-classic/columns#update-an-existing-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/{column_id}/cards - documentation_url: https://docs.github.com/rest/projects/cards#list-project-cards + documentation_url: https://docs.github.com/rest/projects-classic/cards#list-project-cards openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/{column_id}/cards - documentation_url: https://docs.github.com/rest/projects/cards#create-a-project-card + documentation_url: https://docs.github.com/rest/projects-classic/cards#create-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/{column_id}/moves - documentation_url: https://docs.github.com/rest/projects/columns#move-a-project-column + documentation_url: https://docs.github.com/rest/projects-classic/columns#move-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects/projects#delete-a-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#delete-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects/projects#get-a-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#get-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects/projects#update-a-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#update-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/collaborators - documentation_url: https://docs.github.com/rest/projects/collaborators#list-project-collaborators + documentation_url: https://docs.github.com/rest/projects-classic/collaborators#list-project-collaborators openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/{project_id}/collaborators/{username} - documentation_url: https://docs.github.com/rest/projects/collaborators#remove-user-as-a-collaborator + documentation_url: https://docs.github.com/rest/projects-classic/collaborators#remove-user-as-a-collaborator openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PUT /projects/{project_id}/collaborators/{username} - documentation_url: https://docs.github.com/rest/projects/collaborators#add-project-collaborator + documentation_url: https://docs.github.com/rest/projects-classic/collaborators#add-project-collaborator openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/collaborators/{username}/permission - documentation_url: https://docs.github.com/rest/projects/collaborators#get-project-permission-for-a-user + documentation_url: https://docs.github.com/rest/projects-classic/collaborators#get-project-permission-for-a-user openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/columns - documentation_url: https://docs.github.com/rest/projects/columns#list-project-columns + documentation_url: https://docs.github.com/rest/projects-classic/columns#list-project-columns openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/{project_id}/columns - documentation_url: https://docs.github.com/rest/projects/columns#create-a-project-column + documentation_url: https://docs.github.com/rest/projects-classic/columns#create-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -3729,6 +3823,12 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: GET /repos/{owner}/{repo}/activities + documentation_url: https://docs.github.com/rest/repos/repos#list-repository-activities + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - descriptions/ghes-3.17/ghes-3.17.json - name: GET /repos/{owner}/{repo}/assignees documentation_url: https://docs.github.com/rest/issues/assignees#list-assignees openapi_files: @@ -4554,6 +4654,18 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: GET /repos/{owner}/{repo}/dismissal-requests/code-scanning + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#list-dismissal-requests-for-code-scanning-alerts-for-a-repository + openapi_files: + - descriptions/ghec/ghec.json + - name: GET /repos/{owner}/{repo}/dismissal-requests/code-scanning/{alert_number} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#get-a-dismissal-request-for-a-code-scanning-alert-for-a-repository + openapi_files: + - descriptions/ghec/ghec.json + - name: PATCH /repos/{owner}/{repo}/dismissal-requests/code-scanning/{alert_number} + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#review-a-dismissal-request-for-a-code-scanning-alert-for-a-repository + openapi_files: + - descriptions/ghec/ghec.json - name: GET /repos/{owner}/{repo}/dismissal-requests/secret-scanning documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/secret-scanning/alert-dismissal-requests#list-alert-dismissal-requests-for-secret-scanning-for-a-repository openapi_files: @@ -5406,13 +5518,13 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - name: GET /repos/{owner}/{repo}/projects - documentation_url: https://docs.github.com/rest/projects/projects#list-repository-projects + documentation_url: https://docs.github.com/rest/projects-classic/projects#list-repository-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /repos/{owner}/{repo}/projects - documentation_url: https://docs.github.com/rest/projects/projects#create-a-repository-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#create-a-repository-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -6886,7 +6998,7 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /user/projects - documentation_url: https://docs.github.com/rest/projects/projects#create-a-user-project + documentation_url: https://docs.github.com/rest/projects-classic/projects#create-a-user-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -7023,6 +7135,26 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json + - name: POST /users/{username}/attestations/bulk-list + documentation_url: https://docs.github.com/rest/users/attestations#list-attestations-by-bulk-subject-digests + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: POST /users/{username}/attestations/delete-request + documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-in-bulk + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: DELETE /users/{username}/attestations/digest/{subject_digest} + documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-by-subject-digest + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json + - name: DELETE /users/{username}/attestations/{attestation_id} + documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-by-id + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json - name: GET /users/{username}/attestations/{subject_digest} documentation_url: https://docs.github.com/rest/users/attestations#list-attestations openapi_files: @@ -7155,7 +7287,7 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /users/{username}/projects - documentation_url: https://docs.github.com/rest/projects/projects#list-user-projects + documentation_url: https://docs.github.com/rest/projects-classic/projects#list-user-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json From 306b5a3e63d5fec413c1ea17d4fc0641d90ed8e8 Mon Sep 17 00:00:00 2001 From: abhishek Date: Sun, 27 Jul 2025 17:21:21 +0530 Subject: [PATCH 2/4] Update Signed-off-by: abhishek --- github/github-accessors.go | 306 +++++++++++------------ github/github-accessors_test.go | 418 ++++++++++++++++---------------- github/repos.go | 61 +++-- github/repos_test.go | 17 +- openapi_operations.yaml | 6 - 5 files changed, 411 insertions(+), 397 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index ba65fefb3ac..81159ddfe07 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -238,158 +238,6 @@ func (a *ActionsVariable) GetVisibility() string { return *a.Visibility } -// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetAvatarURL() string { - if a == nil || a.AvatarURL == nil { - return "" - } - return *a.AvatarURL -} - -// GetEventsURL returns the EventsURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetEventsURL() string { - if a == nil || a.EventsURL == nil { - return "" - } - return *a.EventsURL -} - -// GetFollowersURL returns the FollowersURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetFollowersURL() string { - if a == nil || a.FollowersURL == nil { - return "" - } - return *a.FollowersURL -} - -// GetFollowingURL returns the FollowingURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetFollowingURL() string { - if a == nil || a.FollowingURL == nil { - return "" - } - return *a.FollowingURL -} - -// GetGistsURL returns the GistsURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetGistsURL() string { - if a == nil || a.GistsURL == nil { - return "" - } - return *a.GistsURL -} - -// GetGravatarID returns the GravatarID field if it's non-nil, zero value otherwise. -func (a *Actor) GetGravatarID() string { - if a == nil || a.GravatarID == nil { - return "" - } - return *a.GravatarID -} - -// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetHTMLURL() string { - if a == nil || a.HTMLURL == nil { - return "" - } - return *a.HTMLURL -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (a *Actor) GetID() int64 { - if a == nil || a.ID == nil { - return 0 - } - return *a.ID -} - -// GetLogin returns the Login field if it's non-nil, zero value otherwise. -func (a *Actor) GetLogin() string { - if a == nil || a.Login == nil { - return "" - } - return *a.Login -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (a *Actor) GetNodeID() string { - if a == nil || a.NodeID == nil { - return "" - } - return *a.NodeID -} - -// GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetOrganizationsURL() string { - if a == nil || a.OrganizationsURL == nil { - return "" - } - return *a.OrganizationsURL -} - -// GetReceivedEventsURL returns the ReceivedEventsURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetReceivedEventsURL() string { - if a == nil || a.ReceivedEventsURL == nil { - return "" - } - return *a.ReceivedEventsURL -} - -// GetReposURL returns the ReposURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetReposURL() string { - if a == nil || a.ReposURL == nil { - return "" - } - return *a.ReposURL -} - -// GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. -func (a *Actor) GetSiteAdmin() bool { - if a == nil || a.SiteAdmin == nil { - return false - } - return *a.SiteAdmin -} - -// GetStarredURL returns the StarredURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetStarredURL() string { - if a == nil || a.StarredURL == nil { - return "" - } - return *a.StarredURL -} - -// GetSubscriptionsURL returns the SubscriptionsURL field if it's non-nil, zero value otherwise. -func (a *Actor) GetSubscriptionsURL() string { - if a == nil || a.SubscriptionsURL == nil { - return "" - } - return *a.SubscriptionsURL -} - -// GetType returns the Type field if it's non-nil, zero value otherwise. -func (a *Actor) GetType() string { - if a == nil || a.Type == nil { - return "" - } - return *a.Type -} - -// GetURL returns the URL field if it's non-nil, zero value otherwise. -func (a *Actor) GetURL() string { - if a == nil || a.URL == nil { - return "" - } - return *a.URL -} - -// GetUserViewType returns the UserViewType field if it's non-nil, zero value otherwise. -func (a *Actor) GetUserViewType() string { - if a == nil || a.UserViewType == nil { - return "" - } - return *a.UserViewType -} - // GetCountryCode returns the CountryCode field if it's non-nil, zero value otherwise. func (a *ActorLocation) GetCountryCode() string { if a == nil || a.CountryCode == nil { @@ -22559,7 +22407,7 @@ func (r *RepositoryActiveCommitters) GetName() string { } // GetActor returns the Actor field. -func (r *RepositoryActivity) GetActor() *Actor { +func (r *RepositoryActivity) GetActor() *RepositoryActor { if r == nil { return nil } @@ -22574,6 +22422,158 @@ func (r *RepositoryActivity) GetTimestamp() Timestamp { return *r.Timestamp } +// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetAvatarURL() string { + if r == nil || r.AvatarURL == nil { + return "" + } + return *r.AvatarURL +} + +// GetEventsURL returns the EventsURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetEventsURL() string { + if r == nil || r.EventsURL == nil { + return "" + } + return *r.EventsURL +} + +// GetFollowersURL returns the FollowersURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetFollowersURL() string { + if r == nil || r.FollowersURL == nil { + return "" + } + return *r.FollowersURL +} + +// GetFollowingURL returns the FollowingURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetFollowingURL() string { + if r == nil || r.FollowingURL == nil { + return "" + } + return *r.FollowingURL +} + +// GetGistsURL returns the GistsURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetGistsURL() string { + if r == nil || r.GistsURL == nil { + return "" + } + return *r.GistsURL +} + +// GetGravatarID returns the GravatarID field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetGravatarID() string { + if r == nil || r.GravatarID == nil { + return "" + } + return *r.GravatarID +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetHTMLURL() string { + if r == nil || r.HTMLURL == nil { + return "" + } + return *r.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetLogin returns the Login field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetLogin() string { + if r == nil || r.Login == nil { + return "" + } + return *r.Login +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetNodeID() string { + if r == nil || r.NodeID == nil { + return "" + } + return *r.NodeID +} + +// GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetOrganizationsURL() string { + if r == nil || r.OrganizationsURL == nil { + return "" + } + return *r.OrganizationsURL +} + +// GetReceivedEventsURL returns the ReceivedEventsURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetReceivedEventsURL() string { + if r == nil || r.ReceivedEventsURL == nil { + return "" + } + return *r.ReceivedEventsURL +} + +// GetReposURL returns the ReposURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetReposURL() string { + if r == nil || r.ReposURL == nil { + return "" + } + return *r.ReposURL +} + +// GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetSiteAdmin() bool { + if r == nil || r.SiteAdmin == nil { + return false + } + return *r.SiteAdmin +} + +// GetStarredURL returns the StarredURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetStarredURL() string { + if r == nil || r.StarredURL == nil { + return "" + } + return *r.StarredURL +} + +// GetSubscriptionsURL returns the SubscriptionsURL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetSubscriptionsURL() string { + if r == nil || r.SubscriptionsURL == nil { + return "" + } + return *r.SubscriptionsURL +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetType() string { + if r == nil || r.Type == nil { + return "" + } + return *r.Type +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetURL() string { + if r == nil || r.URL == nil { + return "" + } + return *r.URL +} + +// GetUserViewType returns the UserViewType field if it's non-nil, zero value otherwise. +func (r *RepositoryActor) GetUserViewType() string { + if r == nil || r.UserViewType == nil { + return "" + } + return *r.UserViewType +} + // GetConfiguration returns the Configuration field. func (r *RepositoryCodeSecurityConfiguration) GetConfiguration() *CodeSecurityConfiguration { if r == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ec5b93db995..1a36145efff 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -320,215 +320,6 @@ func TestActionsVariable_GetVisibility(tt *testing.T) { a.GetVisibility() } -func TestActor_GetAvatarURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{AvatarURL: &zeroValue} - a.GetAvatarURL() - a = &Actor{} - a.GetAvatarURL() - a = nil - a.GetAvatarURL() -} - -func TestActor_GetEventsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{EventsURL: &zeroValue} - a.GetEventsURL() - a = &Actor{} - a.GetEventsURL() - a = nil - a.GetEventsURL() -} - -func TestActor_GetFollowersURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{FollowersURL: &zeroValue} - a.GetFollowersURL() - a = &Actor{} - a.GetFollowersURL() - a = nil - a.GetFollowersURL() -} - -func TestActor_GetFollowingURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{FollowingURL: &zeroValue} - a.GetFollowingURL() - a = &Actor{} - a.GetFollowingURL() - a = nil - a.GetFollowingURL() -} - -func TestActor_GetGistsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{GistsURL: &zeroValue} - a.GetGistsURL() - a = &Actor{} - a.GetGistsURL() - a = nil - a.GetGistsURL() -} - -func TestActor_GetGravatarID(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{GravatarID: &zeroValue} - a.GetGravatarID() - a = &Actor{} - a.GetGravatarID() - a = nil - a.GetGravatarID() -} - -func TestActor_GetHTMLURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{HTMLURL: &zeroValue} - a.GetHTMLURL() - a = &Actor{} - a.GetHTMLURL() - a = nil - a.GetHTMLURL() -} - -func TestActor_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue int64 - a := &Actor{ID: &zeroValue} - a.GetID() - a = &Actor{} - a.GetID() - a = nil - a.GetID() -} - -func TestActor_GetLogin(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{Login: &zeroValue} - a.GetLogin() - a = &Actor{} - a.GetLogin() - a = nil - a.GetLogin() -} - -func TestActor_GetNodeID(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{NodeID: &zeroValue} - a.GetNodeID() - a = &Actor{} - a.GetNodeID() - a = nil - a.GetNodeID() -} - -func TestActor_GetOrganizationsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{OrganizationsURL: &zeroValue} - a.GetOrganizationsURL() - a = &Actor{} - a.GetOrganizationsURL() - a = nil - a.GetOrganizationsURL() -} - -func TestActor_GetReceivedEventsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{ReceivedEventsURL: &zeroValue} - a.GetReceivedEventsURL() - a = &Actor{} - a.GetReceivedEventsURL() - a = nil - a.GetReceivedEventsURL() -} - -func TestActor_GetReposURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{ReposURL: &zeroValue} - a.GetReposURL() - a = &Actor{} - a.GetReposURL() - a = nil - a.GetReposURL() -} - -func TestActor_GetSiteAdmin(tt *testing.T) { - tt.Parallel() - var zeroValue bool - a := &Actor{SiteAdmin: &zeroValue} - a.GetSiteAdmin() - a = &Actor{} - a.GetSiteAdmin() - a = nil - a.GetSiteAdmin() -} - -func TestActor_GetStarredURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{StarredURL: &zeroValue} - a.GetStarredURL() - a = &Actor{} - a.GetStarredURL() - a = nil - a.GetStarredURL() -} - -func TestActor_GetSubscriptionsURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{SubscriptionsURL: &zeroValue} - a.GetSubscriptionsURL() - a = &Actor{} - a.GetSubscriptionsURL() - a = nil - a.GetSubscriptionsURL() -} - -func TestActor_GetType(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{Type: &zeroValue} - a.GetType() - a = &Actor{} - a.GetType() - a = nil - a.GetType() -} - -func TestActor_GetURL(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{URL: &zeroValue} - a.GetURL() - a = &Actor{} - a.GetURL() - a = nil - a.GetURL() -} - -func TestActor_GetUserViewType(tt *testing.T) { - tt.Parallel() - var zeroValue string - a := &Actor{UserViewType: &zeroValue} - a.GetUserViewType() - a = &Actor{} - a.GetUserViewType() - a = nil - a.GetUserViewType() -} - func TestActorLocation_GetCountryCode(tt *testing.T) { tt.Parallel() var zeroValue string @@ -29166,6 +28957,215 @@ func TestRepositoryActivity_GetTimestamp(tt *testing.T) { r.GetTimestamp() } +func TestRepositoryActor_GetAvatarURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{AvatarURL: &zeroValue} + r.GetAvatarURL() + r = &RepositoryActor{} + r.GetAvatarURL() + r = nil + r.GetAvatarURL() +} + +func TestRepositoryActor_GetEventsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{EventsURL: &zeroValue} + r.GetEventsURL() + r = &RepositoryActor{} + r.GetEventsURL() + r = nil + r.GetEventsURL() +} + +func TestRepositoryActor_GetFollowersURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{FollowersURL: &zeroValue} + r.GetFollowersURL() + r = &RepositoryActor{} + r.GetFollowersURL() + r = nil + r.GetFollowersURL() +} + +func TestRepositoryActor_GetFollowingURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{FollowingURL: &zeroValue} + r.GetFollowingURL() + r = &RepositoryActor{} + r.GetFollowingURL() + r = nil + r.GetFollowingURL() +} + +func TestRepositoryActor_GetGistsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{GistsURL: &zeroValue} + r.GetGistsURL() + r = &RepositoryActor{} + r.GetGistsURL() + r = nil + r.GetGistsURL() +} + +func TestRepositoryActor_GetGravatarID(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{GravatarID: &zeroValue} + r.GetGravatarID() + r = &RepositoryActor{} + r.GetGravatarID() + r = nil + r.GetGravatarID() +} + +func TestRepositoryActor_GetHTMLURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{HTMLURL: &zeroValue} + r.GetHTMLURL() + r = &RepositoryActor{} + r.GetHTMLURL() + r = nil + r.GetHTMLURL() +} + +func TestRepositoryActor_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + r := &RepositoryActor{ID: &zeroValue} + r.GetID() + r = &RepositoryActor{} + r.GetID() + r = nil + r.GetID() +} + +func TestRepositoryActor_GetLogin(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{Login: &zeroValue} + r.GetLogin() + r = &RepositoryActor{} + r.GetLogin() + r = nil + r.GetLogin() +} + +func TestRepositoryActor_GetNodeID(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{NodeID: &zeroValue} + r.GetNodeID() + r = &RepositoryActor{} + r.GetNodeID() + r = nil + r.GetNodeID() +} + +func TestRepositoryActor_GetOrganizationsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{OrganizationsURL: &zeroValue} + r.GetOrganizationsURL() + r = &RepositoryActor{} + r.GetOrganizationsURL() + r = nil + r.GetOrganizationsURL() +} + +func TestRepositoryActor_GetReceivedEventsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{ReceivedEventsURL: &zeroValue} + r.GetReceivedEventsURL() + r = &RepositoryActor{} + r.GetReceivedEventsURL() + r = nil + r.GetReceivedEventsURL() +} + +func TestRepositoryActor_GetReposURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{ReposURL: &zeroValue} + r.GetReposURL() + r = &RepositoryActor{} + r.GetReposURL() + r = nil + r.GetReposURL() +} + +func TestRepositoryActor_GetSiteAdmin(tt *testing.T) { + tt.Parallel() + var zeroValue bool + r := &RepositoryActor{SiteAdmin: &zeroValue} + r.GetSiteAdmin() + r = &RepositoryActor{} + r.GetSiteAdmin() + r = nil + r.GetSiteAdmin() +} + +func TestRepositoryActor_GetStarredURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{StarredURL: &zeroValue} + r.GetStarredURL() + r = &RepositoryActor{} + r.GetStarredURL() + r = nil + r.GetStarredURL() +} + +func TestRepositoryActor_GetSubscriptionsURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{SubscriptionsURL: &zeroValue} + r.GetSubscriptionsURL() + r = &RepositoryActor{} + r.GetSubscriptionsURL() + r = nil + r.GetSubscriptionsURL() +} + +func TestRepositoryActor_GetType(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{Type: &zeroValue} + r.GetType() + r = &RepositoryActor{} + r.GetType() + r = nil + r.GetType() +} + +func TestRepositoryActor_GetURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{URL: &zeroValue} + r.GetURL() + r = &RepositoryActor{} + r.GetURL() + r = nil + r.GetURL() +} + +func TestRepositoryActor_GetUserViewType(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RepositoryActor{UserViewType: &zeroValue} + r.GetUserViewType() + r = &RepositoryActor{} + r.GetUserViewType() + r = nil + r.GetUserViewType() +} + func TestRepositoryCodeSecurityConfiguration_GetConfiguration(tt *testing.T) { tt.Parallel() r := &RepositoryCodeSecurityConfiguration{} diff --git a/github/repos.go b/github/repos.go index 9ebfd1d1f9b..1e60c22f54f 100644 --- a/github/repos.go +++ b/github/repos.go @@ -2439,20 +2439,40 @@ func (s *RepositoriesService) IsPrivateReportingEnabled(ctx context.Context, own return privateReporting.Enabled, resp, err } +// RepositoryActivityOptions specifies the optional parameters to the +// RepositoriesService.ListRespositoryActivities method. type RepositoryActivityOptions struct { - Direction string `url:"direction,omitempty"` - Before string `url:"before,omitempty"` - After string `url:"after,omitempty"` - Ref string `url:"ref,omitempty"` - Actor string `url:"actor,omitempty"` - TimePeriod string `url:"time_period,omitempty"` - ActivityType string `url:"activity_type,omitempty"` + // The direction to sort the results + Direction string `url:"direction,omitempty"` - ListOptions + // For paginated result sets, the number of results to include per page. + PerPage int `url:"per_page,omitempty"` + + // A cursor, as given in the Link header. If specified, the query only searches for events before this cursor. + Before string `url:"before,omitempty"` + + // A cursor, as given in the Link header. If specified, the query only searches for events after this cursor. + After string `url:"after,omitempty"` + + // The Git reference for the activities you want to list. + Ref string `url:"ref,omitempty"` + + // The GitHub username to use to filter by the actor who performed the activity. + Actor string `url:"actor,omitempty"` + + // The time period to filter by. + // For example, day will filter for activity that occurred in the past 24 hours, and week will filter for activity that occurred in the past 7 days (168 hours). + // Can be one of: day, week, month, quarter, year + TimePeriod string `url:"time_period,omitempty"` + + // The activity type to filter by. + // For example, you can choose to filter by "force_push", to see all force pushes to the repository. + // Can be one of: push, force_push, branch_creation, branch_deletion, pr_merge, merge_queue_merge + ActivityType string `url:"activity_type,omitempty"` } -// Actor represents a repository actor. -type Actor struct { +// RepositoryActor represents a repository actor. +type RepositoryActor struct { Login *string `json:"login,omitempty"` ID *int64 `json:"id,omitempty"` NodeID *string `json:"node_id,omitempty"` @@ -2474,24 +2494,25 @@ type Actor struct { SiteAdmin *bool `json:"site_admin,omitempty"` } +// RepositoryActivity represents a repository activity. type RepositoryActivity struct { - ID int64 `json:"id"` - NodeID string `json:"node_id"` - Before string `json:"before"` - After string `json:"after"` - Ref string `json:"ref"` - Timestamp *Timestamp `json:"timestamp"` - ActivityType string `json:"activity_type"` - Actor *Actor `json:"actor"` + ID int64 `json:"id"` + NodeID string `json:"node_id"` + Before string `json:"before"` + After string `json:"after"` + Ref string `json:"ref"` + Timestamp *Timestamp `json:"timestamp"` + ActivityType string `json:"activity_type"` + Actor *RepositoryActor `json:"actor"` } // ListRespositoryActivities lists the activities for a repository. // // GitHub API docs: https://docs.github.com/rest/repos/repos#list-repository-activities // -//meta:operation GET /repos/{owner}/{repo}/activities +//meta:operation GET /repos/{owner}/{repo}/activity func (s *RepositoriesService) ListRespositoryActivities(ctx context.Context, owner, repo string, opts *RepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/activities", owner, repo) + u := fmt.Sprintf("repos/%v/%v/activity", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err diff --git a/github/repos_test.go b/github/repos_test.go index 1e80cc88a31..d1dd7998c3b 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4572,7 +4572,7 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/activity", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{ "per_page": "100", @@ -4641,7 +4641,7 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { ]`) }) - opts := &RepositoryActivityOptions{ListOptions: ListOptions{PerPage: 100}} + opts := &RepositoryActivityOptions{PerPage: 100} ctx := context.Background() activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) if err != nil { @@ -4657,7 +4657,7 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { Ref: "refs/heads/main", Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, ActivityType: "push", - Actor: &Actor{ + Actor: &RepositoryActor{ Login: Ptr("testuser1"), ID: Ptr(int64(111111)), NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), @@ -4687,7 +4687,7 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { Ref: "refs/heads/feature", Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 11, 30, 0, 0, time.UTC)}, ActivityType: "branch_deletion", - Actor: &Actor{ + Actor: &RepositoryActor{ Login: Ptr("testuser2"), ID: Ptr(int64(222222)), NodeID: Ptr("MDQ6VXNlcjIyMjIyMg=="), @@ -4734,7 +4734,7 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/activity", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{ "direction": "desc", @@ -4744,7 +4744,6 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) "actor": "testuser1", "time_period": "day", "activity_type": "push", - "page": "2", "per_page": "50", }) fmt.Fprint(w, `[ @@ -4789,7 +4788,7 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) Actor: "testuser1", TimePeriod: "day", ActivityType: "push", - ListOptions: ListOptions{Page: 2, PerPage: 50}, + PerPage: 50, } ctx := context.Background() activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) @@ -4806,7 +4805,7 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) Ref: "refs/heads/main", Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, ActivityType: "push", - Actor: &Actor{ + Actor: &RepositoryActor{ Login: Ptr("testuser1"), ID: Ptr(int64(111111)), NodeID: Ptr("MDQ6VXNlcjExMTExMQ=="), @@ -4839,7 +4838,7 @@ func TestRepositoriesService_ListRespositoryActivities_emptyResponse(t *testing. t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/activities", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/activity", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[]`) }) diff --git a/openapi_operations.yaml b/openapi_operations.yaml index ff687b4b1f6..738ea0bf9c3 100644 --- a/openapi_operations.yaml +++ b/openapi_operations.yaml @@ -3823,12 +3823,6 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: GET /repos/{owner}/{repo}/activities - documentation_url: https://docs.github.com/rest/repos/repos#list-repository-activities - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - descriptions/ghes-3.17/ghes-3.17.json - name: GET /repos/{owner}/{repo}/assignees documentation_url: https://docs.github.com/rest/issues/assignees#list-assignees openapi_files: From 03233155a2d70f622e35e02d2dfd9f622ce2d519 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 28 Jul 2025 16:55:43 +0530 Subject: [PATCH 3/4] Review comments addressed Signed-off-by: abhishek --- github/repos.go | 15 ++-- github/repos_test.go | 38 ++++----- openapi_operations.yaml | 184 +++++++--------------------------------- 3 files changed, 57 insertions(+), 180 deletions(-) diff --git a/github/repos.go b/github/repos.go index 1e60c22f54f..bb27d213efb 100644 --- a/github/repos.go +++ b/github/repos.go @@ -2440,12 +2440,14 @@ func (s *RepositoriesService) IsPrivateReportingEnabled(ctx context.Context, own } // RepositoryActivityOptions specifies the optional parameters to the -// RepositoriesService.ListRespositoryActivities method. +// RepositoriesService.ListRepositoryActivities method. type RepositoryActivityOptions struct { - // The direction to sort the results + // The direction to sort the results by. + // Default: desc + // Can be one of: asc, desc Direction string `url:"direction,omitempty"` - // For paginated result sets, the number of results to include per page. + // For paginated result sets, The number of results per page (max 100). PerPage int `url:"per_page,omitempty"` // A cursor, as given in the Link header. If specified, the query only searches for events before this cursor. @@ -2455,6 +2457,7 @@ type RepositoryActivityOptions struct { After string `url:"after,omitempty"` // The Git reference for the activities you want to list. + // The ref for a branch can be formatted either as refs/heads/BRANCH_NAME or BRANCH_NAME, where BRANCH_NAME is the name of your branch. Ref string `url:"ref,omitempty"` // The GitHub username to use to filter by the actor who performed the activity. @@ -2503,15 +2506,15 @@ type RepositoryActivity struct { Ref string `json:"ref"` Timestamp *Timestamp `json:"timestamp"` ActivityType string `json:"activity_type"` - Actor *RepositoryActor `json:"actor"` + Actor *RepositoryActor `json:"actor,omitempty"` } -// ListRespositoryActivities lists the activities for a repository. +// ListRepositoryActivities lists the activities for a repository. // // GitHub API docs: https://docs.github.com/rest/repos/repos#list-repository-activities // //meta:operation GET /repos/{owner}/{repo}/activity -func (s *RepositoriesService) ListRespositoryActivities(ctx context.Context, owner, repo string, opts *RepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { +func (s *RepositoriesService) ListRepositoryActivities(ctx context.Context, owner, repo string, opts *RepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { u := fmt.Sprintf("repos/%v/%v/activity", owner, repo) u, err := addOptions(u, opts) if err != nil { diff --git a/github/repos_test.go b/github/repos_test.go index d1dd7998c3b..ecfd91832b8 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4568,7 +4568,7 @@ func TestRepository_UnmarshalJSON(t *testing.T) { } } -func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { +func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -4643,9 +4643,9 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { opts := &RepositoryActivityOptions{PerPage: 100} ctx := context.Background() - activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + activities, _, err := client.Repositories.ListRepositoryActivities(ctx, "o", "r", opts) if err != nil { - t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + t.Errorf("Repositories.ListRepositoryActivities returned error: %v", err) } want := []*RepositoryActivity{ @@ -4712,17 +4712,17 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { } if !cmp.Equal(activities, want) { - t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + t.Errorf("Repositories.ListRepositoryActivities returned %+v, want %+v", activities, want) } - const methodName = "ListRespositoryActivities" + const methodName = "ListRepositoryActivities" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.ListRespositoryActivities(ctx, "\n", "\n", opts) + _, _, err = client.Repositories.ListRepositoryActivities(ctx, "\n", "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + got, resp, err := client.Repositories.ListRepositoryActivities(ctx, "o", "r", opts) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -4730,7 +4730,7 @@ func TestRepositoriesService_ListRespositoryActivities(t *testing.T) { }) } -func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) { +func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -4791,9 +4791,9 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) PerPage: 50, } ctx := context.Background() - activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", opts) + activities, _, err := client.Repositories.ListRepositoryActivities(ctx, "o", "r", opts) if err != nil { - t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + t.Errorf("Repositories.ListRepositoryActivities returned error: %v", err) } want := []*RepositoryActivity{ @@ -4830,11 +4830,11 @@ func TestRepositoriesService_ListRespositoryActivities_withOptions(t *testing.T) } if !cmp.Equal(activities, want) { - t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + t.Errorf("Repositories.ListRepositoryActivities returned %+v, want %+v", activities, want) } } -func TestRepositoriesService_ListRespositoryActivities_emptyResponse(t *testing.T) { +func TestRepositoriesService_ListRepositoryActivities_emptyResponse(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -4844,34 +4844,34 @@ func TestRepositoriesService_ListRespositoryActivities_emptyResponse(t *testing. }) ctx := context.Background() - activities, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "r", nil) + activities, _, err := client.Repositories.ListRepositoryActivities(ctx, "o", "r", nil) if err != nil { - t.Errorf("Repositories.ListRespositoryActivities returned error: %v", err) + t.Errorf("Repositories.ListRepositoryActivities returned error: %v", err) } want := []*RepositoryActivity{} if !cmp.Equal(activities, want) { - t.Errorf("Repositories.ListRespositoryActivities returned %+v, want %+v", activities, want) + t.Errorf("Repositories.ListRepositoryActivities returned %+v, want %+v", activities, want) } } -func TestRepositoriesService_ListRespositoryActivities_invalidOwner(t *testing.T) { +func TestRepositoriesService_ListRepositoryActivities_invalidOwner(t *testing.T) { t.Parallel() client, _, _ := setup(t) ctx := context.Background() - _, _, err := client.Repositories.ListRespositoryActivities(ctx, "%", "r", nil) + _, _, err := client.Repositories.ListRepositoryActivities(ctx, "%", "r", nil) if err == nil { t.Error("Expected error to be returned") } } -func TestRepositoriesService_ListRespositoryActivities_invalidRepo(t *testing.T) { +func TestRepositoriesService_ListRepositoryActivities_invalidRepo(t *testing.T) { t.Parallel() client, _, _ := setup(t) ctx := context.Background() - _, _, err := client.Repositories.ListRespositoryActivities(ctx, "o", "%", nil) + _, _, err := client.Repositories.ListRepositoryActivities(ctx, "o", "%", nil) if err == nil { t.Error("Expected error to be returned") } diff --git a/openapi_operations.yaml b/openapi_operations.yaml index 738ea0bf9c3..54e1867b5c8 100644 --- a/openapi_operations.yaml +++ b/openapi_operations.yaml @@ -27,7 +27,7 @@ operation_overrides: documentation_url: https://docs.github.com/rest/pages/pages#request-a-github-pages-build - name: GET /repos/{owner}/{repo}/pages/builds/{build_id} documentation_url: https://docs.github.com/rest/pages/pages#get-github-pages-build -openapi_commit: ecbe0df804f3f85f8a68f48d6e9711d05da6f201 +openapi_commit: 0956844c50850685dce43634d73a69f4dac7989e openapi_operations: - name: GET / documentation_url: https://docs.github.com/rest/meta/meta#github-api-root @@ -720,42 +720,6 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/announcement-banners/enterprises#set-announcement-banner-for-enterprise openapi_files: - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/apps/installable_organizations - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-enterprise-owned-organizations-that-can-have-github-apps-installed - openapi_files: - - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/apps/installable_organizations/{org}/accessible_repositories - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-repositories-belonging-to-an-enterprise-owned-organization - openapi_files: - - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/apps/organizations/{org}/installations - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#list-github-apps-installed-on-an-enterprise-owned-organization - openapi_files: - - descriptions/ghec/ghec.json - - name: POST /enterprises/{enterprise}/apps/organizations/{org}/installations - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#install-a-github-app-on-an-enterprise-owned-organization - openapi_files: - - descriptions/ghec/ghec.json - - name: DELETE /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#uninstall-a-github-app-from-an-enterprise-owned-organization - openapi_files: - - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#get-the-repositories-accessible-to-a-given-github-app-installation - openapi_files: - - descriptions/ghec/ghec.json - - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#toggle-installation-repository-access-between-selected-and-all-repositories - openapi_files: - - descriptions/ghec/ghec.json - - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#grant-repository-access-to-an-organization-installation - openapi_files: - - descriptions/ghec/ghec.json - - name: PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/organization-installations#remove-repository-access-from-an-organization-installation - openapi_files: - - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/audit-log documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise openapi_files: @@ -886,10 +850,6 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/license#get-a-license-sync-status openapi_files: - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/members/{username}/copilot - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/copilot/copilot-user-management#get-copilot-seat-assignment-details-for-an-enterprise-user - openapi_files: - - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/network-configurations documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/network-configurations#list-hosted-compute-network-configurations-for-an-enterprise openapi_files: @@ -981,28 +941,12 @@ openapi_operations: documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#get-all-cost-centers-for-an-enterprise openapi_files: - descriptions/ghec/ghec.json - - name: POST /enterprises/{enterprise}/settings/billing/cost-centers - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#create-a-new-cost-center - openapi_files: - - descriptions/ghec/ghec.json - - name: DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#delete-a-cost-center - openapi_files: - - descriptions/ghec/ghec.json - - name: GET /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#get-a-cost-center-by-id - openapi_files: - - descriptions/ghec/ghec.json - - name: PATCH /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#update-a-cost-center-name - openapi_files: - - descriptions/ghec/ghec.json - name: DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#remove-resources-from-a-cost-center + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#remove-users-from-a-cost-center openapi_files: - descriptions/ghec/ghec.json - name: POST /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#add-resources-to-a-cost-center + documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#add-users-to-a-cost-center openapi_files: - descriptions/ghec/ghec.json - name: GET /enterprises/{enterprise}/settings/billing/packages @@ -1389,21 +1333,6 @@ openapi_operations: openapi_files: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: GET /organizations/{org}/dependabot/repository-access - documentation_url: https://docs.github.com/rest/dependabot/repository-access#lists-the-repositories-dependabot-can-access-in-an-organization - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: PATCH /organizations/{org}/dependabot/repository-access - documentation_url: https://docs.github.com/rest/dependabot/repository-access#updates-dependabots-repository-access-list-for-an-organization - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: PUT /organizations/{org}/dependabot/repository-access/default-level - documentation_url: https://docs.github.com/rest/dependabot/repository-access#set-the-default-repository-access-level-for-dependabot - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - name: GET /organizations/{org}/settings/billing/usage documentation_url: https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization openapi_files: @@ -1839,26 +1768,6 @@ openapi_operations: openapi_files: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: POST /orgs/{org}/attestations/bulk-list - documentation_url: https://docs.github.com/rest/orgs/orgs#list-attestations-by-bulk-subject-digests - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: POST /orgs/{org}/attestations/delete-request - documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-in-bulk - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: DELETE /orgs/{org}/attestations/digest/{subject_digest} - documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-by-subject-digest - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: DELETE /orgs/{org}/attestations/{attestation_id} - documentation_url: https://docs.github.com/rest/orgs/attestations#delete-attestations-by-id - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - name: GET /orgs/{org}/attestations/{subject_digest} documentation_url: https://docs.github.com/rest/orgs/orgs#list-attestations openapi_files: @@ -2199,10 +2108,6 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: GET /orgs/{org}/dismissal-requests/code-scanning - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#list-dismissal-requests-for-code-scanning-alerts-for-an-organization - openapi_files: - - descriptions/ghec/ghec.json - name: GET /orgs/{org}/dismissal-requests/secret-scanning documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/secret-scanning/alert-dismissal-requests#list-alert-dismissal-requests-for-secret-scanning-for-an-org openapi_files: @@ -2741,6 +2646,7 @@ openapi_operations: openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json + - descriptions/ghes-3.17/ghes-3.17.json - name: GET /orgs/{org}/private-registries/public-key documentation_url: https://docs.github.com/rest/private-registries/organization-configurations#get-private-registries-public-key-for-an-organization openapi_files: @@ -2766,13 +2672,13 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /orgs/{org}/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#list-organization-projects + documentation_url: https://docs.github.com/rest/projects/projects#list-organization-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /orgs/{org}/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#create-an-organization-project + documentation_url: https://docs.github.com/rest/projects/projects#create-an-organization-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -3239,115 +3145,115 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects-classic/cards#delete-a-project-card + documentation_url: https://docs.github.com/rest/projects/cards#delete-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects-classic/cards#get-a-project-card + documentation_url: https://docs.github.com/rest/projects/cards#get-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/columns/cards/{card_id} - documentation_url: https://docs.github.com/rest/projects-classic/cards#update-an-existing-project-card + documentation_url: https://docs.github.com/rest/projects/cards#update-an-existing-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/cards/{card_id}/moves - documentation_url: https://docs.github.com/rest/projects-classic/cards#move-a-project-card + documentation_url: https://docs.github.com/rest/projects/cards#move-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects-classic/columns#delete-a-project-column + documentation_url: https://docs.github.com/rest/projects/columns#delete-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects-classic/columns#get-a-project-column + documentation_url: https://docs.github.com/rest/projects/columns#get-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/columns/{column_id} - documentation_url: https://docs.github.com/rest/projects-classic/columns#update-an-existing-project-column + documentation_url: https://docs.github.com/rest/projects/columns#update-an-existing-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/columns/{column_id}/cards - documentation_url: https://docs.github.com/rest/projects-classic/cards#list-project-cards + documentation_url: https://docs.github.com/rest/projects/cards#list-project-cards openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/{column_id}/cards - documentation_url: https://docs.github.com/rest/projects-classic/cards#create-a-project-card + documentation_url: https://docs.github.com/rest/projects/cards#create-a-project-card openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/columns/{column_id}/moves - documentation_url: https://docs.github.com/rest/projects-classic/columns#move-a-project-column + documentation_url: https://docs.github.com/rest/projects/columns#move-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects-classic/projects#delete-a-project + documentation_url: https://docs.github.com/rest/projects/projects#delete-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects-classic/projects#get-a-project + documentation_url: https://docs.github.com/rest/projects/projects#get-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PATCH /projects/{project_id} - documentation_url: https://docs.github.com/rest/projects-classic/projects#update-a-project + documentation_url: https://docs.github.com/rest/projects/projects#update-a-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/collaborators - documentation_url: https://docs.github.com/rest/projects-classic/collaborators#list-project-collaborators + documentation_url: https://docs.github.com/rest/projects/collaborators#list-project-collaborators openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: DELETE /projects/{project_id}/collaborators/{username} - documentation_url: https://docs.github.com/rest/projects-classic/collaborators#remove-user-as-a-collaborator + documentation_url: https://docs.github.com/rest/projects/collaborators#remove-user-as-a-collaborator openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: PUT /projects/{project_id}/collaborators/{username} - documentation_url: https://docs.github.com/rest/projects-classic/collaborators#add-project-collaborator + documentation_url: https://docs.github.com/rest/projects/collaborators#add-project-collaborator openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/collaborators/{username}/permission - documentation_url: https://docs.github.com/rest/projects-classic/collaborators#get-project-permission-for-a-user + documentation_url: https://docs.github.com/rest/projects/collaborators#get-project-permission-for-a-user openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /projects/{project_id}/columns - documentation_url: https://docs.github.com/rest/projects-classic/columns#list-project-columns + documentation_url: https://docs.github.com/rest/projects/columns#list-project-columns openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /projects/{project_id}/columns - documentation_url: https://docs.github.com/rest/projects-classic/columns#create-a-project-column + documentation_url: https://docs.github.com/rest/projects/columns#create-a-project-column openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -4648,18 +4554,6 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: GET /repos/{owner}/{repo}/dismissal-requests/code-scanning - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#list-dismissal-requests-for-code-scanning-alerts-for-a-repository - openapi_files: - - descriptions/ghec/ghec.json - - name: GET /repos/{owner}/{repo}/dismissal-requests/code-scanning/{alert_number} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#get-a-dismissal-request-for-a-code-scanning-alert-for-a-repository - openapi_files: - - descriptions/ghec/ghec.json - - name: PATCH /repos/{owner}/{repo}/dismissal-requests/code-scanning/{alert_number} - documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/alert-dismissal-requests#review-a-dismissal-request-for-a-code-scanning-alert-for-a-repository - openapi_files: - - descriptions/ghec/ghec.json - name: GET /repos/{owner}/{repo}/dismissal-requests/secret-scanning documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/secret-scanning/alert-dismissal-requests#list-alert-dismissal-requests-for-secret-scanning-for-a-repository openapi_files: @@ -5512,13 +5406,13 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - name: GET /repos/{owner}/{repo}/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#list-repository-projects + documentation_url: https://docs.github.com/rest/projects/projects#list-repository-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /repos/{owner}/{repo}/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#create-a-repository-project + documentation_url: https://docs.github.com/rest/projects/projects#create-a-repository-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -6992,7 +6886,7 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: POST /user/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#create-a-user-project + documentation_url: https://docs.github.com/rest/projects/projects#create-a-user-project openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json @@ -7129,26 +7023,6 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - - name: POST /users/{username}/attestations/bulk-list - documentation_url: https://docs.github.com/rest/users/attestations#list-attestations-by-bulk-subject-digests - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: POST /users/{username}/attestations/delete-request - documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-in-bulk - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: DELETE /users/{username}/attestations/digest/{subject_digest} - documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-by-subject-digest - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - - name: DELETE /users/{username}/attestations/{attestation_id} - documentation_url: https://docs.github.com/rest/users/attestations#delete-attestations-by-id - openapi_files: - - descriptions/api.github.com/api.github.com.json - - descriptions/ghec/ghec.json - name: GET /users/{username}/attestations/{subject_digest} documentation_url: https://docs.github.com/rest/users/attestations#list-attestations openapi_files: @@ -7281,7 +7155,7 @@ openapi_operations: - descriptions/ghec/ghec.json - descriptions/ghes-3.17/ghes-3.17.json - name: GET /users/{username}/projects - documentation_url: https://docs.github.com/rest/projects-classic/projects#list-user-projects + documentation_url: https://docs.github.com/rest/projects/projects#list-user-projects openapi_files: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json From a90671a70d87b444b3b6c8154475f66eadc1743a Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 29 Jul 2025 22:52:44 +0530 Subject: [PATCH 4/4] Review comments addressed Signed-off-by: abhishek --- github/repos.go | 6 +++--- github/repos_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/github/repos.go b/github/repos.go index 6cf28b9884f..26dc657f086 100644 --- a/github/repos.go +++ b/github/repos.go @@ -2439,9 +2439,9 @@ func (s *RepositoriesService) IsPrivateReportingEnabled(ctx context.Context, own return privateReporting.Enabled, resp, err } -// RepositoryActivityOptions specifies the optional parameters to the +// ListRepositoryActivityOptions specifies the optional parameters to the // RepositoriesService.ListRepositoryActivities method. -type RepositoryActivityOptions struct { +type ListRepositoryActivityOptions struct { // The direction to sort the results by. // Default: desc // Can be one of: asc, desc @@ -2514,7 +2514,7 @@ type RepositoryActivity struct { // GitHub API docs: https://docs.github.com/rest/repos/repos#list-repository-activities // //meta:operation GET /repos/{owner}/{repo}/activity -func (s *RepositoriesService) ListRepositoryActivities(ctx context.Context, owner, repo string, opts *RepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { +func (s *RepositoriesService) ListRepositoryActivities(ctx context.Context, owner, repo string, opts *ListRepositoryActivityOptions) ([]*RepositoryActivity, *Response, error) { u := fmt.Sprintf("repos/%v/%v/activity", owner, repo) u, err := addOptions(u, opts) if err != nil { diff --git a/github/repos_test.go b/github/repos_test.go index ecfd91832b8..91b20dcb5f2 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4641,7 +4641,7 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { ]`) }) - opts := &RepositoryActivityOptions{PerPage: 100} + opts := &ListRepositoryActivityOptions{PerPage: 100} ctx := context.Background() activities, _, err := client.Repositories.ListRepositoryActivities(ctx, "o", "r", opts) if err != nil { @@ -4780,7 +4780,7 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) ]`) }) - opts := &RepositoryActivityOptions{ + opts := &ListRepositoryActivityOptions{ Direction: "desc", Before: "2023-01-01T12:00:00Z", After: "2023-01-01T11:30:00Z",