Get returns the rate limits for the current client. GitHub API docs: https://docs.github.com/rest/rate-limit/rate-limit?apiVersion=2022-11-28#get-rate-limit-status-for-the-authenticated-user meta:operation GET /rate_limit
(ctx context.Context)
| 76 | // |
| 77 | //meta:operation GET /rate_limit |
| 78 | func (s *RateLimitService) Get(ctx context.Context) (*RateLimits, *Response, error) { |
| 79 | // This resource is not subject to rate limits. |
| 80 | if !s.client.disableRateLimitCheck { |
| 81 | ctx = context.WithValue(ctx, BypassRateLimitCheck, true) |
| 82 | } |
| 83 | |
| 84 | req, err := s.client.NewRequest(ctx, "GET", "rate_limit", nil) |
| 85 | if err != nil { |
| 86 | return nil, nil, err |
| 87 | } |
| 88 | |
| 89 | response := new(struct { |
| 90 | Resources *RateLimits `json:"resources"` |
| 91 | }) |
| 92 | |
| 93 | resp, err := s.client.Do(req, response) |
| 94 | if err != nil { |
| 95 | return nil, resp, err |
| 96 | } |
| 97 | |
| 98 | if response.Resources != nil { |
| 99 | s.client.rateMu.Lock() |
| 100 | if response.Resources.Core != nil { |
| 101 | s.client.rateLimits[CoreCategory] = *response.Resources.Core |
| 102 | } |
| 103 | if response.Resources.Search != nil { |
| 104 | s.client.rateLimits[SearchCategory] = *response.Resources.Search |
| 105 | } |
| 106 | if response.Resources.GraphQL != nil { |
| 107 | s.client.rateLimits[GraphqlCategory] = *response.Resources.GraphQL |
| 108 | } |
| 109 | if response.Resources.IntegrationManifest != nil { |
| 110 | s.client.rateLimits[IntegrationManifestCategory] = *response.Resources.IntegrationManifest |
| 111 | } |
| 112 | if response.Resources.SourceImport != nil { |
| 113 | s.client.rateLimits[SourceImportCategory] = *response.Resources.SourceImport |
| 114 | } |
| 115 | if response.Resources.CodeScanningUpload != nil { |
| 116 | s.client.rateLimits[CodeScanningUploadCategory] = *response.Resources.CodeScanningUpload |
| 117 | } |
| 118 | if response.Resources.ActionsRunnerRegistration != nil { |
| 119 | s.client.rateLimits[ActionsRunnerRegistrationCategory] = *response.Resources.ActionsRunnerRegistration |
| 120 | } |
| 121 | if response.Resources.SCIM != nil { |
| 122 | s.client.rateLimits[ScimCategory] = *response.Resources.SCIM |
| 123 | } |
| 124 | if response.Resources.DependencySnapshots != nil { |
| 125 | s.client.rateLimits[DependencySnapshotsCategory] = *response.Resources.DependencySnapshots |
| 126 | } |
| 127 | if response.Resources.CodeSearch != nil { |
| 128 | s.client.rateLimits[CodeSearchCategory] = *response.Resources.CodeSearch |
| 129 | } |
| 130 | if response.Resources.AuditLog != nil { |
| 131 | s.client.rateLimits[AuditLogCategory] = *response.Resources.AuditLog |
| 132 | } |
| 133 | if response.Resources.DependencySBOM != nil { |
| 134 | s.client.rateLimits[DependencySBOMCategory] = *response.Resources.DependencySBOM |
| 135 | } |
nothing calls this directly
no test coverage detected