Skip to content

Commit

Permalink
Revert "Remove beta features from main (Azure#25795)"
Browse files Browse the repository at this point in the history
This reverts commit df82ec8.
  • Loading branch information
rakshith91 committed Sep 8, 2022
1 parent 81ab001 commit 180f86f
Show file tree
Hide file tree
Showing 92 changed files with 20,995 additions and 6,341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
#: this is the default version
V2020_06_30 = "2020-06-30"
V2021_04_30_PREVIEW = "2021-04-30-Preview"


DEFAULT_VERSION = ApiVersion.V2020_06_30
DEFAULT_VERSION = ApiVersion.V2021_04_30_PREVIEW
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from ._search_client import SearchClient
__all__ = ['SearchClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

VERSION = "unknown"

class SearchClientConfiguration(Configuration):
class SearchClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for SearchClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -27,6 +27,9 @@ class SearchClientConfiguration(Configuration):
:type endpoint: str
:param index_name: The name of the index.
:type index_name: str
:keyword api_version: Api Version. The default value is "2021-04-30-Preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -36,15 +39,17 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
super(SearchClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2021-04-30-Preview") # type: str

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if index_name is None:
raise ValueError("Parameter 'index_name' must not be None.")
super(SearchClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.index_name = index_name
self.api_version = "2020-06-30"
self.api_version = api_version
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.format(VERSION))
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.core import PipelineClient

from . import models
from ._configuration import SearchClientConfiguration
from .operations import DocumentsOperations
from . import models

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.rest import HttpRequest, HttpResponse

class SearchClient(object):
"""Client that can be used to query an index and upload, merge, or delete documents.
Expand All @@ -31,6 +32,9 @@ class SearchClient(object):
:type endpoint: str
:param index_name: The name of the index.
:type index_name: str
:keyword api_version: Api Version. The default value is "2021-04-30-Preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -40,36 +44,48 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{endpoint}/indexes(\'{indexName}\')'
self._config = SearchClientConfiguration(endpoint, index_name, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
_base_url = '{endpoint}/indexes(\'{indexName}\')'
self._config = SearchClientConfiguration(endpoint=endpoint, index_name=index_name, **kwargs)
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)

self.documents = DocumentsOperations(
self._client, self._config, self._serialize, self._deserialize)

def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
def _send_request(
self,
request, # type: HttpRequest
**kwargs # type: Any
):
# type: (...) -> HttpResponse
"""Runs the network request through the client's chained policies.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
:rtype: ~azure.core.rest.HttpResponse
"""

request_copy = deepcopy(request)
path_format_arguments = {
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"indexName": self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, **kwargs)

def close(self):
# type: () -> None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from azure.core.pipeline.transport import HttpRequest

def _convert_request(request, files=None):
data = request.content if not files else None
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
if files:
request.set_formdata_body(files)
return request

def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
formatted_components = template.split("/")
components = [
c for c in formatted_components if "{}".format(key.args[0]) not in c
]
template = "/".join(components)
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@

from ._search_client import SearchClient
__all__ = ['SearchClient']

# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

VERSION = "unknown"

class SearchClientConfiguration(Configuration):
class SearchClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for SearchClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -23,6 +23,9 @@ class SearchClientConfiguration(Configuration):
:type endpoint: str
:param index_name: The name of the index.
:type index_name: str
:keyword api_version: Api Version. The default value is "2021-04-30-Preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -31,15 +34,17 @@ def __init__(
index_name: str,
**kwargs: Any
) -> None:
super(SearchClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2021-04-30-Preview") # type: str

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if index_name is None:
raise ValueError("Parameter 'index_name' must not be None.")
super(SearchClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.index_name = index_name
self.api_version = "2020-06-30"
self.api_version = api_version
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.format(VERSION))
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
Loading

0 comments on commit 180f86f

Please sign in to comment.