-
Notifications
You must be signed in to change notification settings - Fork 3
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
Step 1: Setup GitHub REST API Requests 🤙 #17
Comments
Decided to use https://github.com/edgurgel/tentacat for the GitHub API requests as it appears to be maintained. 👍 |
Used
We definitely need to paginate the request:
@doc """
List members of a `organization`.
The response will differ if the authenticated user is also owner of the
organization.
## Example
Tentacat.Organizations.Members.list "github"
Tentacat.Organizations.Members.list client, "github"
More info at: http://developer.github.com/v3/orgs/members/#members-list
"""
@spec list(Client.t(), binary) :: Tentacat.response()
def list(client \\ %Client{}, organization) do
get("orgs/#{organization}/members", client)
end Opened issue to confirm my understanding: edgurgel/tentacat#210 🤞 |
Might be able to use @doc """
Underlying utility retrieval function. The options passed affect both the
return value and, ultimately, the number of requests made to GitHub.
## Options
* `:pagination` - Can be `:none`, `:manual`, `:stream`, or `:auto`. Defaults to :auto.
- `:none` will only return the first page. You won't have access to the
headers to manually paginate.
- `:auto` will block until all the pages have been retrieved and
concatenated together. Most of the time, this is what you want. For
example, `Tentacat.Repositories.list_users("chrismccord")` and
`Tentacat.Repositories.list_users("octocat")` have the same interface
though one call will page many times and the other not at all.
- `:stream` will return a `Stream`, prepopulated with the first page.
- `:manual` will return a 3 element tuple of `{page_body,
url_for_next_page, auth_credentials}`, which will allow you to control
the paging yourself.
"""
@spec get(binary, Client.t()) :: response
@spec get(binary, Client.t(), keyword) :: response
@spec get(binary, Client.t(), keyword, keyword) ::
response | Enumerable.t() | pagination_response
def get(path, client, params \\ [], options \\ []) do
url =
client
|> url(path)
|> add_params_to_url(params)
case pagination(options) do
nil -> request_stream(:get, url, client.auth)
:none -> request_stream(:get, url, client.auth, "", :one_page)
:auto -> request_stream(:get, url, client.auth)
:stream -> request_stream(:get, url, client.auth, "", :stream)
:manual -> request_with_pagination(:get, url, client.auth)
end
end Thanks to edgurgel/tentacat#190 (comment) (comment on super-stale PR) 👀 Going to take a look at this on the Weekend. 🤞 |
Going to try and
Again, one for Saturday. ⏳ |
In order to get data from GitHub we need to setup the API.
According to the docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api 👀
the rate limiting for authenticated requests is
5,000/hour
. 5️⃣ 🦘That should be more than "enough" for what I have in mind. 📈
But if we need more we can easily add more API users. 💭
We've made HTTP Requests to the GitHub API before in previous projects:
So I think I can piece this together from previous code. 🤞
Todo
@dwyl
Org Members from the GitHub APIThe text was updated successfully, but these errors were encountered: