from datadog_api_client.v1 import ApiClient, ApiException, Configuration from datadog_api_client.v1.model_utils import ApiTypeError # Initializing the API client and configuration config = Configuration() config.host = "https://api.datadoghq.com" config.api_key["apiKey"] = "YOUR_API_KEY" api_client = ApiClient(configuration=config) # Example function that retrieves a monitor and raises ApiTypeError if the response is not JSON def get_monitor(monitor_id): try: api_instance = MonitorApi(api_client) # Retrieve monitor by ID api_response = api_instance.get_monitor(monitor_id) # Raise ApiTypeError if the response is not JSON if not isinstance(api_response, dict): raise ApiTypeError("Unexpected response type. ExpectedIn the above example, we are using the `ApiTypeError` class to handle the case where the response from `api_instance.get_monitor()` method is not a dictionary. If the response is not a dictionary, the `ApiTypeError` exception is raised with a custom error message. Package/library: `datadog_api_client`, but got {}".format(type(api_response))) return api_response except ApiException as e: print("Exception when calling MonitorApi->get_monitor: {}".format(e)) # Calling the function monitor_data = get_monitor(12345)