def _poll(self): """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation status 'Failed' or 'Canceled'. :raises: BadStatus if response status invalid. :raises: BadResponse if response invalid. """ while not self.finished(): self._delay() self.update_status() if TextAnalyticsLROPollingMethod._failed(self.status()): try: job = json.loads(self._pipeline_response.http_response.text()) error_message = "" for err in job["errors"]: error_message += "({}) {}".format(err["code"], err["message"]) raise HttpResponseError(message=error_message, response=self._pipeline_response.http_response) except KeyError: raise OperationFailed("Operation failed or canceled") final_get_url = self._operation.get_final_get_url(self._pipeline_response) if final_get_url: self._pipeline_response = self.request_status(final_get_url) TextAnalyticsLROPollingMethod._raise_if_bad_http_status_and_method( self._pipeline_response.http_response )
def set_initial_status(self, pipeline_response): response = pipeline_response.http_response self._polling_url = response.headers["azure-asyncoperation"] if response.status_code in {200, 201, 202, 204}: return self.get_status(pipeline_response) raise OperationFailed("Operation failed or canceled")
def set_initial_status(self, pipeline_response): # type: (PipelineResponseType) -> str """Process first response after initiating long running operation. :param azure.core.pipeline.PipelineResponse response: initial REST call response. """ self._async_url = pipeline_response.http_response.request.url response = pipeline_response.http_response if response.status_code in {200, 201, 202, 204} and self._async_url: return "InProgress" raise OperationFailed("Operation failed or canceled")
def set_initial_status(self, pipeline_response): # type: (PipelineResponseType) -> str """Process first response after initiating long running operation. :param azure.core.pipeline.PipelineResponse response: initial REST call response. """ self._initial_response = pipeline_response response = pipeline_response.http_response if response.status_code == 202: return "InProgress" if response.status_code == 201: status = self._get_provisioning_state(response) return status or "InProgress" if response.status_code == 200: status = self._get_provisioning_state(response) return status or "Succeeded" if response.status_code == 204: return "Succeeded" raise OperationFailed("Invalid status found")
def _poll(self): """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation status 'Failed' or 'Canceled'. :raises: BadStatus if response status invalid. :raises: BadResponse if response invalid. """ while not self.finished(): self._delay() self.update_status() if self._failed(self.status()): raise OperationFailed("Operation failed or canceled") final_get_url = self._operation.get_final_get_url(self._pipeline_response) if final_get_url: self._pipeline_response = self.request_status(final_get_url) _raise_if_bad_http_status_and_method(self._pipeline_response.http_response)
async def _poll(self): # pylint:disable=invalid-overridden-method """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :raises: OperationFailed if operation status 'Failed' or 'Canceled'. :raises: BadStatus if response status invalid. :raises: BadResponse if response invalid. """ while not self.finished(): await self._delay() await self.update_status() if self._failed(self.status()): raise OperationFailed("Operation failed or canceled") final_get_url = self._operation.get_final_get_url( self._pipeline_response) if final_get_url: self._pipeline_response = await self.request_status(final_get_url) _raise_if_bad_http_status_and_method( self._pipeline_response.http_response)