Skip to content

Commit 7fe58e9

Browse files
authored
remove multiapi generated code (Azure#18052)
* remove multiapi generated code * update
1 parent a527161 commit 7fe58e9

File tree

104 files changed

+946
-29553
lines changed

Some content is hidden

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

104 files changed

+946
-29553
lines changed

sdk/search/azure-search-documents/azure/search/documents/_generated/_configuration.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
8+
119
from typing import TYPE_CHECKING
1210

1311
from azure.core.configuration import Configuration
1412
from azure.core.pipeline import policies
1513

16-
from ._version import VERSION
17-
1814
if TYPE_CHECKING:
1915
# pylint: disable=unused-import,ungrouped-imports
2016
from typing import Any
2117

18+
VERSION = "unknown"
19+
2220
class SearchClientConfiguration(Configuration):
2321
"""Configuration for SearchClient.
2422
@@ -46,7 +44,8 @@ def __init__(
4644

4745
self.endpoint = endpoint
4846
self.index_name = index_name
49-
kwargs.setdefault('sdk_moniker', 'azure-search-documents/{}'.format(VERSION))
47+
self.api_version = "2020-06-30-Preview"
48+
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.format(VERSION))
5049
self._configure(**kwargs)
5150

5251
def _configure(
Lines changed: 40 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,85 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

129
from typing import TYPE_CHECKING
1310

1411
from azure.core import PipelineClient
15-
from azure.profiles import KnownProfiles, ProfileDefinition
16-
from azure.profiles.multiapiclient import MultiApiClientMixin
1712
from msrest import Deserializer, Serializer
1813

19-
from ._configuration import SearchClientConfiguration
20-
2114
if TYPE_CHECKING:
2215
# pylint: disable=unused-import,ungrouped-imports
23-
from typing import Any, Optional
16+
from typing import Any
2417

2518
from azure.core.pipeline.transport import HttpRequest, HttpResponse
2619

27-
class _SDKClient(object):
28-
def __init__(self, *args, **kwargs):
29-
"""This is a fake class to support current implemetation of MultiApiClientMixin."
30-
Will be removed in final version of multiapi azure-core based client
31-
"""
32-
pass
20+
from ._configuration import SearchClientConfiguration
21+
from .operations import DocumentsOperations
22+
from . import models
3323

34-
class SearchClient(MultiApiClientMixin, _SDKClient):
35-
"""Client that can be used to query an index and upload, merge, or delete documents.
3624

37-
This ready contains multiple API versions, to help you deal with all of the Azure clouds
38-
(Azure Stack, Azure Government, Azure China, etc.).
39-
By default, it uses the latest API version available on public Azure.
40-
For production, you should stick to a particular api-version and/or profile.
41-
The profile sets a mapping between an operation group and its API version.
42-
The api-version parameter sets the default API version if the operation
43-
group is not described in the profile.
25+
class SearchClient(object):
26+
"""Client that can be used to query an index and upload, merge, or delete documents.
4427
28+
:ivar documents: DocumentsOperations operations
29+
:vartype documents: azure.search.documents.operations.DocumentsOperations
4530
:param endpoint: The endpoint URL of the search service.
4631
:type endpoint: str
4732
:param index_name: The name of the index.
4833
:type index_name: str
49-
:param api_version: API version to use if no profile is provided, or if missing in profile.
50-
:type api_version: str
51-
:param profile: A profile definition, from KnownProfiles to dict.
52-
:type profile: azure.profiles.KnownProfiles
5334
"""
5435

55-
DEFAULT_API_VERSION = '2020-06-30-Preview'
56-
_PROFILE_TAG = "azure.search.documents.SearchClient"
57-
LATEST_PROFILE = ProfileDefinition({
58-
_PROFILE_TAG: {
59-
None: DEFAULT_API_VERSION,
60-
}},
61-
_PROFILE_TAG + " latest"
62-
)
63-
6436
def __init__(
6537
self,
6638
endpoint, # type: str
6739
index_name, # type: str
68-
api_version=None, # type: Optional[str]
69-
profile=KnownProfiles.default, # type: KnownProfiles
7040
**kwargs # type: Any
7141
):
72-
if api_version == '2020-06-30' or api_version == '2020-06-30-Preview':
73-
base_url = '{endpoint}/indexes(\'{indexName}\')'
74-
else:
75-
raise ValueError("API version {} is not available".format(api_version))
42+
# type: (...) -> None
43+
base_url = '{endpoint}/indexes(\'{indexName}\')'
7644
self._config = SearchClientConfiguration(endpoint, index_name, **kwargs)
7745
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
78-
super(SearchClient, self).__init__(
79-
api_version=api_version,
80-
profile=profile
81-
)
8246

83-
@classmethod
84-
def _models_dict(cls, api_version):
85-
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
47+
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
48+
self._serialize = Serializer(client_models)
49+
self._serialize.client_side_validation = False
50+
self._deserialize = Deserializer(client_models)
8651

87-
@classmethod
88-
def models(cls, api_version=DEFAULT_API_VERSION):
89-
"""Module depends on the API version:
52+
self.documents = DocumentsOperations(
53+
self._client, self._config, self._serialize, self._deserialize)
9054

91-
* 2020-06-30: :mod:`v2020_06.models<azure.search.documents.v2020_06.models>`
92-
* 2020-06-30-Preview: :mod:`v2020_06_preview.models<azure.search.documents.v2020_06_preview.models>`
93-
"""
94-
if api_version == '2020-06-30':
95-
from .v2020_06 import models
96-
return models
97-
elif api_version == '2020-06-30-Preview':
98-
from .v2020_06_preview import models
99-
return models
100-
raise ValueError("API version {} is not available".format(api_version))
101-
102-
@property
103-
def documents(self):
104-
"""Instance depends on the API version:
105-
106-
* 2020-06-30: :class:`DocumentsOperations<azure.search.documents.v2020_06.operations.DocumentsOperations>`
107-
* 2020-06-30-Preview: :class:`DocumentsOperations<azure.search.documents.v2020_06_preview.operations.DocumentsOperations>`
55+
def _send_request(self, http_request, **kwargs):
56+
# type: (HttpRequest, Any) -> HttpResponse
57+
"""Runs the network request through the client's chained policies.
58+
59+
:param http_request: The network request you want to make. Required.
60+
:type http_request: ~azure.core.pipeline.transport.HttpRequest
61+
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
62+
:return: The response of your network call. Does not do error handling on your response.
63+
:rtype: ~azure.core.pipeline.transport.HttpResponse
10864
"""
109-
api_version = self._get_api_version('documents')
110-
if api_version == '2020-06-30':
111-
from .v2020_06.operations import DocumentsOperations as OperationClass
112-
elif api_version == '2020-06-30-Preview':
113-
from .v2020_06_preview.operations import DocumentsOperations as OperationClass
114-
else:
115-
raise ValueError("API version {} does not have operation group 'documents'".format(api_version))
116-
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
65+
path_format_arguments = {
66+
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
67+
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
68+
}
69+
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
70+
stream = kwargs.pop("stream", True)
71+
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
72+
return pipeline_response.http_response
11773

11874
def close(self):
75+
# type: () -> None
11976
self._client.close()
77+
12078
def __enter__(self):
79+
# type: () -> SearchClient
12180
self._client.__enter__()
12281
return self
82+
12383
def __exit__(self, *exc_details):
84+
# type: (Any) -> None
12485
self._client.__exit__(*exc_details)

sdk/search/azure-search-documents/azure/search/documents/_generated/_version.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

sdk/search/azure-search-documents/azure/search/documents/_generated/aio/_configuration.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
8+
119
from typing import Any
1210

1311
from azure.core.configuration import Configuration
1412
from azure.core.pipeline import policies
1513

16-
from .._version import VERSION
14+
VERSION = "unknown"
1715

1816
class SearchClientConfiguration(Configuration):
1917
"""Configuration for SearchClient.
@@ -31,7 +29,7 @@ def __init__(
3129
self,
3230
endpoint: str,
3331
index_name: str,
34-
**kwargs # type: Any
32+
**kwargs: Any
3533
) -> None:
3634
if endpoint is None:
3735
raise ValueError("Parameter 'endpoint' must not be None.")
@@ -41,7 +39,8 @@ def __init__(
4139

4240
self.endpoint = endpoint
4341
self.index_name = index_name
44-
kwargs.setdefault('sdk_moniker', 'azure-search-documents/{}'.format(VERSION))
42+
self.api_version = "2020-06-30-Preview"
43+
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.format(VERSION))
4544
self._configure(**kwargs)
4645

4746
def _configure(

0 commit comments

Comments
 (0)