Skip to content

Commit f691eec

Browse files
committed
update get_[operation]_status to private
add dependency on azure-ai-language-questionanswering
1 parent 2b4f1fc commit f691eec

File tree

4 files changed

+111
-109
lines changed

4 files changed

+111
-109
lines changed

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/azure/ai/language/questionanswering/authoring/_operations/_patch.py

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
from ._operations import (
1919
_QuestionAnsweringAuthoringClientOperationsMixin as _QuestionAnsweringAuthoringClientOperationsMixinGenerated,
2020
)
21+
2122
JSON = MutableMapping[str, Any]
2223

24+
2325
class _QuestionAnsweringAuthoringClientOperationsMixin(_QuestionAnsweringAuthoringClientOperationsMixinGenerated):
2426
"""Mixin class for patching methods with backward compatible parameter names."""
2527

2628
# create_project overloads with 'options' parameter
27-
@overload # type: ignore
29+
@overload # type: ignore
2830
def create_project(
2931
self,
3032
project_name: str,
@@ -48,7 +50,7 @@ def create_project(
4850
:raises ~azure.core.exceptions.HttpResponseError:
4951
"""
5052

51-
@overload # type: ignore
53+
@overload # type: ignore
5254
def create_project(
5355
self, project_name: str, options: JSON, *, content_type: str = "application/json", **kwargs: Any
5456
) -> _models.QuestionAnsweringProject:
@@ -67,7 +69,7 @@ def create_project(
6769
:raises ~azure.core.exceptions.HttpResponseError:
6870
"""
6971

70-
@overload # type: ignore
72+
@overload # type: ignore
7173
def create_project(
7274
self, project_name: str, options: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
7375
) -> _models.QuestionAnsweringProject:
@@ -87,7 +89,7 @@ def create_project(
8789
"""
8890

8991
@distributed_trace
90-
def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
92+
def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
9193
self, project_name: str, options: Union[_models.QuestionAnsweringProject, JSON, IO[bytes]], **kwargs: Any
9294
) -> _models.QuestionAnsweringProject:
9395
"""Create or update a project.
@@ -107,9 +109,14 @@ def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
107109
return super().create_project(project_name=project_name, body=options, **kwargs)
108110

109111
# update_synonyms overloads with 'synonyms' parameter
110-
@overload # type: ignore
112+
@overload # type: ignore
111113
def update_synonyms(
112-
self, project_name: str, synonyms: _models.SynonymAssets, *, content_type: str = "application/json", **kwargs: Any
114+
self,
115+
project_name: str,
116+
synonyms: _models.SynonymAssets,
117+
*,
118+
content_type: str = "application/json",
119+
**kwargs: Any
113120
) -> None:
114121
"""Updates all the synonyms of a project.
115122
@@ -125,7 +132,7 @@ def update_synonyms(
125132
:raises ~azure.core.exceptions.HttpResponseError:
126133
"""
127134

128-
@overload # type: ignore
135+
@overload # type: ignore
129136
def update_synonyms(
130137
self, project_name: str, synonyms: JSON, *, content_type: str = "application/json", **kwargs: Any
131138
) -> None:
@@ -143,7 +150,7 @@ def update_synonyms(
143150
:raises ~azure.core.exceptions.HttpResponseError:
144151
"""
145152

146-
@overload # type: ignore
153+
@overload # type: ignore
147154
def update_synonyms(
148155
self, project_name: str, synonyms: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
149156
) -> None:
@@ -181,7 +188,7 @@ def update_synonyms( # pyright: ignore[reportIncompatibleMethodOverride]
181188
return super().update_synonyms(project_name=project_name, body=synonyms, **kwargs)
182189

183190
# begin_update_qnas overloads with 'qnas' parameter
184-
@overload # type: ignore
191+
@overload # type: ignore
185192
def begin_update_qnas(
186193
self,
187194
project_name: str,
@@ -204,7 +211,7 @@ def begin_update_qnas(
204211
:raises ~azure.core.exceptions.HttpResponseError:
205212
"""
206213

207-
@overload # type: ignore
214+
@overload # type: ignore
208215
def begin_update_qnas(
209216
self, project_name: str, qnas: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
210217
) -> LROPoller[None]:
@@ -223,7 +230,7 @@ def begin_update_qnas(
223230
"""
224231

225232
@distributed_trace
226-
def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
233+
def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
227234
self, project_name: str, qnas: Union[list[_models.UpdateQnaRecord], IO[bytes]], **kwargs: Any
228235
) -> LROPoller[None]:
229236
"""Updates the QnAs of a project.
@@ -242,7 +249,7 @@ def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
242249
return super().begin_update_qnas(project_name=project_name, body=qnas, **kwargs)
243250

244251
# begin_update_sources overloads with 'sources' parameter
245-
@overload # type: ignore
252+
@overload # type: ignore
246253
def begin_update_sources(
247254
self,
248255
project_name: str,
@@ -265,7 +272,7 @@ def begin_update_sources(
265272
:raises ~azure.core.exceptions.HttpResponseError:
266273
"""
267274

268-
@overload # type: ignore
275+
@overload # type: ignore
269276
def begin_update_sources(
270277
self, project_name: str, sources: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
271278
) -> LROPoller[None]:
@@ -284,7 +291,7 @@ def begin_update_sources(
284291
"""
285292

286293
@distributed_trace
287-
def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverride]
294+
def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverride]
288295
self, project_name: str, sources: Union[list[_models.UpdateSourceRecord], IO[bytes]], **kwargs: Any
289296
) -> LROPoller[None]:
290297
"""Updates the sources of a project.
@@ -300,9 +307,7 @@ def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverride]
300307
:raises ~azure.core.exceptions.HttpResponseError:
301308
"""
302309
# Call the parent implementation with 'body' parameter for backward compatibility
303-
return super().begin_update_sources(
304-
project_name=project_name, body=sources, **kwargs
305-
)
310+
return super().begin_update_sources(project_name=project_name, body=sources, **kwargs)
306311

307312

308313
__all__: list[str] = [
@@ -317,3 +322,41 @@ def patch_sdk():
317322
you can't accomplish using the techniques described in
318323
https://aka.ms/azsdk/python/dpcodegen/python/customize
319324
"""
325+
# Hide the generated get_*_status LRO status peek methods from the public surface
326+
# without editing the generated _operations.py file. We do this by:
327+
# 1. Capturing references to the original methods.
328+
# 2. Deleting those attributes from the generated mixin class so normal attribute
329+
# resolution on the public client no longer finds them.
330+
# 3. Exposing private underscore-prefixed versions on our patch subclass for
331+
# internal/testing use if ever needed.
332+
#
333+
# NOTE: This is a breaking change for any user code calling these methods directly.
334+
# Provide release notes / changelog entry accordingly.
335+
original_methods: dict[str, Any] = {}
336+
to_hide = [
337+
"get_delete_status",
338+
"get_export_status",
339+
"get_import_status",
340+
"get_deploy_status",
341+
]
342+
generated_cls = _QuestionAnsweringAuthoringClientOperationsMixinGenerated
343+
for name in to_hide:
344+
if hasattr(generated_cls, name):
345+
original_methods[name] = getattr(generated_cls, name)
346+
try:
347+
delattr(generated_cls, name)
348+
except AttributeError:
349+
pass # Already removed
350+
351+
# Attach private replicas to the patch subclass so internal code could still call them
352+
patch_cls = _QuestionAnsweringAuthoringClientOperationsMixin
353+
for public_name, func in original_methods.items():
354+
private_name = f"_{public_name}" # e.g. _get_delete_status
355+
# Avoid overwriting if already defined.
356+
if not hasattr(patch_cls, private_name):
357+
# Bind function so it behaves like an instance method on patch_cls.
358+
setattr(patch_cls, private_name, func)
359+
360+
# Ensure they are not exported via __all__ even if someone adds them later.
361+
# (__all__ currently only lists the mixin class.)
362+
# No action needed unless we want to explicitly assert.

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/azure/ai/language/questionanswering/authoring/aio/_operations/_patch.py

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
from ._operations import (
1717
_QuestionAnsweringAuthoringClientOperationsMixin as _QuestionAnsweringAuthoringClientOperationsMixinGenerated,
1818
)
19+
1920
JSON = MutableMapping[str, Any]
2021

22+
2123
class _QuestionAnsweringAuthoringClientOperationsMixin(_QuestionAnsweringAuthoringClientOperationsMixinGenerated):
2224
"""Mixin class for patching methods with backward compatible parameter names."""
2325

2426
# create_project overloads with 'options' parameter
25-
@overload # type: ignore
27+
@overload # type: ignore
2628
async def create_project(
2729
self,
2830
project_name: str,
@@ -45,7 +47,7 @@ async def create_project(
4547
:raises ~azure.core.exceptions.HttpResponseError:
4648
"""
4749

48-
@overload # type: ignore
50+
@overload # type: ignore
4951
async def create_project(
5052
self, project_name: str, options: JSON, *, content_type: str = "application/json", **kwargs: Any
5153
) -> _models.QuestionAnsweringProject:
@@ -64,7 +66,7 @@ async def create_project(
6466
:raises ~azure.core.exceptions.HttpResponseError:
6567
"""
6668

67-
@overload # type: ignore
69+
@overload # type: ignore
6870
async def create_project(
6971
self, project_name: str, options: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
7072
) -> _models.QuestionAnsweringProject:
@@ -84,10 +86,8 @@ async def create_project(
8486
"""
8587

8688
@distributed_trace_async
87-
async def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
88-
self,
89-
project_name: str,
90-
options: Union[_models.QuestionAnsweringProject, JSON, IO[bytes]], **kwargs: Any
89+
async def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
90+
self, project_name: str, options: Union[_models.QuestionAnsweringProject, JSON, IO[bytes]], **kwargs: Any
9191
) -> _models.QuestionAnsweringProject:
9292
"""Create or update a project.
9393
@@ -106,9 +106,14 @@ async def create_project( # pyright: ignore[reportIncompatibleMethodOverride]
106106
return await super().create_project(project_name=project_name, body=options, **kwargs)
107107

108108
# update_synonyms overloads with 'synonyms' parameter
109-
@overload # type: ignore
109+
@overload # type: ignore
110110
async def update_synonyms(
111-
self, project_name: str, synonyms: _models.SynonymAssets, *, content_type: str = "application/json", **kwargs: Any
111+
self,
112+
project_name: str,
113+
synonyms: _models.SynonymAssets,
114+
*,
115+
content_type: str = "application/json",
116+
**kwargs: Any
112117
) -> None:
113118
"""Updates all the synonyms of a project.
114119
@@ -124,7 +129,7 @@ async def update_synonyms(
124129
:raises ~azure.core.exceptions.HttpResponseError:
125130
"""
126131

127-
@overload # type: ignore
132+
@overload # type: ignore
128133
async def update_synonyms(
129134
self, project_name: str, synonyms: JSON, *, content_type: str = "application/json", **kwargs: Any
130135
) -> None:
@@ -142,7 +147,7 @@ async def update_synonyms(
142147
:raises ~azure.core.exceptions.HttpResponseError:
143148
"""
144149

145-
@overload # type: ignore
150+
@overload # type: ignore
146151
async def update_synonyms(
147152
self, project_name: str, synonyms: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
148153
) -> None:
@@ -161,7 +166,7 @@ async def update_synonyms(
161166
"""
162167

163168
@distributed_trace_async
164-
async def update_synonyms( # pyright: ignore[reportIncompatibleMethodOverride]
169+
async def update_synonyms( # pyright: ignore[reportIncompatibleMethodOverride]
165170
self, project_name: str, synonyms: Union[_models.SynonymAssets, JSON, IO[bytes]], **kwargs: Any
166171
) -> None:
167172
"""Updates all the synonyms of a project.
@@ -180,7 +185,7 @@ async def update_synonyms( # pyright: ignore[reportIncompatibleMethodOverride]
180185
return await super().update_synonyms(project_name=project_name, body=synonyms, **kwargs)
181186

182187
# begin_update_qnas overloads with 'qnas' parameter
183-
@overload # type: ignore
188+
@overload # type: ignore
184189
async def begin_update_qnas(
185190
self,
186191
project_name: str,
@@ -203,7 +208,7 @@ async def begin_update_qnas(
203208
:raises ~azure.core.exceptions.HttpResponseError:
204209
"""
205210

206-
@overload # type: ignore
211+
@overload # type: ignore
207212
async def begin_update_qnas(
208213
self, project_name: str, qnas: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
209214
) -> AsyncLROPoller[None]:
@@ -222,7 +227,7 @@ async def begin_update_qnas(
222227
"""
223228

224229
@distributed_trace_async
225-
async def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
230+
async def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
226231
self, project_name: str, qnas: Union[list[_models.UpdateQnaRecord], IO[bytes]], **kwargs: Any
227232
) -> AsyncLROPoller[None]:
228233
"""Updates the QnAs of a project.
@@ -238,12 +243,10 @@ async def begin_update_qnas( # pyright: ignore[reportIncompatibleMethodOverride]
238243
:raises ~azure.core.exceptions.HttpResponseError:
239244
"""
240245
# Call the parent implementation with 'body' parameter for backward compatibility
241-
return await super().begin_update_qnas(
242-
project_name=project_name, body=qnas, **kwargs
243-
)
246+
return await super().begin_update_qnas(project_name=project_name, body=qnas, **kwargs)
244247

245248
# begin_update_sources overloads with 'sources' parameter
246-
@overload # type: ignore
249+
@overload # type: ignore
247250
async def begin_update_sources(
248251
self,
249252
project_name: str,
@@ -266,7 +269,7 @@ async def begin_update_sources(
266269
:raises ~azure.core.exceptions.HttpResponseError:
267270
"""
268271

269-
@overload # type: ignore
272+
@overload # type: ignore
270273
async def begin_update_sources(
271274
self, project_name: str, sources: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
272275
) -> AsyncLROPoller[None]:
@@ -285,7 +288,7 @@ async def begin_update_sources(
285288
"""
286289

287290
@distributed_trace_async
288-
async def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverride]
291+
async def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverride]
289292
self, project_name: str, sources: Union[list[_models.UpdateSourceRecord], IO[bytes]], **kwargs: Any
290293
) -> AsyncLROPoller[None]:
291294
"""Updates the sources of a project.
@@ -301,9 +304,7 @@ async def begin_update_sources( # pyright: ignore[reportIncompatibleMethodOverri
301304
:raises ~azure.core.exceptions.HttpResponseError:
302305
"""
303306
# Call the parent implementation with 'body' parameter for backward compatibility
304-
return await super().begin_update_sources(
305-
project_name=project_name, body=sources, **kwargs
306-
)
307+
return await super().begin_update_sources(project_name=project_name, body=sources, **kwargs)
307308

308309

309310
__all__: list[str] = [
@@ -318,3 +319,28 @@ def patch_sdk():
318319
you can't accomplish using the techniques described in
319320
https://aka.ms/azsdk/python/dpcodegen/python/customize
320321
"""
322+
# Hide the generated async get_*_status methods (status peek endpoints) without editing
323+
# the generated _operations.py file. Same approach as sync variant.
324+
original_methods: dict[str, Any] = {}
325+
to_hide = [
326+
"get_delete_status",
327+
"get_export_status",
328+
"get_import_status",
329+
"get_deploy_status",
330+
]
331+
generated_cls = _QuestionAnsweringAuthoringClientOperationsMixinGenerated
332+
for name in to_hide:
333+
if hasattr(generated_cls, name):
334+
original_methods[name] = getattr(generated_cls, name)
335+
try:
336+
delattr(generated_cls, name)
337+
except AttributeError:
338+
pass
339+
340+
patch_cls = _QuestionAnsweringAuthoringClientOperationsMixin
341+
for public_name, func in original_methods.items():
342+
private_name = f"_{public_name}" # e.g. _get_delete_status
343+
if not hasattr(patch_cls, private_name):
344+
setattr(patch_cls, private_name, func)
345+
346+
# Do not export these private replicas; __all__ only includes the mixin class currently.

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies = [
3434
"isodate>=0.6.1",
3535
"azure-core>=1.35.0",
3636
"typing-extensions>=4.6.0",
37+
"azure-ai-language-questionanswering>=2.0.0"
3738
]
3839
dynamic = [
3940
"version", "readme"

0 commit comments

Comments
 (0)