CloudStackAIO/CloudStack.py
async def _handle_response(self, response: aiohttp.client_reqrep.ClientResponse, await_final_result: bool) -> dict:
        """
        Handles the response returned from the CloudStack API. Some CloudStack API are implemented asynchronous, which
        means that the API call returns just a job id. The actually expected API response is postponed and a specific
        asyncJobResults API has to be polled using the job id to get the final result once the API call has been
        processed.

        :param response: The response returned by the aiohttp call.
        :type response: aiohttp.client_reqrep.ClientResponse
        :param await_final_result: Specifier that indicates whether the function should poll the asyncJobResult API
                                   until the asynchronous API call has been processed
        :type await_final_result: bool
        :return: Dictionary containing the JSON response of the API call
        :rtype: dict
        """
        try:
            data = await response.json()
        except aiohttp.client_exceptions.ContentTypeError:
            text = await response.text()
            logging.debug('Content returned by server not of type "application/json"\n Content: {}'.format(text))
            raise CloudStackClientException(message="Could not decode content. Server did not return json content!")
        else:
            data = self._transform_data(data)
            if response.status != 200:
                raise CloudStackClientException(message="Async CloudStack call failed!",
                                                error_code=data.get("errorcode", response.status),
                                                error_text=data.get("errortext"),
                                                response=data)

        while await_final_result and ('jobid' in data):
            await asyncio.sleep(self.async_poll_latency)
            data = await self.queryAsyncJobResult(jobid=data['jobid'])
            if data['jobstatus']:  # jobstatus is 0 for pending async CloudStack calls
                if not data['jobresultcode']:  # exit code is zero
                    try:
                        return data['jobresult']
                    except KeyError:
                        pass
                logging.debug("Async CloudStack call returned {}".format(str(data)))
                raise CloudStackClientException(message="Async CloudStack call failed!",
                                                error_code=data.get("errorcode"),
                                                error_text=data.get("errortext"),
                                                response=data)

        return data
async def _handle_response(self, response: aiohttp.client_reqrep.ClientResponse, await_final_result: bool) -> dict:
        """
        Handles the response returned from the CloudStack API. Some CloudStack API are implemented asynchronous, which
        means that the API call returns just a job id. The actually expected API response is postponed and a specific
        asyncJobResults API has to be polled using the job id to get the final result once the API call has been
        processed.

        :param response: The response returned by the aiohttp call.
        :type response: aiohttp.client_reqrep.ClientResponse
        :param await_final_result: Specifier that indicates whether the function should poll the asyncJobResult API
                                   until the asynchronous API call has been processed
        :type await_final_result: bool
        :return: Dictionary containing the JSON response of the API call
        :rtype: dict
        """
        try:
            data = await response.json()
        except aiohttp.client_exceptions.ContentTypeError:
            text = await response.text()
            logging.debug('Content returned by server not of type "application/json"\n Content: {}'.format(text))
            raise CloudStackClientException(message="Could not decode content. Server did not return json content!")
        else:
            data = self._transform_data(data)
            if response.status != 200:
                raise CloudStackClientException(message="Async CloudStack call failed!",
                                                error_code=data.get("errorcode", response.status),
                                                error_text=data.get("errortext"),
                                                response=data)

        while await_final_result and ('jobid' in data):
            await asyncio.sleep(self.async_poll_latency)
            data = await self.queryAsyncJobResult(jobid=data['jobid'])
            if data['jobstatus']:  # jobstatus is 0 for pending async CloudStack calls
                if not data['jobresultcode']:  # exit code is zero
                    try:
                        return data['jobresult']
                    except KeyError:
                        pass
                logging.debug("Async CloudStack call returned {}".format(str(data)))
                raise CloudStackClientException(message="Async CloudStack call failed!",
                                                error_code=data.get("errorcode"),
                                                error_text=data.get("errortext"),
                                                response=data)

        return data
Handles the response returned from the CloudStack API. Some CloudStack API are implemented asynchronous, which
        means that the API call returns just a job id. The actually expected API response is postponed and a specific
        asyncJobResults API has to be polled using the job id to get the final result once the API call has been
        processed.

        :param response: The response returned by the aiohttp call.
        :type response: aiohttp.client_reqrep.ClientResponse
        :param await_final_result: Specifier that indicates whether the function should poll the asyncJobResult API
                                   until the asynchronous API call has been processed
        :type await_final_result: bool
        :return: Dictionary containing the JSON response of the API call
        :rtype: dict