-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gqlmod/httpx
Update for httpx
- Loading branch information
Showing
3 changed files
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
""" | ||
Provider for Cirrus CI's GraphQL API. | ||
""" | ||
from gqlmod.helpers.urllib import UrllibJsonProvider | ||
from gqlmod.helpers.httpx import HttpxProvider | ||
|
||
|
||
class CirrusCiProvider(UrllibJsonProvider): | ||
class CirrusCiProvider(HttpxProvider): | ||
endpoint = 'https://api.cirrus-ci.com/graphql' | ||
|
||
def __init__(self, token=None): | ||
self.token = token | ||
|
||
def modify_request(self, req, variables): | ||
def build_request(self, query, variables): | ||
req = super().build_request(query, variables) | ||
if self.token: | ||
req.add_header('Authorization', f"Bearer {self.token}") | ||
req.headers['Authorization'] = f"Bearer {self.token}" | ||
return req |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters