@@ -10,6 +10,7 @@ import (
1010 "encoding/json"
1111 "errors"
1212 "fmt"
13+ "net/http"
1314 "time"
1415)
1516
@@ -491,6 +492,10 @@ func (s *CopilotService) GetSeatDetails(ctx context.Context, org, user string) (
491492
492493// GetEnterpriseMetrics gets Copilot usage metrics for an enterprise.
493494//
495+ // Deprecated: Focus has shifted to the new Download Copilot Usage Metrics APIs.
496+ // These endpoints are kept around for GitHub Enterprise Server users, but are no longer supported on the Public GitHub service.
497+ // Use GetEnterpriseDailyMetricsReport or GetEnterpriseMetricsReport instead.
498+ //
494499// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-enterprise
495500//
496501//meta:operation GET /enterprises/{enterprise}/copilot/metrics
@@ -517,6 +522,9 @@ func (s *CopilotService) GetEnterpriseMetrics(ctx context.Context, enterprise st
517522
518523// GetEnterpriseTeamMetrics gets Copilot usage metrics for an enterprise team.
519524//
525+ // Deprecated: Focus has shifted to the new Download Copilot Usage Metrics APIs.
526+ // These endpoints are kept around for GitHub Enterprise Server users, but are no longer supported on the Public GitHub service.
527+ //
520528// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-enterprise-team
521529//
522530//meta:operation GET /enterprises/{enterprise}/team/{team_slug}/copilot/metrics
@@ -543,6 +551,10 @@ func (s *CopilotService) GetEnterpriseTeamMetrics(ctx context.Context, enterpris
543551
544552// GetOrganizationMetrics gets Copilot usage metrics for an organization.
545553//
554+ // Deprecated: Focus has shifted to the new Download Copilot Usage Metrics APIs.
555+ // These endpoints are kept around for GitHub Enterprise Server users, but are no longer supported on the Public GitHub service.
556+ // Use GetOrganizationDailyMetricsReport or GetOrganizationMetricsReport instead.
557+ //
546558// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-an-organization
547559//
548560//meta:operation GET /orgs/{org}/copilot/metrics
@@ -569,6 +581,9 @@ func (s *CopilotService) GetOrganizationMetrics(ctx context.Context, org string,
569581
570582// GetOrganizationTeamMetrics gets Copilot usage metrics for an organization team.
571583//
584+ // Deprecated: Focus has shifted to the new Download Copilot Usage Metrics APIs.
585+ // These endpoints are kept around for GitHub Enterprise Server users, but are no longer supported on the Public GitHub service.
586+ //
572587// GitHub API docs: https://docs.github.com/rest/copilot/copilot-metrics#get-copilot-metrics-for-a-team
573588//
574589//meta:operation GET /orgs/{org}/team/{team_slug}/copilot/metrics
@@ -784,3 +799,32 @@ func (s *CopilotService) GetOrganizationUsersMetricsReport(ctx context.Context,
784799
785800 return report , resp , nil
786801}
802+
803+ // DownloadCopilotMetrics downloads a Copilot metrics report from the provided download link
804+ // and returns the metric data. This can be used to download metrics from a link returned by
805+ // GetEnterpriseDailyMetricsReport, GetEnterpriseMetricsReport, GetEnterpriseUsersDailyMetricsReport,
806+ // GetEnterpriseUsersMetricsReport, GetOrganizationDailyMetricsReport, GetOrganizationMetricsReport,
807+ // GetOrganizationUsersDailyMetricsReport, GetOrganizationUsersMetricsReport.
808+ func (s * CopilotService ) DownloadCopilotMetrics (ctx context.Context , url string ) ([]* CopilotMetrics , * Response , error ) {
809+ req , err := http .NewRequestWithContext (ctx , "GET" , url , nil )
810+ if err != nil {
811+ return nil , nil , err
812+ }
813+
814+ resp , err := s .client .client .Do (req )
815+ if err != nil {
816+ return nil , nil , err
817+ }
818+ defer resp .Body .Close ()
819+
820+ if err := CheckResponse (resp ); err != nil {
821+ return nil , newResponse (resp ), err
822+ }
823+
824+ var metrics []* CopilotMetrics
825+ if err := json .NewDecoder (resp .Body ).Decode (& metrics ); err != nil {
826+ return nil , newResponse (resp ), err
827+ }
828+
829+ return metrics , newResponse (resp ), nil
830+ }
0 commit comments