azure-ai-textanalytics 5.3.0b1__py3-none-any.whl → 6.0.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-textanalytics might be problematic. Click here for more details.
- azure/ai/textanalytics/__init__.py +26 -197
- azure/ai/textanalytics/_client.py +111 -0
- azure/ai/textanalytics/_configuration.py +73 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/operations → _operations}/__init__.py +13 -8
- azure/ai/textanalytics/_operations/_operations.py +716 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/models → _operations}/_patch.py +8 -6
- azure/ai/textanalytics/_patch.py +350 -0
- azure/ai/textanalytics/{_generated/aio → _utils}/__init__.py +1 -5
- azure/ai/textanalytics/_utils/model_base.py +1237 -0
- azure/ai/textanalytics/{_generated/_serialization.py → _utils/serialization.py} +640 -616
- azure/ai/textanalytics/{_generated/v2022_05_01/aio/_vendor.py → _utils/utils.py} +10 -12
- azure/ai/textanalytics/_version.py +8 -7
- azure/ai/textanalytics/aio/__init__.py +25 -14
- azure/ai/textanalytics/aio/_client.py +115 -0
- azure/ai/textanalytics/aio/_configuration.py +75 -0
- azure/ai/textanalytics/{_generated/v2022_10_01_preview/aio/operations → aio/_operations}/__init__.py +13 -8
- azure/ai/textanalytics/aio/_operations/_operations.py +623 -0
- azure/ai/textanalytics/{_generated/v2022_05_01 → aio/_operations}/_patch.py +8 -6
- azure/ai/textanalytics/aio/_patch.py +344 -0
- azure/ai/textanalytics/models/__init__.py +402 -0
- azure/ai/textanalytics/models/_enums.py +1979 -0
- azure/ai/textanalytics/models/_models.py +6641 -0
- azure/ai/textanalytics/{_generated/v2022_05_01/aio → models}/_patch.py +8 -6
- azure/ai/textanalytics/py.typed +1 -0
- {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/METADATA +755 -319
- azure_ai_textanalytics-6.0.0b1.dist-info/RECORD +29 -0
- {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/WHEEL +1 -1
- azure/ai/textanalytics/_base_client.py +0 -111
- azure/ai/textanalytics/_check.py +0 -22
- azure/ai/textanalytics/_dict_mixin.py +0 -54
- azure/ai/textanalytics/_generated/__init__.py +0 -16
- azure/ai/textanalytics/_generated/_configuration.py +0 -70
- azure/ai/textanalytics/_generated/_operations_mixin.py +0 -795
- azure/ai/textanalytics/_generated/_text_analytics_client.py +0 -126
- azure/ai/textanalytics/_generated/_version.py +0 -8
- azure/ai/textanalytics/_generated/aio/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/aio/_operations_mixin.py +0 -776
- azure/ai/textanalytics/_generated/aio/_text_analytics_client.py +0 -124
- azure/ai/textanalytics/_generated/models.py +0 -8
- azure/ai/textanalytics/_generated/v2022_05_01/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_05_01/_configuration.py +0 -72
- azure/ai/textanalytics/_generated/v2022_05_01/_text_analytics_client.py +0 -100
- azure/ai/textanalytics/_generated/v2022_05_01/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v2022_05_01/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_05_01/aio/_configuration.py +0 -71
- azure/ai/textanalytics/_generated/v2022_05_01/aio/_text_analytics_client.py +0 -97
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_patch.py +0 -121
- azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_text_analytics_client_operations.py +0 -603
- azure/ai/textanalytics/_generated/v2022_05_01/models/__init__.py +0 -281
- azure/ai/textanalytics/_generated/v2022_05_01/models/_models_py3.py +0 -5722
- azure/ai/textanalytics/_generated/v2022_05_01/models/_text_analytics_client_enums.py +0 -439
- azure/ai/textanalytics/_generated/v2022_05_01/operations/_patch.py +0 -120
- azure/ai/textanalytics/_generated/v2022_05_01/operations/_text_analytics_client_operations.py +0 -744
- azure/ai/textanalytics/_generated/v2022_10_01_preview/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_configuration.py +0 -72
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_text_analytics_client.py +0 -100
- azure/ai/textanalytics/_generated/v2022_10_01_preview/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_configuration.py +0 -71
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_text_analytics_client.py +0 -97
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_patch.py +0 -121
- azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_text_analytics_client_operations.py +0 -603
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/__init__.py +0 -407
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_models_py3.py +0 -8462
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_patch.py +0 -72
- azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_text_analytics_client_enums.py +0 -730
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_patch.py +0 -120
- azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_text_analytics_client_operations.py +0 -744
- azure/ai/textanalytics/_generated/v3_0/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_0/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/v3_0/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py +0 -96
- azure/ai/textanalytics/_generated/v3_0/_vendor.py +0 -33
- azure/ai/textanalytics/_generated/v3_0/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_0/aio/_configuration.py +0 -65
- azure/ai/textanalytics/_generated/v3_0/aio/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py +0 -93
- azure/ai/textanalytics/_generated/v3_0/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v3_0/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_0/aio/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py +0 -428
- azure/ai/textanalytics/_generated/v3_0/models/__init__.py +0 -81
- azure/ai/textanalytics/_generated/v3_0/models/_models_py3.py +0 -1467
- azure/ai/textanalytics/_generated/v3_0/models/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/models/_text_analytics_client_enums.py +0 -58
- azure/ai/textanalytics/_generated/v3_0/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_0/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py +0 -604
- azure/ai/textanalytics/_generated/v3_1/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_1/_configuration.py +0 -66
- azure/ai/textanalytics/_generated/v3_1/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_1/_text_analytics_client.py +0 -98
- azure/ai/textanalytics/_generated/v3_1/_vendor.py +0 -45
- azure/ai/textanalytics/_generated/v3_1/aio/__init__.py +0 -20
- azure/ai/textanalytics/_generated/v3_1/aio/_configuration.py +0 -65
- azure/ai/textanalytics/_generated/v3_1/aio/_patch.py +0 -31
- azure/ai/textanalytics/_generated/v3_1/aio/_text_analytics_client.py +0 -95
- azure/ai/textanalytics/_generated/v3_1/aio/_vendor.py +0 -27
- azure/ai/textanalytics/_generated/v3_1/aio/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_1/aio/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/aio/operations/_text_analytics_client_operations.py +0 -1291
- azure/ai/textanalytics/_generated/v3_1/models/__init__.py +0 -205
- azure/ai/textanalytics/_generated/v3_1/models/_models_py3.py +0 -3976
- azure/ai/textanalytics/_generated/v3_1/models/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/models/_text_analytics_client_enums.py +0 -367
- azure/ai/textanalytics/_generated/v3_1/operations/__init__.py +0 -18
- azure/ai/textanalytics/_generated/v3_1/operations/_patch.py +0 -19
- azure/ai/textanalytics/_generated/v3_1/operations/_text_analytics_client_operations.py +0 -1709
- azure/ai/textanalytics/_lro.py +0 -552
- azure/ai/textanalytics/_models.py +0 -3142
- azure/ai/textanalytics/_policies.py +0 -66
- azure/ai/textanalytics/_request_handlers.py +0 -104
- azure/ai/textanalytics/_response_handlers.py +0 -580
- azure/ai/textanalytics/_text_analytics_client.py +0 -1802
- azure/ai/textanalytics/_user_agent.py +0 -8
- azure/ai/textanalytics/_validate.py +0 -113
- azure/ai/textanalytics/aio/_base_client_async.py +0 -95
- azure/ai/textanalytics/aio/_lro_async.py +0 -501
- azure/ai/textanalytics/aio/_response_handlers_async.py +0 -94
- azure/ai/textanalytics/aio/_text_analytics_client_async.py +0 -1800
- azure_ai_textanalytics-5.3.0b1.dist-info/RECORD +0 -115
- {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info/licenses}/LICENSE +0 -0
- {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
"""Customize generated code here.
|
|
7
|
+
|
|
8
|
+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
|
|
9
|
+
"""
|
|
10
|
+
# coding: utf-8
|
|
11
|
+
import json
|
|
12
|
+
from typing import Any, Callable, Dict, IO, Mapping, Optional, TypeVar, Union, cast, overload, Generic, TYPE_CHECKING
|
|
13
|
+
from collections.abc import MutableMapping # pylint:disable=import-error
|
|
14
|
+
|
|
15
|
+
from azure.core.exceptions import HttpResponseError
|
|
16
|
+
from azure.core.pipeline import PipelineResponse
|
|
17
|
+
from azure.core.polling import AsyncLROPoller, AsyncPollingMethod, AsyncNoPolling
|
|
18
|
+
from azure.core.polling.async_base_polling import AsyncLROBasePolling
|
|
19
|
+
from azure.core.rest import HttpRequest, AsyncHttpResponse
|
|
20
|
+
from azure.core.tracing.decorator_async import distributed_trace_async
|
|
21
|
+
from azure.core.utils import case_insensitive_dict
|
|
22
|
+
from azure.core.credentials import AzureKeyCredential
|
|
23
|
+
from azure.core.async_paging import AsyncItemPaged
|
|
24
|
+
|
|
25
|
+
from ._client import TextAnalysisClient as AnalysisTextClientGenerated
|
|
26
|
+
from .. import models as _models
|
|
27
|
+
from ..models import AnalyzeTextOperationState, TextActions
|
|
28
|
+
from .._utils.serialization import Serializer
|
|
29
|
+
from .._patch import _parse_operation_id
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from azure.core.credentials_async import AsyncTokenCredential
|
|
33
|
+
|
|
34
|
+
JSON = MutableMapping[str, Any]
|
|
35
|
+
_Unset: Any = object()
|
|
36
|
+
T = TypeVar("T")
|
|
37
|
+
PollingReturnType_co = TypeVar("PollingReturnType_co", covariant=True)
|
|
38
|
+
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
|
|
39
|
+
|
|
40
|
+
_SERIALIZER = Serializer()
|
|
41
|
+
_SERIALIZER.client_side_validation = False
|
|
42
|
+
|
|
43
|
+
class AnalyzeTextAsyncLROPoller(AsyncLROPoller[PollingReturnType_co], Generic[PollingReturnType_co]):
|
|
44
|
+
"""Custom **async** poller that returns ``PollingReturnType_co`` and exposes operation metadata."""
|
|
45
|
+
|
|
46
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
47
|
+
super().__init__(*args, **kwargs)
|
|
48
|
+
self._last_state: Optional[AnalyzeTextOperationState] = None # set by deserializer
|
|
49
|
+
|
|
50
|
+
# internal: called by the deserializer to update details()
|
|
51
|
+
def _record_state_for_details(self, state: AnalyzeTextOperationState) -> None:
|
|
52
|
+
self._last_state = state
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def details(self) -> Mapping[str, Any]:
|
|
56
|
+
"""Metadata associated with the long-running operation.
|
|
57
|
+
|
|
58
|
+
:return: A mapping with keys like ``operation_id`` and, when available,
|
|
59
|
+
``status``, ``job_id``, ``display_name``, ``created_at``,
|
|
60
|
+
``last_updated_at``, ``expires_on``, ``statistics``,
|
|
61
|
+
``errors``, and ``next_link``.
|
|
62
|
+
:rtype: Mapping[str, Any]
|
|
63
|
+
"""
|
|
64
|
+
try:
|
|
65
|
+
headers = (
|
|
66
|
+
getattr(self.polling_method(), "_initial_response").http_response.headers # type: ignore[attr-defined]
|
|
67
|
+
)
|
|
68
|
+
op_loc = headers.get("Operation-Location") or headers.get("operation-location")
|
|
69
|
+
except (AttributeError, TypeError):
|
|
70
|
+
op_loc = None
|
|
71
|
+
|
|
72
|
+
info: Dict[str, Any] = {"operation_id": _parse_operation_id(op_loc)}
|
|
73
|
+
if self._last_state is not None:
|
|
74
|
+
s = self._last_state
|
|
75
|
+
info.update(
|
|
76
|
+
{
|
|
77
|
+
"status": s.status,
|
|
78
|
+
"job_id": s.job_id,
|
|
79
|
+
"display_name": s.display_name,
|
|
80
|
+
"created_at": s.created_at,
|
|
81
|
+
"last_updated_at": s.last_updated_at,
|
|
82
|
+
"expires_on": s.expires_on,
|
|
83
|
+
"statistics": s.statistics,
|
|
84
|
+
"errors": s.errors,
|
|
85
|
+
"next_link": s.next_link,
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
return info
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_continuation_token(
|
|
92
|
+
cls,
|
|
93
|
+
polling_method: AsyncPollingMethod[PollingReturnType_co],
|
|
94
|
+
continuation_token: str,
|
|
95
|
+
**kwargs: Any,
|
|
96
|
+
) -> "AnalyzeTextAsyncLROPoller[PollingReturnType_co]":
|
|
97
|
+
client, initial_response, deserialization_callback = polling_method.from_continuation_token(
|
|
98
|
+
continuation_token, **kwargs
|
|
99
|
+
)
|
|
100
|
+
return cls(client, initial_response, deserialization_callback, polling_method)
|
|
101
|
+
|
|
102
|
+
class TextAnalysisClient(AnalysisTextClientGenerated):
|
|
103
|
+
"""**Async** client for Text Analysis APIs."""
|
|
104
|
+
|
|
105
|
+
def __init__(
|
|
106
|
+
self,
|
|
107
|
+
endpoint: str,
|
|
108
|
+
credential: Union[AzureKeyCredential, "AsyncTokenCredential"],
|
|
109
|
+
*,
|
|
110
|
+
api_version: Optional[str] = None,
|
|
111
|
+
**kwargs: Any,
|
|
112
|
+
) -> None:
|
|
113
|
+
"""Create a TextAnalysisClient.
|
|
114
|
+
|
|
115
|
+
:param endpoint: Supported Cognitive Services endpoint.
|
|
116
|
+
:type endpoint: str
|
|
117
|
+
:param credential: Key or token credential.
|
|
118
|
+
:type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.AsyncTokenCredential
|
|
119
|
+
:keyword api_version: The API version to use for this operation. Default value is
|
|
120
|
+
``"2025-05-15-preview"``. Note that overriding this default value may result in unsupported
|
|
121
|
+
behavior.
|
|
122
|
+
:paramtype api_version: str
|
|
123
|
+
"""
|
|
124
|
+
if api_version is not None:
|
|
125
|
+
kwargs["api_version"] = api_version
|
|
126
|
+
super().__init__(endpoint=endpoint, credential=credential, **kwargs)
|
|
127
|
+
|
|
128
|
+
@overload
|
|
129
|
+
async def begin_analyze_text_job(
|
|
130
|
+
self,
|
|
131
|
+
*,
|
|
132
|
+
text_input: _models.MultiLanguageTextInput,
|
|
133
|
+
actions: list[_models.AnalyzeTextOperationAction],
|
|
134
|
+
content_type: str = "application/json",
|
|
135
|
+
display_name: Optional[str] = None,
|
|
136
|
+
default_language: Optional[str] = None,
|
|
137
|
+
cancel_after: Optional[float] = None,
|
|
138
|
+
**kwargs: Any,
|
|
139
|
+
) -> AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]]:
|
|
140
|
+
"""Submit a collection of text documents for analysis. Specify one or more unique tasks to be
|
|
141
|
+
executed as a long-running operation.
|
|
142
|
+
|
|
143
|
+
:keyword text_input: Contains the input to be analyzed. Required.
|
|
144
|
+
:paramtype text_input: ~azure.ai.textanalytics.models.MultiLanguageTextInput
|
|
145
|
+
:keyword actions: List of tasks to be performed as part of the LRO. Required.
|
|
146
|
+
:paramtype actions: list[~azure.ai.textanalytics.models.AnalyzeTextOperationAction]
|
|
147
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
148
|
+
Default value is ``"application/json"``.
|
|
149
|
+
:paramtype content_type: str
|
|
150
|
+
:keyword display_name: Name for the task. Default value is ``None``.
|
|
151
|
+
:paramtype display_name: str
|
|
152
|
+
:keyword default_language: Default language to use for records requesting automatic language
|
|
153
|
+
detection. Default value is ``None``.
|
|
154
|
+
:paramtype default_language: str
|
|
155
|
+
:keyword cancel_after: Optional duration in seconds after which the job will be canceled if not
|
|
156
|
+
completed. Default value is ``None``.
|
|
157
|
+
:paramtype cancel_after: float
|
|
158
|
+
:return: A poller whose ``result()`` yields ``AsyncItemPaged[TextActions]`` and exposes metadata via
|
|
159
|
+
``.details``.
|
|
160
|
+
:rtype: ~azure.ai.textanalytics.AnalyzeTextAsyncLROPoller[
|
|
161
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.textanalytics.models.TextActions]]
|
|
162
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
@overload
|
|
166
|
+
async def begin_analyze_text_job(
|
|
167
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
168
|
+
) -> AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]]:
|
|
169
|
+
"""Submit a collection of text documents for analysis. Specify one or more unique tasks to be
|
|
170
|
+
executed as a long-running operation.
|
|
171
|
+
|
|
172
|
+
:param body: Required.
|
|
173
|
+
:type body: JSON
|
|
174
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
175
|
+
Default value is ``"application/json"``.
|
|
176
|
+
:paramtype content_type: str
|
|
177
|
+
:return: A poller whose ``result()`` yields ``AsyncItemPaged[TextActions]`` and exposes metadata via
|
|
178
|
+
``.details``.
|
|
179
|
+
:rtype: ~azure.ai.textanalytics.AnalyzeTextAsyncLROPoller[
|
|
180
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.textanalytics.models.TextActions]]
|
|
181
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
@overload
|
|
185
|
+
async def begin_analyze_text_job(
|
|
186
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
187
|
+
) -> AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]]:
|
|
188
|
+
"""Submit a collection of text documents for analysis. Specify one or more unique tasks to be
|
|
189
|
+
executed as a long-running operation.
|
|
190
|
+
|
|
191
|
+
:param body: Required.
|
|
192
|
+
:type body: IO[bytes]
|
|
193
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
194
|
+
Default value is ``"application/json"``.
|
|
195
|
+
:paramtype content_type: str
|
|
196
|
+
:return: A poller whose ``result()`` yields ``AsyncItemPaged[TextActions]`` and exposes metadata via
|
|
197
|
+
``.details``.
|
|
198
|
+
:rtype: ~azure.ai.textanalytics.AnalyzeTextAsyncLROPoller[
|
|
199
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.textanalytics.models.TextActions]]
|
|
200
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
@distributed_trace_async
|
|
204
|
+
async def begin_analyze_text_job( # type: ignore[override]
|
|
205
|
+
self,
|
|
206
|
+
body: Union[JSON, IO[bytes]] = _Unset,
|
|
207
|
+
*,
|
|
208
|
+
text_input: _models.MultiLanguageTextInput = _Unset,
|
|
209
|
+
actions: list[_models.AnalyzeTextOperationAction] = _Unset,
|
|
210
|
+
display_name: Optional[str] = None,
|
|
211
|
+
default_language: Optional[str] = None,
|
|
212
|
+
cancel_after: Optional[float] = None,
|
|
213
|
+
**kwargs: Any,
|
|
214
|
+
) -> AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]]:
|
|
215
|
+
"""Submit a collection of text documents for analysis. Specify one or more unique tasks to be
|
|
216
|
+
executed as a long-running operation.
|
|
217
|
+
|
|
218
|
+
:param body: Is either a JSON type or a IO[bytes] type. Required.
|
|
219
|
+
:type body: JSON or IO[bytes]
|
|
220
|
+
:keyword text_input: Contains the input to be analyzed. Required.
|
|
221
|
+
:paramtype text_input: ~azure.ai.textanalytics.models.MultiLanguageTextInput
|
|
222
|
+
:keyword actions: List of tasks to be performed as part of the LRO. Required.
|
|
223
|
+
:paramtype actions: list[~azure.ai.textanalytics.models.AnalyzeTextOperationAction]
|
|
224
|
+
:keyword display_name: Name for the task. Default value is ``None``.
|
|
225
|
+
:paramtype display_name: str
|
|
226
|
+
:keyword default_language: Default language to use for records requesting automatic language
|
|
227
|
+
detection. Default value is ``None``.
|
|
228
|
+
:paramtype default_language: str
|
|
229
|
+
:keyword cancel_after: Optional duration in seconds after which the job will be canceled if not
|
|
230
|
+
completed. Default value is ``None``.
|
|
231
|
+
:paramtype cancel_after: float
|
|
232
|
+
:return: A poller whose ``result()`` yields ``AsyncItemPaged[TextActions]`` and exposes metadata via
|
|
233
|
+
``.details``.
|
|
234
|
+
:rtype: ~azure.ai.textanalytics.AnalyzeTextAsyncLROPoller[
|
|
235
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.textanalytics.models.TextActions]]
|
|
236
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
237
|
+
"""
|
|
238
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
239
|
+
_params = kwargs.pop("params", {}) or {}
|
|
240
|
+
|
|
241
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
242
|
+
polling: Union[
|
|
243
|
+
bool, AsyncPollingMethod[AsyncItemPaged["TextActions"]]
|
|
244
|
+
] = kwargs.pop("polling", True)
|
|
245
|
+
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
|
|
246
|
+
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
|
|
247
|
+
cls: ClsType[AsyncItemPaged["TextActions"]] = kwargs.pop("cls", None)
|
|
248
|
+
kwargs.pop("error_map", None)
|
|
249
|
+
|
|
250
|
+
path_format_arguments = {
|
|
251
|
+
"Endpoint": self._serialize.url( # type: ignore[attr-defined]
|
|
252
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
253
|
+
),
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async def _fetch_state_by_next_link(next_link: str) -> AnalyzeTextOperationState:
|
|
257
|
+
req = HttpRequest("GET", next_link)
|
|
258
|
+
resp = await self._client.send_request(req) # type: ignore[attr-defined]
|
|
259
|
+
if resp.status_code != 200:
|
|
260
|
+
raise HttpResponseError(response=resp)
|
|
261
|
+
data = json.loads(await resp.text())
|
|
262
|
+
return AnalyzeTextOperationState(data)
|
|
263
|
+
|
|
264
|
+
def _build_pager_from_state(
|
|
265
|
+
state: AnalyzeTextOperationState,
|
|
266
|
+
) -> AsyncItemPaged["TextActions"]:
|
|
267
|
+
async def extract_data(s: AnalyzeTextOperationState):
|
|
268
|
+
next_link = s.next_link
|
|
269
|
+
actions_payload: TextActions = s.actions
|
|
270
|
+
return next_link, [actions_payload]
|
|
271
|
+
|
|
272
|
+
async def get_next(token: Optional[str]) -> Optional[AnalyzeTextOperationState]:
|
|
273
|
+
if token is None:
|
|
274
|
+
return state
|
|
275
|
+
if not token:
|
|
276
|
+
return None
|
|
277
|
+
return await _fetch_state_by_next_link(token)
|
|
278
|
+
|
|
279
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
280
|
+
|
|
281
|
+
poller_holder: Dict[str, AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]]] = {}
|
|
282
|
+
|
|
283
|
+
def get_long_running_output(pipeline_response):
|
|
284
|
+
final = pipeline_response.http_response
|
|
285
|
+
if final.status_code == 200:
|
|
286
|
+
data = json.loads(final.text())
|
|
287
|
+
op_state = AnalyzeTextOperationState(data)
|
|
288
|
+
|
|
289
|
+
poller_ref = poller_holder["poller"]
|
|
290
|
+
poller_ref._record_state_for_details(op_state) # pylint:disable=protected-access
|
|
291
|
+
|
|
292
|
+
paged = _build_pager_from_state(op_state)
|
|
293
|
+
return cls(pipeline_response, paged, {}) if cls else paged
|
|
294
|
+
raise HttpResponseError(response=final)
|
|
295
|
+
|
|
296
|
+
if polling is True:
|
|
297
|
+
polling_method: AsyncPollingMethod[AsyncItemPaged["TextActions"]] = cast(
|
|
298
|
+
AsyncPollingMethod[AsyncItemPaged["TextActions"]],
|
|
299
|
+
AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs),
|
|
300
|
+
)
|
|
301
|
+
elif polling is False:
|
|
302
|
+
polling_method = cast(AsyncPollingMethod[AsyncItemPaged["TextActions"]], AsyncNoPolling())
|
|
303
|
+
else:
|
|
304
|
+
polling_method = cast(AsyncPollingMethod[AsyncItemPaged["TextActions"]], polling)
|
|
305
|
+
|
|
306
|
+
if cont_token:
|
|
307
|
+
return AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]].from_continuation_token(
|
|
308
|
+
polling_method=polling_method,
|
|
309
|
+
continuation_token=cont_token,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
initial_kwargs = dict( # pylint:disable=use-dict-literal
|
|
313
|
+
text_input=text_input,
|
|
314
|
+
actions=actions,
|
|
315
|
+
display_name=display_name,
|
|
316
|
+
default_language=default_language,
|
|
317
|
+
cancel_after=cancel_after,
|
|
318
|
+
content_type=content_type,
|
|
319
|
+
cls=lambda x, y, z: x, # passthrough raw pipeline response
|
|
320
|
+
headers=_headers,
|
|
321
|
+
params=_params,
|
|
322
|
+
**kwargs,
|
|
323
|
+
)
|
|
324
|
+
if body is not _Unset and body is not None:
|
|
325
|
+
initial_kwargs["body"] = body
|
|
326
|
+
|
|
327
|
+
raw_result = await self._analyze_text_job_initial(**initial_kwargs)
|
|
328
|
+
await raw_result.http_response.read() # type: ignore[attr-defined]
|
|
329
|
+
|
|
330
|
+
lro: AnalyzeTextAsyncLROPoller[AsyncItemPaged["TextActions"]] = AnalyzeTextAsyncLROPoller(
|
|
331
|
+
self._client, raw_result, get_long_running_output, polling_method
|
|
332
|
+
)
|
|
333
|
+
poller_holder["poller"] = lro
|
|
334
|
+
return lro
|
|
335
|
+
|
|
336
|
+
def patch_sdk():
|
|
337
|
+
"""Do not remove from this file.
|
|
338
|
+
|
|
339
|
+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
|
|
340
|
+
you can't accomplish using the techniques described in
|
|
341
|
+
https://aka.ms/azsdk/python/dpcodegen/python/customize
|
|
342
|
+
"""
|
|
343
|
+
|
|
344
|
+
__all__ = ["TextAnalysisClient", "AnalyzeTextAsyncLROPoller"]
|