Provides a structured list of the specified resource from the the github API.
Usage
gh(path, proxy_url = NULL, token = NULL)
github_api(path, proxy_url = NULL, token = NULL)
rate_limit(proxy_url = NULL, token = NULL)
Arguments
- path
Character string with path to the API resource.
- proxy_url
Character string defining a network proxy in the form host:port. Default is NULL in which case the API call will not use a proxy.
- token
Character string holding a github personal access token (PAT) to be used for requests that requires authorization. Default value is NULL in which case the request will be unauthorized unless PAT can be obtained from the environmental variable GITHUB_PAT.
Value
A list of class github_api containing the parsed content, API
resource path and the response object. For rate_limit()
the path is
always "/rate_limit" and can hence be used to detect if the limit is
exceeded (without being counted as a request itself). If the allowed API
rate is exceeded gh()
will return a message stating the fact and
simple suggestions on how to remedy the problem.
Details
For most use cases only gh()
will be relevant. The helper function
github_api()
do the actual lifting while rate_limit()
handles
API rate limits.
Examples
## Get all branches of a repository. If the api rate limit is exceeded this
## function will return NULL and an informative message
gh("repos/Rapporteket/sship/branches")
#> $content
#> name commit.sha
#> 1 gh-pages 80c94d4a73569812591d9ad81ff36d833cff12c8
#> 2 main 739887739212802f1cb8a35bd57f4688c1a694b8
#> commit.url
#> 1 https://api.github.com/repos/Rapporteket/sship/commits/80c94d4a73569812591d9ad81ff36d833cff12c8
#> 2 https://api.github.com/repos/Rapporteket/sship/commits/739887739212802f1cb8a35bd57f4688c1a694b8
#> protected protection.enabled
#> 1 FALSE FALSE
#> 2 TRUE TRUE
#> protection.required_status_checks.enforcement_level
#> 1 off
#> 2 non_admins
#> protection.required_status_checks.contexts
#> 1
#> 2 macOS-latest (release), ubuntu-20.04 (release), windows-latest (release)
#> protection.required_status_checks.checks
#> 1 NULL
#> 2 macOS-latest (release), ubuntu-20.04 (release), windows-latest (release), NA, NA, NA
#> protection_url
#> 1 https://api.github.com/repos/Rapporteket/sship/branches/gh-pages/protection
#> 2 https://api.github.com/repos/Rapporteket/sship/branches/main/protection
#>
#> $path
#> [1] "repos/Rapporteket/sship/branches"
#>
#> $response
#> Response [https://api.github.com/repos/Rapporteket/sship/branches]
#> Date: 2022-12-13 14:18
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 1.04 kB
#>
#>
#> attr(,"class")
#> [1] "github_api"
## helper functions that will normally not be used
github_api("/rate_limit")
#> $content
#> $content$resources
#> $content$resources$core
#> $content$resources$core$limit
#> [1] 5000
#>
#> $content$resources$core$used
#> [1] 29
#>
#> $content$resources$core$remaining
#> [1] 4971
#>
#> $content$resources$core$reset
#> [1] 1670943319
#>
#>
#> $content$resources$search
#> $content$resources$search$limit
#> [1] 30
#>
#> $content$resources$search$used
#> [1] 0
#>
#> $content$resources$search$remaining
#> [1] 30
#>
#> $content$resources$search$reset
#> [1] 1670941141
#>
#>
#> $content$resources$graphql
#> $content$resources$graphql$limit
#> [1] 5000
#>
#> $content$resources$graphql$used
#> [1] 0
#>
#> $content$resources$graphql$remaining
#> [1] 5000
#>
#> $content$resources$graphql$reset
#> [1] 1670944681
#>
#>
#> $content$resources$integration_manifest
#> $content$resources$integration_manifest$limit
#> [1] 5000
#>
#> $content$resources$integration_manifest$used
#> [1] 0
#>
#> $content$resources$integration_manifest$remaining
#> [1] 5000
#>
#> $content$resources$integration_manifest$reset
#> [1] 1670944681
#>
#>
#> $content$resources$source_import
#> $content$resources$source_import$limit
#> [1] 100
#>
#> $content$resources$source_import$used
#> [1] 0
#>
#> $content$resources$source_import$remaining
#> [1] 100
#>
#> $content$resources$source_import$reset
#> [1] 1670941141
#>
#>
#> $content$resources$code_scanning_upload
#> $content$resources$code_scanning_upload$limit
#> [1] 1000
#>
#> $content$resources$code_scanning_upload$used
#> [1] 0
#>
#> $content$resources$code_scanning_upload$remaining
#> [1] 1000
#>
#> $content$resources$code_scanning_upload$reset
#> [1] 1670944681
#>
#>
#> $content$resources$actions_runner_registration
#> $content$resources$actions_runner_registration$limit
#> [1] 10000
#>
#> $content$resources$actions_runner_registration$used
#> [1] 0
#>
#> $content$resources$actions_runner_registration$remaining
#> [1] 10000
#>
#> $content$resources$actions_runner_registration$reset
#> [1] 1670944681
#>
#>
#> $content$resources$scim
#> $content$resources$scim$limit
#> [1] 15000
#>
#> $content$resources$scim$used
#> [1] 0
#>
#> $content$resources$scim$remaining
#> [1] 15000
#>
#> $content$resources$scim$reset
#> [1] 1670944681
#>
#>
#> $content$resources$dependency_snapshots
#> $content$resources$dependency_snapshots$limit
#> [1] 100
#>
#> $content$resources$dependency_snapshots$used
#> [1] 0
#>
#> $content$resources$dependency_snapshots$remaining
#> [1] 100
#>
#> $content$resources$dependency_snapshots$reset
#> [1] 1670941141
#>
#>
#>
#> $content$rate
#> $content$rate$limit
#> [1] 5000
#>
#> $content$rate$used
#> [1] 29
#>
#> $content$rate$remaining
#> [1] 4971
#>
#> $content$rate$reset
#> [1] 1670943319
#>
#>
#>
#> $path
#> [1] "/rate_limit"
#>
#> $response
#> Response [https://api.github.com/rate_limit]
#> Date: 2022-12-13 14:18
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 768 B
#>
#>
#> attr(,"class")
#> [1] "github_api"
rate_limit()
#> $content
#> $content$resources
#> $content$resources$core
#> $content$resources$core$limit
#> [1] 5000
#>
#> $content$resources$core$used
#> [1] 29
#>
#> $content$resources$core$remaining
#> [1] 4971
#>
#> $content$resources$core$reset
#> [1] 1670943319
#>
#>
#> $content$resources$search
#> $content$resources$search$limit
#> [1] 30
#>
#> $content$resources$search$used
#> [1] 0
#>
#> $content$resources$search$remaining
#> [1] 30
#>
#> $content$resources$search$reset
#> [1] 1670941141
#>
#>
#> $content$resources$graphql
#> $content$resources$graphql$limit
#> [1] 5000
#>
#> $content$resources$graphql$used
#> [1] 0
#>
#> $content$resources$graphql$remaining
#> [1] 5000
#>
#> $content$resources$graphql$reset
#> [1] 1670944681
#>
#>
#> $content$resources$integration_manifest
#> $content$resources$integration_manifest$limit
#> [1] 5000
#>
#> $content$resources$integration_manifest$used
#> [1] 0
#>
#> $content$resources$integration_manifest$remaining
#> [1] 5000
#>
#> $content$resources$integration_manifest$reset
#> [1] 1670944681
#>
#>
#> $content$resources$source_import
#> $content$resources$source_import$limit
#> [1] 100
#>
#> $content$resources$source_import$used
#> [1] 0
#>
#> $content$resources$source_import$remaining
#> [1] 100
#>
#> $content$resources$source_import$reset
#> [1] 1670941141
#>
#>
#> $content$resources$code_scanning_upload
#> $content$resources$code_scanning_upload$limit
#> [1] 1000
#>
#> $content$resources$code_scanning_upload$used
#> [1] 0
#>
#> $content$resources$code_scanning_upload$remaining
#> [1] 1000
#>
#> $content$resources$code_scanning_upload$reset
#> [1] 1670944681
#>
#>
#> $content$resources$actions_runner_registration
#> $content$resources$actions_runner_registration$limit
#> [1] 10000
#>
#> $content$resources$actions_runner_registration$used
#> [1] 0
#>
#> $content$resources$actions_runner_registration$remaining
#> [1] 10000
#>
#> $content$resources$actions_runner_registration$reset
#> [1] 1670944681
#>
#>
#> $content$resources$scim
#> $content$resources$scim$limit
#> [1] 15000
#>
#> $content$resources$scim$used
#> [1] 0
#>
#> $content$resources$scim$remaining
#> [1] 15000
#>
#> $content$resources$scim$reset
#> [1] 1670944681
#>
#>
#> $content$resources$dependency_snapshots
#> $content$resources$dependency_snapshots$limit
#> [1] 100
#>
#> $content$resources$dependency_snapshots$used
#> [1] 0
#>
#> $content$resources$dependency_snapshots$remaining
#> [1] 100
#>
#> $content$resources$dependency_snapshots$reset
#> [1] 1670941141
#>
#>
#>
#> $content$rate
#> $content$rate$limit
#> [1] 5000
#>
#> $content$rate$used
#> [1] 29
#>
#> $content$rate$remaining
#> [1] 4971
#>
#> $content$rate$reset
#> [1] 1670943319
#>
#>
#>
#> $path
#> [1] "/rate_limit"
#>
#> $response
#> Response [https://api.github.com/rate_limit]
#> Date: 2022-12-13 14:18
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 768 B
#>
#>
#> attr(,"class")
#> [1] "github_api"