Skip to content

Commit 549f9da

Browse files
[AutoRelease] t2-search-2023-10-10-69787(can only be merged by SDK owner) (Azure#32398)
* code and test * local-live-test --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <v-chenjiang@microsoft.com>
1 parent 6c8c930 commit 549f9da

File tree

74 files changed

+1487
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1487
-425
lines changed

sdk/search/azure-mgmt-search/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Release History
22

3+
## 9.1.0 (2023-10-23)
4+
5+
### Features Added
6+
7+
- Added operation group SearchManagementClientOperationsMixin
8+
- Added operation group UsagesOperations
9+
- Model SearchService has a new parameter semantic_search
10+
- Model SearchServiceUpdate has a new parameter semantic_search
11+
312
## 9.0.0 (2023-02-15)
413

514
### Features Added

sdk/search/azure-mgmt-search/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,3 @@ Code samples for this package can be found at:
5959
If you encounter any bugs or have suggestions, please file an issue in the
6060
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
6161
section of the project.
62-
63-
64-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-search%2FREADME.png)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "33a7dbc1743fdacb8e2259011a035154a98cad66",
2+
"commit": "e1017d9ab49f41296177b4f4c9ac741fb7de044d",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.9.7",
55
"use": [
6-
"@autorest/python@6.2.16",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.7.1",
7+
"@autorest/modelerfour@4.26.2"
88
],
9-
"autorest_command": "autorest specification/search/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.16 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/search/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
1010
"readme": "specification/search/resource-manager/readme.md"
1111
}

sdk/search/azure-mgmt-search/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/search/azure-mgmt-search",
5-
"Tag": "python/search/azure-mgmt-search_93798f8ec0"
5+
"Tag": "python/search/azure-mgmt-search_b2ac0b29f6"
66
}

sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py

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

9-
import sys
109
from typing import Any, TYPE_CHECKING
1110

1211
from azure.core.configuration import Configuration
@@ -15,11 +14,6 @@
1514

1615
from ._version import VERSION
1716

18-
if sys.version_info >= (3, 8):
19-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
20-
else:
21-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
22-
2317
if TYPE_CHECKING:
2418
# pylint: disable=unused-import,ungrouped-imports
2519
from azure.core.credentials import TokenCredential
@@ -36,14 +30,14 @@ class SearchManagementClientConfiguration(Configuration): # pylint: disable=too
3630
:param subscription_id: The unique identifier for a Microsoft Azure subscription. You can
3731
obtain this value from the Azure Resource Manager API or the portal. Required.
3832
:type subscription_id: str
39-
:keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this
33+
:keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this
4034
default value may result in unsupported behavior.
4135
:paramtype api_version: str
4236
"""
4337

4438
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
4539
super(SearchManagementClientConfiguration, self).__init__(**kwargs)
46-
api_version: Literal["2022-09-01"] = kwargs.pop("api_version", "2022-09-01")
40+
api_version: str = kwargs.pop("api_version", "2023-11-01")
4741

4842
if credential is None:
4943
raise ValueError("Parameter 'credential' must not be None.")

sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
PrivateEndpointConnectionsOperations,
2222
PrivateLinkResourcesOperations,
2323
QueryKeysOperations,
24+
SearchManagementClientOperationsMixin,
2425
ServicesOperations,
2526
SharedPrivateLinkResourcesOperations,
27+
UsagesOperations,
2628
)
2729

2830
if TYPE_CHECKING:
2931
# pylint: disable=unused-import,ungrouped-imports
3032
from azure.core.credentials import TokenCredential
3133

3234

33-
class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
35+
class SearchManagementClient(
36+
SearchManagementClientOperationsMixin
37+
): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3438
"""Client that can be used to manage Azure Cognitive Search services and API keys.
3539
3640
:ivar operations: Operations operations
@@ -49,14 +53,16 @@ class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyw
4953
:ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations
5054
:vartype shared_private_link_resources:
5155
azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations
56+
:ivar usages: UsagesOperations operations
57+
:vartype usages: azure.mgmt.search.operations.UsagesOperations
5258
:param credential: Credential needed for the client to connect to Azure. Required.
5359
:type credential: ~azure.core.credentials.TokenCredential
5460
:param subscription_id: The unique identifier for a Microsoft Azure subscription. You can
5561
obtain this value from the Azure Resource Manager API or the portal. Required.
5662
:type subscription_id: str
5763
:param base_url: Service URL. Default value is "https://management.azure.com".
5864
:type base_url: str
59-
:keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this
65+
:keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this
6066
default value may result in unsupported behavior.
6167
:paramtype api_version: str
6268
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -73,7 +79,7 @@ def __init__(
7379
self._config = SearchManagementClientConfiguration(
7480
credential=credential, subscription_id=subscription_id, **kwargs
7581
)
76-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
82+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
7783

7884
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
7985
self._serialize = Serializer(client_models)
@@ -92,6 +98,7 @@ def __init__(
9298
self.shared_private_link_resources = SharedPrivateLinkResourcesOperations(
9399
self._client, self._config, self._serialize, self._deserialize
94100
)
101+
self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize)
95102

96103
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97104
"""Runs the network request through the client's chained policies.
@@ -122,5 +129,5 @@ def __enter__(self) -> "SearchManagementClient":
122129
self._client.__enter__()
123130
return self
124131

125-
def __exit__(self, *exc_details) -> None:
132+
def __exit__(self, *exc_details: Any) -> None:
126133
self._client.__exit__(*exc_details)

sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
629629
if xml_desc.get("attr", False):
630630
if xml_ns:
631631
ET.register_namespace(xml_prefix, xml_ns)
632-
xml_name = "{}{}".format(xml_ns, xml_name)
632+
xml_name = "{{{}}}{}".format(xml_ns, xml_name)
633633
serialized.set(xml_name, new_attr) # type: ignore
634634
continue
635635
if xml_desc.get("text", False):
@@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
662662
_serialized.update(_new_attr) # type: ignore
663663
_new_attr = _new_attr[k] # type: ignore
664664
_serialized = _serialized[k]
665-
except ValueError:
666-
continue
665+
except ValueError as err:
666+
if isinstance(err, SerializationError):
667+
raise
667668

668669
except (AttributeError, KeyError, TypeError) as err:
669670
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
@@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):
741742
742743
:param data: The data to be serialized.
743744
:param str data_type: The type to be serialized from.
745+
:keyword bool skip_quote: Whether to skip quote the serialized result.
746+
Defaults to False.
744747
:rtype: str
745748
:raises: TypeError if serialization fails.
746749
:raises: ValueError if data is None
@@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
749752
# Treat the list aside, since we don't want to encode the div separator
750753
if data_type.startswith("["):
751754
internal_data_type = data_type[1:-1]
752-
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
753-
if not kwargs.get("skip_quote", False):
754-
data = [quote(str(d), safe="") for d in data]
755-
return str(self.serialize_iter(data, internal_data_type, **kwargs))
755+
do_quote = not kwargs.get("skip_quote", False)
756+
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))
756757

757758
# Not a list, regular serialization
758759
output = self.serialize_data(data, data_type, **kwargs)
@@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
891892
not be None or empty.
892893
:param str div: If set, this str will be used to combine the elements
893894
in the iterable into a combined string. Default is 'None'.
895+
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
896+
Defaults to False.
894897
:rtype: list, str
895898
"""
896899
if isinstance(data, str):
@@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
903906
for d in data:
904907
try:
905908
serialized.append(self.serialize_data(d, iter_type, **kwargs))
906-
except ValueError:
909+
except ValueError as err:
910+
if isinstance(err, SerializationError):
911+
raise
907912
serialized.append(None)
908913

914+
if kwargs.get("do_quote", False):
915+
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]
916+
909917
if div:
910918
serialized = ["" if s is None else str(s) for s in serialized]
911919
serialized = div.join(serialized)
@@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
950958
for key, value in attr.items():
951959
try:
952960
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
953-
except ValueError:
961+
except ValueError as err:
962+
if isinstance(err, SerializationError):
963+
raise
954964
serialized[self.serialize_unicode(key)] = None
955965

956966
if "xml" in serialization_ctxt:
@@ -1271,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type):
12711281
xml_name = internal_type_xml_map.get("name", internal_type.__name__)
12721282
xml_ns = internal_type_xml_map.get("ns", None)
12731283
if xml_ns:
1274-
xml_name = "{}{}".format(xml_ns, xml_name)
1284+
xml_name = "{{{}}}{}".format(xml_ns, xml_name)
12751285
return xml_name
12761286

12771287

@@ -1295,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data):
12951305
# Integrate namespace if necessary
12961306
xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None))
12971307
if xml_ns:
1298-
xml_name = "{}{}".format(xml_ns, xml_name)
1308+
xml_name = "{{{}}}{}".format(xml_ns, xml_name)
12991309

13001310
# If it's an attribute, that's simple
13011311
if xml_desc.get("attr", False):

sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py

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

8-
from typing import List, cast
8+
from abc import ABC
9+
from typing import TYPE_CHECKING
910

1011
from azure.core.pipeline.transport import HttpRequest
1112

13+
from ._configuration import SearchManagementClientConfiguration
14+
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from azure.core import PipelineClient
18+
19+
from ._serialization import Deserializer, Serializer
20+
1221

1322
def _convert_request(request, files=None):
1423
data = request.content if not files else None
@@ -18,13 +27,10 @@ def _convert_request(request, files=None):
1827
return request
1928

2029

21-
def _format_url_section(template, **kwargs):
22-
components = template.split("/")
23-
while components:
24-
try:
25-
return template.format(**kwargs)
26-
except KeyError as key:
27-
# Need the cast, as for some reasons "split" is typed as list[str | Any]
28-
formatted_components = cast(List[str], template.split("/"))
29-
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
30-
template = "/".join(components)
30+
class SearchManagementClientMixinABC(ABC):
31+
"""DO NOT use this class. It is for internal typing use only."""
32+
33+
_client: "PipelineClient"
34+
_config: SearchManagementClientConfiguration
35+
_serialize: "Serializer"
36+
_deserialize: "Deserializer"

sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "9.0.0"
9+
VERSION = "9.1.0"

sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py

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

9-
import sys
109
from typing import Any, TYPE_CHECKING
1110

1211
from azure.core.configuration import Configuration
@@ -15,11 +14,6 @@
1514

1615
from .._version import VERSION
1716

18-
if sys.version_info >= (3, 8):
19-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
20-
else:
21-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
22-
2317
if TYPE_CHECKING:
2418
# pylint: disable=unused-import,ungrouped-imports
2519
from azure.core.credentials_async import AsyncTokenCredential
@@ -36,14 +30,14 @@ class SearchManagementClientConfiguration(Configuration): # pylint: disable=too
3630
:param subscription_id: The unique identifier for a Microsoft Azure subscription. You can
3731
obtain this value from the Azure Resource Manager API or the portal. Required.
3832
:type subscription_id: str
39-
:keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this
33+
:keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this
4034
default value may result in unsupported behavior.
4135
:paramtype api_version: str
4236
"""
4337

4438
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
4539
super(SearchManagementClientConfiguration, self).__init__(**kwargs)
46-
api_version: Literal["2022-09-01"] = kwargs.pop("api_version", "2022-09-01")
40+
api_version: str = kwargs.pop("api_version", "2023-11-01")
4741

4842
if credential is None:
4943
raise ValueError("Parameter 'credential' must not be None.")

0 commit comments

Comments
 (0)