Prepare headers for API requests. Args: custom_headers: Additional headers to include Returns: Headers dictionary with standard headers and any custom headers
(self, custom_headers: Optional[Dict[str, str]] = None)
| 31 | self.auth_token = token |
| 32 | |
| 33 | def prepare_headers(self, custom_headers: Optional[Dict[str, str]] = None) -> Dict[str, str]: |
| 34 | """ |
| 35 | Prepare headers for API requests. |
| 36 | |
| 37 | Args: |
| 38 | custom_headers: Additional headers to include |
| 39 | Returns: |
| 40 | Headers dictionary with standard headers and any custom headers |
| 41 | """ |
| 42 | headers = { |
| 43 | "User-Agent": f"agentops-python/{get_agentops_version() or 'unknown'}", |
| 44 | } |
| 45 | |
| 46 | # Only add Authorization header if we have a token |
| 47 | if self.auth_token: |
| 48 | headers["Authorization"] = f"Bearer {self.auth_token}" |
| 49 | |
| 50 | if custom_headers: |
| 51 | headers.update(custom_headers) |
| 52 | return headers |
| 53 | |
| 54 | def post(self, path: str, body: Union[str, bytes], headers: Optional[Dict[str, str]] = None) -> requests.Response: |
| 55 | """ |
no test coverage detected