Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields to RateLimits struct #2339

Closed
shokada opened this issue Apr 21, 2022 · 5 comments · Fixed by #2340
Closed

Add fields to RateLimits struct #2339

shokada opened this issue Apr 21, 2022 · 5 comments · Fixed by #2340
Assignees

Comments

@shokada
Copy link
Contributor

shokada commented Apr 21, 2022

Hi there.

Currently the /rate_limit response looks like this.

-> % curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghs_xxx" https://api.github.com/rate_limit
{
  "resources": {
    "core": {
      "limit": 15000,
      "used": 9406,
      "remaining": 5594,
      "reset": 1650339361
    },
    "search": {
      "limit": 30,
      "used": 0,
      "remaining": 30,
      "reset": 1650337238
    },
    "graphql": {
      "limit": 12500,
      "used": 0,
      "remaining": 12500,
      "reset": 1650340778
    },
    "integration_manifest": {
      "limit": 5000,
      "used": 0,
      "remaining": 5000,
      "reset": 1650340778
    },
    "source_import": {
      "limit": 100,
      "used": 0,
      "remaining": 100,
      "reset": 1650337238
    },
    "code_scanning_upload": {
      "limit": 1000,
      "used": 0,
      "remaining": 1000,
      "reset": 1650340778
    },
    "actions_runner_registration": {
      "limit": 10000,
      "used": 71,
      "remaining": 9929,
      "reset": 1650340715
    },
    "scim": {
      "limit": 15000,
      "used": 0,
      "remaining": 15000,
      "reset": 1650340778
    }
  },
  "rate": {
    "limit": 15000,
    "used": 9406,
    "remaining": 5594,
    "reset": 1650339361
  }
}

However, the RateLimits struct defines only the core and search fields.

go-github/github/github.go

Lines 1080 to 1094 in 00e4233

type RateLimits struct {
// The rate limit for non-search API requests. Unauthenticated
// 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
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
Search *Rate `json:"search"`
}

Can items other than core and search be added to the RateLimits struct?

@gmlewis
Copy link
Collaborator

gmlewis commented Apr 21, 2022

Thank you for the report, @shokada !
Yes, they can.

Would you like to submit a PR or would you like me to open up this issue to other contributors to this repo?

@shokada
Copy link
Contributor Author

shokada commented Apr 21, 2022

@gmlewis Thank you for the reply!

Would you like to submit a PR or would you like me to open up this issue to other contributors to this repo?

Yes, I will try to submit a PR.

@gmlewis
Copy link
Collaborator

gmlewis commented Apr 21, 2022

Great! It's yours.

@xun-guo-anzx
Copy link
Contributor

Thanks @shokada @gmlewis . May I request a release for this feature once the PR is merged?

@gmlewis
Copy link
Collaborator

gmlewis commented May 9, 2022

Thanks @shokada @gmlewis . May I request a release for this feature once the PR is merged?

Sure, no problem.

gmlewis pushed a commit that referenced this issue May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants