Make a GET request to the API. Args: path: The API path. params: Query parameters. Returns: The API response. Raises: AgentRPCError: If the request fails for any reason.
(self, path: str, params: Optional[Dict[str, Any]] = None)
| 160 | ) |
| 161 | |
| 162 | def get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Any: |
| 163 | """Make a GET request to the API. |
| 164 | |
| 165 | Args: |
| 166 | path: The API path. |
| 167 | params: Query parameters. |
| 168 | |
| 169 | Returns: |
| 170 | The API response. |
| 171 | |
| 172 | Raises: |
| 173 | AgentRPCError: If the request fails for any reason. |
| 174 | """ |
| 175 | url = f"{self.endpoint}{path}" |
| 176 | |
| 177 | try: |
| 178 | response = requests.get(url, params=params, headers=self.headers) |
| 179 | response.raise_for_status() |
| 180 | return response.json() |
| 181 | except requests.HTTPError as e: |
| 182 | raise AgentRPCError( |
| 183 | f"HTTP error: {e.response.status_code} - {e.response.text}", |
| 184 | status_code=e.response.status_code, |
| 185 | response=e.response.text, |
| 186 | ) |
| 187 | except requests.RequestException as e: |
| 188 | raise AgentRPCError(f"Request error: {str(e)}") |
| 189 | except Exception as e: |
| 190 | raise AgentRPCError(f"Unexpected error: {str(e)}") |
| 191 | |
| 192 | def post( |
| 193 | self, path: str, data: Dict[str, Any], params: Optional[Dict[str, Any]] = None |
no test coverage detected