From d11d3176ac94c915d640d9f16bf8cd0bb1bdcaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Mon, 29 Dec 2025 12:05:39 +0100 Subject: [PATCH 01/12] feat: Add support for Copilot usage metrics reports API --- github/copilot.go | 205 ++++++++++++++++++ github/copilot_test.go | 360 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 24 +++ github/github-accessors_test.go | 33 +++ 4 files changed, 622 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index 25f5969ebe8..451950d6e3b 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -185,6 +185,19 @@ type CopilotMetrics struct { CopilotDotcomPullRequests *CopilotDotcomPullRequests `json:"copilot_dotcom_pull_requests,omitempty"` } +// CopilotMetricsReportOptions specifies the optional parameters for single-day metrics report endpoints. +type CopilotMetricsReportOptions struct { + Day string `url:"day"` // Required, format: YYYY-MM-DD +} + +// CopilotMetricsReportResponse represents the response from Copilot metrics report endpoints. +type CopilotMetricsReportResponse struct { + DownloadLinks []string `json:"download_links"` + ReportDay *string `json:"report_day,omitempty"` // For 1-day reports + ReportStartDay *string `json:"report_start_day,omitempty"` // For 28-day reports + ReportEndDay *string `json:"report_end_day,omitempty"` // For 28-day reports +} + // UnmarshalJSON implements the json.Unmarshaler interface. func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error { // Using an alias to avoid infinite recursion when calling json.Unmarshal @@ -574,3 +587,195 @@ func (s *CopilotService) GetOrganizationTeamMetrics(ctx context.Context, org, te return metrics, resp, nil } + +// GetEnterpriseMetricsReport1Day gets a report containing Copilot metrics for a single day for an enterprise. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics-for-a-specific-day +// +//meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-1-day +func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-1-day", enterprise) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetEnterpriseMetricsReport28Day gets a report containing Copilot metrics for a 28-day rolling window for an enterprise. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics +// +//meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-28-day/latest +func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-28-day/latest", enterprise) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetEnterpriseMetricsReportUsers1Day gets a report containing Copilot user metrics for a single day for an enterprise. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics-for-a-specific-day +// +//meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-1-day +func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-1-day", enterprise) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetEnterpriseMetricsReportUsers28Day gets a report containing Copilot user metrics for a 28-day rolling window for an enterprise. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics +// +//meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-28-day/latest +func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-28-day/latest", enterprise) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetOrganizationMetricsReport1Day gets a report containing Copilot metrics for a single day for an organization. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics-for-a-specific-day +// +//meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-1-day +func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-1-day", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetOrganizationMetricsReport28Day gets a report containing Copilot metrics for a 28-day rolling window for an organization. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics +// +//meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-28-day/latest +func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-28-day/latest", org) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetOrganizationMetricsReportUsers1Day gets a report containing Copilot user metrics for a single day for an organization. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics-for-a-specific-day +// +//meta:operation GET /orgs/{org}/copilot/metrics/reports/users-1-day +func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-1-day", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} + +// GetOrganizationMetricsReportUsers28Day gets a report containing Copilot user metrics for a 28-day rolling window for an organization. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics +// +//meta:operation GET /orgs/{org}/copilot/metrics/reports/users-28-day/latest +func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsReportResponse, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-28-day/latest", org) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var report *CopilotMetricsReportResponse + resp, err := s.client.Do(ctx, req, &report) + if err != nil { + return nil, resp, err + } + + return report, resp, nil +} diff --git a/github/copilot_test.go b/github/copilot_test.go index 8c6ca23f09d..c0debabb34e 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2509,3 +2509,363 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { return resp, err }) } + +func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/enterprises/e/copilot/metrics/reports/enterprise-1-day", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"day": "2025-07-01"}) + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_day": "2025-07-01" + }`) + }) + + ctx := t.Context() + opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} + got, _, err := client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "e", opts) + if err != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportDay: Ptr("2025-07-01"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned %+v, want %+v", got, want) + } + + const methodName = "GetEnterpriseMetricsReport1Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "e", opts) + if got != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/enterprises/e/copilot/metrics/reports/enterprise-28-day/latest", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_start_day": "2025-07-01", + "report_end_day": "2025-07-28" + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "e") + if err != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportStartDay: Ptr("2025-07-01"), + ReportEndDay: Ptr("2025-07-28"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned %+v, want %+v", got, want) + } + + const methodName = "GetEnterpriseMetricsReport28Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "\n") + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "e") + if got != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/enterprises/e/copilot/metrics/reports/users-1-day", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"day": "2025-07-01"}) + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_day": "2025-07-01" + }`) + }) + + ctx := t.Context() + opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} + got, _, err := client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "e", opts) + if err != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportDay: Ptr("2025-07-01"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned %+v, want %+v", got, want) + } + + const methodName = "GetEnterpriseMetricsReportUsers1Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "e", opts) + if got != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/enterprises/e/copilot/metrics/reports/users-28-day/latest", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_start_day": "2025-07-01", + "report_end_day": "2025-07-28" + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "e") + if err != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportStartDay: Ptr("2025-07-01"), + ReportEndDay: Ptr("2025-07-28"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned %+v, want %+v", got, want) + } + + const methodName = "GetEnterpriseMetricsReportUsers28Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "\n") + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "e") + if got != nil { + t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot/metrics/reports/organization-1-day", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"day": "2025-07-01"}) + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_day": "2025-07-01" + }`) + }) + + ctx := t.Context() + opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} + got, _, err := client.Copilot.GetOrganizationMetricsReport1Day(ctx, "o", opts) + if err != nil { + t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportDay: Ptr("2025-07-01"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned %+v, want %+v", got, want) + } + + const methodName = "GetOrganizationMetricsReport1Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetOrganizationMetricsReport1Day(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetOrganizationMetricsReport1Day(ctx, "o", opts) + if got != nil { + t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot/metrics/reports/organization-28-day/latest", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_start_day": "2025-07-01", + "report_end_day": "2025-07-28" + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.GetOrganizationMetricsReport28Day(ctx, "o") + if err != nil { + t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportStartDay: Ptr("2025-07-01"), + ReportEndDay: Ptr("2025-07-28"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned %+v, want %+v", got, want) + } + + const methodName = "GetOrganizationMetricsReport28Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetOrganizationMetricsReport28Day(ctx, "\n") + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetOrganizationMetricsReport28Day(ctx, "o") + if got != nil { + t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot/metrics/reports/users-1-day", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"day": "2025-07-01"}) + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_day": "2025-07-01" + }`) + }) + + ctx := t.Context() + opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} + got, _, err := client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "o", opts) + if err != nil { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportDay: Ptr("2025-07-01"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned %+v, want %+v", got, want) + } + + const methodName = "GetOrganizationMetricsReportUsers1Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "o", opts) + if got != nil { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned %+v, want nil", got) + } + return resp, err + }) +} + +func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot/metrics/reports/users-28-day/latest", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "download_links": ["https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"], + "report_start_day": "2025-07-01", + "report_end_day": "2025-07-28" + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "o") + if err != nil { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned error: %v", err) + } + + want := &CopilotMetricsReportResponse{ + DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, + ReportStartDay: Ptr("2025-07-01"), + ReportEndDay: Ptr("2025-07-28"), + } + + if !cmp.Equal(got, want) { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned %+v, want %+v", got, want) + } + + const methodName = "GetOrganizationMetricsReportUsers28Day" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "\n") + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "o") + if got != nil { + t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned %+v, want nil", got) + } + return resp, err + }) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 35d86729d03..8448c7bf0bb 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6286,6 +6286,30 @@ func (c *CopilotMetricsListOptions) GetUntil() time.Time { return *c.Until } +// GetReportDay returns the ReportDay field if it's non-nil, zero value otherwise. +func (c *CopilotMetricsReportResponse) GetReportDay() string { + if c == nil || c.ReportDay == nil { + return "" + } + return *c.ReportDay +} + +// GetReportEndDay returns the ReportEndDay field if it's non-nil, zero value otherwise. +func (c *CopilotMetricsReportResponse) GetReportEndDay() string { + if c == nil || c.ReportEndDay == nil { + return "" + } + return *c.ReportEndDay +} + +// GetReportStartDay returns the ReportStartDay field if it's non-nil, zero value otherwise. +func (c *CopilotMetricsReportResponse) GetReportStartDay() string { + if c == nil || c.ReportStartDay == nil { + return "" + } + return *c.ReportStartDay +} + // GetSeatBreakdown returns the SeatBreakdown field. func (c *CopilotOrganizationDetails) GetSeatBreakdown() *CopilotSeatBreakdown { if c == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 3dcbd7129c4..cd5deb537cf 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8204,6 +8204,39 @@ func TestCopilotMetricsListOptions_GetUntil(tt *testing.T) { c.GetUntil() } +func TestCopilotMetricsReportResponse_GetReportDay(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotMetricsReportResponse{ReportDay: &zeroValue} + c.GetReportDay() + c = &CopilotMetricsReportResponse{} + c.GetReportDay() + c = nil + c.GetReportDay() +} + +func TestCopilotMetricsReportResponse_GetReportEndDay(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotMetricsReportResponse{ReportEndDay: &zeroValue} + c.GetReportEndDay() + c = &CopilotMetricsReportResponse{} + c.GetReportEndDay() + c = nil + c.GetReportEndDay() +} + +func TestCopilotMetricsReportResponse_GetReportStartDay(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotMetricsReportResponse{ReportStartDay: &zeroValue} + c.GetReportStartDay() + c = &CopilotMetricsReportResponse{} + c.GetReportStartDay() + c = nil + c.GetReportStartDay() +} + func TestCopilotOrganizationDetails_GetSeatBreakdown(tt *testing.T) { tt.Parallel() c := &CopilotOrganizationDetails{} From cc49b283bcf5148a27806967a2cc64d9d05af27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Tue, 30 Dec 2025 12:21:25 +0100 Subject: [PATCH 02/12] refactor: use separate structs for single-day and multi-day responses --- github/copilot.go | 47 ++++++++++++++++++--------------- github/copilot_test.go | 40 ++++++++++++++-------------- github/github-accessors.go | 24 ----------------- github/github-accessors_test.go | 33 ----------------------- 4 files changed, 46 insertions(+), 98 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 451950d6e3b..3bdcc907d38 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -190,12 +190,17 @@ type CopilotMetricsReportOptions struct { Day string `url:"day"` // Required, format: YYYY-MM-DD } -// CopilotMetricsReportResponse represents the response from Copilot metrics report endpoints. -type CopilotMetricsReportResponse struct { +// CopilotMetricsDailyReportResponse represents the response from 1-day Copilot metrics report endpoints. +type CopilotMetricsDailyReportResponse struct { + DownloadLinks []string `json:"download_links"` + ReportDay string `json:"report_day"` +} + +// CopilotMetricsPeriodReportResponse represents the response from 28-day Copilot metrics report endpoints. +type CopilotMetricsPeriodReportResponse struct { DownloadLinks []string `json:"download_links"` - ReportDay *string `json:"report_day,omitempty"` // For 1-day reports - ReportStartDay *string `json:"report_start_day,omitempty"` // For 28-day reports - ReportEndDay *string `json:"report_end_day,omitempty"` // For 28-day reports + ReportStartDay string `json:"report_start_day"` + ReportEndDay string `json:"report_end_day"` } // UnmarshalJSON implements the json.Unmarshaler interface. @@ -593,7 +598,7 @@ func (s *CopilotService) GetOrganizationTeamMetrics(ctx context.Context, org, te // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-1-day -func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { @@ -605,7 +610,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, ent return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsDailyReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -619,7 +624,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, ent // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsPeriodReportResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) @@ -627,7 +632,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, en return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsPeriodReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -641,7 +646,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, en // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { @@ -653,7 +658,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsDailyReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -667,7 +672,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsPeriodReportResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) @@ -675,7 +680,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Contex return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsPeriodReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -689,7 +694,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Contex // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-1-day -func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-1-day", org) u, err := addOptions(u, opts) if err != nil { @@ -701,7 +706,7 @@ func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, o return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsDailyReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -715,7 +720,7 @@ func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, o // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsPeriodReportResponse, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) @@ -723,7 +728,7 @@ func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsPeriodReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -737,7 +742,7 @@ func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-1-day", org) u, err := addOptions(u, opts) if err != nil { @@ -749,7 +754,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Conte return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsDailyReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -763,7 +768,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Conte // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsPeriodReportResponse, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) @@ -771,7 +776,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Cont return nil, nil, err } - var report *CopilotMetricsReportResponse + var report *CopilotMetricsPeriodReportResponse resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err diff --git a/github/copilot_test.go b/github/copilot_test.go index c0debabb34e..f14a96e37b6 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2530,9 +2530,9 @@ func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsDailyReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportDay: Ptr("2025-07-01"), + ReportDay: "2025-07-01", } if !cmp.Equal(got, want) { @@ -2574,10 +2574,10 @@ func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsPeriodReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportStartDay: Ptr("2025-07-01"), - ReportEndDay: Ptr("2025-07-28"), + ReportStartDay: "2025-07-01", + ReportEndDay: "2025-07-28", } if !cmp.Equal(got, want) { @@ -2620,9 +2620,9 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsDailyReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportDay: Ptr("2025-07-01"), + ReportDay: "2025-07-01", } if !cmp.Equal(got, want) { @@ -2664,10 +2664,10 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsPeriodReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportStartDay: Ptr("2025-07-01"), - ReportEndDay: Ptr("2025-07-28"), + ReportStartDay: "2025-07-01", + ReportEndDay: "2025-07-28", } if !cmp.Equal(got, want) { @@ -2710,9 +2710,9 @@ func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsDailyReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportDay: Ptr("2025-07-01"), + ReportDay: "2025-07-01", } if !cmp.Equal(got, want) { @@ -2754,10 +2754,10 @@ func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsPeriodReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportStartDay: Ptr("2025-07-01"), - ReportEndDay: Ptr("2025-07-28"), + ReportStartDay: "2025-07-01", + ReportEndDay: "2025-07-28", } if !cmp.Equal(got, want) { @@ -2800,9 +2800,9 @@ func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsDailyReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportDay: Ptr("2025-07-01"), + ReportDay: "2025-07-01", } if !cmp.Equal(got, want) { @@ -2844,10 +2844,10 @@ func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned error: %v", err) } - want := &CopilotMetricsReportResponse{ + want := &CopilotMetricsPeriodReportResponse{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, - ReportStartDay: Ptr("2025-07-01"), - ReportEndDay: Ptr("2025-07-28"), + ReportStartDay: "2025-07-01", + ReportEndDay: "2025-07-28", } if !cmp.Equal(got, want) { diff --git a/github/github-accessors.go b/github/github-accessors.go index 8448c7bf0bb..35d86729d03 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6286,30 +6286,6 @@ func (c *CopilotMetricsListOptions) GetUntil() time.Time { return *c.Until } -// GetReportDay returns the ReportDay field if it's non-nil, zero value otherwise. -func (c *CopilotMetricsReportResponse) GetReportDay() string { - if c == nil || c.ReportDay == nil { - return "" - } - return *c.ReportDay -} - -// GetReportEndDay returns the ReportEndDay field if it's non-nil, zero value otherwise. -func (c *CopilotMetricsReportResponse) GetReportEndDay() string { - if c == nil || c.ReportEndDay == nil { - return "" - } - return *c.ReportEndDay -} - -// GetReportStartDay returns the ReportStartDay field if it's non-nil, zero value otherwise. -func (c *CopilotMetricsReportResponse) GetReportStartDay() string { - if c == nil || c.ReportStartDay == nil { - return "" - } - return *c.ReportStartDay -} - // GetSeatBreakdown returns the SeatBreakdown field. func (c *CopilotOrganizationDetails) GetSeatBreakdown() *CopilotSeatBreakdown { if c == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index cd5deb537cf..3dcbd7129c4 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8204,39 +8204,6 @@ func TestCopilotMetricsListOptions_GetUntil(tt *testing.T) { c.GetUntil() } -func TestCopilotMetricsReportResponse_GetReportDay(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CopilotMetricsReportResponse{ReportDay: &zeroValue} - c.GetReportDay() - c = &CopilotMetricsReportResponse{} - c.GetReportDay() - c = nil - c.GetReportDay() -} - -func TestCopilotMetricsReportResponse_GetReportEndDay(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CopilotMetricsReportResponse{ReportEndDay: &zeroValue} - c.GetReportEndDay() - c = &CopilotMetricsReportResponse{} - c.GetReportEndDay() - c = nil - c.GetReportEndDay() -} - -func TestCopilotMetricsReportResponse_GetReportStartDay(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CopilotMetricsReportResponse{ReportStartDay: &zeroValue} - c.GetReportStartDay() - c = &CopilotMetricsReportResponse{} - c.GetReportStartDay() - c = nil - c.GetReportStartDay() -} - func TestCopilotOrganizationDetails_GetSeatBreakdown(tt *testing.T) { tt.Parallel() c := &CopilotOrganizationDetails{} From ed3fa223480c621b3553982fa7e59d17d59b54b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:46:58 +0100 Subject: [PATCH 03/12] refactor: rename CopilotMetricsDailyReportResponse to CopilotMetricsDailyReport --- github/copilot.go | 20 ++++++++++---------- github/copilot_test.go | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 3bdcc907d38..300b957dae6 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -190,8 +190,8 @@ type CopilotMetricsReportOptions struct { Day string `url:"day"` // Required, format: YYYY-MM-DD } -// CopilotMetricsDailyReportResponse represents the response from 1-day Copilot metrics report endpoints. -type CopilotMetricsDailyReportResponse struct { +// CopilotMetricsDailyReport represents the response from 1-day Copilot metrics report endpoints. +type CopilotMetricsDailyReport struct { DownloadLinks []string `json:"download_links"` ReportDay string `json:"report_day"` } @@ -598,7 +598,7 @@ func (s *CopilotService) GetOrganizationTeamMetrics(ctx context.Context, org, te // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-1-day -func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { @@ -610,7 +610,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, ent return nil, nil, err } - var report *CopilotMetricsDailyReportResponse + var report *CopilotMetricsDailyReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -646,7 +646,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, en // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { @@ -658,7 +658,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context return nil, nil, err } - var report *CopilotMetricsDailyReportResponse + var report *CopilotMetricsDailyReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -694,7 +694,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Contex // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-1-day -func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-1-day", org) u, err := addOptions(u, opts) if err != nil { @@ -706,7 +706,7 @@ func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, o return nil, nil, err } - var report *CopilotMetricsDailyReportResponse + var report *CopilotMetricsDailyReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -742,7 +742,7 @@ func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-1-day", org) u, err := addOptions(u, opts) if err != nil { @@ -754,7 +754,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Conte return nil, nil, err } - var report *CopilotMetricsDailyReportResponse + var report *CopilotMetricsDailyReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err diff --git a/github/copilot_test.go b/github/copilot_test.go index f14a96e37b6..8bce2695d29 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2530,7 +2530,7 @@ func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned error: %v", err) } - want := &CopilotMetricsDailyReportResponse{ + want := &CopilotMetricsDailyReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportDay: "2025-07-01", } @@ -2620,7 +2620,7 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned error: %v", err) } - want := &CopilotMetricsDailyReportResponse{ + want := &CopilotMetricsDailyReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportDay: "2025-07-01", } @@ -2710,7 +2710,7 @@ func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned error: %v", err) } - want := &CopilotMetricsDailyReportResponse{ + want := &CopilotMetricsDailyReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportDay: "2025-07-01", } @@ -2800,7 +2800,7 @@ func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned error: %v", err) } - want := &CopilotMetricsDailyReportResponse{ + want := &CopilotMetricsDailyReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportDay: "2025-07-01", } From 9a7018baabb191a99acfa1de9c1fe59393b1813a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:47:54 +0100 Subject: [PATCH 04/12] refactor: rename CopilotMetricsPeriodReportResponse to CopilotMetricsReport --- github/copilot.go | 20 ++++++++++---------- github/copilot_test.go | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 300b957dae6..4ed4f91ba20 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -196,8 +196,8 @@ type CopilotMetricsDailyReport struct { ReportDay string `json:"report_day"` } -// CopilotMetricsPeriodReportResponse represents the response from 28-day Copilot metrics report endpoints. -type CopilotMetricsPeriodReportResponse struct { +// CopilotMetricsReport represents the response from 28-day Copilot metrics report endpoints. +type CopilotMetricsReport struct { DownloadLinks []string `json:"download_links"` ReportStartDay string `json:"report_start_day"` ReportEndDay string `json:"report_end_day"` @@ -624,7 +624,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, ent // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsPeriodReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) @@ -632,7 +632,7 @@ func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, en return nil, nil, err } - var report *CopilotMetricsPeriodReportResponse + var report *CopilotMetricsReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -672,7 +672,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsPeriodReportResponse, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) @@ -680,7 +680,7 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Contex return nil, nil, err } - var report *CopilotMetricsPeriodReportResponse + var report *CopilotMetricsReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -720,7 +720,7 @@ func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, o // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsPeriodReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) @@ -728,7 +728,7 @@ func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, return nil, nil, err } - var report *CopilotMetricsPeriodReportResponse + var report *CopilotMetricsReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err @@ -768,7 +768,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Conte // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsPeriodReportResponse, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) @@ -776,7 +776,7 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Cont return nil, nil, err } - var report *CopilotMetricsPeriodReportResponse + var report *CopilotMetricsReport resp, err := s.client.Do(ctx, req, &report) if err != nil { return nil, resp, err diff --git a/github/copilot_test.go b/github/copilot_test.go index 8bce2695d29..6033022e644 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2574,7 +2574,7 @@ func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned error: %v", err) } - want := &CopilotMetricsPeriodReportResponse{ + want := &CopilotMetricsReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportStartDay: "2025-07-01", ReportEndDay: "2025-07-28", @@ -2664,7 +2664,7 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned error: %v", err) } - want := &CopilotMetricsPeriodReportResponse{ + want := &CopilotMetricsReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportStartDay: "2025-07-01", ReportEndDay: "2025-07-28", @@ -2754,7 +2754,7 @@ func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned error: %v", err) } - want := &CopilotMetricsPeriodReportResponse{ + want := &CopilotMetricsReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportStartDay: "2025-07-01", ReportEndDay: "2025-07-28", @@ -2844,7 +2844,7 @@ func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned error: %v", err) } - want := &CopilotMetricsPeriodReportResponse{ + want := &CopilotMetricsReport{ DownloadLinks: []string{"https://example.com/copilot-usage-report-1.json", "https://example.com/copilot-usage-report-2.json"}, ReportStartDay: "2025-07-01", ReportEndDay: "2025-07-28", From 0afbbea1ded6e690f0e289ac819091c3c4c81f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:49:32 +0100 Subject: [PATCH 05/12] refactor: rename GetEnterpriseMetricsReport28Day to GetEnterpriseMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 4ed4f91ba20..09b44b81d20 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -619,12 +619,12 @@ func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, ent return report, resp, nil } -// GetEnterpriseMetricsReport28Day gets a report containing Copilot metrics for a 28-day rolling window for an enterprise. +// GetEnterpriseMetricsReport gets a report containing Copilot metrics for a 28-day rolling window for an enterprise. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReport28Day(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { +func (s *CopilotService) GetEnterpriseMetricsReport(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/copilot_test.go b/github/copilot_test.go index 6033022e644..148e4185506 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2555,7 +2555,7 @@ func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { }) } -func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { +func TestCopilotService_GetEnterpriseMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2569,9 +2569,9 @@ func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { }) ctx := t.Context() - got, _, err := client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "e") + got, _, err := client.Copilot.GetEnterpriseMetricsReport(ctx, "e") if err != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned error: %v", err) + t.Errorf("Copilot.GetEnterpriseMetricsReport returned error: %v", err) } want := &CopilotMetricsReport{ @@ -2581,20 +2581,20 @@ func TestCopilotService_GetEnterpriseMetricsReport28Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetEnterpriseMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetEnterpriseMetricsReport28Day" + const methodName = "GetEnterpriseMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "\n") + _, _, err = client.Copilot.GetEnterpriseMetricsReport(ctx, "\n") return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetEnterpriseMetricsReport28Day(ctx, "e") + got, resp, err := client.Copilot.GetEnterpriseMetricsReport(ctx, "e") if got != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReport28Day returned %+v, want nil", got) + t.Errorf("Copilot.GetEnterpriseMetricsReport returned %+v, want nil", got) } return resp, err }) From 0a55e0c433ef2d3fe7092e0341069b837b897dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:51:10 +0100 Subject: [PATCH 06/12] refactor: rename GetEnterpriseMetricsReportUsers28Day to GetEnterpriseUsersMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 09b44b81d20..12b4cada53b 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -667,12 +667,12 @@ func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context return report, resp, nil } -// GetEnterpriseMetricsReportUsers28Day gets a report containing Copilot user metrics for a 28-day rolling window for an enterprise. +// GetEnterpriseUsersMetricsReport gets a report containing Copilot user metrics for a 28-day rolling window for an enterprise. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetEnterpriseMetricsReportUsers28Day(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { +func (s *CopilotService) GetEnterpriseUsersMetricsReport(ctx context.Context, enterprise string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-28-day/latest", enterprise) req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/copilot_test.go b/github/copilot_test.go index 148e4185506..a012f855e1f 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2645,7 +2645,7 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { }) } -func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { +func TestCopilotService_GetEnterpriseUsersMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2659,9 +2659,9 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { }) ctx := t.Context() - got, _, err := client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "e") + got, _, err := client.Copilot.GetEnterpriseUsersMetricsReport(ctx, "e") if err != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned error: %v", err) + t.Errorf("Copilot.GetEnterpriseUsersMetricsReport returned error: %v", err) } want := &CopilotMetricsReport{ @@ -2671,20 +2671,20 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers28Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetEnterpriseUsersMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetEnterpriseMetricsReportUsers28Day" + const methodName = "GetEnterpriseUsersMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "\n") + _, _, err = client.Copilot.GetEnterpriseUsersMetricsReport(ctx, "\n") return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetEnterpriseMetricsReportUsers28Day(ctx, "e") + got, resp, err := client.Copilot.GetEnterpriseUsersMetricsReport(ctx, "e") if got != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers28Day returned %+v, want nil", got) + t.Errorf("Copilot.GetEnterpriseUsersMetricsReport returned %+v, want nil", got) } return resp, err }) From ec61a5421edeeb404c3588f6c5aa02002a00e88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:51:59 +0100 Subject: [PATCH 07/12] refactor: rename GetOrganizationMetricsReport28Day to GetOrganizationMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 12b4cada53b..aacc816c3a2 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -715,12 +715,12 @@ func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, o return report, resp, nil } -// GetOrganizationMetricsReport28Day gets a report containing Copilot metrics for a 28-day rolling window for an organization. +// GetOrganizationMetricsReport gets a report containing Copilot metrics for a 28-day rolling window for an organization. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReport28Day(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { +func (s *CopilotService) GetOrganizationMetricsReport(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/copilot_test.go b/github/copilot_test.go index a012f855e1f..fadcdbcd8db 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2735,7 +2735,7 @@ func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { }) } -func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { +func TestCopilotService_GetOrganizationMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2749,9 +2749,9 @@ func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { }) ctx := t.Context() - got, _, err := client.Copilot.GetOrganizationMetricsReport28Day(ctx, "o") + got, _, err := client.Copilot.GetOrganizationMetricsReport(ctx, "o") if err != nil { - t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned error: %v", err) + t.Errorf("Copilot.GetOrganizationMetricsReport returned error: %v", err) } want := &CopilotMetricsReport{ @@ -2761,20 +2761,20 @@ func TestCopilotService_GetOrganizationMetricsReport28Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetOrganizationMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetOrganizationMetricsReport28Day" + const methodName = "GetOrganizationMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetOrganizationMetricsReport28Day(ctx, "\n") + _, _, err = client.Copilot.GetOrganizationMetricsReport(ctx, "\n") return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetOrganizationMetricsReport28Day(ctx, "o") + got, resp, err := client.Copilot.GetOrganizationMetricsReport(ctx, "o") if got != nil { - t.Errorf("Copilot.GetOrganizationMetricsReport28Day returned %+v, want nil", got) + t.Errorf("Copilot.GetOrganizationMetricsReport returned %+v, want nil", got) } return resp, err }) From b0ab2e2e38e1cdb3f176eb69cd805c050043e7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:52:40 +0100 Subject: [PATCH 08/12] refactor: rename GetOrganizationMetricsReportUsers28Day to GetOrganizationUsersMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index aacc816c3a2..08433e50c4e 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -763,12 +763,12 @@ func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Conte return report, resp, nil } -// GetOrganizationMetricsReportUsers28Day gets a report containing Copilot user metrics for a 28-day rolling window for an organization. +// GetOrganizationUsersMetricsReport gets a report containing Copilot user metrics for a 28-day rolling window for an organization. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-28-day/latest -func (s *CopilotService) GetOrganizationMetricsReportUsers28Day(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { +func (s *CopilotService) GetOrganizationUsersMetricsReport(ctx context.Context, org string) (*CopilotMetricsReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-28-day/latest", org) req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/copilot_test.go b/github/copilot_test.go index fadcdbcd8db..f4131459e37 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2825,7 +2825,7 @@ func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { }) } -func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { +func TestCopilotService_GetOrganizationUsersMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2839,9 +2839,9 @@ func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { }) ctx := t.Context() - got, _, err := client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "o") + got, _, err := client.Copilot.GetOrganizationUsersMetricsReport(ctx, "o") if err != nil { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned error: %v", err) + t.Errorf("Copilot.GetOrganizationUsersMetricsReport returned error: %v", err) } want := &CopilotMetricsReport{ @@ -2851,20 +2851,20 @@ func TestCopilotService_GetOrganizationMetricsReportUsers28Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetOrganizationUsersMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetOrganizationMetricsReportUsers28Day" + const methodName = "GetOrganizationUsersMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "\n") + _, _, err = client.Copilot.GetOrganizationUsersMetricsReport(ctx, "\n") return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetOrganizationMetricsReportUsers28Day(ctx, "o") + got, resp, err := client.Copilot.GetOrganizationUsersMetricsReport(ctx, "o") if got != nil { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers28Day returned %+v, want nil", got) + t.Errorf("Copilot.GetOrganizationUsersMetricsReport returned %+v, want nil", got) } return resp, err }) From 5c179e92793f6cf227d32a91ee916508e7b80ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:53:25 +0100 Subject: [PATCH 09/12] refactor: rename GetEnterpriseMetricsReport1Day to GetEnterpriseDailyMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 08433e50c4e..e8053d2e62f 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -593,12 +593,12 @@ func (s *CopilotService) GetOrganizationTeamMetrics(ctx context.Context, org, te return metrics, resp, nil } -// GetEnterpriseMetricsReport1Day gets a report containing Copilot metrics for a single day for an enterprise. +// GetEnterpriseDailyMetricsReport gets a report containing Copilot metrics for a single day for an enterprise. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-enterprise-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/enterprise-1-day -func (s *CopilotService) GetEnterpriseMetricsReport1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { +func (s *CopilotService) GetEnterpriseDailyMetricsReport(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/enterprise-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index f4131459e37..fe4dbe5abda 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2510,7 +2510,7 @@ func TestCopilotService_GetOrganizationTeamMetrics(t *testing.T) { }) } -func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { +func TestCopilotService_GetEnterpriseDailyMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2525,9 +2525,9 @@ func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { ctx := t.Context() opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} - got, _, err := client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "e", opts) + got, _, err := client.Copilot.GetEnterpriseDailyMetricsReport(ctx, "e", opts) if err != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned error: %v", err) + t.Errorf("Copilot.GetEnterpriseDailyMetricsReport returned error: %v", err) } want := &CopilotMetricsDailyReport{ @@ -2536,20 +2536,20 @@ func TestCopilotService_GetEnterpriseMetricsReport1Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetEnterpriseDailyMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetEnterpriseMetricsReport1Day" + const methodName = "GetEnterpriseDailyMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "\n", opts) + _, _, err = client.Copilot.GetEnterpriseDailyMetricsReport(ctx, "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetEnterpriseMetricsReport1Day(ctx, "e", opts) + got, resp, err := client.Copilot.GetEnterpriseDailyMetricsReport(ctx, "e", opts) if got != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReport1Day returned %+v, want nil", got) + t.Errorf("Copilot.GetEnterpriseDailyMetricsReport returned %+v, want nil", got) } return resp, err }) From a936b9182858792a10a0f00a17ef7bc11002b3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:54:00 +0100 Subject: [PATCH 10/12] refactor: rename GetEnterpriseMetricsReportUsers1Day to GetEnterpriseUsersDailyMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index e8053d2e62f..11282398bee 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -641,12 +641,12 @@ func (s *CopilotService) GetEnterpriseMetricsReport(ctx context.Context, enterpr return report, resp, nil } -// GetEnterpriseMetricsReportUsers1Day gets a report containing Copilot user metrics for a single day for an enterprise. +// GetEnterpriseUsersDailyMetricsReport gets a report containing Copilot user metrics for a single day for an enterprise. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-users-usage-metrics-for-a-specific-day // //meta:operation GET /enterprises/{enterprise}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetEnterpriseMetricsReportUsers1Day(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { +func (s *CopilotService) GetEnterpriseUsersDailyMetricsReport(ctx context.Context, enterprise string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("enterprises/%v/copilot/metrics/reports/users-1-day", enterprise) u, err := addOptions(u, opts) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index fe4dbe5abda..8b390e74212 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2600,7 +2600,7 @@ func TestCopilotService_GetEnterpriseMetricsReport(t *testing.T) { }) } -func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { +func TestCopilotService_GetEnterpriseUsersDailyMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2615,9 +2615,9 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { ctx := t.Context() opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} - got, _, err := client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "e", opts) + got, _, err := client.Copilot.GetEnterpriseUsersDailyMetricsReport(ctx, "e", opts) if err != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned error: %v", err) + t.Errorf("Copilot.GetEnterpriseUsersDailyMetricsReport returned error: %v", err) } want := &CopilotMetricsDailyReport{ @@ -2626,20 +2626,20 @@ func TestCopilotService_GetEnterpriseMetricsReportUsers1Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetEnterpriseUsersDailyMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetEnterpriseMetricsReportUsers1Day" + const methodName = "GetEnterpriseUsersDailyMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "\n", opts) + _, _, err = client.Copilot.GetEnterpriseUsersDailyMetricsReport(ctx, "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetEnterpriseMetricsReportUsers1Day(ctx, "e", opts) + got, resp, err := client.Copilot.GetEnterpriseUsersDailyMetricsReport(ctx, "e", opts) if got != nil { - t.Errorf("Copilot.GetEnterpriseMetricsReportUsers1Day returned %+v, want nil", got) + t.Errorf("Copilot.GetEnterpriseUsersDailyMetricsReport returned %+v, want nil", got) } return resp, err }) From e4d51ecc0757fea2ce397333b893b88d07082f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:54:29 +0100 Subject: [PATCH 11/12] refactor: rename GetOrganizationMetricsReport1Day to GetOrganizationDailyMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 11282398bee..48c2b5d35ff 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -689,12 +689,12 @@ func (s *CopilotService) GetEnterpriseUsersMetricsReport(ctx context.Context, en return report, resp, nil } -// GetOrganizationMetricsReport1Day gets a report containing Copilot metrics for a single day for an organization. +// GetOrganizationDailyMetricsReport gets a report containing Copilot metrics for a single day for an organization. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/organization-1-day -func (s *CopilotService) GetOrganizationMetricsReport1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { +func (s *CopilotService) GetOrganizationDailyMetricsReport(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/organization-1-day", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index 8b390e74212..eb28bfb792c 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2690,7 +2690,7 @@ func TestCopilotService_GetEnterpriseUsersMetricsReport(t *testing.T) { }) } -func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { +func TestCopilotService_GetOrganizationDailyMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2705,9 +2705,9 @@ func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { ctx := t.Context() opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} - got, _, err := client.Copilot.GetOrganizationMetricsReport1Day(ctx, "o", opts) + got, _, err := client.Copilot.GetOrganizationDailyMetricsReport(ctx, "o", opts) if err != nil { - t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned error: %v", err) + t.Errorf("Copilot.GetOrganizationDailyMetricsReport returned error: %v", err) } want := &CopilotMetricsDailyReport{ @@ -2716,20 +2716,20 @@ func TestCopilotService_GetOrganizationMetricsReport1Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetOrganizationDailyMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetOrganizationMetricsReport1Day" + const methodName = "GetOrganizationDailyMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetOrganizationMetricsReport1Day(ctx, "\n", opts) + _, _, err = client.Copilot.GetOrganizationDailyMetricsReport(ctx, "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetOrganizationMetricsReport1Day(ctx, "o", opts) + got, resp, err := client.Copilot.GetOrganizationDailyMetricsReport(ctx, "o", opts) if got != nil { - t.Errorf("Copilot.GetOrganizationMetricsReport1Day returned %+v, want nil", got) + t.Errorf("Copilot.GetOrganizationDailyMetricsReport returned %+v, want nil", got) } return resp, err }) From beae111b4aac6dea3972e88ad3dfdeaddb1d86d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Lundstr=C3=B6m?= Date: Fri, 2 Jan 2026 08:54:58 +0100 Subject: [PATCH 12/12] refactor: rename GetOrganizationMetricsReportUsers1Day to GetOrganizationUsersDailyMetricsReport --- github/copilot.go | 4 ++-- github/copilot_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 48c2b5d35ff..7a7a13a6a2b 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -737,12 +737,12 @@ func (s *CopilotService) GetOrganizationMetricsReport(ctx context.Context, org s return report, resp, nil } -// GetOrganizationMetricsReportUsers1Day gets a report containing Copilot user metrics for a single day for an organization. +// GetOrganizationUsersDailyMetricsReport gets a report containing Copilot user metrics for a single day for an organization. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-usage-metrics#get-copilot-organization-users-usage-metrics-for-a-specific-day // //meta:operation GET /orgs/{org}/copilot/metrics/reports/users-1-day -func (s *CopilotService) GetOrganizationMetricsReportUsers1Day(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { +func (s *CopilotService) GetOrganizationUsersDailyMetricsReport(ctx context.Context, org string, opts *CopilotMetricsReportOptions) (*CopilotMetricsDailyReport, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/metrics/reports/users-1-day", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index eb28bfb792c..781dc0570a5 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -2780,7 +2780,7 @@ func TestCopilotService_GetOrganizationMetricsReport(t *testing.T) { }) } -func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { +func TestCopilotService_GetOrganizationUsersDailyMetricsReport(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2795,9 +2795,9 @@ func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { ctx := t.Context() opts := &CopilotMetricsReportOptions{Day: "2025-07-01"} - got, _, err := client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "o", opts) + got, _, err := client.Copilot.GetOrganizationUsersDailyMetricsReport(ctx, "o", opts) if err != nil { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned error: %v", err) + t.Errorf("Copilot.GetOrganizationUsersDailyMetricsReport returned error: %v", err) } want := &CopilotMetricsDailyReport{ @@ -2806,20 +2806,20 @@ func TestCopilotService_GetOrganizationMetricsReportUsers1Day(t *testing.T) { } if !cmp.Equal(got, want) { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned %+v, want %+v", got, want) + t.Errorf("Copilot.GetOrganizationUsersDailyMetricsReport returned %+v, want %+v", got, want) } - const methodName = "GetOrganizationMetricsReportUsers1Day" + const methodName = "GetOrganizationUsersDailyMetricsReport" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "\n", opts) + _, _, err = client.Copilot.GetOrganizationUsersDailyMetricsReport(ctx, "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.GetOrganizationMetricsReportUsers1Day(ctx, "o", opts) + got, resp, err := client.Copilot.GetOrganizationUsersDailyMetricsReport(ctx, "o", opts) if got != nil { - t.Errorf("Copilot.GetOrganizationMetricsReportUsers1Day returned %+v, want nil", got) + t.Errorf("Copilot.GetOrganizationUsersDailyMetricsReport returned %+v, want nil", got) } return resp, err })