def req()

in src/pydolphinscheduler/resources_plugin/github.py [0:0]


    def req(self, path: str):
        """Send HTTP request, parse response data, and get file content."""
        headers = {
            "Content-Type": "application/json; charset=utf-8",
        }
        if self.access_token is not None:
            headers.setdefault("Authorization", f"Bearer {self.access_token}")
        self.get_git_file_info(path)
        response = requests.get(
            headers=headers,
            url=self.get_req_url(),
            params={"ref": self._git_file_info.branch},
        )
        if response.status_code == requests.codes.ok:
            json_response = response.json()
            content = base64.b64decode(json_response["content"])
            return content.decode("utf-8")
        else:
            raise Exception(response.json())