From c820559a1d149a9688b3dd9fc5286f209429959d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Mar 2022 08:33:16 +0000 Subject: [PATCH] CodeGen from PR 18229 in Azure/azure-rest-api-specs Merge cba6c8790f19cebf81fa7104a249ee795c945216 into 5f211aa39ff4fa8891fbdf7da840d13ef8ac5fcd --- sdk/search/azure-mgmt-search/_meta.json | 11 + .../azure/mgmt/search/__init__.py | 9 +- .../azure/mgmt/search/_configuration.py | 19 +- .../azure/mgmt/search/_metadata.json | 108 ++ .../azure/mgmt/search/_patch.py | 31 + .../mgmt/search/_search_management_client.py | 102 +- .../azure/mgmt/search/_vendor.py | 27 + .../azure/mgmt/search/_version.py | 2 +- .../azure/mgmt/search/aio/__init__.py | 5 + .../azure/mgmt/search/aio/_configuration.py | 6 +- .../azure/mgmt/search/aio/_patch.py | 31 + .../search/aio/_search_management_client.py | 94 +- .../aio/operations/_admin_keys_operations.py | 90 +- .../mgmt/search/aio/operations/_operations.py | 44 +- ...private_endpoint_connections_operations.py | 221 ++- .../_private_link_resources_operations.py | 81 +- .../aio/operations/_query_keys_operations.py | 158 +- .../aio/operations/_services_operations.py | 413 +++--- ...hared_private_link_resources_operations.py | 277 ++-- .../azure/mgmt/search/models/__init__.py | 102 +- .../azure/mgmt/search/models/_models.py | 1276 ----------------- .../azure/mgmt/search/models/_models_py3.py | 427 ++++-- .../models/_search_management_client_enums.py | 43 +- .../operations/_admin_keys_operations.py | 202 ++- .../mgmt/search/operations/_operations.py | 83 +- ...private_endpoint_connections_operations.py | 447 ++++-- .../_private_link_resources_operations.py | 137 +- .../operations/_query_keys_operations.py | 321 +++-- .../search/operations/_services_operations.py | 776 ++++++---- ...hared_private_link_resources_operations.py | 527 ++++--- 30 files changed, 2950 insertions(+), 3120 deletions(-) create mode 100644 sdk/search/azure-mgmt-search/_meta.json create mode 100644 sdk/search/azure-mgmt-search/azure/mgmt/search/_metadata.json create mode 100644 sdk/search/azure-mgmt-search/azure/mgmt/search/_patch.py create mode 100644 sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py create mode 100644 sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_patch.py delete mode 100644 sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models.py diff --git a/sdk/search/azure-mgmt-search/_meta.json b/sdk/search/azure-mgmt-search/_meta.json new file mode 100644 index 000000000000..77e8749a230f --- /dev/null +++ b/sdk/search/azure-mgmt-search/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "7abc4511b9cac664f6d977b6c5de789dabe45c1a", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/search/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/search/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py index bcfbc4ac70f1..7bdaa203a441 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SearchManagementClient'] -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() diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py index 7739f74e4c79..62c5a4c460aa 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class SearchManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(SearchManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(SearchManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_metadata.json b/sdk/search/azure-mgmt-search/azure/mgmt/search/_metadata.json new file mode 100644 index 000000000000..48437edab10b --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_metadata.json @@ -0,0 +1,108 @@ +{ + "chosen_version": "2020-08-01", + "total_api_version_list": ["2020-08-01"], + "client": { + "name": "SearchManagementClient", + "filename": "_search_management_client", + "description": "Client that can be used to manage Azure Cognitive Search services and API keys.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SearchManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SearchManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "admin_keys": "AdminKeysOperations", + "query_keys": "QueryKeysOperations", + "services": "ServicesOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "shared_private_link_resources": "SharedPrivateLinkResourcesOperations" + } +} \ No newline at end of file diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_patch.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_patch.py @@ -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 \ No newline at end of file diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py index 99b4e7bf9ed9..aa63c774316f 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py @@ -6,29 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SearchManagementClientConfiguration +from .operations import AdminKeysOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, ServicesOperations, SharedPrivateLinkResourcesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import SearchManagementClientConfiguration -from .operations import Operations -from .operations import AdminKeysOperations -from .operations import QueryKeysOperations -from .operations import ServicesOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import SharedPrivateLinkResourcesOperations -from . import models - - -class SearchManagementClient(object): +class SearchManagementClient: """Client that can be used to manage Azure Cognitive Search services and API keys. :ivar operations: Operations operations @@ -42,49 +35,70 @@ class SearchManagementClient(object): :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.search.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.search.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.search.operations.PrivateEndpointConnectionsOperations :ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations - :vartype shared_private_link_resources: azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations + :vartype shared_private_link_resources: + azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can + obtain this value from the Azure Resource Manager API or the portal. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SearchManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SearchManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.admin_keys = AdminKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_keys = QueryKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.shared_private_link_resources = SharedPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + 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.rest.HttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.admin_keys = AdminKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.query_keys = QueryKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shared_private_link_resources = SharedPrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py @@ -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) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py index 399efc6e18c8..a206b968f460 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py @@ -8,3 +8,8 @@ from ._search_management_client import SearchManagementClient __all__ = ['SearchManagementClient'] + +# `._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() diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py index 7ee7568b61a0..52f62c422e88 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(SearchManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(SearchManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_patch.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_patch.py @@ -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 \ No newline at end of file diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py index 661e7fc7197a..9d29f6dd6cbb 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py @@ -6,27 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SearchManagementClientConfiguration +from .operations import AdminKeysOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, ServicesOperations, SharedPrivateLinkResourcesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SearchManagementClientConfiguration -from .operations import Operations -from .operations import AdminKeysOperations -from .operations import QueryKeysOperations -from .operations import ServicesOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import SharedPrivateLinkResourcesOperations -from .. import models - - -class SearchManagementClient(object): +class SearchManagementClient: """Client that can be used to manage Azure Cognitive Search services and API keys. :ivar operations: Operations operations @@ -38,50 +33,73 @@ class SearchManagementClient(object): :ivar services: ServicesOperations operations :vartype services: azure.mgmt.search.aio.operations.ServicesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.search.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.search.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.search.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.search.aio.operations.PrivateEndpointConnectionsOperations :ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations - :vartype shared_private_link_resources: azure.mgmt.search.aio.operations.SharedPrivateLinkResourcesOperations + :vartype shared_private_link_resources: + azure.mgmt.search.aio.operations.SharedPrivateLinkResourcesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal. + :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can + obtain this value from the Azure Resource Manager API or the portal. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = SearchManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = SearchManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.admin_keys = AdminKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_keys = QueryKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.shared_private_link_resources = SharedPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + 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.rest.AsyncHttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.admin_keys = AdminKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.query_keys = QueryKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shared_private_link_resources = SharedPrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py index 08868ef943b8..257d2fd73b78 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._admin_keys_operations import build_get_request, build_regenerate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,12 +44,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.AdminKeyResult": """Gets the primary and secondary admin API keys for the specified Azure Cognitive Search service. @@ -56,7 +61,8 @@ async def get( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: AdminKeyResult, or the result of cls(response) :rtype: ~azure.mgmt.search.models.AdminKeyResult @@ -67,33 +73,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -107,15 +101,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listAdminKeys'} # type: ignore + + @distributed_trace_async async def regenerate( self, resource_group_name: str, search_service_name: str, key_kind: Union[str, "_models.AdminKeyKind"], search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.AdminKeyResult": """Regenerates either the primary or secondary admin API key. You can only regenerate one key at a time. @@ -130,7 +127,8 @@ async def regenerate( 'secondary'. :type key_kind: str or ~azure.mgmt.search.models.AdminKeyKind :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: AdminKeyResult, or the result of cls(response) :rtype: ~azure.mgmt.search.models.AdminKeyResult @@ -141,34 +139,22 @@ async def regenerate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.regenerate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'keyKind': self._serialize.url("key_kind", key_kind, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_regenerate_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + key_kind=key_kind, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.regenerate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,4 +168,6 @@ async def regenerate( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/regenerateAdminKey/{keyKind}'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py index 11a63e080f33..2b4ef57fb2b6 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,9 +46,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available REST API operations of the Microsoft.Search provider. @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +101,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py index 0a8dc622049a..eb8569aa2cb8 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_by_service_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -48,7 +54,7 @@ async def update( private_endpoint_connection_name: str, private_endpoint_connection: "_models.PrivateEndpointConnection", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.PrivateEndpointConnection": """Updates a Private Endpoint connection to the search service in the given resource group. @@ -65,7 +71,8 @@ async def update( update. :type private_endpoint_connection: ~azure.mgmt.search.models.PrivateEndpointConnection :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection @@ -76,39 +83,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -122,15 +117,18 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, search_service_name: str, private_endpoint_connection_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.PrivateEndpointConnection": """Gets the details of the private endpoint connection to the search service in the given resource group. @@ -145,7 +143,8 @@ async def get( Azure Cognitive Search service with the specified resource group. :type private_endpoint_connection_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection @@ -156,34 +155,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,15 +184,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, search_service_name: str, private_endpoint_connection_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> Optional["_models.PrivateEndpointConnection"]: """Disconnects the private endpoint connection and deletes it from the search service. @@ -219,7 +209,8 @@ async def delete( Azure Cognitive Search service with the specified resource group. :type private_endpoint_connection_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection or None @@ -230,34 +221,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,14 +252,17 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def list_by_service( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: """Gets a list of all private endpoint connections in the given service. @@ -291,10 +273,13 @@ def list_by_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -302,42 +287,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -355,6 +339,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py index 973c136aa168..f74e0bb8eb8b 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_list_supported_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_supported( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PrivateLinkResourcesResult"]: """Gets a list of all supported private link resource types for the given service. @@ -57,10 +63,13 @@ def list_supported( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourcesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.PrivateLinkResourcesResult] + :return: An iterator like instance of either PrivateLinkResourcesResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.PrivateLinkResourcesResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesResult"] @@ -68,42 +77,41 @@ def list_supported( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_supported.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_supported_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_supported.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_supported_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourcesResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,6 +129,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py index 4256fd7a2882..ed1ddcd83b2d 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._query_keys_operations import build_create_request, build_delete_request, build_list_by_search_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, search_service_name: str, name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.QueryKey": """Generates a new query key for the specified search service. You can create up to 50 query keys per service. @@ -61,7 +67,8 @@ async def create( :param name: The name of the new query API key. :type name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: QueryKey, or the result of cls(response) :rtype: ~azure.mgmt.search.models.QueryKey @@ -72,34 +79,22 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + name=name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,14 +108,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/createQueryKey/{name}'} # type: ignore + + @distributed_trace def list_by_search_service( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ListQueryKeysResult"]: """Returns the list of query API keys for the given Azure Cognitive Search service. @@ -131,7 +129,8 @@ def list_by_search_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueryKeysResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.ListQueryKeysResult] @@ -142,42 +141,41 @@ def list_by_search_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_search_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_search_service_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_search_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_search_service_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListQueryKeysResult', pipeline_response) + deserialized = self._deserialize("ListQueryKeysResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -195,18 +193,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_search_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, search_service_name: str, key: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> None: """Deletes the specified query key. Unlike admin keys, query keys are not regenerated. The process for regenerating a query key is to delete and then recreate it. @@ -220,7 +220,8 @@ async def delete( :param key: The query key to be deleted. Query keys are identified by value, not by name. :type key: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -231,34 +232,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'key': self._serialize.url("key", key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + key=key, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -270,3 +259,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/deleteQueryKey/{key}'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py index 01772b4cb987..05ace1546c17 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._services_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,45 +54,33 @@ async def _create_or_update_initial( search_service_name: str, service: "_models.SearchService", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SearchService": cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service, 'SearchService') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(service, 'SearchService') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,15 +98,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, search_service_name: str, service: "_models.SearchService", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.SearchService"]: """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. @@ -131,18 +127,23 @@ async def begin_create_or_update( :param service: The definition of the search service to create or update. :type service: ~azure.mgmt.search.models.SearchService :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SearchService or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SearchService or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.search.models.SearchService] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchService"] lro_delay = kwargs.pop( 'polling_interval', @@ -155,27 +156,21 @@ async def begin_create_or_update( search_service_name=search_service_name, service=service, search_management_request_options=search_management_request_options, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SearchService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -187,15 +182,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, search_service_name: str, service: "_models.SearchServiceUpdate", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SearchService": """Updates an existing search service in the given resource group. @@ -207,7 +204,8 @@ async def update( :param service: The definition of the search service to update. :type service: ~azure.mgmt.search.models.SearchServiceUpdate :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchService, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SearchService @@ -218,38 +216,26 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service, 'SearchServiceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(service, 'SearchServiceUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -263,14 +249,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SearchService": """Gets the search service with the given name in the given resource group. @@ -281,7 +270,8 @@ async def get( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchService, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SearchService @@ -292,33 +282,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -332,14 +310,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> None: """Deletes a search service in the given resource group, along with its associated resources. @@ -350,7 +331,8 @@ async def delete( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -361,33 +343,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,11 +370,13 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SearchServiceListResult"]: """Gets a list of all search services in the given resource group. @@ -412,10 +384,13 @@ def list_by_resource_group( can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SearchServiceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SearchServiceListResult] + :return: An iterator like instance of either SearchServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SearchServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchServiceListResult"] @@ -423,41 +398,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SearchServiceListResult', pipeline_response) + deserialized = self._deserialize("SearchServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -475,23 +448,28 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices'} # type: ignore + @distributed_trace def list_by_subscription( self, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SearchServiceListResult"]: """Gets a list of all search services in the given subscription. :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SearchServiceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SearchServiceListResult] + :return: An iterator like instance of either SearchServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SearchServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchServiceListResult"] @@ -499,40 +477,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SearchServiceListResult', pipeline_response) + deserialized = self._deserialize("SearchServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -550,16 +525,18 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Search/searchServices'} # type: ignore + @distributed_trace_async async def check_name_availability( self, name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.CheckNameAvailabilityOutput": """Checks whether or not the given search service name is available for use. Search service names must be globally unique since they are part of the service URI @@ -570,7 +547,8 @@ async def check_name_availability( cannot contain consecutive dashes, and must be between 2 and 60 characters in length. :type name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityOutput, or the result of cls(response) :rtype: ~azure.mgmt.search.models.CheckNameAvailabilityOutput @@ -581,38 +559,25 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id + _check_name_availability_input = _models.CheckNameAvailabilityInput(name=name, type=type) + _json = self._serialize.body(_check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _check_name_availability_input = _models.CheckNameAvailabilityInput(name=name) - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -626,4 +591,6 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Search/checkNameAvailability'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py index 464150b31714..7318783dc01b 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._shared_private_link_resources_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,46 +55,34 @@ async def _create_or_update_initial( shared_private_link_resource_name: str, shared_private_link_resource: "_models.SharedPrivateLinkResource", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> Optional["_models.SharedPrivateLinkResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SharedPrivateLinkResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(shared_private_link_resource, 'SharedPrivateLinkResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(shared_private_link_resource, 'SharedPrivateLinkResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +98,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -114,7 +110,7 @@ async def begin_create_or_update( shared_private_link_resource_name: str, shared_private_link_resource: "_models.SharedPrivateLinkResource", search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.SharedPrivateLinkResource"]: """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. @@ -132,18 +128,23 @@ async def begin_create_or_update( create or update. :type shared_private_link_resource: ~azure.mgmt.search.models.SharedPrivateLinkResource :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.search.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -157,28 +158,21 @@ async def begin_create_or_update( shared_private_link_resource_name=shared_private_link_resource_name, shared_private_link_resource=shared_private_link_resource, search_management_request_options=search_management_request_options, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -190,15 +184,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, search_service_name: str, shared_private_link_resource_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SharedPrivateLinkResource": """Gets the details of the shared private link resource managed by the search service in the given resource group. @@ -213,7 +209,8 @@ async def get( by the Azure Cognitive Search service within the specified resource group. :type shared_private_link_resource_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedPrivateLinkResource, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SharedPrivateLinkResource @@ -224,34 +221,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -265,49 +250,39 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, search_service_name: str, shared_private_link_resource_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -320,13 +295,15 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, search_service_name: str, shared_private_link_resource_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Initiates the deletion of the shared private link resource from the search service. @@ -340,18 +317,21 @@ async def begin_delete( by the Azure Cognitive Search service within the specified resource group. :type shared_private_link_resource_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -367,22 +347,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -394,14 +366,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + @distributed_trace def list_by_service( self, resource_group_name: str, search_service_name: str, search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SharedPrivateLinkResourceListResult"]: """Gets a list of all shared private link resources managed by the given service. @@ -412,10 +386,13 @@ def list_by_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedPrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SharedPrivateLinkResourceListResult] + :return: An iterator like instance of either SharedPrivateLinkResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.SharedPrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResourceListResult"] @@ -423,42 +400,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedPrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -476,6 +452,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py index 6c96a589b8c8..4bb01e78affe 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py @@ -6,74 +6,40 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AdminKeyResult - from ._models_py3 import AsyncOperationResult - from ._models_py3 import CheckNameAvailabilityInput - from ._models_py3 import CheckNameAvailabilityOutput - from ._models_py3 import CloudErrorBody - from ._models_py3 import Identity - from ._models_py3 import IpRule - from ._models_py3 import ListQueryKeysResult - from ._models_py3 import NetworkRuleSet - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateEndpoint - from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceProperties - from ._models_py3 import PrivateLinkResourcesResult - from ._models_py3 import QueryKey - from ._models_py3 import Resource - from ._models_py3 import SearchManagementRequestOptions - from ._models_py3 import SearchService - from ._models_py3 import SearchServiceListResult - from ._models_py3 import SearchServiceUpdate - from ._models_py3 import ShareablePrivateLinkResourceProperties - from ._models_py3 import ShareablePrivateLinkResourceType - from ._models_py3 import SharedPrivateLinkResource - from ._models_py3 import SharedPrivateLinkResourceListResult - from ._models_py3 import SharedPrivateLinkResourceProperties - from ._models_py3 import Sku - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import AdminKeyResult # type: ignore - from ._models import AsyncOperationResult # type: ignore - from ._models import CheckNameAvailabilityInput # type: ignore - from ._models import CheckNameAvailabilityOutput # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import Identity # type: ignore - from ._models import IpRule # type: ignore - from ._models import ListQueryKeysResult # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateEndpointConnectionPropertiesPrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceProperties # type: ignore - from ._models import PrivateLinkResourcesResult # type: ignore - from ._models import QueryKey # type: ignore - from ._models import Resource # type: ignore - from ._models import SearchManagementRequestOptions # type: ignore - from ._models import SearchService # type: ignore - from ._models import SearchServiceListResult # type: ignore - from ._models import SearchServiceUpdate # type: ignore - from ._models import ShareablePrivateLinkResourceProperties # type: ignore - from ._models import ShareablePrivateLinkResourceType # type: ignore - from ._models import SharedPrivateLinkResource # type: ignore - from ._models import SharedPrivateLinkResourceListResult # type: ignore - from ._models import SharedPrivateLinkResourceProperties # type: ignore - from ._models import Sku # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import AdminKeyResult +from ._models_py3 import AsyncOperationResult +from ._models_py3 import CheckNameAvailabilityInput +from ._models_py3 import CheckNameAvailabilityOutput +from ._models_py3 import CloudErrorBody +from ._models_py3 import Identity +from ._models_py3 import IpRule +from ._models_py3 import ListQueryKeysResult +from ._models_py3 import NetworkRuleSet +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateEndpoint +from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceProperties +from ._models_py3 import PrivateLinkResourcesResult +from ._models_py3 import QueryKey +from ._models_py3 import Resource +from ._models_py3 import SearchManagementRequestOptions +from ._models_py3 import SearchService +from ._models_py3 import SearchServiceListResult +from ._models_py3 import SearchServiceUpdate +from ._models_py3 import ShareablePrivateLinkResourceProperties +from ._models_py3 import ShareablePrivateLinkResourceType +from ._models_py3 import SharedPrivateLinkResource +from ._models_py3 import SharedPrivateLinkResourceListResult +from ._models_py3 import SharedPrivateLinkResourceProperties +from ._models_py3 import Sku +from ._models_py3 import TrackedResource + from ._search_management_client_enums import ( AdminKeyKind, diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models.py deleted file mode 100644 index 53a01ae8574b..000000000000 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models.py +++ /dev/null @@ -1,1276 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class AdminKeyResult(msrest.serialization.Model): - """Response containing the primary and secondary admin API keys for a given Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_key: The primary admin API key of the search service. - :vartype primary_key: str - :ivar secondary_key: The secondary admin API key of the search service. - :vartype secondary_key: str - """ - - _validation = { - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - } - - _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdminKeyResult, self).__init__(**kwargs) - self.primary_key = None - self.secondary_key = None - - -class AsyncOperationResult(msrest.serialization.Model): - """The details of a long running asynchronous shared private link resource operation. - - :param status: The current status of the long running asynchronous shared private link resource - operation. Possible values include: "Running", "Succeeded", "Failed". - :type status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceAsyncOperationResult - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsyncOperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - - -class CheckNameAvailabilityInput(msrest.serialization.Model): - """Input of check name availability API. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The search service name to validate. Search service names must only - contain lowercase letters, digits or dashes, cannot use dash as the first two or last one - characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in - length. - :type name: str - :ivar type: Required. The type of the resource whose name is to be validated. This value must - always be 'searchServices'. Default value: "searchServices". - :vartype type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - type = "searchServices" - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityInput, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityOutput(msrest.serialization.Model): - """Output of check name availability API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_name_available: A value indicating whether the name is available. - :vartype is_name_available: bool - :ivar reason: The reason why the name is not available. 'Invalid' indicates the name provided - does not match the naming requirements (incorrect length, unsupported characters, etc.). - 'AlreadyExists' indicates that the name is already in use and is therefore unavailable. - Possible values include: "Invalid", "AlreadyExists". - :vartype reason: str or ~azure.mgmt.search.models.UnavailableNameReason - :ivar message: A message that explains why the name is invalid and provides resource naming - requirements. Available only if 'Invalid' is returned in the 'reason' property. - :vartype message: str - """ - - _validation = { - 'is_name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'is_name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityOutput, self).__init__(**kwargs) - self.is_name_available = None - self.reason = None - self.message = None - - -class CloudErrorBody(msrest.serialization.Model): - """Describes a particular API error with an error code and a message. - - :param code: An error code that describes the error condition more precisely than an HTTP - status code. Can be used to programmatically handle specific error cases. - :type code: str - :param message: A message that describes the error in detail and provides debugging - information. - :type message: str - :param target: The target of the particular error (for example, the name of the property in - error). - :type target: str - :param details: Contains nested errors that are related to this error. - :type details: list[~azure.mgmt.search.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class Identity(msrest.serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :param type: Required. The identity type. Possible values include: "None", "SystemAssigned". - :type type: str or ~azure.mgmt.search.models.IdentityType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs['type'] - - -class IpRule(msrest.serialization.Model): - """The IP restriction rule of the Azure Cognitive Search service. - - :param value: Value corresponding to a single IPv4 address (eg., 123.1.2.3) or an IP range in - CIDR format (eg., 123.1.2.3/24) to be allowed. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IpRule, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ListQueryKeysResult(msrest.serialization.Model): - """Response containing the query API keys for a given Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The query keys for the Azure Cognitive Search service. - :vartype value: list[~azure.mgmt.search.models.QueryKey] - :ivar next_link: Request URL that can be used to query next page of query keys. Returned when - the total number of requested query keys exceed maximum page size. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[QueryKey]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ListQueryKeysResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class NetworkRuleSet(msrest.serialization.Model): - """Network specific rules that determine how the Azure Cognitive Search service may be reached. - - :param ip_rules: A list of IP restriction rules that defines the inbound network(s) with - allowing access to the search service endpoint. At the meantime, all other public IP networks - are blocked by the firewall. These restriction rules are applied only when the - 'publicNetworkAccess' of the search service is 'enabled'; otherwise, traffic over public - interface is not allowed even with any public IP rules, and private endpoint connections would - be the exclusive access method. - :type ip_rules: list[~azure.mgmt.search.models.IpRule] - """ - - _attribute_map = { - 'ip_rules': {'key': 'ipRules', 'type': '[IpRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.ip_rules = kwargs.get('ip_rules', None) - - -class Operation(msrest.serialization.Model): - """Describes a REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation. This name is of the form - {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that describes the operation. - :vartype display: ~azure.mgmt.search.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - - -class OperationDisplay(msrest.serialization.Model): - """The object that describes the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The friendly name of the resource provider. - :vartype provider: str - :ivar operation: The operation type: read, write, delete, listKeys/action, etc. - :vartype operation: str - :ivar resource: The resource type on which the operation is performed. - :vartype resource: str - :ivar description: The friendly name of the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'operation': {'readonly': True}, - 'resource': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.operation = None - self.resource = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of the request to list REST API operations. It contains a list of operations and a URL to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.search.models.Operation] - :ivar next_link: The URL to get the next set of operation list results, if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class PrivateEndpointConnection(Resource): - """Describes an existing Private Endpoint connection to the Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param properties: Describes the properties of an existing Private Endpoint connection to the - Azure Cognitive Search service. - :type properties: ~azure.mgmt.search.models.PrivateEndpointConnectionProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """Response containing a list of Private Endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Private Endpoint connections. - :vartype value: list[~azure.mgmt.search.models.PrivateEndpointConnection] - :ivar next_link: Request URL that can be used to query next page of private endpoint - connections. Returned when the total number of requested private endpoint connections exceed - maximum page size. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. - - :param private_endpoint: The private endpoint resource from Microsoft.Network provider. - :type private_endpoint: - ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateEndpoint - :param private_link_service_connection_state: Describes the current state of an existing - Private Link Service connection to the Azure Private Endpoint. - :type private_link_service_connection_state: - ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState - """ - - _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpointConnectionPropertiesPrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - - -class PrivateEndpointConnectionPropertiesPrivateEndpoint(msrest.serialization.Model): - """The private endpoint resource from Microsoft.Network provider. - - :param id: The resource id of the private endpoint resource from Microsoft.Network provider. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionPropertiesPrivateEndpoint, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState(msrest.serialization.Model): - """Describes the current state of an existing Private Link Service connection to the Azure Private Endpoint. - - :param status: Status of the the private link service connection. Can be Pending, Approved, - Rejected, or Disconnected. Possible values include: "Pending", "Approved", "Rejected", - "Disconnected". - :type status: str or ~azure.mgmt.search.models.PrivateLinkServiceConnectionStatus - :param description: The description for the private link service connection state. - :type description: str - :param actions_required: A description of any extra actions that may be required. - :type actions_required: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - self.actions_required = kwargs.get('actions_required', "None") - - -class PrivateLinkResource(Resource): - """Describes a supported private link resource for the Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar properties: Describes the properties of a supported private link resource for the Azure - Cognitive Search service. - :vartype properties: ~azure.mgmt.search.models.PrivateLinkResourceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.properties = None - - -class PrivateLinkResourceProperties(msrest.serialization.Model): - """Describes the properties of a supported private link resource for the Azure Cognitive Search service. For a given API version, this represents the 'supported' groupIds when creating a shared private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The group ID of the private link resource. - :vartype group_id: str - :ivar required_members: The list of required members of the private link resource. - :vartype required_members: list[str] - :ivar required_zone_names: The list of required DNS zone names of the private link resource. - :vartype required_zone_names: list[str] - :ivar shareable_private_link_resource_types: The list of resources that are onboarded to - private link service, that are supported by Azure Cognitive Search. - :vartype shareable_private_link_resource_types: - list[~azure.mgmt.search.models.ShareablePrivateLinkResourceType] - """ - - _validation = { - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'required_zone_names': {'readonly': True}, - 'shareable_private_link_resource_types': {'readonly': True}, - } - - _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, - 'shareable_private_link_resource_types': {'key': 'shareablePrivateLinkResourceTypes', 'type': '[ShareablePrivateLinkResourceType]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceProperties, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = None - self.shareable_private_link_resource_types = None - - -class PrivateLinkResourcesResult(msrest.serialization.Model): - """Response containing a list of supported Private Link Resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of supported Private Link Resources. - :vartype value: list[~azure.mgmt.search.models.PrivateLinkResource] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourcesResult, self).__init__(**kwargs) - self.value = None - - -class QueryKey(msrest.serialization.Model): - """Describes an API key for a given Azure Cognitive Search service that has permissions for query operations only. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the query API key; may be empty. - :vartype name: str - :ivar key: The value of the query API key. - :vartype key: str - """ - - _validation = { - 'name': {'readonly': True}, - 'key': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryKey, self).__init__(**kwargs) - self.name = None - self.key = None - - -class SearchManagementRequestOptions(msrest.serialization.Model): - """Parameter group. - - :param client_request_id: A client-generated GUID value that identifies this request. If - specified, this will be included in response information as a way to track the request. - :type client_request_id: str - """ - - _attribute_map = { - 'client_request_id': {'key': 'clientRequestId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SearchManagementRequestOptions, self).__init__(**kwargs) - self.client_request_id = kwargs.get('client_request_id', None) - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class SearchService(TrackedResource): - """Describes an Azure Cognitive Search service and its current state. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param sku: The SKU of the Search Service, which determines price tier and capacity limits. - This property is required when creating a new Search Service. - :type sku: ~azure.mgmt.search.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.search.models.Identity - :param replica_count: The number of replicas in the search service. If specified, it must be a - value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. - :type replica_count: int - :param partition_count: The number of partitions in the search service; if specified, it can be - 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' - services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. - :type partition_count: int - :param hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable - up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the - maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' - or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: - "default", "highDensity". Default value: "default". - :type hosting_mode: str or ~azure.mgmt.search.models.HostingMode - :param public_network_access: This value can be set to 'enabled' to avoid breaking changes on - existing customer resources and templates. If set to 'disabled', traffic over public interface - is not allowed, and private endpoint connections would be the exclusive access method. Possible - values include: "enabled", "disabled". Default value: "enabled". - :type public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess - :ivar status: The status of the search service. Possible values include: 'running': The search - service is running and no provisioning operations are underway. 'provisioning': The search - service is being provisioned or scaled up or down. 'deleting': The search service is being - deleted. 'degraded': The search service is degraded. This can occur when the underlying search - units are not healthy. The search service is most likely operational, but performance might be - slow and some requests might be dropped. 'disabled': The search service is disabled. In this - state, the service will reject all API requests. 'error': The search service is in an error - state. If your service is in the degraded, disabled, or error states, it means the Azure - Cognitive Search team is actively investigating the underlying issue. Dedicated services in - these states are still chargeable based on the number of search units provisioned. Possible - values include: "running", "provisioning", "deleting", "degraded", "disabled", "error". - :vartype status: str or ~azure.mgmt.search.models.SearchServiceStatus - :ivar status_details: The details of the search service status. - :vartype status_details: str - :ivar provisioning_state: The state of the last provisioning operation performed on the search - service. Provisioning is an intermediate state that occurs while service capacity is being - established. After capacity is set up, provisioningState changes to either 'succeeded' or - 'failed'. Client applications can poll provisioning status (the recommended polling interval is - from 30 seconds to one minute) by using the Get Search Service operation to see when an - operation is completed. If you are using the free service, this value tends to come back as - 'succeeded' directly in the call to Create search service. This is because the free service - uses capacity that is already set up. Possible values include: "succeeded", "provisioning", - "failed". - :vartype provisioning_state: str or ~azure.mgmt.search.models.ProvisioningState - :param network_rule_set: Network specific rules that determine how the Azure Cognitive Search - service may be reached. - :type network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet - :ivar private_endpoint_connections: The list of private endpoint connections to the Azure - Cognitive Search service. - :vartype private_endpoint_connections: - list[~azure.mgmt.search.models.PrivateEndpointConnection] - :ivar shared_private_link_resources: The list of shared private link resources managed by the - Azure Cognitive Search service. - :vartype shared_private_link_resources: - list[~azure.mgmt.search.models.SharedPrivateLinkResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'replica_count': {'maximum': 12, 'minimum': 1}, - 'partition_count': {'maximum': 12, 'minimum': 1}, - 'status': {'readonly': True}, - 'status_details': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'shared_private_link_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'replica_count': {'key': 'properties.replicaCount', 'type': 'int'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'int'}, - 'hosting_mode': {'key': 'properties.hostingMode', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'shared_private_link_resources': {'key': 'properties.sharedPrivateLinkResources', 'type': '[SharedPrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(SearchService, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.replica_count = kwargs.get('replica_count', 1) - self.partition_count = kwargs.get('partition_count', 1) - self.hosting_mode = kwargs.get('hosting_mode', "default") - self.public_network_access = kwargs.get('public_network_access', "enabled") - self.status = None - self.status_details = None - self.provisioning_state = None - self.network_rule_set = kwargs.get('network_rule_set', None) - self.private_endpoint_connections = None - self.shared_private_link_resources = None - - -class SearchServiceListResult(msrest.serialization.Model): - """Response containing a list of Azure Cognitive Search services. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of search services. - :vartype value: list[~azure.mgmt.search.models.SearchService] - :ivar next_link: Request URL that can be used to query next page of search services. Returned - when the total number of requested search services exceed maximum page size. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SearchService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SearchServiceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SearchServiceUpdate(Resource): - """The parameters used to update an Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param sku: The SKU of the Search Service, which determines price tier and capacity limits. - This property is required when creating a new Search Service. - :type sku: ~azure.mgmt.search.models.Sku - :param location: The geographic location of the resource. This must be one of the supported and - registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). - This property is required when creating a new resource. - :type location: str - :param tags: A set of tags. Tags to help categorize the resource in the Azure portal. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.search.models.Identity - :param replica_count: The number of replicas in the search service. If specified, it must be a - value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. - :type replica_count: int - :param partition_count: The number of partitions in the search service; if specified, it can be - 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' - services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. - :type partition_count: int - :param hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable - up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the - maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' - or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: - "default", "highDensity". Default value: "default". - :type hosting_mode: str or ~azure.mgmt.search.models.HostingMode - :param public_network_access: This value can be set to 'enabled' to avoid breaking changes on - existing customer resources and templates. If set to 'disabled', traffic over public interface - is not allowed, and private endpoint connections would be the exclusive access method. Possible - values include: "enabled", "disabled". Default value: "enabled". - :type public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess - :ivar status: The status of the search service. Possible values include: 'running': The search - service is running and no provisioning operations are underway. 'provisioning': The search - service is being provisioned or scaled up or down. 'deleting': The search service is being - deleted. 'degraded': The search service is degraded. This can occur when the underlying search - units are not healthy. The search service is most likely operational, but performance might be - slow and some requests might be dropped. 'disabled': The search service is disabled. In this - state, the service will reject all API requests. 'error': The search service is in an error - state. If your service is in the degraded, disabled, or error states, it means the Azure - Cognitive Search team is actively investigating the underlying issue. Dedicated services in - these states are still chargeable based on the number of search units provisioned. Possible - values include: "running", "provisioning", "deleting", "degraded", "disabled", "error". - :vartype status: str or ~azure.mgmt.search.models.SearchServiceStatus - :ivar status_details: The details of the search service status. - :vartype status_details: str - :ivar provisioning_state: The state of the last provisioning operation performed on the search - service. Provisioning is an intermediate state that occurs while service capacity is being - established. After capacity is set up, provisioningState changes to either 'succeeded' or - 'failed'. Client applications can poll provisioning status (the recommended polling interval is - from 30 seconds to one minute) by using the Get Search Service operation to see when an - operation is completed. If you are using the free service, this value tends to come back as - 'succeeded' directly in the call to Create search service. This is because the free service - uses capacity that is already set up. Possible values include: "succeeded", "provisioning", - "failed". - :vartype provisioning_state: str or ~azure.mgmt.search.models.ProvisioningState - :param network_rule_set: Network specific rules that determine how the Azure Cognitive Search - service may be reached. - :type network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet - :ivar private_endpoint_connections: The list of private endpoint connections to the Azure - Cognitive Search service. - :vartype private_endpoint_connections: - list[~azure.mgmt.search.models.PrivateEndpointConnection] - :ivar shared_private_link_resources: The list of shared private link resources managed by the - Azure Cognitive Search service. - :vartype shared_private_link_resources: - list[~azure.mgmt.search.models.SharedPrivateLinkResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'replica_count': {'maximum': 12, 'minimum': 1}, - 'partition_count': {'maximum': 12, 'minimum': 1}, - 'status': {'readonly': True}, - 'status_details': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'shared_private_link_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'replica_count': {'key': 'properties.replicaCount', 'type': 'int'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'int'}, - 'hosting_mode': {'key': 'properties.hostingMode', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'shared_private_link_resources': {'key': 'properties.sharedPrivateLinkResources', 'type': '[SharedPrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(SearchServiceUpdate, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.replica_count = kwargs.get('replica_count', 1) - self.partition_count = kwargs.get('partition_count', 1) - self.hosting_mode = kwargs.get('hosting_mode', "default") - self.public_network_access = kwargs.get('public_network_access', "enabled") - self.status = None - self.status_details = None - self.provisioning_state = None - self.network_rule_set = kwargs.get('network_rule_set', None) - self.private_endpoint_connections = None - self.shared_private_link_resources = None - - -class ShareablePrivateLinkResourceProperties(msrest.serialization.Model): - """Describes the properties of a resource type that has been onboarded to private link service, supported by Azure Cognitive Search. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The resource provider type for the resource that has been onboarded to private link - service, supported by Azure Cognitive Search. - :vartype type: str - :ivar group_id: The resource provider group id for the resource that has been onboarded to - private link service, supported by Azure Cognitive Search. - :vartype group_id: str - :ivar description: The description of the resource type that has been onboarded to private link - service, supported by Azure Cognitive Search. - :vartype description: str - """ - - _validation = { - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareablePrivateLinkResourceProperties, self).__init__(**kwargs) - self.type = None - self.group_id = None - self.description = None - - -class ShareablePrivateLinkResourceType(msrest.serialization.Model): - """Describes an resource type that has been onboarded to private link service, supported by Azure Cognitive Search. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the resource type that has been onboarded to private link service, - supported by Azure Cognitive Search. - :vartype name: str - :ivar properties: Describes the properties of a resource type that has been onboarded to - private link service, supported by Azure Cognitive Search. - :vartype properties: ~azure.mgmt.search.models.ShareablePrivateLinkResourceProperties - """ - - _validation = { - 'name': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ShareablePrivateLinkResourceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareablePrivateLinkResourceType, self).__init__(**kwargs) - self.name = None - self.properties = None - - -class SharedPrivateLinkResource(Resource): - """Describes a Shared Private Link Resource managed by the Azure Cognitive Search service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param properties: Describes the properties of a Shared Private Link Resource managed by the - Azure Cognitive Search service. - :type properties: ~azure.mgmt.search.models.SharedPrivateLinkResourceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'SharedPrivateLinkResourceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedPrivateLinkResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class SharedPrivateLinkResourceListResult(msrest.serialization.Model): - """Response containing a list of Shared Private Link Resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Shared Private Link Resources. - :vartype value: list[~azure.mgmt.search.models.SharedPrivateLinkResource] - :param next_link: The URL to get the next set of shared private link resources, if there are - any. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedPrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedPrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class SharedPrivateLinkResourceProperties(msrest.serialization.Model): - """Describes the properties of an existing Shared Private Link Resource managed by the Azure Cognitive Search service. - - :param private_link_resource_id: The resource id of the resource the shared private link - resource is for. - :type private_link_resource_id: str - :param group_id: The group id from the provider of resource the shared private link resource is - for. - :type group_id: str - :param request_message: The request message for requesting approval of the shared private link - resource. - :type request_message: str - :param resource_region: Optional. Can be used to specify the Azure Resource Manager location of - the resource to which a shared private link is to be created. This is only required for those - resources whose DNS configuration are regional (such as Azure Kubernetes Service). - :type resource_region: str - :param status: Status of the shared private link resource. Can be Pending, Approved, Rejected - or Disconnected. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceStatus - :param provisioning_state: The provisioning state of the shared private link resource. Can be - Updating, Deleting, Failed, Succeeded or Incomplete. Possible values include: "Updating", - "Deleting", "Failed", "Succeeded", "Incomplete". - :type provisioning_state: str or - ~azure.mgmt.search.models.SharedPrivateLinkResourceProvisioningState - """ - - _attribute_map = { - 'private_link_resource_id': {'key': 'privateLinkResourceId', 'type': 'str'}, - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'request_message': {'key': 'requestMessage', 'type': 'str'}, - 'resource_region': {'key': 'resourceRegion', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedPrivateLinkResourceProperties, self).__init__(**kwargs) - self.private_link_resource_id = kwargs.get('private_link_resource_id', None) - self.group_id = kwargs.get('group_id', None) - self.request_message = kwargs.get('request_message', None) - self.resource_region = kwargs.get('resource_region', None) - self.status = kwargs.get('status', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class Sku(msrest.serialization.Model): - """Defines the SKU of an Azure Cognitive Search Service, which determines price tier and capacity limits. - - :param name: The SKU of the search service. Valid values include: 'free': Shared service. - 'basic': Dedicated service with up to 3 replicas. 'standard': Dedicated service with up to 12 - partitions and 12 replicas. 'standard2': Similar to standard, but with more capacity per search - unit. 'standard3': The largest Standard offering with up to 12 partitions and 12 replicas (or - up to 3 partitions with more indexes if you also set the hostingMode property to - 'highDensity'). 'storage_optimized_l1': Supports 1TB per partition, up to 12 partitions. - 'storage_optimized_l2': Supports 2TB per partition, up to 12 partitions.'. Possible values - include: "free", "basic", "standard", "standard2", "standard3", "storage_optimized_l1", - "storage_optimized_l2". - :type name: str or ~azure.mgmt.search.models.SkuName - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py index b36db8ef1086..67f14c6eac40 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py @@ -38,6 +38,8 @@ def __init__( self, **kwargs ): + """ + """ super(AdminKeyResult, self).__init__(**kwargs) self.primary_key = None self.secondary_key = None @@ -46,9 +48,9 @@ def __init__( class AsyncOperationResult(msrest.serialization.Model): """The details of a long running asynchronous shared private link resource operation. - :param status: The current status of the long running asynchronous shared private link resource + :ivar status: The current status of the long running asynchronous shared private link resource operation. Possible values include: "Running", "Succeeded", "Failed". - :type status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceAsyncOperationResult + :vartype status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceAsyncOperationResult """ _attribute_map = { @@ -61,6 +63,12 @@ def __init__( status: Optional[Union[str, "SharedPrivateLinkResourceAsyncOperationResult"]] = None, **kwargs ): + """ + :keyword status: The current status of the long running asynchronous shared private link + resource operation. Possible values include: "Running", "Succeeded", "Failed". + :paramtype status: str or + ~azure.mgmt.search.models.SharedPrivateLinkResourceAsyncOperationResult + """ super(AsyncOperationResult, self).__init__(**kwargs) self.status = status @@ -72,13 +80,13 @@ class CheckNameAvailabilityInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The search service name to validate. Search service names must only + :ivar name: Required. The search service name to validate. Search service names must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in length. - :type name: str - :ivar type: Required. The type of the resource whose name is to be validated. This value must - always be 'searchServices'. Default value: "searchServices". + :vartype name: str + :ivar type: The type of the resource whose name is to be validated. This value must always be + 'searchServices'. Has constant value: "searchServices". :vartype type: str """ @@ -100,6 +108,13 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The search service name to validate. Search service names must only + contain lowercase letters, digits or dashes, cannot use dash as the first two or last one + characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in + length. + :paramtype name: str + """ super(CheckNameAvailabilityInput, self).__init__(**kwargs) self.name = name @@ -137,6 +152,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityOutput, self).__init__(**kwargs) self.is_name_available = None self.reason = None @@ -146,17 +163,16 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """Describes a particular API error with an error code and a message. - :param code: An error code that describes the error condition more precisely than an HTTP - status code. Can be used to programmatically handle specific error cases. - :type code: str - :param message: A message that describes the error in detail and provides debugging - information. - :type message: str - :param target: The target of the particular error (for example, the name of the property in + :ivar code: An error code that describes the error condition more precisely than an HTTP status + code. Can be used to programmatically handle specific error cases. + :vartype code: str + :ivar message: A message that describes the error in detail and provides debugging information. + :vartype message: str + :ivar target: The target of the particular error (for example, the name of the property in error). - :type target: str - :param details: Contains nested errors that are related to this error. - :type details: list[~azure.mgmt.search.models.CloudErrorBody] + :vartype target: str + :ivar details: Contains nested errors that are related to this error. + :vartype details: list[~azure.mgmt.search.models.CloudErrorBody] """ _attribute_map = { @@ -175,6 +191,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An error code that describes the error condition more precisely than an HTTP + status code. Can be used to programmatically handle specific error cases. + :paramtype code: str + :keyword message: A message that describes the error in detail and provides debugging + information. + :paramtype message: str + :keyword target: The target of the particular error (for example, the name of the property in + error). + :paramtype target: str + :keyword details: Contains nested errors that are related to this error. + :paramtype details: list[~azure.mgmt.search.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -193,8 +222,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: Required. The identity type. Possible values include: "None", "SystemAssigned". - :type type: str or ~azure.mgmt.search.models.IdentityType + :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned". + :vartype type: str or ~azure.mgmt.search.models.IdentityType """ _validation = { @@ -215,6 +244,10 @@ def __init__( type: Union[str, "IdentityType"], **kwargs ): + """ + :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned". + :paramtype type: str or ~azure.mgmt.search.models.IdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -224,9 +257,9 @@ def __init__( class IpRule(msrest.serialization.Model): """The IP restriction rule of the Azure Cognitive Search service. - :param value: Value corresponding to a single IPv4 address (eg., 123.1.2.3) or an IP range in + :ivar value: Value corresponding to a single IPv4 address (eg., 123.1.2.3) or an IP range in CIDR format (eg., 123.1.2.3/24) to be allowed. - :type value: str + :vartype value: str """ _attribute_map = { @@ -239,6 +272,11 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Value corresponding to a single IPv4 address (eg., 123.1.2.3) or an IP range in + CIDR format (eg., 123.1.2.3/24) to be allowed. + :paramtype value: str + """ super(IpRule, self).__init__(**kwargs) self.value = value @@ -269,6 +307,8 @@ def __init__( self, **kwargs ): + """ + """ super(ListQueryKeysResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -277,13 +317,13 @@ def __init__( class NetworkRuleSet(msrest.serialization.Model): """Network specific rules that determine how the Azure Cognitive Search service may be reached. - :param ip_rules: A list of IP restriction rules that defines the inbound network(s) with + :ivar ip_rules: A list of IP restriction rules that defines the inbound network(s) with allowing access to the search service endpoint. At the meantime, all other public IP networks are blocked by the firewall. These restriction rules are applied only when the 'publicNetworkAccess' of the search service is 'enabled'; otherwise, traffic over public interface is not allowed even with any public IP rules, and private endpoint connections would be the exclusive access method. - :type ip_rules: list[~azure.mgmt.search.models.IpRule] + :vartype ip_rules: list[~azure.mgmt.search.models.IpRule] """ _attribute_map = { @@ -296,6 +336,15 @@ def __init__( ip_rules: Optional[List["IpRule"]] = None, **kwargs ): + """ + :keyword ip_rules: A list of IP restriction rules that defines the inbound network(s) with + allowing access to the search service endpoint. At the meantime, all other public IP networks + are blocked by the firewall. These restriction rules are applied only when the + 'publicNetworkAccess' of the search service is 'enabled'; otherwise, traffic over public + interface is not allowed even with any public IP rules, and private endpoint connections would + be the exclusive access method. + :paramtype ip_rules: list[~azure.mgmt.search.models.IpRule] + """ super(NetworkRuleSet, self).__init__(**kwargs) self.ip_rules = ip_rules @@ -326,6 +375,8 @@ def __init__( self, **kwargs ): + """ + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = None @@ -364,6 +415,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.operation = None @@ -396,6 +449,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -432,6 +487,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -451,9 +508,9 @@ class PrivateEndpointConnection(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Describes the properties of an existing Private Endpoint connection to the + :ivar properties: Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. - :type properties: ~azure.mgmt.search.models.PrivateEndpointConnectionProperties + :vartype properties: ~azure.mgmt.search.models.PrivateEndpointConnectionProperties """ _validation = { @@ -475,6 +532,11 @@ def __init__( properties: Optional["PrivateEndpointConnectionProperties"] = None, **kwargs ): + """ + :keyword properties: Describes the properties of an existing Private Endpoint connection to the + Azure Cognitive Search service. + :paramtype properties: ~azure.mgmt.search.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.properties = properties @@ -506,6 +568,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -514,12 +578,12 @@ def __init__( class PrivateEndpointConnectionProperties(msrest.serialization.Model): """Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. - :param private_endpoint: The private endpoint resource from Microsoft.Network provider. - :type private_endpoint: + :ivar private_endpoint: The private endpoint resource from Microsoft.Network provider. + :vartype private_endpoint: ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateEndpoint - :param private_link_service_connection_state: Describes the current state of an existing - Private Link Service connection to the Azure Private Endpoint. - :type private_link_service_connection_state: + :ivar private_link_service_connection_state: Describes the current state of an existing Private + Link Service connection to the Azure Private Endpoint. + :vartype private_link_service_connection_state: ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState """ @@ -535,6 +599,15 @@ def __init__( private_link_service_connection_state: Optional["PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState"] = None, **kwargs ): + """ + :keyword private_endpoint: The private endpoint resource from Microsoft.Network provider. + :paramtype private_endpoint: + ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateEndpoint + :keyword private_link_service_connection_state: Describes the current state of an existing + Private Link Service connection to the Azure Private Endpoint. + :paramtype private_link_service_connection_state: + ~azure.mgmt.search.models.PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -543,8 +616,8 @@ def __init__( class PrivateEndpointConnectionPropertiesPrivateEndpoint(msrest.serialization.Model): """The private endpoint resource from Microsoft.Network provider. - :param id: The resource id of the private endpoint resource from Microsoft.Network provider. - :type id: str + :ivar id: The resource id of the private endpoint resource from Microsoft.Network provider. + :vartype id: str """ _attribute_map = { @@ -557,6 +630,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The resource id of the private endpoint resource from Microsoft.Network provider. + :paramtype id: str + """ super(PrivateEndpointConnectionPropertiesPrivateEndpoint, self).__init__(**kwargs) self.id = id @@ -564,14 +641,14 @@ def __init__( class PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState(msrest.serialization.Model): """Describes the current state of an existing Private Link Service connection to the Azure Private Endpoint. - :param status: Status of the the private link service connection. Can be Pending, Approved, + :ivar status: Status of the the private link service connection. Can be Pending, Approved, Rejected, or Disconnected. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.search.models.PrivateLinkServiceConnectionStatus - :param description: The description for the private link service connection state. - :type description: str - :param actions_required: A description of any extra actions that may be required. - :type actions_required: str + :vartype status: str or ~azure.mgmt.search.models.PrivateLinkServiceConnectionStatus + :ivar description: The description for the private link service connection state. + :vartype description: str + :ivar actions_required: A description of any extra actions that may be required. + :vartype actions_required: str """ _attribute_map = { @@ -588,6 +665,16 @@ def __init__( actions_required: Optional[str] = "None", **kwargs ): + """ + :keyword status: Status of the the private link service connection. Can be Pending, Approved, + Rejected, or Disconnected. Possible values include: "Pending", "Approved", "Rejected", + "Disconnected". + :paramtype status: str or ~azure.mgmt.search.models.PrivateLinkServiceConnectionStatus + :keyword description: The description for the private link service connection state. + :paramtype description: str + :keyword actions_required: A description of any extra actions that may be required. + :paramtype actions_required: str + """ super(PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -630,6 +717,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResource, self).__init__(**kwargs) self.properties = None @@ -669,6 +758,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourceProperties, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -697,6 +788,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourcesResult, self).__init__(**kwargs) self.value = None @@ -726,6 +819,8 @@ def __init__( self, **kwargs ): + """ + """ super(QueryKey, self).__init__(**kwargs) self.name = None self.key = None @@ -734,9 +829,9 @@ def __init__( class SearchManagementRequestOptions(msrest.serialization.Model): """Parameter group. - :param client_request_id: A client-generated GUID value that identifies this request. If + :ivar client_request_id: A client-generated GUID value that identifies this request. If specified, this will be included in response information as a way to track the request. - :type client_request_id: str + :vartype client_request_id: str """ _attribute_map = { @@ -749,6 +844,11 @@ def __init__( client_request_id: Optional[str] = None, **kwargs ): + """ + :keyword client_request_id: A client-generated GUID value that identifies this request. If + specified, this will be included in response information as a way to track the request. + :paramtype client_request_id: str + """ super(SearchManagementRequestOptions, self).__init__(**kwargs) self.client_request_id = client_request_id @@ -768,10 +868,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -796,6 +896,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -816,33 +922,33 @@ class SearchService(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param sku: The SKU of the Search Service, which determines price tier and capacity limits. - This property is required when creating a new Search Service. - :type sku: ~azure.mgmt.search.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.search.models.Identity - :param replica_count: The number of replicas in the search service. If specified, it must be a + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar sku: The SKU of the Search Service, which determines price tier and capacity limits. This + property is required when creating a new Search Service. + :vartype sku: ~azure.mgmt.search.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.search.models.Identity + :ivar replica_count: The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. - :type replica_count: int - :param partition_count: The number of partitions in the search service; if specified, it can be + :vartype replica_count: int + :ivar partition_count: The number of partitions in the search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. - :type partition_count: int - :param hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable + :vartype partition_count: int + :ivar hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: "default", "highDensity". Default value: "default". - :type hosting_mode: str or ~azure.mgmt.search.models.HostingMode - :param public_network_access: This value can be set to 'enabled' to avoid breaking changes on + :vartype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :ivar public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Possible values include: "enabled", "disabled". Default value: "enabled". - :type public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess + :vartype public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess :ivar status: The status of the search service. Possible values include: 'running': The search service is running and no provisioning operations are underway. 'provisioning': The search service is being provisioned or scaled up or down. 'deleting': The search service is being @@ -867,9 +973,9 @@ class SearchService(TrackedResource): uses capacity that is already set up. Possible values include: "succeeded", "provisioning", "failed". :vartype provisioning_state: str or ~azure.mgmt.search.models.ProvisioningState - :param network_rule_set: Network specific rules that determine how the Azure Cognitive Search + :ivar network_rule_set: Network specific rules that determine how the Azure Cognitive Search service may be reached. - :type network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet + :vartype network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet :ivar private_endpoint_connections: The list of private endpoint connections to the Azure Cognitive Search service. :vartype private_endpoint_connections: @@ -928,6 +1034,40 @@ def __init__( network_rule_set: Optional["NetworkRuleSet"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword sku: The SKU of the Search Service, which determines price tier and capacity limits. + This property is required when creating a new Search Service. + :paramtype sku: ~azure.mgmt.search.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.search.models.Identity + :keyword replica_count: The number of replicas in the search service. If specified, it must be + a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic + SKU. + :paramtype replica_count: int + :keyword partition_count: The number of partitions in the search service; if specified, it can + be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For + 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 + and 3. + :paramtype partition_count: int + :keyword hosting_mode: Applicable only for the standard3 SKU. You can set this property to + enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than + the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either + 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values + include: "default", "highDensity". Default value: "default". + :paramtype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :keyword public_network_access: This value can be set to 'enabled' to avoid breaking changes on + existing customer resources and templates. If set to 'disabled', traffic over public interface + is not allowed, and private endpoint connections would be the exclusive access method. Possible + values include: "enabled", "disabled". Default value: "enabled". + :paramtype public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess + :keyword network_rule_set: Network specific rules that determine how the Azure Cognitive Search + service may be reached. + :paramtype network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet + """ super(SearchService, self).__init__(tags=tags, location=location, **kwargs) self.sku = sku self.identity = identity @@ -969,6 +1109,8 @@ def __init__( self, **kwargs ): + """ + """ super(SearchServiceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -987,35 +1129,35 @@ class SearchServiceUpdate(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param sku: The SKU of the Search Service, which determines price tier and capacity limits. - This property is required when creating a new Search Service. - :type sku: ~azure.mgmt.search.models.Sku - :param location: The geographic location of the resource. This must be one of the supported and + :ivar sku: The SKU of the Search Service, which determines price tier and capacity limits. This + property is required when creating a new Search Service. + :vartype sku: ~azure.mgmt.search.models.Sku + :ivar location: The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). This property is required when creating a new resource. - :type location: str - :param tags: A set of tags. Tags to help categorize the resource in the Azure portal. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.search.models.Identity - :param replica_count: The number of replicas in the search service. If specified, it must be a + :vartype location: str + :ivar tags: A set of tags. Tags to help categorize the resource in the Azure portal. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.search.models.Identity + :ivar replica_count: The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. - :type replica_count: int - :param partition_count: The number of partitions in the search service; if specified, it can be + :vartype replica_count: int + :ivar partition_count: The number of partitions in the search service; if specified, it can be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. - :type partition_count: int - :param hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable + :vartype partition_count: int + :ivar hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values include: "default", "highDensity". Default value: "default". - :type hosting_mode: str or ~azure.mgmt.search.models.HostingMode - :param public_network_access: This value can be set to 'enabled' to avoid breaking changes on + :vartype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :ivar public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Possible values include: "enabled", "disabled". Default value: "enabled". - :type public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess + :vartype public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess :ivar status: The status of the search service. Possible values include: 'running': The search service is running and no provisioning operations are underway. 'provisioning': The search service is being provisioned or scaled up or down. 'deleting': The search service is being @@ -1040,9 +1182,9 @@ class SearchServiceUpdate(Resource): uses capacity that is already set up. Possible values include: "succeeded", "provisioning", "failed". :vartype provisioning_state: str or ~azure.mgmt.search.models.ProvisioningState - :param network_rule_set: Network specific rules that determine how the Azure Cognitive Search + :ivar network_rule_set: Network specific rules that determine how the Azure Cognitive Search service may be reached. - :type network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet + :vartype network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet :ivar private_endpoint_connections: The list of private endpoint connections to the Azure Cognitive Search service. :vartype private_endpoint_connections: @@ -1100,6 +1242,42 @@ def __init__( network_rule_set: Optional["NetworkRuleSet"] = None, **kwargs ): + """ + :keyword sku: The SKU of the Search Service, which determines price tier and capacity limits. + This property is required when creating a new Search Service. + :paramtype sku: ~azure.mgmt.search.models.Sku + :keyword location: The geographic location of the resource. This must be one of the supported + and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). + This property is required when creating a new resource. + :paramtype location: str + :keyword tags: A set of tags. Tags to help categorize the resource in the Azure portal. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.search.models.Identity + :keyword replica_count: The number of replicas in the search service. If specified, it must be + a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic + SKU. + :paramtype replica_count: int + :keyword partition_count: The number of partitions in the search service; if specified, it can + be 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For + 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 + and 3. + :paramtype partition_count: int + :keyword hosting_mode: Applicable only for the standard3 SKU. You can set this property to + enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than + the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either + 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Possible values + include: "default", "highDensity". Default value: "default". + :paramtype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :keyword public_network_access: This value can be set to 'enabled' to avoid breaking changes on + existing customer resources and templates. If set to 'disabled', traffic over public interface + is not allowed, and private endpoint connections would be the exclusive access method. Possible + values include: "enabled", "disabled". Default value: "enabled". + :paramtype public_network_access: str or ~azure.mgmt.search.models.PublicNetworkAccess + :keyword network_rule_set: Network specific rules that determine how the Azure Cognitive Search + service may be reached. + :paramtype network_rule_set: ~azure.mgmt.search.models.NetworkRuleSet + """ super(SearchServiceUpdate, self).__init__(**kwargs) self.sku = sku self.location = location @@ -1149,6 +1327,8 @@ def __init__( self, **kwargs ): + """ + """ super(ShareablePrivateLinkResourceProperties, self).__init__(**kwargs) self.type = None self.group_id = None @@ -1182,6 +1362,8 @@ def __init__( self, **kwargs ): + """ + """ super(ShareablePrivateLinkResourceType, self).__init__(**kwargs) self.name = None self.properties = None @@ -1200,9 +1382,9 @@ class SharedPrivateLinkResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Describes the properties of a Shared Private Link Resource managed by the + :ivar properties: Describes the properties of a Shared Private Link Resource managed by the Azure Cognitive Search service. - :type properties: ~azure.mgmt.search.models.SharedPrivateLinkResourceProperties + :vartype properties: ~azure.mgmt.search.models.SharedPrivateLinkResourceProperties """ _validation = { @@ -1224,6 +1406,11 @@ def __init__( properties: Optional["SharedPrivateLinkResourceProperties"] = None, **kwargs ): + """ + :keyword properties: Describes the properties of a Shared Private Link Resource managed by the + Azure Cognitive Search service. + :paramtype properties: ~azure.mgmt.search.models.SharedPrivateLinkResourceProperties + """ super(SharedPrivateLinkResource, self).__init__(**kwargs) self.properties = properties @@ -1235,9 +1422,9 @@ class SharedPrivateLinkResourceListResult(msrest.serialization.Model): :ivar value: The list of Shared Private Link Resources. :vartype value: list[~azure.mgmt.search.models.SharedPrivateLinkResource] - :param next_link: The URL to get the next set of shared private link resources, if there are + :ivar next_link: The URL to get the next set of shared private link resources, if there are any. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -1255,6 +1442,11 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The URL to get the next set of shared private link resources, if there are + any. + :paramtype next_link: str + """ super(SharedPrivateLinkResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = next_link @@ -1263,26 +1455,26 @@ def __init__( class SharedPrivateLinkResourceProperties(msrest.serialization.Model): """Describes the properties of an existing Shared Private Link Resource managed by the Azure Cognitive Search service. - :param private_link_resource_id: The resource id of the resource the shared private link + :ivar private_link_resource_id: The resource id of the resource the shared private link resource is for. - :type private_link_resource_id: str - :param group_id: The group id from the provider of resource the shared private link resource is + :vartype private_link_resource_id: str + :ivar group_id: The group id from the provider of resource the shared private link resource is for. - :type group_id: str - :param request_message: The request message for requesting approval of the shared private link + :vartype group_id: str + :ivar request_message: The request message for requesting approval of the shared private link resource. - :type request_message: str - :param resource_region: Optional. Can be used to specify the Azure Resource Manager location of + :vartype request_message: str + :ivar resource_region: Optional. Can be used to specify the Azure Resource Manager location of the resource to which a shared private link is to be created. This is only required for those resources whose DNS configuration are regional (such as Azure Kubernetes Service). - :type resource_region: str - :param status: Status of the shared private link resource. Can be Pending, Approved, Rejected - or Disconnected. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceStatus - :param provisioning_state: The provisioning state of the shared private link resource. Can be + :vartype resource_region: str + :ivar status: Status of the shared private link resource. Can be Pending, Approved, Rejected or + Disconnected. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". + :vartype status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceStatus + :ivar provisioning_state: The provisioning state of the shared private link resource. Can be Updating, Deleting, Failed, Succeeded or Incomplete. Possible values include: "Updating", "Deleting", "Failed", "Succeeded", "Incomplete". - :type provisioning_state: str or + :vartype provisioning_state: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceProvisioningState """ @@ -1306,6 +1498,29 @@ def __init__( provisioning_state: Optional[Union[str, "SharedPrivateLinkResourceProvisioningState"]] = None, **kwargs ): + """ + :keyword private_link_resource_id: The resource id of the resource the shared private link + resource is for. + :paramtype private_link_resource_id: str + :keyword group_id: The group id from the provider of resource the shared private link resource + is for. + :paramtype group_id: str + :keyword request_message: The request message for requesting approval of the shared private + link resource. + :paramtype request_message: str + :keyword resource_region: Optional. Can be used to specify the Azure Resource Manager location + of the resource to which a shared private link is to be created. This is only required for + those resources whose DNS configuration are regional (such as Azure Kubernetes Service). + :paramtype resource_region: str + :keyword status: Status of the shared private link resource. Can be Pending, Approved, Rejected + or Disconnected. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". + :paramtype status: str or ~azure.mgmt.search.models.SharedPrivateLinkResourceStatus + :keyword provisioning_state: The provisioning state of the shared private link resource. Can be + Updating, Deleting, Failed, Succeeded or Incomplete. Possible values include: "Updating", + "Deleting", "Failed", "Succeeded", "Incomplete". + :paramtype provisioning_state: str or + ~azure.mgmt.search.models.SharedPrivateLinkResourceProvisioningState + """ super(SharedPrivateLinkResourceProperties, self).__init__(**kwargs) self.private_link_resource_id = private_link_resource_id self.group_id = group_id @@ -1318,7 +1533,7 @@ def __init__( class Sku(msrest.serialization.Model): """Defines the SKU of an Azure Cognitive Search Service, which determines price tier and capacity limits. - :param name: The SKU of the search service. Valid values include: 'free': Shared service. + :ivar name: The SKU of the search service. Valid values include: 'free': Shared service. 'basic': Dedicated service with up to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 replicas. 'standard2': Similar to standard, but with more capacity per search unit. 'standard3': The largest Standard offering with up to 12 partitions and 12 replicas (or @@ -1327,7 +1542,7 @@ class Sku(msrest.serialization.Model): 'storage_optimized_l2': Supports 2TB per partition, up to 12 partitions.'. Possible values include: "free", "basic", "standard", "standard2", "standard3", "storage_optimized_l1", "storage_optimized_l2". - :type name: str or ~azure.mgmt.search.models.SkuName + :vartype name: str or ~azure.mgmt.search.models.SkuName """ _attribute_map = { @@ -1340,5 +1555,17 @@ def __init__( name: Optional[Union[str, "SkuName"]] = None, **kwargs ): + """ + :keyword name: The SKU of the search service. Valid values include: 'free': Shared service. + 'basic': Dedicated service with up to 3 replicas. 'standard': Dedicated service with up to 12 + partitions and 12 replicas. 'standard2': Similar to standard, but with more capacity per search + unit. 'standard3': The largest Standard offering with up to 12 partitions and 12 replicas (or + up to 3 partitions with more indexes if you also set the hostingMode property to + 'highDensity'). 'storage_optimized_l1': Supports 1TB per partition, up to 12 partitions. + 'storage_optimized_l2': Supports 2TB per partition, up to 12 partitions.'. Possible values + include: "free", "basic", "standard", "standard2", "standard3", "storage_optimized_l1", + "storage_optimized_l2". + :paramtype name: str or ~azure.mgmt.search.models.SkuName + """ super(Sku, self).__init__(**kwargs) self.name = name diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py index dcf1986edb74..f05c3fb0742c 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py @@ -6,32 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AdminKeyKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AdminKeyKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIMARY = "primary" SECONDARY = "secondary" -class HostingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HostingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For @@ -41,14 +26,14 @@ class HostingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "default" HIGH_DENSITY = "highDensity" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the the private link service connection. Can be Pending, Approved, Rejected, or Disconnected. """ @@ -58,7 +43,7 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the last provisioning operation performed on the search service. Provisioning is an intermediate state that occurs while service capacity is being established. After capacity is set up, provisioningState changes to either 'succeeded' or 'failed'. Client applications can @@ -72,7 +57,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PROVISIONING = "provisioning" FAILED = "failed" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. @@ -81,7 +66,7 @@ class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "enabled" DISABLED = "disabled" -class SearchServiceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SearchServiceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the search service. Possible values include: 'running': The search service is running and no provisioning operations are underway. 'provisioning': The search service is being provisioned or scaled up or down. 'deleting': The search service is being deleted. @@ -101,7 +86,7 @@ class SearchServiceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "disabled" ERROR = "error" -class SharedPrivateLinkResourceAsyncOperationResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedPrivateLinkResourceAsyncOperationResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current status of the long running asynchronous shared private link resource operation. """ @@ -109,7 +94,7 @@ class SharedPrivateLinkResourceAsyncOperationResult(with_metaclass(_CaseInsensit SUCCEEDED = "Succeeded" FAILED = "Failed" -class SharedPrivateLinkResourceProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedPrivateLinkResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the shared private link resource. Can be Updating, Deleting, Failed, Succeeded or Incomplete. """ @@ -120,7 +105,7 @@ class SharedPrivateLinkResourceProvisioningState(with_metaclass(_CaseInsensitive SUCCEEDED = "Succeeded" INCOMPLETE = "Incomplete" -class SharedPrivateLinkResourceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedPrivateLinkResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. """ @@ -129,7 +114,7 @@ class SharedPrivateLinkResourceStatus(with_metaclass(_CaseInsensitiveEnumMeta, s REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The SKU of the search service. Valid values include: 'free': Shared service. 'basic': Dedicated service with up to 3 replicas. 'standard': Dedicated service with up to 12 partitions and 12 replicas. 'standard2': Similar to standard, but with more capacity per search unit. @@ -147,7 +132,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STORAGE_OPTIMIZED_L1 = "storage_optimized_l1" STORAGE_OPTIMIZED_L2 = "storage_optimized_l2" -class UnavailableNameReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableNameReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason why the name is not available. 'Invalid' indicates the name provided does not match the naming requirements (incorrect length, unsupported characters, etc.). 'AlreadyExists' indicates that the name is already in use and is therefore unavailable. diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py index 40e81e6bc65f..1a89984ec2ed 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py @@ -5,22 +5,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listAdminKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_request( + resource_group_name: str, + search_service_name: str, + key_kind: Union[str, "_models.AdminKeyKind"], + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/regenerateAdminKey/{keyKind}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "keyKind": _SERIALIZER.url("key_kind", key_kind, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AdminKeysOperations(object): """AdminKeysOperations operations. @@ -44,14 +126,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.AdminKeyResult" + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.AdminKeyResult": """Gets the primary and secondary admin API keys for the specified Azure Cognitive Search service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -61,7 +143,8 @@ def get( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: AdminKeyResult, or the result of cls(response) :rtype: ~azure.mgmt.search.models.AdminKeyResult @@ -72,33 +155,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -112,17 +183,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listAdminKeys'} # type: ignore + + @distributed_trace def regenerate( self, - resource_group_name, # type: str - search_service_name, # type: str - key_kind, # type: Union[str, "_models.AdminKeyKind"] - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.AdminKeyResult" + resource_group_name: str, + search_service_name: str, + key_kind: Union[str, "_models.AdminKeyKind"], + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.AdminKeyResult": """Regenerates either the primary or secondary admin API key. You can only regenerate one key at a time. @@ -136,7 +209,8 @@ def regenerate( 'secondary'. :type key_kind: str or ~azure.mgmt.search.models.AdminKeyKind :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: AdminKeyResult, or the result of cls(response) :rtype: ~azure.mgmt.search.models.AdminKeyResult @@ -147,34 +221,22 @@ def regenerate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.regenerate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'keyKind': self._serialize.url("key_kind", key_kind, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_regenerate_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + key_kind=key_kind, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.regenerate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,4 +250,6 @@ def regenerate( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/regenerateAdminKey/{keyKind}'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py index a7de7c963eb7..6d33d2278644 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Search/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available REST API operations of the Microsoft.Search provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +127,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py index b8c4752d5fe3..e713b9e96ec9 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py @@ -5,23 +5,196 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_update_request( + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_service_request( + subscription_id: str, + resource_group_name: str, + search_service_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -45,16 +218,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - search_service_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Updates a Private Endpoint connection to the search service in the given resource group. :param resource_group_name: The name of the resource group within the current subscription. You @@ -70,7 +243,8 @@ def update( update. :type private_endpoint_connection: ~azure.mgmt.search.models.PrivateEndpointConnection :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection @@ -81,39 +255,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -127,17 +289,19 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - search_service_name, # type: str - private_endpoint_connection_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets the details of the private endpoint connection to the search service in the given resource group. @@ -151,7 +315,8 @@ def get( Azure Cognitive Search service with the specified resource group. :type private_endpoint_connection_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection @@ -162,34 +327,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,17 +356,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - search_service_name, # type: str - private_endpoint_connection_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + search_service_name: str, + private_endpoint_connection_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: """Disconnects the private endpoint connection and deletes it from the search service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -226,7 +381,8 @@ def delete( Azure Cognitive Search service with the specified resource group. :type private_endpoint_connection_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection or None @@ -237,34 +393,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -280,16 +424,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Gets a list of all private endpoint connections in the given service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -299,10 +445,13 @@ def list_by_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -310,42 +459,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -363,6 +511,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py index af599a679589..26bb6ad82e6c 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py @@ -5,23 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_supported_request( + subscription_id: str, + resource_group_name: str, + search_service_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateLinkResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -45,14 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_supported( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourcesResult"] + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.PrivateLinkResourcesResult"]: """Gets a list of all supported private link resource types for the given service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -62,9 +103,11 @@ def list_supported( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourcesResult or the result of cls(response) + :return: An iterator like instance of either PrivateLinkResourcesResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.PrivateLinkResourcesResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -73,42 +116,41 @@ def list_supported( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_supported.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_supported_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_supported.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_supported_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateLinkResourcesResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,6 +168,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py index 264a009d70b5..106c9c3a29b0 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py @@ -5,23 +5,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + resource_group_name: str, + search_service_name: str, + name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/createQueryKey/{name}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_search_service_request( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + search_service_name: str, + key: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/deleteQueryKey/{key}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "key": _SERIALIZER.url("key", key, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class QueryKeysOperations(object): """QueryKeysOperations operations. @@ -45,15 +168,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create( self, - resource_group_name, # type: str - search_service_name, # type: str - name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.QueryKey" + resource_group_name: str, + search_service_name: str, + name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.QueryKey": """Generates a new query key for the specified search service. You can create up to 50 query keys per service. @@ -66,7 +189,8 @@ def create( :param name: The name of the new query API key. :type name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: QueryKey, or the result of cls(response) :rtype: ~azure.mgmt.search.models.QueryKey @@ -77,34 +201,22 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + name=name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,16 +230,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/createQueryKey/{name}'} # type: ignore + + @distributed_trace def list_by_search_service( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListQueryKeysResult"] + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.ListQueryKeysResult"]: """Returns the list of query API keys for the given Azure Cognitive Search service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -137,7 +251,8 @@ def list_by_search_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueryKeysResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.ListQueryKeysResult] @@ -148,42 +263,41 @@ def list_by_search_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_search_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_search_service_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_search_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_search_service_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListQueryKeysResult', pipeline_response) + deserialized = self._deserialize("ListQueryKeysResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -201,20 +315,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_search_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - search_service_name, # type: str - key, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + search_service_name: str, + key: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> None: """Deletes the specified query key. Unlike admin keys, query keys are not regenerated. The process for regenerating a query key is to delete and then recreate it. @@ -227,7 +342,8 @@ def delete( :param key: The query key to be deleted. Query keys are identified by value, not by name. :type key: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -238,34 +354,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'key': self._serialize.url("key", key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + key=key, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,3 +381,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/deleteQueryKey/{key}'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py index 3cfd440d0228..27783fe540cd 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py @@ -5,25 +5,315 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + search_service_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Search/searchServices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Search/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServicesOperations(object): """ServicesOperations operations. @@ -49,50 +339,37 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - resource_group_name, # type: str - search_service_name, # type: str - service, # type: "_models.SearchService" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SearchService" + resource_group_name: str, + search_service_name: str, + service: "_models.SearchService", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.SearchService": cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service, 'SearchService') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(service, 'SearchService') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,17 +387,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - search_service_name, # type: str - service, # type: "_models.SearchService" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SearchService"] + resource_group_name: str, + search_service_name: str, + service: "_models.SearchService", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> LROPoller["_models.SearchService"]: """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. @@ -137,18 +416,23 @@ def begin_create_or_update( :param service: The definition of the search service to create or update. :type service: ~azure.mgmt.search.models.SearchService :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SearchService or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SearchService or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.search.models.SearchService] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchService"] lro_delay = kwargs.pop( 'polling_interval', @@ -161,27 +445,21 @@ def begin_create_or_update( search_service_name=search_service_name, service=service, search_management_request_options=search_management_request_options, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SearchService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -193,17 +471,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - search_service_name, # type: str - service, # type: "_models.SearchServiceUpdate" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SearchService" + resource_group_name: str, + search_service_name: str, + service: "_models.SearchServiceUpdate", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.SearchService": """Updates an existing search service in the given resource group. :param resource_group_name: The name of the resource group within the current subscription. You @@ -214,7 +493,8 @@ def update( :param service: The definition of the search service to update. :type service: ~azure.mgmt.search.models.SearchServiceUpdate :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchService, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SearchService @@ -225,38 +505,26 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service, 'SearchServiceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(service, 'SearchServiceUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -270,16 +538,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SearchService" + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.SearchService": """Gets the search service with the given name in the given resource group. :param resource_group_name: The name of the resource group within the current subscription. You @@ -289,7 +559,8 @@ def get( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchService, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SearchService @@ -300,33 +571,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,16 +599,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> None: """Deletes a search service in the given resource group, along with its associated resources. :param resource_group_name: The name of the resource group within the current subscription. You @@ -359,7 +620,8 @@ def delete( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -370,33 +632,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -409,22 +659,25 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SearchServiceListResult"] + resource_group_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.SearchServiceListResult"]: """Gets a list of all search services in the given resource group. :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. :type resource_group_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SearchServiceListResult or the result of cls(response) + :return: An iterator like instance of either SearchServiceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.SearchServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -433,41 +686,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SearchServiceListResult', pipeline_response) + deserialized = self._deserialize("SearchServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -485,23 +736,26 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices'} # type: ignore + @distributed_trace def list_by_subscription( self, - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SearchServiceListResult"] + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.SearchServiceListResult"]: """Gets a list of all search services in the given subscription. :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SearchServiceListResult or the result of cls(response) + :return: An iterator like instance of either SearchServiceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.SearchServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -510,40 +764,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SearchServiceListResult', pipeline_response) + deserialized = self._deserialize("SearchServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -561,18 +812,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Search/searchServices'} # type: ignore + @distributed_trace def check_name_availability( self, - name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityOutput" + name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.CheckNameAvailabilityOutput": """Checks whether or not the given search service name is available for use. Search service names must be globally unique since they are part of the service URI (https://:code:``.search.windows.net). @@ -582,7 +834,8 @@ def check_name_availability( cannot contain consecutive dashes, and must be between 2 and 60 characters in length. :type name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityOutput, or the result of cls(response) :rtype: ~azure.mgmt.search.models.CheckNameAvailabilityOutput @@ -593,38 +846,25 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id + _check_name_availability_input = _models.CheckNameAvailabilityInput(name=name, type=type) + _json = self._serialize.body(_check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _check_name_availability_input = _models.CheckNameAvailabilityInput(name=name) - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -638,4 +878,6 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Search/checkNameAvailability'} # type: ignore + diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py index 4c874ff112ff..4b2ddc6b4930 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py @@ -5,25 +5,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_service_request( + subscription_id: str, + resource_group_name: str, + search_service_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['x-ms-client-request-id'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SharedPrivateLinkResourcesOperations(object): """SharedPrivateLinkResourcesOperations operations. @@ -49,52 +222,39 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - resource_group_name, # type: str - search_service_name, # type: str - shared_private_link_resource_name, # type: str - shared_private_link_resource, # type: "_models.SharedPrivateLinkResource" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SharedPrivateLinkResource"] + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + shared_private_link_resource: "_models.SharedPrivateLinkResource", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Optional["_models.SharedPrivateLinkResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SharedPrivateLinkResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(shared_private_link_resource, 'SharedPrivateLinkResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = self._serialize.body(shared_private_link_resource, 'SharedPrivateLinkResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + client_request_id=_client_request_id, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,18 +270,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - search_service_name, # type: str - shared_private_link_resource_name, # type: str - shared_private_link_resource, # type: "_models.SharedPrivateLinkResource" - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SharedPrivateLinkResource"] + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + shared_private_link_resource: "_models.SharedPrivateLinkResource", + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> LROPoller["_models.SharedPrivateLinkResource"]: """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. @@ -138,18 +300,23 @@ def begin_create_or_update( create or update. :type shared_private_link_resource: ~azure.mgmt.search.models.SharedPrivateLinkResource :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.search.models.SharedPrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -163,28 +330,21 @@ def begin_create_or_update( shared_private_link_resource_name=shared_private_link_resource_name, shared_private_link_resource=shared_private_link_resource, search_management_request_options=search_management_request_options, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -196,17 +356,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - search_service_name, # type: str - shared_private_link_resource_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedPrivateLinkResource" + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> "_models.SharedPrivateLinkResource": """Gets the details of the shared private link resource managed by the search service in the given resource group. @@ -220,7 +381,8 @@ def get( by the Azure Cognitive Search service within the specified resource group. :type shared_private_link_resource_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedPrivateLinkResource, or the result of cls(response) :rtype: ~azure.mgmt.search.models.SharedPrivateLinkResource @@ -231,34 +393,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_get_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -272,50 +422,39 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - search_service_name, # type: str - shared_private_link_resource_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _client_request_id = None if search_management_request_options is not None: _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_delete_request_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -328,15 +467,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - search_service_name, # type: str - shared_private_link_resource_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + search_service_name: str, + shared_private_link_resource_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> LROPoller[None]: """Initiates the deletion of the shared private link resource from the search service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -349,18 +489,21 @@ def begin_delete( by the Azure Cognitive Search service within the specified resource group. :type shared_private_link_resource_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -376,22 +519,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - 'sharedPrivateLinkResourceName': self._serialize.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -403,16 +538,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - search_service_name, # type: str - search_management_request_options=None, # type: Optional["_models.SearchManagementRequestOptions"] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedPrivateLinkResourceListResult"] + resource_group_name: str, + search_service_name: str, + search_management_request_options: Optional["_models.SearchManagementRequestOptions"] = None, + **kwargs: Any + ) -> Iterable["_models.SharedPrivateLinkResourceListResult"]: """Gets a list of all shared private link resources managed by the given service. :param resource_group_name: The name of the resource group within the current subscription. You @@ -422,10 +558,13 @@ def list_by_service( specified resource group. :type search_service_name: str :param search_management_request_options: Parameter group. - :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedPrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.SharedPrivateLinkResourceListResult] + :return: An iterator like instance of either SharedPrivateLinkResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.SharedPrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResourceListResult"] @@ -433,42 +572,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _client_request_id = None - if search_management_request_options is not None: - _client_request_id = search_management_request_options.client_request_id - api_version = "2020-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if _client_request_id is not None: - header_parameters['x-ms-client-request-id'] = self._serialize.header("client_request_id", _client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'searchServiceName': self._serialize.url("search_service_name", search_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + search_service_name=search_service_name, + client_request_id=_client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedPrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,6 +624,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data )