Skip to content

Commit

Permalink
TA autogenerated code for v3.2-preview.1 (#13794)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhahn authored Nov 19, 2020
1 parent fd0f1f6 commit 3261830
Show file tree
Hide file tree
Showing 194 changed files with 99,763 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@
RecognizePiiEntitiesResult,
PiiEntity,
PiiEntityDomainType,
AnalyzeHealthcareResultItem,
HealthcareEntity,
HealthcareRelation,
HealthcareEntityLink,
EntitiesRecognitionTask,
PiiEntitiesRecognitionTask,
KeyPhraseExtractionTask,
TextAnalysisResult,
RequestStatistics
)
from._paging import AnalyzeHealthcareResult

__all__ = [
'TextAnalyticsApiVersion',
Expand Down Expand Up @@ -61,6 +71,16 @@
'RecognizePiiEntitiesResult',
'PiiEntity',
'PiiEntityDomainType',
'AnalyzeHealthcareResultItem',
'AnalyzeHealthcareResult',
'HealthcareEntity',
'HealthcareRelation',
'HealthcareEntityLink',
'EntitiesRecognitionTask',
'PiiEntitiesRecognitionTask',
'KeyPhraseExtractionTask',
'TextAnalysisResult',
'RequestStatistics'
]

__version__ = VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# coding=utf-8
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

from azure.core.polling.base_polling import OperationFailed, BadStatus
from azure.core.polling.async_base_polling import AsyncLROBasePolling


_FINISHED = frozenset(["succeeded", "cancelled", "failed", "partiallysucceeded"])
_FAILED = frozenset(["failed"])
_SUCCEEDED = frozenset(["succeeded", "partiallysucceeded"])


class TextAnalyticsAsyncLROPollingMethod(AsyncLROBasePolling):

def finished(self):
"""Is this polling finished?
:rtype: bool
"""
return TextAnalyticsAsyncLROPollingMethod._finished(self.status())

@staticmethod
def _finished(status):
if hasattr(status, "value"):
status = status.value
return str(status).lower() in _FINISHED

@staticmethod
def _failed(status):
if hasattr(status, "value"):
status = status.value
return str(status).lower() in _FAILED

@staticmethod
def _raise_if_bad_http_status_and_method(response):
"""Check response status code is valid.
Must be 200, 201, 202, or 204.
:raises: BadStatus if invalid status.
"""
code = response.status_code
if code in {200, 201, 202, 204}:
return
raise BadStatus(
"Invalid return status {!r} for {!r} operation".format(
code, response.request.method
)
)

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.
: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():
await self._delay()
await self.update_status()

if TextAnalyticsAsyncLROPollingMethod._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)
TextAnalyticsAsyncLROPollingMethod._raise_if_bad_http_status_and_method(
self._pipeline_response.http_response
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# coding=utf-8
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

from azure.core.async_paging import AsyncItemPaged


class AnalyzeHealthcareResultAsync(AsyncItemPaged):
def __init__(self, *args, **kwargs):
self.model_version = kwargs.pop('model_version')
self.statistics = kwargs.pop('statistics')
super(AnalyzeHealthcareResultAsync, self).__init__(*args, **kwargs)


class AnalyzeResultAsync(AsyncItemPaged):
def __init__(self, *args, **kwargs):
self.statistics = kwargs.pop('statistics')
super(AnalyzeResultAsync, self).__init__(*args, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class TextAnalyticsApiVersion(str, Enum):
"""Text Analytics API versions supported by this package"""

V3_1_PREVIEW_3 = "v3.1-preview.3"

#: this is the default version
V3_1_PREVIEW = "v3.1-preview.2"
V3_0 = "v3.0"
Expand Down
Loading

0 comments on commit 3261830

Please sign in to comment.