GetRateLimitCategory returns the rate limit RateLimitCategory of the endpoint, determined by HTTP method and Request.URL.Path.
(method, path string)
| 1828 | |
| 1829 | // GetRateLimitCategory returns the rate limit RateLimitCategory of the endpoint, determined by HTTP method and Request.URL.Path. |
| 1830 | func GetRateLimitCategory(method, path string) RateLimitCategory { |
| 1831 | switch { |
| 1832 | // https://docs.github.com/rest/rate-limit?apiVersion=2022-11-28#about-rate-limits |
| 1833 | default: |
| 1834 | // NOTE: coreCategory is returned for actionsRunnerRegistrationCategory too, |
| 1835 | // because no API found for this category. |
| 1836 | return CoreCategory |
| 1837 | |
| 1838 | // https://docs.github.com/rest/search/search?apiVersion=2022-11-28#search-code |
| 1839 | case strings.HasPrefix(path, "/search/code") && |
| 1840 | method == "GET": |
| 1841 | return CodeSearchCategory |
| 1842 | |
| 1843 | case strings.HasPrefix(path, "/search/"): |
| 1844 | return SearchCategory |
| 1845 | case path == "/graphql": |
| 1846 | return GraphqlCategory |
| 1847 | case strings.HasPrefix(path, "/app-manifests/") && |
| 1848 | strings.HasSuffix(path, "/conversions") && |
| 1849 | method == "POST": |
| 1850 | return IntegrationManifestCategory |
| 1851 | |
| 1852 | // https://docs.github.com/rest/migrations/source-imports?apiVersion=2022-11-28#start-an-import |
| 1853 | case strings.HasPrefix(path, "/repos/") && |
| 1854 | strings.HasSuffix(path, "/import") && |
| 1855 | method == "PUT": |
| 1856 | return SourceImportCategory |
| 1857 | |
| 1858 | // https://docs.github.com/rest/code-scanning?apiVersion=2022-11-28#upload-an-analysis-as-sarif-data |
| 1859 | case strings.HasSuffix(path, "/code-scanning/sarifs"): |
| 1860 | return CodeScanningUploadCategory |
| 1861 | |
| 1862 | // https://docs.github.com/enterprise-cloud@latest/rest/scim?apiVersion=2022-11-28 |
| 1863 | case strings.HasPrefix(path, "/scim/"): |
| 1864 | return ScimCategory |
| 1865 | |
| 1866 | // https://docs.github.com/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28#create-a-snapshot-of-dependencies-for-a-repository |
| 1867 | case strings.HasPrefix(path, "/repos/") && |
| 1868 | strings.HasSuffix(path, "/dependency-graph/snapshots") && |
| 1869 | method == "POST": |
| 1870 | return DependencySnapshotsCategory |
| 1871 | |
| 1872 | // https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs?apiVersion=2022-11-28#get-the-audit-log-for-an-organization |
| 1873 | case strings.HasSuffix(path, "/audit-log"): |
| 1874 | return AuditLogCategory |
| 1875 | |
| 1876 | // https://docs.github.com/rest/dependency-graph/sboms?apiVersion=2022-11-28#export-a-software-bill-of-materials-sbom-for-a-repository |
| 1877 | case strings.HasPrefix(path, "/repos/") && |
| 1878 | strings.HasSuffix(path, "/dependency-graph/sbom"): |
| 1879 | return DependencySBOMCategory |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | // RateLimits returns the rate limits for the current client. |
| 1884 | // |
no outgoing calls
searching dependent graphs…