Skip to content

Commit 1032245

Browse files
CLU - March SDK - Remaining issues (Azure#23851)
* set default value for participiant id and conv id * regenerate * update samples * Update changelog * add direct target samples * update swagger reference and delete outdated parameters * regenerate to fix samples and tests * re-record tests * Update shared_requirements * Update core min dependency Co-authored-by: Anna Tisch <[email protected]>
1 parent b610248 commit 1032245

File tree

40 files changed

+708
-366
lines changed

40 files changed

+708
-366
lines changed

sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 1.0.0b3 (2022-03-01)
3+
## 1.0.0b3 (2022-04-12)
44

55
### Features Added
66
* Entity resolutions
@@ -9,16 +9,6 @@
99
### Breaking Changes
1010
Input and output structures are different from previous release.
1111

12-
## 1.0.0b2 (Unreleased)
13-
14-
### Features Added
15-
16-
### Breaking Changes
17-
18-
### Bugs Fixed
19-
20-
### Other Changes
21-
2212
## 1.0.0b1 (2021-11-03)
2313

2414
### Features Added

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._conversation_analysis_client import ConversationAnalysisClient
9+
from ._client import ConversationAnalysisClient
1010
from ._version import VERSION
1111

1212
__version__ = VERSION
13+
14+
try:
15+
from ._patch import __all__ as _patch_all
16+
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
17+
except ImportError:
18+
_patch_all = []
19+
from ._patch import patch_sdk as _patch_sdk
1320
__all__ = ['ConversationAnalysisClient']
21+
__all__.extend([p for p in _patch_all if p not in __all__])
1422

15-
# `._patch.py` is used for handwritten extensions to the generated code
16-
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
17-
from ._patch import patch_sdk
18-
patch_sdk()
23+
_patch_sdk()

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
from ._operations import ConversationAnalysisClientOperationsMixin
1010

11+
from ._patch import __all__ as _patch_all
12+
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
13+
from ._patch import patch_sdk as _patch_sdk
1114
__all__ = [
1215
'ConversationAnalysisClientOperationsMixin',
1316
]
17+
__all__.extend([p for p in _patch_all if p not in __all__])
18+
_patch_sdk()

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/_operations.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
from azure.core.pipeline.transport import HttpResponse
1616
from azure.core.rest import HttpRequest
1717
from azure.core.tracing.decorator import distributed_trace
18+
from azure.core.utils import case_insensitive_dict
1819

1920
from .. import models as _models
21+
from .._vendor import MixinABC
2022
T = TypeVar('T')
2123
JSONType = Any
2224
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -30,41 +32,42 @@ def build_analyze_conversation_request(
3032
content: Any = None,
3133
**kwargs: Any
3234
) -> HttpRequest:
33-
api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str
34-
content_type = kwargs.pop('content_type', None) # type: Optional[str]
35+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
36+
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
37+
38+
api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01-preview")) # type: str
39+
content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
40+
accept = _headers.pop('Accept', "application/json")
3541

36-
accept = "application/json"
3742
# Construct URL
3843
_url = "/:analyze-conversations"
3944

4045
# Construct parameters
41-
_query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any]
42-
_query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')
46+
_params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')
4347

4448
# Construct headers
45-
_header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
4649
if content_type is not None:
47-
_header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
48-
_header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
50+
_headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
51+
_headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
4952

5053
return HttpRequest(
5154
method="POST",
5255
url=_url,
53-
params=_query_parameters,
54-
headers=_header_parameters,
56+
params=_params,
57+
headers=_headers,
5558
json=json,
5659
content=content,
5760
**kwargs
5861
)
5962

60-
class ConversationAnalysisClientOperationsMixin(object):
63+
class ConversationAnalysisClientOperationsMixin(MixinABC):
6164

6265
@distributed_trace
6366
def analyze_conversation(
6467
self,
65-
task: "_models.AnalyzeConversationTask",
68+
task: _models.AnalyzeConversationTask,
6669
**kwargs: Any
67-
) -> "_models.AnalyzeConversationTaskResult":
70+
) -> _models.AnalyzeConversationTaskResult:
6871
"""Analyzes the input conversation utterance.
6972
7073
:param task: A single conversational task to execute.
@@ -73,28 +76,33 @@ def analyze_conversation(
7376
:rtype: ~azure.ai.language.conversations.models.AnalyzeConversationTaskResult
7477
:raises: ~azure.core.exceptions.HttpResponseError
7578
"""
76-
cls = kwargs.pop('cls', None) # type: ClsType["_models.AnalyzeConversationTaskResult"]
7779
error_map = {
7880
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
7981
}
80-
error_map.update(kwargs.pop('error_map', {}))
82+
error_map.update(kwargs.pop('error_map', {}) or {})
83+
84+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
85+
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
8186

82-
api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str
83-
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
87+
api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01-preview")) # type: str
88+
content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str]
89+
cls = kwargs.pop('cls', None) # type: ClsType[_models.AnalyzeConversationTaskResult]
8490

8591
_json = self._serialize.body(task, 'AnalyzeConversationTask')
8692

8793
request = build_analyze_conversation_request(
8894
api_version=api_version,
8995
content_type=content_type,
9096
json=_json,
97+
headers=_headers,
98+
params=_params,
9199
)
92100
path_format_arguments = {
93101
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
94102
}
95-
request.url = self._client.format_url(request.url, **path_format_arguments)
103+
request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
96104

97-
pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access
105+
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
98106
request,
99107
stream=False,
100108
**kwargs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
"""Customize generated code here.
6+
7+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8+
"""
9+
from typing import List
10+
11+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
12+
13+
def patch_sdk():
14+
"""Do not remove from this file.
15+
16+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
17+
you can't accomplish using the techniques described in
18+
https://aka.ms/azsdk/python/dpcodegen/python/customize
19+
"""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from abc import ABC
9+
from typing import TYPE_CHECKING
10+
11+
from ._configuration import ConversationAnalysisClientConfiguration
12+
13+
if TYPE_CHECKING:
14+
# pylint: disable=unused-import,ungrouped-imports
15+
from msrest import Deserializer, Serializer
16+
17+
from azure.core import PipelineClient
18+
19+
20+
class MixinABC(ABC):
21+
"""DO NOT use this class. It is for internal typing use only."""
22+
_client: "PipelineClient"
23+
_config: ConversationAnalysisClientConfiguration
24+
_serialize: "Serializer"
25+
_deserialize: "Deserializer"

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._conversation_analysis_client import ConversationAnalysisClient
9+
from ._client import ConversationAnalysisClient
10+
11+
try:
12+
from ._patch import __all__ as _patch_all
13+
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
14+
except ImportError:
15+
_patch_all = []
16+
from ._patch import patch_sdk as _patch_sdk
1017
__all__ = ['ConversationAnalysisClient']
18+
__all__.extend([p for p in _patch_all if p not in __all__])
1119

12-
# `._patch.py` is used for handwritten extensions to the generated code
13-
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
14-
from ._patch import patch_sdk
15-
patch_sdk()
20+
_patch_sdk()

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_operations/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
from ._operations import ConversationAnalysisClientOperationsMixin
1010

11+
from ._patch import __all__ as _patch_all
12+
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
13+
from ._patch import patch_sdk as _patch_sdk
1114
__all__ = [
1215
'ConversationAnalysisClientOperationsMixin',
1316
]
17+
__all__.extend([p for p in _patch_all if p not in __all__])
18+
_patch_sdk()

0 commit comments

Comments
 (0)