diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/_meta.json b/sdk/voiceservices/azure-mgmt-voiceservices/_meta.json index c487f2861490..62fa02687df1 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/_meta.json +++ b/sdk/voiceservices/azure-mgmt-voiceservices/_meta.json @@ -1,11 +1,11 @@ { - "commit": "84113e300ebbd2e804f000b73b522ffd8acedd4a", + "commit": "e2da5fddc05c40236d0d8e2533172d7f806d1c43", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/voiceservices/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/voiceservices/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/voiceservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_configuration.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_configuration.py index ed98daf6ce73..d61404b13c52 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_configuration.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_configuration.py @@ -29,14 +29,14 @@ class VoiceServicesMgmtClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(VoiceServicesMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-31") + api_version: str = kwargs.pop("api_version", "2023-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_serialization.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_serialization.py index 842ae727fbbc..4bae2292227b 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_serialization.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_serialization.py @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_vendor.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_vendor.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_voice_services_mgmt_client.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_voice_services_mgmt_client.py index c8596a24e024..70c59dd54219 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_voice_services_mgmt_client.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/_voice_services_mgmt_client.py @@ -40,7 +40,7 @@ class VoiceServicesMgmtClient: # pylint: disable=client-accepts-api-version-key :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_configuration.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_configuration.py index 958f3be52f44..8307c79eeda1 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_configuration.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_configuration.py @@ -29,14 +29,14 @@ class VoiceServicesMgmtClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(VoiceServicesMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-31") + api_version: str = kwargs.pop("api_version", "2023-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_voice_services_mgmt_client.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_voice_services_mgmt_client.py index 1965854412ab..7af3cf11ec33 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_voice_services_mgmt_client.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/_voice_services_mgmt_client.py @@ -40,7 +40,7 @@ class VoiceServicesMgmtClient: # pylint: disable=client-accepts-api-version-key :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-31". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_communications_gateways_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_communications_gateways_operations.py index 0b12a5b0de81..7f282bf17844 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_communications_gateways_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_communications_gateways_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -328,7 +329,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "CommunicationsGateway") @@ -538,127 +539,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" } - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a CommunicationsGateway. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param communications_gateway_name: Unique identifier for this deployment. Required. - :type communications_gateway_name: str - :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: 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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" - } - @overload async def update( self, @@ -759,7 +639,7 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IO, bytes)): + if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "CommunicationsGatewayUpdate") @@ -801,3 +681,124 @@ async def update( update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a CommunicationsGateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param communications_gateway_name: Unique identifier for this deployment. Required. + :type communications_gateway_name: str + :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: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + } diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_name_availability_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_name_availability_operations.py index 99fdf5c75226..2f5bed2aa44c 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_name_availability_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_name_availability_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -130,7 +131,7 @@ async def check_local( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "CheckNameAvailabilityRequest") diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_test_lines_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_test_lines_operations.py index 4567e2ca22cb..39de38b8ea91 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_test_lines_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/aio/operations/_test_lines_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -247,7 +248,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "TestLine") @@ -464,131 +465,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" } - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - test_line_name=test_line_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a TestLine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param communications_gateway_name: Unique identifier for this deployment. Required. - :type communications_gateway_name: str - :param test_line_name: Unique identifier for this test line. Required. - :type test_line_name: str - :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: 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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - test_line_name=test_line_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" - } - @overload async def update( self, @@ -698,7 +574,7 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IO, bytes)): + if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "TestLineUpdate") @@ -741,3 +617,128 @@ async def update( update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + test_line_name=test_line_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a TestLine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param communications_gateway_name: Unique identifier for this deployment. Required. + :type communications_gateway_name: str + :param test_line_name: Unique identifier for this test line. Required. + :type test_line_name: str + :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: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + test_line_name=test_line_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + } diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/__init__.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/__init__.py index ee84c9bd2f66..17d34929e5fe 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/__init__.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/__init__.py @@ -6,35 +6,46 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import ApiBridgeProperties from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResponse from ._models_py3 import CommunicationsGateway from ._models_py3 import CommunicationsGatewayListResult from ._models_py3 import CommunicationsGatewayUpdate +from ._models_py3 import CustomSipHeader +from ._models_py3 import CustomSipHeadersProperties +from ._models_py3 import DnsDelegationProperties +from ._models_py3 import DnsDelegationsProperties from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse +from ._models_py3 import ManagedServiceIdentity from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import PrimaryRegionProperties from ._models_py3 import Resource from ._models_py3 import ServiceRegionProperties +from ._models_py3 import Sku from ._models_py3 import SystemData from ._models_py3 import TestLine from ._models_py3 import TestLineListResult from ._models_py3 import TestLineUpdate from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentity from ._voice_services_mgmt_client_enums import ActionType +from ._voice_services_mgmt_client_enums import ApiBridgeActivationState from ._voice_services_mgmt_client_enums import AutoGeneratedDomainNameLabelScope from ._voice_services_mgmt_client_enums import CheckNameAvailabilityReason from ._voice_services_mgmt_client_enums import CommunicationsPlatform from ._voice_services_mgmt_client_enums import Connectivity from ._voice_services_mgmt_client_enums import CreatedByType from ._voice_services_mgmt_client_enums import E911Type +from ._voice_services_mgmt_client_enums import ManagedServiceIdentityType from ._voice_services_mgmt_client_enums import Origin from ._voice_services_mgmt_client_enums import ProvisioningState +from ._voice_services_mgmt_client_enums import SkuTier from ._voice_services_mgmt_client_enums import Status from ._voice_services_mgmt_client_enums import TeamsCodecs from ._voice_services_mgmt_client_enums import TestLinePurpose @@ -43,34 +54,45 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ApiBridgeProperties", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "CommunicationsGateway", "CommunicationsGatewayListResult", "CommunicationsGatewayUpdate", + "CustomSipHeader", + "CustomSipHeadersProperties", + "DnsDelegationProperties", + "DnsDelegationsProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "ManagedServiceIdentity", "Operation", "OperationDisplay", "OperationListResult", "PrimaryRegionProperties", "Resource", "ServiceRegionProperties", + "Sku", "SystemData", "TestLine", "TestLineListResult", "TestLineUpdate", "TrackedResource", + "UserAssignedIdentity", "ActionType", + "ApiBridgeActivationState", "AutoGeneratedDomainNameLabelScope", "CheckNameAvailabilityReason", "CommunicationsPlatform", "Connectivity", "CreatedByType", "E911Type", + "ManagedServiceIdentityType", "Origin", "ProvisioningState", + "SkuTier", "Status", "TeamsCodecs", "TestLinePurpose", diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_models_py3.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_models_py3.py index 78c017a1bb0c..473bb7853568 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_models_py3.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_models_py3.py @@ -8,20 +8,60 @@ # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class ApiBridgeProperties(_serialization.Model): + """Configuration of the API Bridge. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar configure_api_bridge: The activation state of the API Bridge for this Communications + Gateway. Known values are: "enabled" and "disabled". + :vartype configure_api_bridge: str or ~azure.mgmt.voiceservices.models.ApiBridgeActivationState + :ivar endpoint_fqdns: FQDNs for sending requests to the API Bridge endpoint. + :vartype endpoint_fqdns: list[str] + :ivar allowed_address_prefixes: The allowed source IP addresses or CIDR ranges for accessing + the API Bridge. + :vartype allowed_address_prefixes: list[str] + """ + + _validation = { + "endpoint_fqdns": {"readonly": True}, + } + + _attribute_map = { + "configure_api_bridge": {"key": "configureApiBridge", "type": "str"}, + "endpoint_fqdns": {"key": "endpointFqdns", "type": "[str]"}, + "allowed_address_prefixes": {"key": "allowedAddressPrefixes", "type": "[str]"}, + } + + def __init__( + self, + *, + configure_api_bridge: Optional[Union[str, "_models.ApiBridgeActivationState"]] = None, + allowed_address_prefixes: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword configure_api_bridge: The activation state of the API Bridge for this Communications + Gateway. Known values are: "enabled" and "disabled". + :paramtype configure_api_bridge: str or + ~azure.mgmt.voiceservices.models.ApiBridgeActivationState + :keyword allowed_address_prefixes: The allowed source IP addresses or CIDR ranges for accessing + the API Bridge. + :paramtype allowed_address_prefixes: list[str] + """ + super().__init__(**kwargs) + self.configure_api_bridge = configure_api_bridge + self.endpoint_fqdns = None + self.allowed_address_prefixes = allowed_address_prefixes class CheckNameAvailabilityRequest(_serialization.Model): @@ -208,6 +248,10 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.voiceservices.models.ManagedServiceIdentity + :ivar sku: The SKU (Stock Keeping Unit) assigned to this resource. + :vartype sku: ~azure.mgmt.voiceservices.models.Sku :ivar provisioning_state: Resource provisioning state. Known values are: "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.voiceservices.models.ProvisioningState @@ -225,7 +269,7 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan :ivar platforms: What platforms to support. :vartype platforms: list[str or ~azure.mgmt.voiceservices.models.CommunicationsPlatform] :ivar api_bridge: Details of API bridge functionality, if required. - :vartype api_bridge: JSON + :vartype api_bridge: ~azure.mgmt.voiceservices.models.ApiBridgeProperties :ivar auto_generated_domain_name_label_scope: The scope at which the auto-generated domain name can be re-used. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". @@ -239,8 +283,21 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan :vartype teams_voicemail_pilot_number: str :ivar on_prem_mcp_enabled: Whether an on-premises Mobile Control Point is in use. :vartype on_prem_mcp_enabled: bool + :ivar integrated_mcp_enabled: Whether an integrated Mobile Control Point is in use. + :vartype integrated_mcp_enabled: bool :ivar emergency_dial_strings: A list of dial strings used for emergency calling. :vartype emergency_dial_strings: list[str] + :ivar dns_delegations: Details of DNS Domains to delegate to the Communications Gateway. + :vartype dns_delegations: ~azure.mgmt.voiceservices.models.DnsDelegationsProperties + :ivar custom_sip_headers: Custom SIP Header to add to any subscriber with a custom_header + value, if required. + :vartype custom_sip_headers: ~azure.mgmt.voiceservices.models.CustomSipHeadersProperties + :ivar allocated_signaling_address_prefixes: A list of IP allocated prefixes which may be used + to receive signaling data from this Communications Gateway. + :vartype allocated_signaling_address_prefixes: list[str] + :ivar allocated_media_address_prefixes: A list of allocated IP prefixes which may be used to + receive media data from this Communications Gateway. + :vartype allocated_media_address_prefixes: list[str] """ _validation = { @@ -253,6 +310,8 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan "status": {"readonly": True}, "platforms": {"min_items": 1}, "auto_generated_domain_name_label": {"readonly": True}, + "allocated_signaling_address_prefixes": {"readonly": True}, + "allocated_media_address_prefixes": {"readonly": True}, } _attribute_map = { @@ -262,6 +321,8 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "sku": {"key": "sku", "type": "Sku"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "service_locations": {"key": "properties.serviceLocations", "type": "[ServiceRegionProperties]"}, @@ -269,7 +330,7 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan "codecs": {"key": "properties.codecs", "type": "[str]"}, "e911_type": {"key": "properties.e911Type", "type": "str"}, "platforms": {"key": "properties.platforms", "type": "[str]"}, - "api_bridge": {"key": "properties.apiBridge", "type": "object"}, + "api_bridge": {"key": "properties.apiBridge", "type": "ApiBridgeProperties"}, "auto_generated_domain_name_label_scope": { "key": "properties.autoGeneratedDomainNameLabelScope", "type": "str", @@ -277,26 +338,39 @@ class CommunicationsGateway(TrackedResource): # pylint: disable=too-many-instan "auto_generated_domain_name_label": {"key": "properties.autoGeneratedDomainNameLabel", "type": "str"}, "teams_voicemail_pilot_number": {"key": "properties.teamsVoicemailPilotNumber", "type": "str"}, "on_prem_mcp_enabled": {"key": "properties.onPremMcpEnabled", "type": "bool"}, + "integrated_mcp_enabled": {"key": "properties.integratedMcpEnabled", "type": "bool"}, "emergency_dial_strings": {"key": "properties.emergencyDialStrings", "type": "[str]"}, + "dns_delegations": {"key": "properties.dnsDelegations", "type": "DnsDelegationsProperties"}, + "custom_sip_headers": {"key": "properties.customSipHeaders", "type": "CustomSipHeadersProperties"}, + "allocated_signaling_address_prefixes": { + "key": "properties.allocatedSignalingAddressPrefixes", + "type": "[str]", + }, + "allocated_media_address_prefixes": {"key": "properties.allocatedMediaAddressPrefixes", "type": "[str]"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + sku: Optional["_models.Sku"] = None, service_locations: Optional[List["_models.ServiceRegionProperties"]] = None, connectivity: Optional[Union[str, "_models.Connectivity"]] = None, codecs: Optional[List[Union[str, "_models.TeamsCodecs"]]] = None, e911_type: Optional[Union[str, "_models.E911Type"]] = None, platforms: Optional[List[Union[str, "_models.CommunicationsPlatform"]]] = None, - api_bridge: Optional[JSON] = None, + api_bridge: Optional["_models.ApiBridgeProperties"] = None, auto_generated_domain_name_label_scope: Optional[ Union[str, "_models.AutoGeneratedDomainNameLabelScope"] ] = None, teams_voicemail_pilot_number: Optional[str] = None, on_prem_mcp_enabled: bool = False, + integrated_mcp_enabled: bool = False, emergency_dial_strings: List[str] = ["911", "933"], + dns_delegations: Optional["_models.DnsDelegationsProperties"] = None, + custom_sip_headers: Optional["_models.CustomSipHeadersProperties"] = None, **kwargs: Any ) -> None: """ @@ -304,6 +378,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: ~azure.mgmt.voiceservices.models.ManagedServiceIdentity + :keyword sku: The SKU (Stock Keeping Unit) assigned to this resource. + :paramtype sku: ~azure.mgmt.voiceservices.models.Sku :keyword service_locations: The regions in which to deploy the resources needed for Teams Calling. :paramtype service_locations: list[~azure.mgmt.voiceservices.models.ServiceRegionProperties] @@ -316,7 +394,7 @@ def __init__( :keyword platforms: What platforms to support. :paramtype platforms: list[str or ~azure.mgmt.voiceservices.models.CommunicationsPlatform] :keyword api_bridge: Details of API bridge functionality, if required. - :paramtype api_bridge: JSON + :paramtype api_bridge: ~azure.mgmt.voiceservices.models.ApiBridgeProperties :keyword auto_generated_domain_name_label_scope: The scope at which the auto-generated domain name can be re-used. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". @@ -327,10 +405,19 @@ def __init__( :paramtype teams_voicemail_pilot_number: str :keyword on_prem_mcp_enabled: Whether an on-premises Mobile Control Point is in use. :paramtype on_prem_mcp_enabled: bool + :keyword integrated_mcp_enabled: Whether an integrated Mobile Control Point is in use. + :paramtype integrated_mcp_enabled: bool :keyword emergency_dial_strings: A list of dial strings used for emergency calling. :paramtype emergency_dial_strings: list[str] + :keyword dns_delegations: Details of DNS Domains to delegate to the Communications Gateway. + :paramtype dns_delegations: ~azure.mgmt.voiceservices.models.DnsDelegationsProperties + :keyword custom_sip_headers: Custom SIP Header to add to any subscriber with a custom_header + value, if required. + :paramtype custom_sip_headers: ~azure.mgmt.voiceservices.models.CustomSipHeadersProperties """ super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.sku = sku self.provisioning_state = None self.status = None self.service_locations = service_locations @@ -343,7 +430,12 @@ def __init__( self.auto_generated_domain_name_label = None self.teams_voicemail_pilot_number = teams_voicemail_pilot_number self.on_prem_mcp_enabled = on_prem_mcp_enabled + self.integrated_mcp_enabled = integrated_mcp_enabled self.emergency_dial_strings = emergency_dial_strings + self.dns_delegations = dns_delegations + self.custom_sip_headers = custom_sip_headers + self.allocated_signaling_address_prefixes = None + self.allocated_media_address_prefixes = None class CommunicationsGatewayListResult(_serialization.Model): @@ -383,23 +475,136 @@ def __init__( class CommunicationsGatewayUpdate(_serialization.Model): """The type used for update operations of the CommunicationsGateway. + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.voiceservices.models.ManagedServiceIdentity + :ivar sku: The SKU (Stock Keeping Unit) assigned to this resource. + :vartype sku: ~azure.mgmt.voiceservices.models.Sku :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "sku": {"key": "sku", "type": "Sku"}, "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + identity: Optional["_models.ManagedServiceIdentity"] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: ~azure.mgmt.voiceservices.models.ManagedServiceIdentity + :keyword sku: The SKU (Stock Keeping Unit) assigned to this resource. + :paramtype sku: ~azure.mgmt.voiceservices.models.Sku :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ super().__init__(**kwargs) + self.identity = identity + self.sku = sku self.tags = tags +class CustomSipHeader(_serialization.Model): + """Details of a Custom SIP Header. + + :ivar name: The name of the Custom SIP Header. + :vartype name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: The name of the Custom SIP Header. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class CustomSipHeadersProperties(_serialization.Model): + """Properties of Custom SIP Headers. + + :ivar headers: The Custom SIP Headers to apply to the calls which traverse the Communications + Gateway. + :vartype headers: list[~azure.mgmt.voiceservices.models.CustomSipHeader] + """ + + _attribute_map = { + "headers": {"key": "headers", "type": "[CustomSipHeader]"}, + } + + def __init__(self, *, headers: Optional[List["_models.CustomSipHeader"]] = None, **kwargs: Any) -> None: + """ + :keyword headers: The Custom SIP Headers to apply to the calls which traverse the + Communications Gateway. + :paramtype headers: list[~azure.mgmt.voiceservices.models.CustomSipHeader] + """ + super().__init__(**kwargs) + self.headers = headers + + +class DnsDelegationProperties(_serialization.Model): + """Details of a DNS Domain delegated to the Communications Gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar domain: Domain name to delegate. + :vartype domain: str + :ivar name_servers: The Azure-hosted DNS Name Servers for the delegated DNS Zones. + :vartype name_servers: list[str] + """ + + _validation = { + "name_servers": {"readonly": True}, + } + + _attribute_map = { + "domain": {"key": "domain", "type": "str"}, + "name_servers": {"key": "nameServers", "type": "[str]"}, + } + + def __init__(self, *, domain: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword domain: Domain name to delegate. + :paramtype domain: str + """ + super().__init__(**kwargs) + self.domain = domain + self.name_servers = None + + +class DnsDelegationsProperties(_serialization.Model): + """Details of DNS Domains delegated to the Communications Gateway. + + :ivar delegations: DNS Domains to delegate for the creation of DNS Zones by the Azure + Communications Gateway. + :vartype delegations: list[~azure.mgmt.voiceservices.models.DnsDelegationProperties] + """ + + _attribute_map = { + "delegations": {"key": "delegations", "type": "[DnsDelegationProperties]"}, + } + + def __init__(self, *, delegations: Optional[List["_models.DnsDelegationProperties"]] = None, **kwargs: Any) -> None: + """ + :keyword delegations: DNS Domains to delegate for the creation of DNS Zones by the Azure + Communications Gateway. + :paramtype delegations: list[~azure.mgmt.voiceservices.models.DnsDelegationProperties] + """ + super().__init__(**kwargs) + self.delegations = delegations + + class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. @@ -492,6 +697,70 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error +class ManagedServiceIdentity(_serialization.Model): + """Managed service identity (system assigned and/or user assigned identities). + + 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 service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned, UserAssigned". + :vartype type: str or ~azure.mgmt.voiceservices.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.voiceservices.models.UserAssignedIdentity] + """ + + _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"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned, UserAssigned". + :paramtype type: str or ~azure.mgmt.voiceservices.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.voiceservices.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. @@ -623,10 +892,10 @@ class PrimaryRegionProperties(_serialization.Model): :vartype operator_addresses: list[str] :ivar esrp_addresses: IP address to use to contact the ESRP from this region. :vartype esrp_addresses: list[str] - :ivar allowed_signaling_source_address_prefixes: The allowed source IP address or CIDR ranges + :ivar allowed_signaling_source_address_prefixes: The allowed source IP addresses or CIDR ranges for signaling. :vartype allowed_signaling_source_address_prefixes: list[str] - :ivar allowed_media_source_address_prefixes: The allowed source IP address or CIDR ranges for + :ivar allowed_media_source_address_prefixes: The allowed source IP addresses or CIDR ranges for media. :vartype allowed_media_source_address_prefixes: list[str] """ @@ -657,10 +926,10 @@ def __init__( :paramtype operator_addresses: list[str] :keyword esrp_addresses: IP address to use to contact the ESRP from this region. :paramtype esrp_addresses: list[str] - :keyword allowed_signaling_source_address_prefixes: The allowed source IP address or CIDR + :keyword allowed_signaling_source_address_prefixes: The allowed source IP addresses or CIDR ranges for signaling. :paramtype allowed_signaling_source_address_prefixes: list[str] - :keyword allowed_media_source_address_prefixes: The allowed source IP address or CIDR ranges + :keyword allowed_media_source_address_prefixes: The allowed source IP addresses or CIDR ranges for media. :paramtype allowed_media_source_address_prefixes: list[str] """ @@ -710,6 +979,75 @@ def __init__( self.primary_region_properties = primary_region_properties +class Sku(_serialization.Model): + """The resource model definition representing SKU. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :vartype name: str + :ivar tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Known values are: "Free", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.voiceservices.models.SkuTier + :ivar size: The SKU size. When the name field is the combination of tier and some other value, + this would be the standalone code. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: If the SKU supports scale out/in then the capacity integer should be included. + If scale out/in is not possible for the resource this may be omitted. + :vartype capacity: int + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__( + self, + *, + name: str, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + size: Optional[str] = None, + family: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :paramtype name: str + :keyword tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Known values are: "Free", "Basic", + "Standard", and "Premium". + :paramtype tier: str or ~azure.mgmt.voiceservices.models.SkuTier + :keyword size: The SKU size. When the name field is the combination of tier and some other + value, this would be the standalone code. + :paramtype size: str + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword capacity: If the SKU supports scale out/in then the capacity integer should be + included. If scale out/in is not possible for the resource this may be omitted. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.capacity = capacity + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -903,3 +1241,31 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N """ super().__init__(**kwargs) self.tags = tags + + +class UserAssignedIdentity(_serialization.Model): + """User assigned identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_voice_services_mgmt_client_enums.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_voice_services_mgmt_client_enums.py index 94235ad88fac..4345e7b39235 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_voice_services_mgmt_client_enums.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/models/_voice_services_mgmt_client_enums.py @@ -16,13 +16,27 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class ApiBridgeActivationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """API Bridge activation state.""" + + ENABLED = "enabled" + """API Bridge is enabled""" + DISABLED = "disabled" + """API Bridge is disabled""" + + class AutoGeneratedDomainNameLabelScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available auto-generated domain name scopes.""" TENANT_REUSE = "TenantReuse" + """Generated domain name label depends on resource name and tenant ID.""" SUBSCRIPTION_REUSE = "SubscriptionReuse" + """Generated domain name label depends on resource name, tenant ID and subscription ID.""" RESOURCE_GROUP_REUSE = "ResourceGroupReuse" + """Generated domain name label depends on resource name, tenant ID, subscription ID and resource + #: group name.""" NO_REUSE = "NoReuse" + """Generated domain name label is always unique.""" class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -36,7 +50,11 @@ class CommunicationsPlatform(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available platform types.""" OPERATOR_CONNECT = "OperatorConnect" + """Operator Connect""" TEAMS_PHONE_MOBILE = "TeamsPhoneMobile" + """Teams Phone Mobile""" + TEAMS_DIRECT_ROUTING = "TeamsDirectRouting" + """Teams Direct Routing""" class Connectivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -65,6 +83,17 @@ class E911Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Emergency calls are routed directly to the ESRP""" +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + + class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". @@ -79,8 +108,22 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the resource.""" SUCCEEDED = "Succeeded" + """Resource has been created.""" FAILED = "Failed" + """Resource creation failed.""" CANCELED = "Canceled" + """Resource creation was canceled.""" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This field is required to be implemented by the Resource Provider if the service has more than + one tier, but is not required on a PUT. + """ + + FREE = "Free" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -98,15 +141,23 @@ class TeamsCodecs(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The voice codecs expected for communication with Teams.""" PCMA = "PCMA" + """Pulse code modulation(PCM) U-law narrowband audio codec(G.711u)""" PCMU = "PCMU" + """Pulse code modulation(PCM) U-law narrowband audio codec(G.711u)""" G722 = "G722" + """G.722 wideband audio codec""" G722_2 = "G722_2" + """G.722.2 wideband audio codec""" SILK8 = "SILK_8" + """SILK/8000 narrowband audio codec""" SILK16 = "SILK_16" + """SILK/16000 wideband audio codec""" class TestLinePurpose(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The purpose of the TestLine resource.""" MANUAL = "Manual" + """The test line is used for manual testing""" AUTOMATED = "Automated" + """The test line is used for automated testing""" diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_communications_gateways_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_communications_gateways_operations.py index c78f510683db..29f3ec055ba7 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_communications_gateways_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_communications_gateways_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,7 +30,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +43,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +54,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,7 +69,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +101,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +119,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +136,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +155,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,13 +168,14 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_update_request( resource_group_name: str, communications_gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,25 +193,26 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_delete_request( resource_group_name: str, communications_gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,17 +230,15 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class CommunicationsGatewaysOperations: @@ -523,7 +524,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "CommunicationsGateway") @@ -729,126 +730,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" } - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a CommunicationsGateway. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param communications_gateway_name: Unique identifier for this deployment. Required. - :type communications_gateway_name: str - :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: 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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" - } - @overload def update( self, @@ -949,7 +830,7 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IO, bytes)): + if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "CommunicationsGatewayUpdate") @@ -991,3 +872,124 @@ def update( update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, communications_gateway_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a CommunicationsGateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param communications_gateway_name: Unique identifier for this deployment. Required. + :type communications_gateway_name: str + :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: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + } diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_name_availability_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_name_availability_operations.py index 6e59550721e8..54f62a561dd5 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_name_availability_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_name_availability_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +39,7 @@ def build_check_local_request(location: str, subscription_id: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -52,7 +53,7 @@ def build_check_local_request(location: str, subscription_id: str, **kwargs: Any "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,7 +165,7 @@ def check_local( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "CheckNameAvailabilityRequest") diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_operations.py index d725a5d34195..590c931ee9d2 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_operations.py @@ -40,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_test_lines_operations.py b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_test_lines_operations.py index 5c9a3df7727e..9a858d1528ef 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_test_lines_operations.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/azure/mgmt/voiceservices/operations/_test_lines_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,7 +30,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,13 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_communications_gateway_request( # pylint: disable=name-too-long +def build_list_by_communications_gateway_request( resource_group_name: str, communications_gateway_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +63,7 @@ def build_list_by_communications_gateway_request( # pylint: disable=name-too-lo ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +99,7 @@ def build_get_request( "testLineName": _SERIALIZER.url("test_line_name", test_line_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -115,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -135,7 +136,7 @@ def build_create_or_update_request( "testLineName": _SERIALIZER.url("test_line_name", test_line_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,13 +149,14 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_update_request( resource_group_name: str, communications_gateway_name: str, test_line_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -173,25 +175,26 @@ def build_delete_request( "testLineName": _SERIALIZER.url("test_line_name", test_line_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_delete_request( resource_group_name: str, communications_gateway_name: str, test_line_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-31")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -210,17 +213,15 @@ def build_update_request( "testLineName": _SERIALIZER.url("test_line_name", test_line_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class TestLinesOperations: @@ -428,7 +429,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource, (IO, bytes)): + if isinstance(resource, (IOBase, bytes)): _content = resource else: _json = self._serialize.body(resource, "TestLine") @@ -641,130 +642,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" } - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - test_line_name=test_line_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a TestLine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param communications_gateway_name: Unique identifier for this deployment. Required. - :type communications_gateway_name: str - :param test_line_name: Unique identifier for this test line. Required. - :type test_line_name: str - :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: 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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - communications_gateway_name=communications_gateway_name, - test_line_name=test_line_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" - } - @overload def update( self, @@ -874,7 +751,7 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IO, bytes)): + if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "TestLineUpdate") @@ -917,3 +794,128 @@ def update( update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + test_line_name=test_line_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, communications_gateway_name: str, test_line_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a TestLine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param communications_gateway_name: Unique identifier for this deployment. Required. + :type communications_gateway_name: str + :param test_line_name: Unique identifier for this test line. Required. + :type test_line_name: str + :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: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + communications_gateway_name=communications_gateway_name, + test_line_name=test_line_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + } diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_create_or_update.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_create_or_update.py index eea99989d9b5..b2fc391232da 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_create_or_update.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_create_or_update.py @@ -35,11 +35,14 @@ def main(): resource={ "location": "useast", "properties": { + "apiBridge": {"allowedAddressPrefixes": ["198.51.100.192/26"], "configureApiBridge": "enabled"}, "autoGeneratedDomainNameLabelScope": "NoReuse", "codecs": ["PCMA"], "connectivity": "PublicAddress", + "customSipHeaders": {"headers": [{"name": "x-contoso-commsgw-identifier"}]}, + "dnsDelegations": {"delegations": [{"domain": "commsgw.contoso.com"}]}, "e911Type": "Standard", - "platforms": ["OperatorConnect"], + "platforms": ["OperatorConnect", "TeamsDirectRouting"], "serviceLocations": [ { "name": "useast", @@ -60,11 +63,12 @@ def main(): ], "teamsVoicemailPilotNumber": "1234567890", }, + "sku": {"name": "standard"}, }, ).result() print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_CreateOrUpdate.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/CommunicationsGateways_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_delete.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_delete.py index 3639192bdccc..fffd81f25550 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_delete.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_delete.py @@ -29,13 +29,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.communications_gateways.begin_delete( + client.communications_gateways.begin_delete( resource_group_name="testrg", communications_gateway_name="myname", ).result() - print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_Delete.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/CommunicationsGateways_Delete.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_get.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_get.py index 5d2db1c6002f..e6841b5edf51 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_get.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_Get.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/CommunicationsGateways_Get.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_resource_group.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_resource_group.py index 58795a29ba40..7278e8dbe682 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_resource_group.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListByResourceGroup.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/CommunicationsGateways_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_subscription.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_subscription.py index d6b5c78ca602..e968213d7cb1 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_subscription.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/communications_gateways_list_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListBySubscription.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/CommunicationsGateways_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/name_availability_check_local.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/name_availability_check_local.py index 84674bccb453..c4e1f73ae8cc 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/name_availability_check_local.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/name_availability_check_local.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/NameAvailability_CheckLocal.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/NameAvailability_CheckLocal.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/operations_list.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/operations_list.py index 01a47a6c1d50..a162a2577496 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/operations_list.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/operations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/Operations_List.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_create_or_update.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_create_or_update.py index 4680aa6271f4..a6ca6b5d568a 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_create_or_update.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_create_or_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_CreateOrUpdate.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/TestLines_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_delete.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_delete.py index 8868b7893b38..790b78fc63d5 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_delete.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_delete.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.test_lines.begin_delete( + client.test_lines.begin_delete( resource_group_name="testrg", communications_gateway_name="myname", test_line_name="myline", ).result() - print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_Delete.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/TestLines_Delete.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_get.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_get.py index 341192676a08..c984561ebd10 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_get.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_Get.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/TestLines_Get.json if __name__ == "__main__": main() diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_list_by_communications_gateway.py b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_list_by_communications_gateway.py index 4903d0f57c0a..a057270d79c7 100644 --- a/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_list_by_communications_gateway.py +++ b/sdk/voiceservices/azure-mgmt-voiceservices/generated_samples/test_lines_list_by_communications_gateway.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_ListByCommunicationsGateway.json +# x-ms-original-file: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-09-01/examples/TestLines_ListByCommunicationsGateway.json if __name__ == "__main__": main()