Initializes the API client with a specified server URL and an option to create response files. :param api_url: The base URL for the API server. If not specified, defaults to "http://localhost:8000". :param create_response_files: Indicates if the client should cr
(self, api_url: Optional[str] = None, create_response_files: bool = True)
| 22 | |
| 23 | class Api: |
| 24 | def __init__(self, api_url: Optional[str] = None, create_response_files: bool = True) -> None: |
| 25 | """ |
| 26 | Initializes the API client with a specified server URL and an option to create response files. |
| 27 | |
| 28 | :param api_url: The base URL for the API server. If not specified, defaults to "http://localhost:8000". |
| 29 | :param create_response_files: Indicates if the client should create response files for each API call. This is useful for debugging or development purposes. Defaults to True. |
| 30 | """ |
| 31 | DEFAULT_API_URL = "http://localhost:8000" |
| 32 | self._api_url = remove_after_first_slash(api_url) if api_url else DEFAULT_API_URL |
| 33 | self._create_response_files = create_response_files # Flag for creating response files |
| 34 | if not self.is_api_running(): |
| 35 | raise ApiException(f"API at {self._api_url} is not running. Please check if the API is up and running.") |
| 36 | |
| 37 | def _write_json(self, filename, data): |
| 38 | """ |
nothing calls this directly
no test coverage detected