azure-ai-textanalytics 5.3.0b2__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.

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