@@ -203,6 +203,7 @@ type Client struct {
203203 Organizations * OrganizationsService
204204 Projects * ProjectsService
205205 PullRequests * PullRequestsService
206+ RateLimit * RateLimitService
206207 Reactions * ReactionsService
207208 Repositories * RepositoriesService
208209 SCIM * SCIMService
@@ -424,6 +425,7 @@ func (c *Client) initialize() {
424425 c .Organizations = (* OrganizationsService )(& c .common )
425426 c .Projects = (* ProjectsService )(& c .common )
426427 c .PullRequests = (* PullRequestsService )(& c .common )
428+ c .RateLimit = (* RateLimitService )(& c .common )
427429 c .Reactions = (* ReactionsService )(& c .common )
428430 c .Repositories = (* RepositoriesService )(& c .common )
429431 c .SCIM = (* SCIMService )(& c .common )
@@ -1281,54 +1283,6 @@ func parseBoolResponse(err error) (bool, error) {
12811283 return false , err
12821284}
12831285
1284- // Rate represents the rate limit for the current client.
1285- type Rate struct {
1286- // The number of requests per hour the client is currently limited to.
1287- Limit int `json:"limit"`
1288-
1289- // The number of remaining requests the client can make this hour.
1290- Remaining int `json:"remaining"`
1291-
1292- // The time at which the current rate limit will reset.
1293- Reset Timestamp `json:"reset"`
1294- }
1295-
1296- func (r Rate ) String () string {
1297- return Stringify (r )
1298- }
1299-
1300- // RateLimits represents the rate limits for the current client.
1301- type RateLimits struct {
1302- // The rate limit for non-search API requests. Unauthenticated
1303- // requests are limited to 60 per hour. Authenticated requests are
1304- // limited to 5,000 per hour.
1305- //
1306- // GitHub API docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
1307- Core * Rate `json:"core"`
1308-
1309- // The rate limit for search API requests. Unauthenticated requests
1310- // are limited to 10 requests per minutes. Authenticated requests are
1311- // limited to 30 per minute.
1312- //
1313- // GitHub API docs: https://docs.github.com/en/rest/search#rate-limit
1314- Search * Rate `json:"search"`
1315-
1316- // GitHub API docs: https://docs.github.com/en/graphql/overview/resource-limitations#rate-limit
1317- GraphQL * Rate `json:"graphql"`
1318-
1319- // GitHub API dos: https://docs.github.com/en/rest/rate-limit
1320- IntegrationManifest * Rate `json:"integration_manifest"`
1321-
1322- SourceImport * Rate `json:"source_import"`
1323- CodeScanningUpload * Rate `json:"code_scanning_upload"`
1324- ActionsRunnerRegistration * Rate `json:"actions_runner_registration"`
1325- SCIM * Rate `json:"scim"`
1326- }
1327-
1328- func (r RateLimits ) String () string {
1329- return Stringify (r )
1330- }
1331-
13321286type rateLimitCategory uint8
13331287
13341288const (
@@ -1378,53 +1332,10 @@ func category(method, path string) rateLimitCategory {
13781332}
13791333
13801334// RateLimits returns the rate limits for the current client.
1335+ //
1336+ // Deprecated: Use RateLimitService.Get instead.
13811337func (c * Client ) RateLimits (ctx context.Context ) (* RateLimits , * Response , error ) {
1382- req , err := c .NewRequest ("GET" , "rate_limit" , nil )
1383- if err != nil {
1384- return nil , nil , err
1385- }
1386-
1387- response := new (struct {
1388- Resources * RateLimits `json:"resources"`
1389- })
1390-
1391- // This resource is not subject to rate limits.
1392- ctx = context .WithValue (ctx , bypassRateLimitCheck , true )
1393- resp , err := c .Do (ctx , req , response )
1394- if err != nil {
1395- return nil , resp , err
1396- }
1397-
1398- if response .Resources != nil {
1399- c .rateMu .Lock ()
1400- if response .Resources .Core != nil {
1401- c .rateLimits [coreCategory ] = * response .Resources .Core
1402- }
1403- if response .Resources .Search != nil {
1404- c .rateLimits [searchCategory ] = * response .Resources .Search
1405- }
1406- if response .Resources .GraphQL != nil {
1407- c .rateLimits [graphqlCategory ] = * response .Resources .GraphQL
1408- }
1409- if response .Resources .IntegrationManifest != nil {
1410- c .rateLimits [integrationManifestCategory ] = * response .Resources .IntegrationManifest
1411- }
1412- if response .Resources .SourceImport != nil {
1413- c .rateLimits [sourceImportCategory ] = * response .Resources .SourceImport
1414- }
1415- if response .Resources .CodeScanningUpload != nil {
1416- c .rateLimits [codeScanningUploadCategory ] = * response .Resources .CodeScanningUpload
1417- }
1418- if response .Resources .ActionsRunnerRegistration != nil {
1419- c .rateLimits [actionsRunnerRegistrationCategory ] = * response .Resources .ActionsRunnerRegistration
1420- }
1421- if response .Resources .SCIM != nil {
1422- c .rateLimits [scimCategory ] = * response .Resources .SCIM
1423- }
1424- c .rateMu .Unlock ()
1425- }
1426-
1427- return response .Resources , resp , nil
1338+ return c .RateLimit .Get (ctx )
14281339}
14291340
14301341func setCredentialsAsHeaders (req * http.Request , id , secret string ) * http.Request {
0 commit comments