(self, path, data="", method=HTTPMethod.GET, accept="", data_call=False, raise_on_failure=True)
| 19 | return f"https://api.github.com/repos/{self.OWNER}/{self.DATA_REPO}" |
| 20 | |
| 21 | def api_call(self, path, data="", method=HTTPMethod.GET, accept="", data_call=False, raise_on_failure=True): |
| 22 | token = self.DATA_TOKEN if data_call else self.API_TOKEN |
| 23 | if token: |
| 24 | headers = {"Authorization": f"Bearer {self.DATA_TOKEN if data_call else self.API_TOKEN}", \ |
| 25 | "Accept": f"application/vnd.github{accept}+json"} |
| 26 | else: |
| 27 | headers = {} |
| 28 | path = f'{self.DATA_ROUTE if data_call else self.API_ROUTE}/{path}' |
| 29 | r = requests.request(method, path, headers=headers, data=data) |
| 30 | if not r.ok and raise_on_failure: |
| 31 | raise Exception(f"Call to {path} failed with {r.status_code}") |
| 32 | else: |
| 33 | return r |
| 34 | |
| 35 | def upload_file(self, bucket, path, file_name): |
| 36 | with open(path, "rb") as f: |
no test coverage detected