diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py index fb2d51067f80..d39745c161ac 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- # pylint: disable=docstring-keyword-should-match-keyword-only -from typing import List, Optional, Union, Any +from typing import List, Optional, Union, Any, cast, Dict import uuid from azure.core.credentials import TokenCredential, AzureKeyCredential @@ -96,7 +96,7 @@ def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "PhoneNumbersCl """ endpoint, access_key = parse_connection_str(conn_str) - return cls(endpoint, access_key, **kwargs) + return cls(endpoint, AzureKeyCredential(access_key), **kwargs) @distributed_trace def begin_purchase_phone_numbers( @@ -240,7 +240,9 @@ def begin_update_phone_number_capabilities( ) result_properties = poller.result().additional_properties - if "status" in result_properties and result_properties["status"].lower() == "failed": + if (result_properties is not None and + "status" in result_properties and + result_properties["status"].lower() == "failed"): raise HttpResponseError( message=result_properties["error"]["message"]) @@ -271,7 +273,8 @@ def list_purchased_phone_numbers(self, **kwargs: Any) -> ItemPaged[PurchasedPhon :returns: An iterator of purchased phone numbers. :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PurchasedPhoneNumber] """ - return self._phone_number_client.phone_numbers.list_phone_numbers(**kwargs) + return cast(ItemPaged[PurchasedPhoneNumber], + self._phone_number_client.phone_numbers.list_phone_numbers(**kwargs)) @distributed_trace def list_available_countries(self, **kwargs: Any) -> ItemPaged[PhoneNumberCountry]: @@ -287,9 +290,10 @@ def list_available_countries(self, **kwargs: Any) -> ItemPaged[PhoneNumberCountr ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PhoneNumberCountry] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_available_countries( - accept_language=self._accepted_language, **kwargs - ) + return cast(ItemPaged[PhoneNumberCountry], + self._phone_number_client.phone_numbers.list_available_countries( + accept_language=self._accepted_language, **kwargs + )) @distributed_trace def list_available_localities(self, country_code: str, **kwargs: Any) -> ItemPaged[PhoneNumberLocality]: @@ -310,13 +314,14 @@ def list_available_localities(self, country_code: str, **kwargs: Any) -> ItemPag ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PhoneNumberLocality] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_available_localities( - country_code, - administrative_division=kwargs.pop( - "administrative_division", None), - accept_language=self._accepted_language, - **kwargs - ) + return cast(ItemPaged[PhoneNumberLocality], + self._phone_number_client.phone_numbers.list_available_localities( + country_code, + administrative_division=kwargs.pop( + "administrative_division", None), + accept_language=self._accepted_language, + **kwargs + )) @distributed_trace def list_available_offerings(self, country_code: str, **kwargs: Any) -> ItemPaged[PhoneNumberOffering]: @@ -340,12 +345,13 @@ def list_available_offerings(self, country_code: str, **kwargs: Any) -> ItemPage ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PhoneNumberOffering] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_offerings( - country_code, - phone_number_type=kwargs.pop("phone_number_type", None), - assignment_type=kwargs.pop("assignment_type", None), - **kwargs - ) + return cast(ItemPaged[PhoneNumberOffering], + self._phone_number_client.phone_numbers.list_offerings( + country_code, + phone_number_type=kwargs.pop("phone_number_type", None), + assignment_type=kwargs.pop("assignment_type", None), + **kwargs + )) @distributed_trace def list_available_area_codes( @@ -374,15 +380,16 @@ def list_available_area_codes( :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PhoneNumberAreaCode] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_area_codes( - country_code, - phone_number_type=phone_number_type, - assignment_type=kwargs.pop("assignment_type", None), - locality=kwargs.pop("locality", None), - administrative_division=kwargs.pop( - "administrative_division", None), - **kwargs - ) + return cast(ItemPaged[PhoneNumberAreaCode], + self._phone_number_client.phone_numbers.list_area_codes( + country_code, + phone_number_type=phone_number_type, + assignment_type=kwargs.pop("assignment_type", None), + locality=kwargs.pop("locality", None), + administrative_division=kwargs.pop( + "administrative_division", None), + **kwargs + )) @distributed_trace def search_operator_information( @@ -443,9 +450,10 @@ def list_reservations( # This allows mapping the generated model to the public model. # Internally, the generated client will create an instance of this iterator with each fetched page. - return self._phone_number_client.phone_numbers.list_reservations( - max_page_size=max_page_size, - **kwargs) + return cast(ItemPaged[PhoneNumbersReservation], + self._phone_number_client.phone_numbers.list_reservations( + max_page_size=max_page_size, + **kwargs)) @distributed_trace def create_or_update_reservation( @@ -481,15 +489,18 @@ def create_or_update_reservation( except ValueError as exc: raise ValueError("reservation_id must be in valid UUID format") from exc - phone_numbers = {} + phone_numbers: Dict[str, Optional[AvailablePhoneNumber]] = {} if numbers_to_add: for number in numbers_to_add: - phone_numbers[number.id] = number + if number.id is not None: + phone_numbers[number.id] = number if numbers_to_remove: - for number in numbers_to_remove: - phone_numbers[number] = None + for number_id in numbers_to_remove: + phone_numbers[number_id] = None - reservation = PhoneNumbersReservation(phone_numbers=phone_numbers) + # Cast to satisfy type checker - merge-patch operations allow None values + reservation = PhoneNumbersReservation( + phone_numbers=cast(Optional[Dict[str, AvailablePhoneNumber]], phone_numbers)) return self._phone_number_client.phone_numbers.create_or_update_reservation( reservation_id, reservation, **kwargs) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py index baac0e9e416b..61c8aa3b31be 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- # pylint: disable=docstring-keyword-should-match-keyword-only -from typing import List, Optional, Union, Any +from typing import List, Optional, Union, Any, cast, Dict import uuid from azure.core.credentials_async import AsyncTokenCredential @@ -99,7 +99,7 @@ def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "PhoneNumbersCl """ endpoint, access_key = parse_connection_str(conn_str) - return cls(endpoint, access_key, **kwargs) + return cls(endpoint, AzureKeyCredential(access_key), **kwargs) @distributed_trace_async async def begin_purchase_phone_numbers( @@ -268,7 +268,10 @@ def list_purchased_phone_numbers(self, **kwargs: Any) -> AsyncItemPaged[Purchase ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.PurchasedPhoneNumber] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_phone_numbers(**kwargs) + return cast( + AsyncItemPaged[PurchasedPhoneNumber], + self._phone_number_client.phone_numbers.list_phone_numbers(**kwargs) + ) @distributed_trace def list_available_countries(self, **kwargs: Any) -> AsyncItemPaged[PhoneNumberCountry]: @@ -284,8 +287,11 @@ def list_available_countries(self, **kwargs: Any) -> AsyncItemPaged[PhoneNumberC ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.PhoneNumberCountry] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_available_countries( - accept_language=self._accepted_language, **kwargs + return cast( + AsyncItemPaged[PhoneNumberCountry], + self._phone_number_client.phone_numbers.list_available_countries( + accept_language=self._accepted_language, **kwargs + ) ) @distributed_trace @@ -307,12 +313,15 @@ def list_available_localities(self, country_code: str, **kwargs: Any) -> AsyncIt ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.PhoneNumberLocality] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_available_localities( - country_code, - administrative_division=kwargs.pop( - "administrative_division", None), - accept_language=self._accepted_language, - **kwargs + return cast( + AsyncItemPaged[PhoneNumberLocality], + self._phone_number_client.phone_numbers.list_available_localities( + country_code, + administrative_division=kwargs.pop( + "administrative_division", None), + accept_language=self._accepted_language, + **kwargs + ) ) @distributed_trace @@ -337,12 +346,12 @@ def list_available_offerings(self, country_code: str, **kwargs: Any) -> AsyncIte ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.PhoneNumberOffering] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_offerings( + return cast(AsyncItemPaged[PhoneNumberOffering], self._phone_number_client.phone_numbers.list_offerings( country_code, phone_number_type=kwargs.pop("phone_number_type", None), assignment_type=kwargs.pop("assignment_type", None), **kwargs - ) + )) @distributed_trace def list_available_area_codes( @@ -371,7 +380,7 @@ def list_available_area_codes( :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.PhoneNumberAreaCode] :raises ~azure.core.exceptions.HttpResponseError: """ - return self._phone_number_client.phone_numbers.list_area_codes( + return cast(AsyncItemPaged[PhoneNumberAreaCode], self._phone_number_client.phone_numbers.list_area_codes( country_code, phone_number_type=phone_number_type, assignment_type=kwargs.pop("assignment_type", None), @@ -379,7 +388,7 @@ def list_available_area_codes( administrative_division=kwargs.pop( "administrative_division", None), **kwargs - ) + )) @distributed_trace_async async def search_operator_information( @@ -451,9 +460,9 @@ def list_reservations( ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.PhoneNumbersReservation] """ - return self._phone_number_client.phone_numbers.list_reservations( + return cast(AsyncItemPaged[PhoneNumbersReservation], self._phone_number_client.phone_numbers.list_reservations( max_page_size=max_page_size, - **kwargs) + **kwargs)) @distributed_trace_async async def create_or_update_reservation( @@ -489,15 +498,18 @@ async def create_or_update_reservation( except ValueError as exc: raise ValueError("reservation_id must be in valid UUID format") from exc - phone_numbers = {} + phone_numbers: Dict[str, Optional[AvailablePhoneNumber]] = {} if numbers_to_add: for number in numbers_to_add: - phone_numbers[number.id] = number + if number.id is not None: + phone_numbers[number.id] = number if numbers_to_remove: - for number in numbers_to_remove: - phone_numbers[number] = None + for number_id in numbers_to_remove: + phone_numbers[number_id] = None - reservation = PhoneNumbersReservation(phone_numbers=phone_numbers) + # Cast to satisfy type checker - merge-patch operations allow None values + reservation = PhoneNumbersReservation( + phone_numbers=cast(Optional[Dict[str, AvailablePhoneNumber]], phone_numbers)) return await self._phone_number_client.phone_numbers.create_or_update_reservation( reservation_id, reservation, **kwargs diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_patch.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_patch.py index 17dbc073e01b..04a7dde0a435 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_patch.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_patch.py @@ -28,5 +28,8 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md + +__all__: list[str] = [] + def patch_sdk(): pass diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/aio/_patch.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/aio/_patch.py index 17dbc073e01b..472e4cca0a6b 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/aio/_patch.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/aio/_patch.py @@ -26,6 +26,9 @@ # -------------------------------------------------------------------------- +__all__: list[str] = [] + + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py index adcc74e1d191..d233bec4dc86 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py @@ -4,11 +4,12 @@ # license information. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, List, Any +from typing import TYPE_CHECKING, List, Any, Union, cast, Dict from urllib.parse import urlparse from azure.core.tracing.decorator import distributed_trace from azure.core.paging import ItemPaged +from azure.core.credentials import AzureKeyCredential from ._models import SipTrunk, SipTrunkRoute from ._generated.models import SipConfiguration, SipTrunkInternal, SipTrunkRouteInternal @@ -28,7 +29,7 @@ class SipRoutingClient(object): :param endpoint: The endpoint url for Azure Communication Service resource. :type endpoint: str :param credential: The credentials with which to authenticate. - :type credential: TokenCredential + :type credential: Union[TokenCredential, AzureKeyCredential, str] :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str @@ -36,7 +37,7 @@ class SipRoutingClient(object): def __init__( self, endpoint: str, - credential: "TokenCredential", + credential: Union["TokenCredential", AzureKeyCredential, str], **kwargs: Any ) -> None: @@ -93,6 +94,12 @@ def get_trunk( config = self._rest_service.sip_routing.get(**kwargs) + if config.trunks is None: + raise KeyError("No SIP trunks are configured.") + + if trunk_fqdn not in config.trunks: + raise KeyError(f"Trunk with FQDN '{trunk_fqdn}' not found.") + trunk = config.trunks[trunk_fqdn] return SipTrunk(fqdn=trunk_fqdn, sip_signaling_port=trunk.sip_signaling_port) @@ -132,7 +139,10 @@ def delete_trunk( if trunk_fqdn is None: raise ValueError("Parameter 'trunk_fqdn' must not be None.") - self._rest_service.sip_routing.update(body=SipConfiguration(trunks={trunk_fqdn: None}), **kwargs) + # Note: The API accepts None values in the trunks dict to indicate deletion + # but the type annotation doesn't reflect this. We use cast to work around this. + trunks_dict = cast("Dict[str, SipTrunkInternal]", {trunk_fqdn: None}) + self._rest_service.sip_routing.update(body=SipConfiguration(trunks=trunks_dict), **kwargs) @distributed_trace def list_trunks( @@ -147,7 +157,13 @@ def list_trunks( """ def extract_data(config): - list_of_elem = [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in config.trunks.items()] + if config.trunks is None: + list_of_elem = [] + else: + list_of_elem = [ + SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) + for k, v in config.trunks.items() + ] return None, list_of_elem # pylint: disable=unused-argument @@ -169,10 +185,18 @@ def list_routes( """ def extract_data(config): - list_of_elem = [ - SipTrunkRoute(description=x.description, name=x.name, number_pattern=x.number_pattern, trunks=x.trunks) - for x in config.routes - ] + if config.routes is None: + list_of_elem = [] + else: + list_of_elem = [ + SipTrunkRoute( + description=x.description, + name=x.name, + number_pattern=x.number_pattern, + trunks=x.trunks + ) + for x in config.routes + ] return None, list_of_elem # pylint: disable=unused-argument @@ -205,9 +229,13 @@ def set_trunks( for x in old_trunks: if x.fqdn not in [o.fqdn for o in trunks]: - config.trunks[x.fqdn] = None + if config.trunks is not None: + # Note: The API accepts None values in the trunks dict to indicate deletion + # but the type annotation doesn't reflect this. We use cast to work around this. + trunk_dict = cast(Dict[str, Any], config.trunks) + trunk_dict[x.fqdn] = None - if len(config.trunks) > 0: + if config.trunks is not None and len(config.trunks) > 0: self._rest_service.sip_routing.update(body=config, **kwargs) @distributed_trace @@ -237,6 +265,8 @@ def set_routes( def _list_trunks_(self, **kwargs: Any) -> List[SipTrunk]: config = self._rest_service.sip_routing.get(**kwargs) + if config.trunks is None: + return [] return [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in config.trunks.items()] def _update_trunks_( @@ -248,6 +278,8 @@ def _update_trunks_( modified_config = SipConfiguration(trunks=trunks_internal) new_config = self._rest_service.sip_routing.update(body=modified_config, **kwargs) + if new_config.trunks is None: + return [] return [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in new_config.trunks.items()] def close(self) -> None: diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py index 4004f3dc469c..f40a4c5d299a 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py @@ -4,10 +4,11 @@ # license information. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, List, Any +from typing import TYPE_CHECKING, List, Any, Union, cast, Dict from urllib.parse import urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.credentials import AzureKeyCredential from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async @@ -30,7 +31,7 @@ class SipRoutingClient(object): :param endpoint: The endpoint url for Azure Communication Service resource. :type endpoint: str :param credential: The credentials with which to authenticate. - :type credential: AsyncTokenCredential + :type credential: Union[AsyncTokenCredential, AzureKeyCredential, str] :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str @@ -39,7 +40,7 @@ class SipRoutingClient(object): def __init__( self, endpoint: str, - credential: "AsyncTokenCredential", + credential: Union["AsyncTokenCredential", AzureKeyCredential, str], **kwargs: Any ) -> None: @@ -98,6 +99,12 @@ async def get_trunk( config = await self._rest_service.sip_routing.get(**kwargs) + if config.trunks is None: + raise KeyError("No SIP trunks are configured.") + + if trunk_fqdn not in config.trunks: + raise KeyError(f"Trunk with FQDN '{trunk_fqdn}' not found.") + trunk = config.trunks[trunk_fqdn] return SipTrunk(fqdn=trunk_fqdn, sip_signaling_port=trunk.sip_signaling_port) @@ -137,7 +144,10 @@ async def delete_trunk( if trunk_fqdn is None: raise ValueError("Parameter 'trunk_fqdn' must not be None.") - await self._rest_service.sip_routing.update(body=SipConfiguration(trunks={trunk_fqdn: None}), **kwargs) + # Note: The API accepts None values in the trunks dict to indicate deletion + # but the type annotation doesn't reflect this. We use cast to work around this. + trunks_dict = cast("Dict[str, SipTrunkInternal]", {trunk_fqdn: None}) + await self._rest_service.sip_routing.update(body=SipConfiguration(trunks=trunks_dict), **kwargs) @distributed_trace def list_trunks( @@ -152,7 +162,13 @@ def list_trunks( """ async def extract_data(config): - list_of_elem = [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in config.trunks.items()] + if config.trunks is None: + list_of_elem = [] + else: + list_of_elem = [ + SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) + for k, v in config.trunks.items() + ] return None, AsyncList(list_of_elem) # pylint: disable=unused-argument @@ -174,10 +190,18 @@ def list_routes( """ async def extract_data(config): - list_of_elem = [ - SipTrunkRoute(description=x.description, name=x.name, number_pattern=x.number_pattern, trunks=x.trunks) - for x in config.routes - ] + if config.routes is None: + list_of_elem = [] + else: + list_of_elem = [ + SipTrunkRoute( + description=x.description, + name=x.name, + number_pattern=x.number_pattern, + trunks=x.trunks + ) + for x in config.routes + ] return None, AsyncList(list_of_elem) # pylint: disable=unused-argument @@ -210,9 +234,13 @@ async def set_trunks( for x in old_trunks: if x.fqdn not in [o.fqdn for o in trunks]: - config.trunks[x.fqdn] = None + if config.trunks is not None: + # Note: The API accepts None values in the trunks dict to indicate deletion + # but the type annotation doesn't reflect this. We use cast to work around this. + trunk_dict = cast(Dict[str, Any], config.trunks) + trunk_dict[x.fqdn] = None - if len(config.trunks) > 0: + if config.trunks is not None and len(config.trunks) > 0: await self._rest_service.sip_routing.update(body=config, **kwargs) @distributed_trace_async @@ -242,17 +270,21 @@ async def set_routes( async def _list_trunks_(self, **kwargs: Any): config = await self._rest_service.sip_routing.get(**kwargs) + if config.trunks is None: + return [] return [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in config.trunks.items()] async def _update_trunks_( self, trunks: List[SipTrunk], **kwargs: Any - ) -> SipTrunk: + ) -> List[SipTrunk]: trunks_internal = {x.fqdn: SipTrunkInternal(sip_signaling_port=x.sip_signaling_port) for x in trunks} modified_config = SipConfiguration(trunks=trunks_internal) new_config = await self._rest_service.sip_routing.update(body=modified_config, **kwargs) + if new_config.trunks is None: + return [] return [SipTrunk(fqdn=k, sip_signaling_port=v.sip_signaling_port) for k, v in new_config.trunks.items()] async def close(self) -> None: diff --git a/sdk/communication/azure-communication-phonenumbers/pyproject.toml b/sdk/communication/azure-communication-phonenumbers/pyproject.toml index 05ee5668ed6a..f51cbbbb7407 100644 --- a/sdk/communication/azure-communication-phonenumbers/pyproject.toml +++ b/sdk/communication/azure-communication-phonenumbers/pyproject.toml @@ -1,4 +1,2 @@ [tool.azure-sdk-build] -mypy = false -pyright = false -type_check_samples = false +pyright = false \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py index 172a5fd5f166..68b836e160d9 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py @@ -22,7 +22,7 @@ import uuid from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string( connection_str) @@ -49,13 +49,16 @@ def browse_and_reserve_numbers_bulk(): ) # Check if any errors occurred during reservation - numbers_with_error = [ - n for n in reservation.phone_numbers.values() if n.status == "error"] + if reservation.phone_numbers: + numbers_with_error = [ + n for n in reservation.phone_numbers.values() if n.status == "error"] if any(numbers_with_error): print("Errors occurred during reservation:") for number in numbers_with_error: + error_code = number.error.code if number.error and number.error.code else "Unknown" + error_message = number.error.message if number.error and number.error.message else "Unknown error" print( - f"Phone number: {number.phone_number}, Error: {number.error.code}, Message: {number.error.message}") + f"Phone number: {number.phone_number}, Error: {error_code}, Message: {error_message}") else: print("Reservation operation completed without errors.") diff --git a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py index ce0995aa392f..163a3260efe0 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py @@ -23,7 +23,7 @@ import uuid from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string( connection_str) @@ -50,13 +50,16 @@ async def browse_and_reserve_numbers_bulk(): ) # Check if any errors occurred during reservation - numbers_with_error = [ - n for n in reservation.phone_numbers.values() if n.status == "error"] + if reservation.phone_numbers: + numbers_with_error = [ + n for n in reservation.phone_numbers.values() if n.status == "error"] if any(numbers_with_error): print("Errors occurred during reservation:") for number in numbers_with_error: + error_code = number.error.code if number.error and number.error.code else "Unknown" + error_message = number.error.message if number.error and number.error.message else "Unknown error" print( - f"Phone number: {number.phone_number}, Error: {number.error.code}, Message: {number.error.message}") + f"Phone number: {number.phone_number}, Error: {error_code}, Message: {error_message}") else: print("Reservation operation completed without errors.") diff --git a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py index 336c4bbdec6b..adc34dba960a 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py @@ -22,7 +22,7 @@ import uuid from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string( connection_str) @@ -45,13 +45,16 @@ def browse_and_reserve_phone_numbers(): ) # Check if any errors occurred during reservation - numbers_with_error = [ - n for n in reservation.phone_numbers.values() if n.status == "error"] + if reservation.phone_numbers: + numbers_with_error = [ + n for n in reservation.phone_numbers.values() if n.status == "error"] if any(numbers_with_error): print("Errors occurred during reservation:") for number in numbers_with_error: + error_code = number.error.code if number.error and number.error.code else "Unknown" + error_message = number.error.message if number.error and number.error.message else "Unknown error" print( - f"Phone number: {number.phone_number}, Error: {number.error.code}, Message: {number.error.message}") + f"Phone number: {number.phone_number}, Error: {error_code}, Message: {error_message}") else: print("Reservation operation completed without errors.") diff --git a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py index d038b7449806..ad5aef41ad96 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py @@ -23,7 +23,7 @@ import uuid from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string( connection_str) @@ -46,13 +46,16 @@ async def browse_and_reserve_phone_numbers(): ) # Check if any errors occurred during reservation - numbers_with_error = [ - n for n in reservation.phone_numbers.values() if n.status == "error"] - if any(numbers_with_error): + if reservation.phone_numbers: + numbers_with_error = [ + n for n in reservation.phone_numbers.values() if n.status == "error"] + if reservation.phone_numbers and any(numbers_with_error): print("Errors occurred during reservation:") for number in numbers_with_error: + error_code = number.error.code if number.error and number.error.code else "Unknown" + error_message = number.error.message if number.error and number.error.message else "Unknown error" print( - f"Phone number: {number.phone_number}, Error: {number.error.code}, Message: {number.error.message}") + f"Phone number: {number.phone_number}, Error: {error_code}, Message: {error_message}") else: print("Reservation operation completed without errors.") diff --git a/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample.py index ee5accf442d5..4d57dcfa5563 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample.py @@ -21,8 +21,8 @@ import os from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number = os.getenv("AZURE_PHONE_NUMBER") # e.g. "+18001234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number = os.environ["AZURE_PHONE_NUMBER"] # e.g. "+18001234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample_async.py index 1d5cf6cbe1fe..2aec5e7c227d 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/get_purchased_phone_number_sample_async.py @@ -22,8 +22,8 @@ import os from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number = os.getenv("AZURE_PHONE_NUMBER") # e.g. "+18001234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number = os.environ["AZURE_PHONE_NUMBER"] # e.g. "+18001234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample.py index d9e25d9f2b9f..be1a892de1f3 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample.py @@ -20,7 +20,7 @@ import os from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample_async.py index 606f8241bdd9..dce6df0af8a3 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/list_purchased_phone_numbers_sample_async.py @@ -21,7 +21,7 @@ import os from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/managed_identity_authentication_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/managed_identity_authentication_sample.py index 506083340554..205bef9b2240 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/managed_identity_authentication_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/managed_identity_authentication_sample.py @@ -24,7 +24,7 @@ from azure.communication.phonenumbers._shared.utils import parse_connection_str from azure.identity import DefaultAzureCredential -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] endpoint, _ = parse_connection_str(connection_str) phone_numbers_client = PhoneNumbersClient(endpoint, DefaultAzureCredential()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample.py index 320383080756..debccf88b602 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample.py @@ -22,8 +22,8 @@ import os from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -search_id = os.getenv("AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +search_id = os.environ["AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample_async.py index 22a61e2eecb9..0228f0dcc139 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample_async.py @@ -23,8 +23,8 @@ import os from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -search_id = os.getenv("AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +search_id = os.environ["AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample.py index 2cdd28b8aec2..9a7d31a080d9 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample.py @@ -21,8 +21,8 @@ import os from azure.communication.phonenumbers import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number_to_release = os.getenv("AZURE_PHONE_NUMBER_TO_RELEASE") # e.g. "+18001234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number_to_release = os.environ["AZURE_PHONE_NUMBER_TO_RELEASE"] # e.g. "+18001234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample_async.py index f031dc8ee1d7..160fafe7f610 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample_async.py @@ -22,8 +22,8 @@ import os from azure.communication.phonenumbers.aio import PhoneNumbersClient -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number_to_release = os.getenv("AZURE_PHONE_NUMBER_TO_RELEASE") # e.g. "+18001234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number_to_release = os.environ["AZURE_PHONE_NUMBER_TO_RELEASE"] # e.g. "+18001234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample.py index d8b02dac69be..bfebf08c27d7 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample.py @@ -26,7 +26,7 @@ PhoneNumberCapabilityType, ) -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample_async.py index 829c5d7efabc..3fc291885095 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample_async.py @@ -27,7 +27,7 @@ PhoneNumberCapabilityType, ) -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample.py index 65faec66e44c..58084d6fc5e2 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample.py @@ -20,12 +20,12 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) def delete_sip_trunk_sample(): - trunk_fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") + trunk_fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] client.delete_trunk(trunk_fqdn) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample_async.py index ac1ac9efcbc1..136707816085 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/delete_sip_trunk_sample_async.py @@ -21,12 +21,12 @@ import asyncio from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) async def delete_sip_trunk_sample(): - trunk_fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") + trunk_fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] async with client: await client.delete_trunk(trunk_fqdn) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample.py index b38e671fd2fe..3eaf1de0c836 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample.py @@ -19,7 +19,7 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample_async.py index 53229e227be5..3771a26ec657 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_routes_sample_async.py @@ -20,7 +20,7 @@ import asyncio from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample.py index 7d6be24d1b92..e46877c04fdd 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample.py @@ -20,12 +20,12 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) def get_sip_trunk_sample(): - trunk_fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") + trunk_fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] try: sip_trunk = client.get_trunk(trunk_fqdn) print(sip_trunk.fqdn) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample_async.py index 91de0e05fa80..3c33e46eb513 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunk_sample_async.py @@ -21,12 +21,12 @@ import asyncio from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) async def get_sip_trunk_sample(): - trunk_fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") + trunk_fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] try: async with client: sip_trunk = await client.get_trunk(trunk_fqdn) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample.py index ce7030b9e9fd..87a5d96ccdb0 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample.py @@ -19,7 +19,7 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample_async.py index 54c5fbdad0fa..20bb47de6801 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/get_sip_trunks_sample_async.py @@ -20,7 +20,7 @@ import asyncio from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample.py index c72c2cfacae1..1f599724cd18 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample.py @@ -24,7 +24,7 @@ name="First rule", description="Handle numbers starting with '+123'", number_pattern="\+123[0-9]+", trunks=[] ) ] -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample_async.py index 1f6938aec437..f9f317aa4326 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_routes_sample_async.py @@ -26,7 +26,7 @@ name="First rule", description="Handle numbers starting with '+123'", number_pattern="\+123[0-9]+", trunks=[] ) ] -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample.py index cd6fe6f837ac..c52419a3a01d 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample.py @@ -21,9 +21,9 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient, SipTrunk -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") -signaling_port = os.getenv("COMMUNICATION_SAMPLES_SIGNALING_PORT") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] +signaling_port = os.environ["COMMUNICATION_SAMPLES_SIGNALING_PORT"] client = SipRoutingClient.from_connection_string(connection_string) new_trunk = SipTrunk(fqdn=fqdn, sip_signaling_port=signaling_port) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample_async.py index 3b9f28ad62a1..867810f77f24 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunk_sample_async.py @@ -23,9 +23,9 @@ from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient from azure.communication.phonenumbers.siprouting import SipTrunk -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") -signaling_port = os.getenv("COMMUNICATION_SAMPLES_SIGNALING_PORT") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] +signaling_port = os.environ["COMMUNICATION_SAMPLES_SIGNALING_PORT"] client = SipRoutingClient.from_connection_string(connection_string) new_trunk = SipTrunk(fqdn=fqdn, sip_signaling_port=signaling_port) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample.py index 6d1beae587dc..254ef2aab9e3 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample.py @@ -21,10 +21,10 @@ import os from azure.communication.phonenumbers.siprouting import SipRoutingClient, SipTrunk -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) -fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") -signaling_port = os.getenv("COMMUNICATION_SAMPLES_SIGNALING_PORT") +fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] +signaling_port = os.environ["COMMUNICATION_SAMPLES_SIGNALING_PORT"] TRUNKS = [SipTrunk(fqdn=fqdn, sip_signaling_port=signaling_port)] diff --git a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample_async.py index 8d8714f0a28c..556d99d6ed3e 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/siprouting/set_sip_trunks_sample_async.py @@ -23,10 +23,10 @@ from azure.communication.phonenumbers.siprouting.aio import SipRoutingClient from azure.communication.phonenumbers.siprouting import SipTrunk -connection_string = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") +connection_string = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] client = SipRoutingClient.from_connection_string(connection_string) -fqdn = os.getenv("COMMUNICATION_SAMPLES_TRUNK_FQDN") -signaling_port = os.getenv("COMMUNICATION_SAMPLES_SIGNALING_PORT") +fqdn = os.environ["COMMUNICATION_SAMPLES_TRUNK_FQDN"] +signaling_port = os.environ["COMMUNICATION_SAMPLES_SIGNALING_PORT"] TRUNKS = [SipTrunk(fqdn=fqdn, sip_signaling_port=signaling_port)] diff --git a/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample.py index e5bd584f3104..0747742b14c9 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample.py @@ -21,8 +21,8 @@ import os from azure.communication.phonenumbers import PhoneNumbersClient, PhoneNumberCapabilityType -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number_to_update = os.getenv("AZURE_PHONE_NUMBER") # e.g. "+15551234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number_to_update = os.environ["AZURE_PHONE_NUMBER"] # e.g. "+15551234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample_async.py index ebfef32512c7..44fec057fe78 100644 --- a/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample_async.py +++ b/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample_async.py @@ -23,8 +23,8 @@ from azure.communication.phonenumbers.aio import PhoneNumbersClient from azure.communication.phonenumbers import PhoneNumberCapabilityType -connection_str = os.getenv("COMMUNICATION_SAMPLES_CONNECTION_STRING") -phone_number_to_update = os.getenv("AZURE_PHONE_NUMBER") # e.g. "+15551234567" +connection_str = os.environ["COMMUNICATION_SAMPLES_CONNECTION_STRING"] +phone_number_to_update = os.environ["AZURE_PHONE_NUMBER"] # e.g. "+15551234567" phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str)