diff --git a/github/github.go b/github/github.go index 080a8794dd..ccaf090f3b 100644 --- a/github/github.go +++ b/github/github.go @@ -1082,15 +1082,26 @@ type RateLimits struct { // requests are limited to 60 per hour. Authenticated requests are // limited to 5,000 per hour. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#rate-limiting + // GitHub API docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting Core *Rate `json:"core"` // The rate limit for search API requests. Unauthenticated requests // are limited to 10 requests per minutes. Authenticated requests are // limited to 30 per minute. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#rate-limit + // GitHub API docs: https://docs.github.com/en/rest/search#rate-limit Search *Rate `json:"search"` + + // GitHub API docs: https://docs.github.com/en/graphql/overview/resource-limitations#rate-limit + Graphql *Rate `json:"graphql"` + + // GitHub API dos: https://docs.github.com/en/rest/rate-limit + IntegrationManifest *Rate `json:"integration_manifest"` + + SourceImport *Rate `json:"source_import"` + CodeScanningUpload *Rate `json:"code_scanning_upload"` + ActionsRunnerRegistration *Rate `json:"actions_runner_registration"` + Scim *Rate `json:"scim"` } func (r RateLimits) String() string { @@ -1102,6 +1113,12 @@ type rateLimitCategory uint8 const ( coreCategory rateLimitCategory = iota searchCategory + graphqlCategory + integrationManifestCategory + sourceImportCategory + codeScanningUploadCategory + actionsRunnerRegistrationCategory + scimCategory categories // An array of this length will be able to contain all rate limit categories. ) diff --git a/github/github_test.go b/github/github_test.go index 475eb9d820..b87382aba4 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -474,10 +474,16 @@ func TestClient_rateLimits(t *testing.T) { func TestRateLimits_String(t *testing.T) { v := RateLimits{ - Core: &Rate{}, - Search: &Rate{}, - } - want := `github.RateLimits{Core:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, Search:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}}` + Core: &Rate{}, + Search: &Rate{}, + Graphql: &Rate{}, + IntegrationManifest: &Rate{}, + SourceImport: &Rate{}, + CodeScanningUpload: &Rate{}, + ActionsRunnerRegistration: &Rate{}, + Scim: &Rate{}, + } + want := `github.RateLimits{Core:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, Search:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, Graphql:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, IntegrationManifest:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, SourceImport:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, CodeScanningUpload:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, ActionsRunnerRegistration:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, Scim:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}}` if got := v.String(); got != want { t.Errorf("RateLimits.String = %v, want %v", got, want) } @@ -2394,6 +2400,36 @@ func TestRateLimits_Marshal(t *testing.T) { Remaining: 1, Reset: Timestamp{referenceTime}, }, + Graphql: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, + IntegrationManifest: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, + SourceImport: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, + CodeScanningUpload: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, + ActionsRunnerRegistration: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, + Scim: &Rate{ + Limit: 1, + Remaining: 1, + Reset: Timestamp{referenceTime}, + }, } want := `{ @@ -2406,6 +2442,36 @@ func TestRateLimits_Marshal(t *testing.T) { "limit": 1, "remaining": 1, "reset": ` + referenceTimeStr + ` + }, + "graphql": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` + }, + "integration_manifest": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` + }, + "source_import": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` + }, + "code_scanning_upload": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` + }, + "actions_runner_registration": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` + }, + "scim": { + "limit": 1, + "remaining": 1, + "reset": ` + referenceTimeStr + ` } }`