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

ETag not supported to make conditional requests through API? #536

Open
instructure-analytics opened this issue Mar 15, 2017 · 5 comments
Open

Comments

@instructure-analytics
Copy link

I notice that the GitHubObject has an eTag attribute, but I don't see the ability to pass this in to any of the different api calls. Am I missing something or is this a missing feature? I notice it's mentioned in the v2 API docs.

@sfdye sfdye added the question label Apr 7, 2018
@stale
Copy link

stale bot commented Jul 5, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 5, 2018
@sfdye sfdye removed the wontfix label Jul 12, 2018
@stale
Copy link

stale bot commented Sep 10, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 10, 2018
@raphaelyancey
Copy link

I also would very much like this to be implemented in PyGithub.

@stale stale bot removed the stale label Sep 13, 2018
@jovezhong
Copy link

+1 If this lib can keep tracking the ETag and sending If-None-Match: last_etag in header, this will make us much easier to keep calling the GitHub REST API without being throttled or getting duplicated events

Example on https://docs.github.com/en/rest/reference/activity

$ curl -I https://api.github.com/users/tater/events

HTTP/2 200
X-Poll-Interval: 60
ETag: "a18c3bded88eb5dbb5c849a489412bf3"

The quotes around the ETag value are important
$ curl -I https://api.github.com/users/tater/events
$ -H 'If-None-Match: "a18c3bded88eb5dbb5c849a489412bf3"'

HTTP/2 304
X-Poll-Interval: 60

@michaelwooley
Copy link

I think that this can be achieved (to greater and lesser degrees) by making it easy for users to leverage requests-cache. (That is, I don't think that PyGithub needs to get into the business of cache management.)

In fact, requests-cache has a sample script that demonstrates use with the PyGithub specifically. I like that it works but I'm not crazy about the fact that it clobbers the entire requests package in order to do so. The docs also mention some other issues.

I have a draft branch implementing a second approach to this: master...michaelwooley:PyGithub:michaelwooley/add-custom-session . Basically, this allows someone to pass in a custom requests.Session similar to what happens in python-gitlab.

This colab notebook demos my progress so far.

I'm encountering issues with insuring that the headers are handled correctly, though. In particular:

  • rate limit updates. (I actually am less concerned about this currently.) Don't want to pull stale rate limit info from a cached response.
  • etag parsing This is something I need to look into more.

If there is still interest in this, I could add further tests and open up an MR.

michaelwooley added a commit to michaelwooley/nya that referenced this issue Jan 5, 2023
michaelwooley added a commit to michaelwooley/nya that referenced this issue Jan 6, 2023
michaelwooley added a commit to michaelwooley/nya that referenced this issue Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants