performs a requests.put with the correct headers for a GitHub request. see: https://developer.github.com/v4/ Args: query: the graphQL query string (excluding the variables section) token: a GitHub API token string variables: a dict of key=value variables that will be sent with
(query, token, variables=None)
| 26 | |
| 27 | |
| 28 | def do_github_graphql_request(query, token, variables=None): |
| 29 | """performs a requests.put with the correct headers for a GitHub request. |
| 30 | |
| 31 | see: https://developer.github.com/v4/ |
| 32 | |
| 33 | Args: |
| 34 | query: the graphQL query string (excluding the variables section) |
| 35 | token: a GitHub API token string |
| 36 | variables: a dict of key=value variables that will be sent with the query |
| 37 | |
| 38 | Returns: |
| 39 | A requests.Response object |
| 40 | """ |
| 41 | url = "https://api.github.com/graphql" |
| 42 | headers = { |
| 43 | "Authorization": "bearer " + token, |
| 44 | } |
| 45 | data = json.dumps({"query": query, "variables": json.dumps(variables)}) |
| 46 | return requests.post(url, headers=headers, data=data) |
| 47 | |
| 48 | |
| 49 | ISSUES_QUERY = """ |