diff --git a/sdk/communication/azure-communication-phonenumbers/README.md b/sdk/communication/azure-communication-phonenumbers/README.md index b5b61a40139b..0c75a7bce28f 100644 --- a/sdk/communication/azure-communication-phonenumbers/README.md +++ b/sdk/communication/azure-communication-phonenumbers/README.md @@ -16,153 +16,129 @@ Install the Azure Communication Phone Numbers client library for Python with [pi pip install azure-communication-phonenumbers ``` -# Key concepts +## Key concepts -## CommunicationPhoneNumberClient ### Initializing Phone Numbers Client ```python -# You can find your endpoint and access token from your resource in the Azure Portal +# You can find your connection string from your resource in the Azure Portal import os -from azure.communication.phonenumbers import PhoneNumbersAdministrationClient +from azure.communication.phonenumbers import PhoneNumbersClient from azure.identity import DefaultAzureCredential -endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') +endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') # To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have your # AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables. phone_number_administration_client = PhoneNumbersAdministrationClient(endpoint, DefaultAzureCredential()) ``` -### Initializing Phone Numbers Client Using Connection String +### Initializing the Client Using Your Connection String Connection string authentication is also available for Phone Numbers Client. ```python -# You can find your endpoint and access token from your resource in the Azure Portal +# You can find your connection string from your resource in the Azure Portal import os -from azure.communication.phonenumbers import PhoneNumbersAdministrationClient +from azure.communication.phonenumbers import PhoneNumbersClient connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) ``` -### Phone plans overview +### Phone Number Types overview -Phone plans come in two types; Geographic and Toll-Free. Geographic phone plans are phone plans associated with a location, whose phone numbers' area codes are associated with the area code of a geographic location. Toll-Free phone plans are phone plans not associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888. +Phone numbers come in two types; Geographic and Toll-Free. Geographic phone numbers are phone numbers associated with a location, whose area codes are associated with the area code of a geographic location. Toll-Free phone numbers are phone numbers with no associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888. -All geographic phone plans within the same country are grouped into a phone plan group with a Geographic phone number type. All Toll-Free phone plans within the same country are grouped into a phone plan group. +### Searching and Purchasing and Releasing numbers -### Reserving and Acquiring numbers +Phone numbers can be searched through the search creation API by providing an area code, quantity of phone numbers, application type, phone number type, and capabilities. The provided quantity of phone numbers will be reserved for ten minutes and can be purchased within this time. If the search is not purchased, the phone numbers will become available to others after ten minutes. If the search is purchased, then the phone numbers are acquired for the Azure resources. -Phone numbers can be reserved through the begin_reserve_phone_numbers API by providing a phone plan id, an area code and quantity of phone numbers. The provided quantity of phone numbers will be reserved for ten minutes. This reservation of phone numbers can either be cancelled or purchased. If the reservation is cancelled, then the phone numbers will become available to others. If the reservation is purchased, then the phone numbers are acquired for the Azure resources. +Phone numbers can also be released using the release API. -### Configuring / Assigning numbers +## Examples -Phone numbers can be assigned to a callback URL via the configure number API. As part of the configuration, you will need an acquired phone number, callback URL and application id. +### Get All Phone Numbers -# Examples -The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including: - -## Communication Phone number -### Get Countries +Lists all of your acquired phone numbers ```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -supported_countries = phone_number_administration_client.list_all_supported_countries() -for supported_country in supported_countries: - print(supported_country) +acquired_phone_numbers = phone_numbers_client.list_acquired_phone_numbers() +acquired_phone_number = acquired_phone_numbers.next() +print(acquired_phone_number.phone_number) ``` -### Get Phone Plan Groups +### Get Phone Number -Phone plan groups come in two types, Geographic and Toll-Free. +Gets the information from the specified phone number ```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups( - country_code='' -) -for phone_plan_group in phone_plan_groups_response: - print(phone_plan_group) +result = phone_numbers_client.get_phone_number("") +print(result.country_code) +print(result.phone_number) ``` -### Get Phone Plans +## Long Running Operations -Unlike Toll-Free phone plans, area codes for Geographic Phone Plans are empty. Area codes are found in the Area Codes API. +The Phone Number Client supports a variety of long running operations that allow indefinite polling time to the functions listed down below. -```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -phone_plans_response = phone_number_administration_client.list_phone_plans( - country_code='', - phone_plan_group_id='' -) -for phone_plan in phone_plans_response: - print(phone_plan) -``` - -### Get Location Options +### Search for Available Phone Number -For Geographic phone plans, you can query the available geographic locations. The locations options are structured like the geographic hierarchy of a country. For example, the US has states and within each state are cities. +You can search for available phone numbers by providing the capabilities of the phone you want to acquire, the phone number type, the assignment type, and the country code. It's worth mentioning that for the toll-free phone number type, proving the area code is optional. +The result of the search can then be used to purchase the number in the corresponding API. ```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -location_options_response = phone_number_administration_client.get_phone_plan_location_options( - country_code='', - phone_plan_group_id='', - phone_plan_id='' +capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND + ) +poller = phone_numbers_client.begin_search_available_phone_numbers( + "US", + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + area_code ="833", # Area code is optional for toll-free numbers + quantity = 2, # Quantity is optional. If not set, default is 1 + polling = True ) -print(location_options_response) +search_result = poller.result() ``` -### Get Area Codes +### Purchase Phone Numbers -Fetching area codes for geographic phone plans will require the the location options queries set. You must include the chain of geographic locations traversing down the location options object returned by the GetLocationOptions API. +The result of your search can be used to purchase the specificied phone numbers. This can be done by passing the `search_id` from the search response to the purchase phone number API. ```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -all_area_codes = phone_number_administration_client.get_all_area_codes( - location_type="NotRequired", - country_code='', - phone_plan_id='' +purchase_poller = phone_numbers_client.begin_purchase_phone_numbers( + search_result.search_id, + polling=True ) -print(all_area_codes) ``` -### Create Reservation +### Release Phone Number -```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) +Releases an acquired phone number. -poller = phone_number_administration_client.begin_reserve_phone_numbers( - area_code='', - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[''], - quantity=1 +```python +poller = self.phone_number_client.begin_release_phone_number( + "", + polling = True ) ``` -### Get Reservation By Id -```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) +### Updating Phone Number Capabilities -phone_number_reservation_response = phone_number_administration_client.get_reservation_by_id( - reservation_id='' -) -print(reservation_id) -``` +Updates the specified phone number capabilities for Calling and SMS to one of: -### Purchase Reservation +- `PhoneNumberCapabilityType.NONE` +- `PhoneNumberCapabilityType.INBOUND` +- `PhoneNumberCapabilityType.OUTBOUND` +- `PhoneNumberCapabilityType.INBOUND_OUTBOUND` ```python -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - -poller = phone_number_administration_client.begin_purchase_reservation( - reservation_id='' +poller = self.phone_number_client.begin_update_phone_number_capabilities( + "", + PhoneNumberCapabilityType.OUTBOUND, + PhoneNumberCapabilityType.INBOUND_OUTBOUND, + polling = True ) ``` diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/__init__.py index 6916913f8dcd..f9c3de4f04b4 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/__init__.py @@ -4,66 +4,27 @@ # license information. # -------------------------------------------------------------------------- -from ._phone_number_administration_client import PhoneNumbersAdministrationClient -from ._polling import ReservePhoneNumberPolling, PurchaseReservationPolling, ReleasePhoneNumberPolling +from ._phone_numbers_client import PhoneNumbersClient from ._generated.models import ( AcquiredPhoneNumber, - AcquiredPhoneNumbers, - AreaCodes, - CreateSearchOptions, - CreateSearchResponse, - LocationOptionsQuery, - LocationOptionsResponse, - NumberConfigurationResponse, - NumberUpdateCapabilities, - PhoneNumberCountries, - PhoneNumberEntities, - PhoneNumberRelease, - PhoneNumberReservation, - PhonePlanGroups, - PhonePlansResponse, - PstnConfiguration, - ReleaseResponse, - UpdateNumberCapabilitiesResponse, - UpdatePhoneNumberCapabilitiesResponse -) - -from ._shared.models import ( - CommunicationUserIdentifier, - PhoneNumberIdentifier, - UnknownIdentifier + PhoneNumberCapabilities, + PhoneNumberCost, + PhoneNumberSearchResult, + BillingFrequency, + PhoneNumberAssignmentType, + PhoneNumberCapabilityType, + PhoneNumberType, ) __all__ = [ - 'PhoneNumbersAdministrationClient', - 'ReservePhoneNumberPolling', - 'PurchaseReservationPolling', - 'ReleasePhoneNumberPolling', - - # from _phonenumber 'AcquiredPhoneNumber', - 'AcquiredPhoneNumbers', - 'AreaCodes', - 'CreateSearchOptions', - 'CreateSearchResponse', - 'LocationOptionsQuery', - 'LocationOptionsResponse', - 'NumberConfigurationResponse', - 'NumberUpdateCapabilities', - 'PhoneNumberCountries', - 'PhoneNumberEntities', - 'PhoneNumberRelease', - 'PhoneNumberReservation', - 'PhonePlanGroups', - 'PhonePlansResponse', - 'PstnConfiguration', - 'ReleaseResponse', - 'UpdateNumberCapabilitiesResponse', - 'UpdatePhoneNumberCapabilitiesResponse', - - # from _shared - 'CommunicationUserIdentifier', - 'PhoneNumberIdentifier', - 'UnknownIdentifier' + 'PhoneNumberCapabilities', + 'PhoneNumberCost', + 'PhoneNumberSearchResult', + 'BillingFrequency', + 'PhoneNumberAssignmentType', + 'PhoneNumberCapabilityType', + 'PhoneNumberType', + 'PhoneNumbersClient' ] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/__init__.py index 13fcd7af35ce..abbd9c6a0b97 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/__init__.py @@ -6,8 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_service import PhoneNumberAdministrationService -__all__ = ['PhoneNumberAdministrationService'] +from ._phone_numbers_client import PhoneNumbersClient +__all__ = ['PhoneNumbersClient'] try: from ._patch import patch_sdk # type: ignore diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_configuration.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_configuration.py index 2043f061b4f2..6905dc676488 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_configuration.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_configuration.py @@ -17,13 +17,13 @@ VERSION = "unknown" -class PhoneNumberAdministrationServiceConfiguration(Configuration): - """Configuration for PhoneNumberAdministrationService. +class PhoneNumbersClientConfiguration(Configuration): + """Configuration for PhoneNumbersClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: The endpoint of the Azure Communication resource. + :param endpoint: The communication resource, for example https://resourcename.communication.azure.com. :type endpoint: str """ @@ -35,11 +35,11 @@ def __init__( # type: (...) -> None if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + super(PhoneNumbersClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2020-07-20-preview1" - kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + self.api_version = "2021-03-07" + kwargs.setdefault('sdk_moniker', 'phonenumbersclient/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_number_administration_service.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_number_administration_service.py deleted file mode 100644 index 3afc61f3ec81..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_number_administration_service.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -from ._configuration import PhoneNumberAdministrationServiceConfiguration -from .operations import PhoneNumberAdministrationOperations -from . import models - - -class PhoneNumberAdministrationService(object): - """Phone Number Administration Service. - - :ivar phone_number_administration: PhoneNumberAdministrationOperations operations - :vartype phone_number_administration: azure.communication.phonenumbers.operations.PhoneNumberAdministrationOperations - :param endpoint: The endpoint of the Azure Communication resource. - :type endpoint: str - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = '{endpoint}' - self._config = PhoneNumberAdministrationServiceConfiguration(endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.phone_number_administration = PhoneNumberAdministrationOperations( - self._client, self._config, self._serialize, self._deserialize) - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> PhoneNumberAdministrationService - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_numbers_client.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_numbers_client.py new file mode 100644 index 000000000000..2d8d55386d92 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_numbers_client.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import PhoneNumbersClientConfiguration +from .operations import PhoneNumbersOperations +from . import models + + +class PhoneNumbersClient(object): + """The phone numbers client uses Azure Communication Services to acquire and manage phone numbers. + + :ivar phone_numbers: PhoneNumbersOperations operations + :vartype phone_numbers: azure.communication.phonenumbers.operations.PhoneNumbersOperations + :param endpoint: The communication resource, for example https://resourcename.communication.azure.com. + :type endpoint: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + endpoint, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = '{endpoint}' + self._config = PhoneNumbersClientConfiguration(endpoint, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.phone_numbers = PhoneNumbersOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PhoneNumbersClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/__init__.py index 385f28a2876a..0f7fab5f7e31 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_service import PhoneNumberAdministrationService -__all__ = ['PhoneNumberAdministrationService'] +from ._phone_numbers_client import PhoneNumbersClient +__all__ = ['PhoneNumbersClient'] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_configuration.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_configuration.py index 7a46556ea91d..92da00d6b71e 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_configuration.py @@ -13,13 +13,13 @@ VERSION = "unknown" -class PhoneNumberAdministrationServiceConfiguration(Configuration): - """Configuration for PhoneNumberAdministrationService. +class PhoneNumbersClientConfiguration(Configuration): + """Configuration for PhoneNumbersClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: The endpoint of the Azure Communication resource. + :param endpoint: The communication resource, for example https://resourcename.communication.azure.com. :type endpoint: str """ @@ -30,11 +30,11 @@ def __init__( ) -> None: if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + super(PhoneNumbersClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2020-07-20-preview1" - kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + self.api_version = "2021-03-07" + kwargs.setdefault('sdk_moniker', 'phonenumbersclient/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_number_administration_service.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_number_administration_service.py deleted file mode 100644 index f737f6de296a..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_number_administration_service.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core import AsyncPipelineClient -from msrest import Deserializer, Serializer - -from ._configuration import PhoneNumberAdministrationServiceConfiguration -from .operations import PhoneNumberAdministrationOperations -from .. import models - - -class PhoneNumberAdministrationService(object): - """Phone Number Administration Service. - - :ivar phone_number_administration: PhoneNumberAdministrationOperations operations - :vartype phone_number_administration: azure.communication.phonenumbers.aio.operations.PhoneNumberAdministrationOperations - :param endpoint: The endpoint of the Azure Communication resource. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - base_url = '{endpoint}' - self._config = PhoneNumberAdministrationServiceConfiguration(endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.phone_number_administration = PhoneNumberAdministrationOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "PhoneNumberAdministrationService": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_numbers_client.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_numbers_client.py new file mode 100644 index 000000000000..f4478bf96aee --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_numbers_client.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core import AsyncPipelineClient +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import PhoneNumbersClientConfiguration +from .operations import PhoneNumbersOperations +from .. import models + + +class PhoneNumbersClient(object): + """The phone numbers client uses Azure Communication Services to acquire and manage phone numbers. + + :ivar phone_numbers: PhoneNumbersOperations operations + :vartype phone_numbers: azure.communication.phonenumbers.aio.operations.PhoneNumbersOperations + :param endpoint: The communication resource, for example https://resourcename.communication.azure.com. + :type endpoint: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + endpoint: str, + **kwargs: Any + ) -> None: + base_url = '{endpoint}' + self._config = PhoneNumbersClientConfiguration(endpoint, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.phone_numbers = PhoneNumbersOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PhoneNumbersClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/__init__.py index 50478d62d8d6..3da9bcb904f3 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/__init__.py @@ -6,8 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_operations import PhoneNumberAdministrationOperations +from ._phone_numbers_operations import PhoneNumbersOperations __all__ = [ - 'PhoneNumberAdministrationOperations', + 'PhoneNumbersOperations', ] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_number_administration_operations.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_number_administration_operations.py deleted file mode 100644 index 60f15bfc4fb5..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_number_administration_operations.py +++ /dev/null @@ -1,1398 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PhoneNumberAdministrationOperations: - """PhoneNumberAdministrationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.phonenumbers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get_all_phone_numbers( - self, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.AcquiredPhoneNumbers"]: - """Gets the list of the acquired phone numbers. - - Gets the list of the acquired phone numbers. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumbers] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumbers"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) - list_of_elem = deserialized.phone_numbers - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_phone_numbers.metadata = {'url': '/administration/phonenumbers/phonenumbers'} # type: ignore - - async def get_all_area_codes( - self, - location_type: str, - country_code: str, - phone_plan_id: str, - location_options: Optional[List["_models.LocationOptionsQuery"]] = None, - **kwargs - ) -> "_models.AreaCodes": - """Gets a list of the supported area codes. - - Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsQuery] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AreaCodes, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.AreaCodes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AreaCodes"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.LocationOptionsQueries(location_options=location_options) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_all_area_codes.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['locationType'] = self._serialize.query("location_type", location_type, 'str') - query_parameters['phonePlanId'] = self._serialize.query("phone_plan_id", phone_plan_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'LocationOptionsQueries') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AreaCodes', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_all_area_codes.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/areacodes'} # type: ignore - - async def get_capabilities_update( - self, - capabilities_update_id: str, - **kwargs - ) -> "_models.UpdatePhoneNumberCapabilitiesResponse": - """Get capabilities by capabilities update id. - - Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdatePhoneNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.UpdatePhoneNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdatePhoneNumberCapabilitiesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_capabilities_update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'capabilitiesUpdateId': self._serialize.url("capabilities_update_id", capabilities_update_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdatePhoneNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_capabilities_update.metadata = {'url': '/administration/phonenumbers/capabilities/{capabilitiesUpdateId}'} # type: ignore - - async def update_capabilities( - self, - phone_number_capabilities_update: Dict[str, "_models.NumberUpdateCapabilities"], - **kwargs - ) -> "_models.UpdateNumberCapabilitiesResponse": - """Adds or removes phone number capabilities. - - Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: dict[str, ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.UpdateNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateNumberCapabilitiesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.UpdateNumberCapabilitiesRequest(phone_number_capabilities_update=phone_number_capabilities_update) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'UpdateNumberCapabilitiesRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_capabilities.metadata = {'url': '/administration/phonenumbers/capabilities'} # type: ignore - - def get_all_supported_countries( - self, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.PhoneNumberCountries"]: - """Gets a list of supported countries. - - Gets a list of supported countries. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberCountries or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.PhoneNumberCountries] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberCountries"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_supported_countries.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberCountries', pipeline_response) - list_of_elem = deserialized.countries - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_supported_countries.metadata = {'url': '/administration/phonenumbers/countries'} # type: ignore - - async def get_number_configuration( - self, - phone_number: str, - **kwargs - ) -> "_models.NumberConfigurationResponse": - """Endpoint for getting number configurations. - - Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NumberConfigurationResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.NumberConfigurationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NumberConfigurationResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_number_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('NumberConfigurationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_number_configuration.metadata = {'url': '/administration/phonenumbers/numberconfiguration'} # type: ignore - - async def configure_number( - self, - pstn_configuration: "_models.PstnConfiguration", - phone_number: str, - **kwargs - ) -> None: - """Endpoint for configuring a pstn number. - - Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfiguration(pstn_configuration=pstn_configuration, phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.configure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfiguration') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - configure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/configure'} # type: ignore - - async def unconfigure_number( - self, - phone_number: str, - **kwargs - ) -> None: - """Endpoint for unconfiguring a pstn number by removing the configuration. - - Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.unconfigure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unconfigure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/unconfigure'} # type: ignore - - def get_phone_plan_groups( - self, - country_code: str, - locale: Optional[str] = "en-US", - include_rate_information: Optional[bool] = False, - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.PhonePlanGroups"]: - """Gets a list of phone plan groups for the given country. - - Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param include_rate_information: - :type include_rate_information: bool - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlanGroups or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.PhonePlanGroups] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhonePlanGroups"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_phone_plan_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if include_rate_information is not None: - query_parameters['includeRateInformation'] = self._serialize.query("include_rate_information", include_rate_information, 'bool') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlanGroups', pipeline_response) - list_of_elem = deserialized.phone_plan_groups - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_phone_plan_groups.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups'} # type: ignore - - def get_phone_plans( - self, - country_code: str, - phone_plan_group_id: str, - locale: Optional[str] = "en-US", - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.PhonePlansResponse"]: - """Gets a list of phone plans for a phone plan group. - - Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlansResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.PhonePlansResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhonePlansResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_phone_plans.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlansResponse', pipeline_response) - list_of_elem = deserialized.phone_plans - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_phone_plans.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans'} # type: ignore - - async def get_phone_plan_location_options( - self, - country_code: str, - phone_plan_group_id: str, - phone_plan_id: str, - locale: Optional[str] = "en-US", - **kwargs - ) -> "_models.LocationOptionsResponse": - """Gets a list of location options for a phone plan. - - Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationOptionsResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.LocationOptionsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationOptionsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_phone_plan_location_options.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - 'phonePlanId': self._serialize.url("phone_plan_id", phone_plan_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('LocationOptionsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_phone_plan_location_options.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions'} # type: ignore - - async def get_release_by_id( - self, - release_id: str, - **kwargs - ) -> "_models.PhoneNumberRelease": - """Gets a release by a release id. - - Gets a release by a release id. - - :param release_id: Represents the release id. - :type release_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberRelease, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.PhoneNumberRelease - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberRelease"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_release_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'releaseId': self._serialize.url("release_id", release_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('PhoneNumberRelease', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_release_by_id.metadata = {'url': '/administration/phonenumbers/releases/{releaseId}'} # type: ignore - - async def release_phone_numbers( - self, - phone_numbers: List[str], - **kwargs - ) -> "_models.ReleaseResponse": - """Creates a release for the given phone numbers. - - Creates a release for the given phone numbers. - - :param phone_numbers: The list of phone numbers in the release request. - :type phone_numbers: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReleaseResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.ReleaseResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReleaseResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.ReleaseRequest(phone_numbers=phone_numbers) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.release_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'ReleaseRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('ReleaseResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - release_phone_numbers.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore - - def get_all_releases( - self, - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.PhoneNumberEntities"]: - """Gets a list of all releases. - - Gets a list of all releases. - - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberEntities or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.PhoneNumberEntities] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberEntities"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_releases.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_releases.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore - - async def get_search_by_id( - self, - search_id: str, - **kwargs - ) -> "_models.PhoneNumberReservation": - """Get search by search id. - - Get search by search id. - - :param search_id: The search id to be searched for. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberReservation, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.PhoneNumberReservation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberReservation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_search_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('PhoneNumberReservation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_search_by_id.metadata = {'url': '/administration/phonenumbers/searches/{searchId}'} # type: ignore - - async def create_search( - self, - body: Optional["_models.CreateSearchOptions"] = None, - **kwargs - ) -> "_models.CreateSearchResponse": - """Creates a phone number search. - - Creates a phone number search. - - :param body: Defines the search options. - :type body: ~azure.communication.phonenumbers.models.CreateSearchOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CreateSearchResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.CreateSearchResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CreateSearchResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'CreateSearchOptions') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('CreateSearchResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_search.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore - - def get_all_searches( - self, - skip: Optional[int] = 0, - take: Optional[int] = 100, - **kwargs - ) -> AsyncIterable["_models.PhoneNumberEntities"]: - """Gets a list of all searches. - - Gets a list of all searches. - - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberEntities or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.PhoneNumberEntities] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberEntities"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_searches.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_all_searches.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore - - async def cancel_search( - self, - search_id: str, - **kwargs - ) -> None: - """Cancels the search. This means existing numbers in the search will be made available. - - Cancels the search. This means existing numbers in the search will be made available. - - :param search_id: The search id to be canceled. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.cancel_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - cancel_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/cancel'} # type: ignore - - async def purchase_search( - self, - search_id: str, - **kwargs - ) -> None: - """Purchases the phone number search. - - Purchases the phone number search. - - :param search_id: The search id to be purchased. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.purchase_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - purchase_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/purchase'} # type: ignore diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_numbers_operations.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_numbers_operations.py new file mode 100644 index 000000000000..8bcfc898be2c --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/operations/_phone_numbers_operations.py @@ -0,0 +1,852 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PhoneNumbersOperations: + """PhoneNumbersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.communication.phonenumbers.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _search_available_phone_numbers_initial( + self, + country_code: str, + body: "_models.PhoneNumberSearchRequest", + **kwargs + ) -> "_models.PhoneNumberSearchResult": + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._search_available_phone_numbers_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'countryCode': self._serialize.url("country_code", country_code, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PhoneNumberSearchRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['search-id']=self._deserialize('str', response.headers.get('search-id')) + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _search_available_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/:search'} # type: ignore + + async def begin_search_available_phone_numbers( + self, + country_code: str, + body: "_models.PhoneNumberSearchRequest", + **kwargs + ) -> AsyncLROPoller["_models.PhoneNumberSearchResult"]: + """Search for available phone numbers to purchase. + + Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code, e.g. US. + :type country_code: str + :param body: The phone number search request. + :type body: ~azure.communication.phonenumbers.models.PhoneNumberSearchRequest + :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: Pass in True if you'd like the AsyncLROBasePolling polling method, + False for no polling, or 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 PhoneNumberSearchResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._search_available_phone_numbers_initial( + country_code=country_code, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['search-id']=self._deserialize('str', response.headers.get('search-id')) + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'countryCode': self._serialize.url("country_code", country_code, 'str'), + } + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_search_available_phone_numbers.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/:search'} # type: ignore + + async def get_search_result( + self, + search_id: str, + **kwargs + ) -> "_models.PhoneNumberSearchResult": + """Gets a phone number search result by search id. + + Gets a phone number search result by search id. + + :param search_id: The search Id. + :type search_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhoneNumberSearchResult, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.PhoneNumberSearchResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_search_result.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'searchId': self._serialize.url("search_id", search_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_search_result.metadata = {'url': '/availablePhoneNumbers/searchResults/{searchId}'} # type: ignore + + async def _purchase_phone_numbers_initial( + self, + search_id: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.PhoneNumberPurchaseRequest(search_id=search_id) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._purchase_phone_numbers_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PhoneNumberPurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['purchase-id']=self._deserialize('str', response.headers.get('purchase-id')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _purchase_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/:purchase'} # type: ignore + + async def begin_purchase_phone_numbers( + self, + search_id: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller[None]: + """Purchases phone numbers. + + Purchases phone numbers. + + :param search_id: The search id. + :type search_id: 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: Pass in True if you'd like the AsyncLROBasePolling polling method, + False for no polling, or 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: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._purchase_phone_numbers_initial( + search_id=search_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase_phone_numbers.metadata = {'url': '/availablePhoneNumbers/:purchase'} # type: ignore + + async def get_operation( + self, + operation_id: str, + **kwargs + ) -> "_models.PhoneNumberOperation": + """Gets an operation by its id. + + Gets an operation by its id. + + :param operation_id: The id of the operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhoneNumberOperation, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.PhoneNumberOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + deserialized = self._deserialize('PhoneNumberOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore + + async def cancel_operation( + self, + operation_id: str, + **kwargs + ) -> None: + """Cancels an operation by its id. + + Cancels an operation by its id. + + :param operation_id: The id of the operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.cancel_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore + + async def get_by_number( + self, + phone_number: str, + **kwargs + ) -> "_models.AcquiredPhoneNumber": + """Gets the details of the given acquired phone number. + + Gets the details of the given acquired phone number. + + :param phone_number: The acquired phone number whose details are to be fetched in E.164 format, + e.g. +11234567890. + :type phone_number: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AcquiredPhoneNumber, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_by_number.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + async def _release_phone_number_initial( + self, + phone_number: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self._release_phone_number_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['release-id']=self._deserialize('str', response.headers.get('release-id')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _release_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + async def begin_release_phone_number( + self, + phone_number: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Releases an acquired phone number. + + Releases an acquired phone number. + + :param phone_number: Phone number to be released, e.g. +11234567890. + :type phone_number: 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: Pass in True if you'd like the AsyncLROBasePolling polling method, + False for no polling, or 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: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._release_phone_number_initial( + phone_number=phone_number, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_release_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def list_phone_numbers( + self, + skip: Optional[int] = 0, + top: Optional[int] = 100, + **kwargs + ) -> AsyncIterable["_models.AcquiredPhoneNumbers"]: + """Gets the list of all acquired phone numbers. + + Gets the list of all acquired phone numbers. + + :param skip: An optional parameter for how many entries to skip, for pagination purposes. The + default value is 0. + :type skip: int + :param top: An optional parameter for how many entries to return, for pagination purposes. The + default value is 100. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumbers] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumbers"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_phone_numbers.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) + list_of_elem = deserialized.phone_numbers + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_phone_numbers.metadata = {'url': '/phoneNumbers'} # type: ignore + + async def _update_capabilities_initial( + self, + phone_number: str, + calling: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] = None, + sms: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] = None, + **kwargs + ) -> "_models.AcquiredPhoneNumber": + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.PhoneNumberCapabilitiesRequest(calling=calling, sms=sms) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + accept = "application/json" + + # Construct URL + url = self._update_capabilities_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'PhoneNumberCapabilitiesRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['capabilities-id']=self._deserialize('str', response.headers.get('capabilities-id')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _update_capabilities_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}/capabilities'} # type: ignore + + async def begin_update_capabilities( + self, + phone_number: str, + calling: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] = None, + sms: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] = None, + **kwargs + ) -> AsyncLROPoller["_models.AcquiredPhoneNumber"]: + """Updates the capabilities of a phone number. + + Updates the capabilities of a phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B, e.g. +11234567890. + :type phone_number: str + :param calling: Capability value for calling. + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :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: Pass in True if you'd like the AsyncLROBasePolling polling method, + False for no polling, or 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 AcquiredPhoneNumber or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.phonenumbers.models.AcquiredPhoneNumber] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_capabilities_initial( + phone_number=phone_number, + calling=calling, + sms=sms, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['capabilities-id']=self._deserialize('str', response.headers.get('capabilities-id')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_capabilities.metadata = {'url': '/phoneNumbers/{phoneNumber}/capabilities'} # type: ignore diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/__init__.py index 0548f7b51a32..8884e4f716cc 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/__init__.py @@ -9,133 +9,53 @@ try: from ._models_py3 import AcquiredPhoneNumber from ._models_py3 import AcquiredPhoneNumbers - from ._models_py3 import AreaCodes - from ._models_py3 import CarrierDetails - from ._models_py3 import CreateSearchOptions - from ._models_py3 import CreateSearchResponse - from ._models_py3 import ErrorBody - from ._models_py3 import ErrorResponse - from ._models_py3 import LocationOptions - from ._models_py3 import LocationOptionsDetails - from ._models_py3 import LocationOptionsQueries - from ._models_py3 import LocationOptionsQuery - from ._models_py3 import LocationOptionsResponse - from ._models_py3 import NumberConfiguration - from ._models_py3 import NumberConfigurationPhoneNumber - from ._models_py3 import NumberConfigurationResponse - from ._models_py3 import NumberUpdateCapabilities - from ._models_py3 import PhoneNumberCountries - from ._models_py3 import PhoneNumberCountry - from ._models_py3 import PhoneNumberEntities - from ._models_py3 import PhoneNumberEntity - from ._models_py3 import PhoneNumberRelease - from ._models_py3 import PhoneNumberReleaseDetails - from ._models_py3 import PhoneNumberReservation - from ._models_py3 import PhonePlan - from ._models_py3 import PhonePlanGroup - from ._models_py3 import PhonePlanGroups - from ._models_py3 import PhonePlansResponse - from ._models_py3 import PstnConfiguration - from ._models_py3 import RateInformation - from ._models_py3 import ReleaseRequest - from ._models_py3 import ReleaseResponse - from ._models_py3 import UpdateNumberCapabilitiesRequest - from ._models_py3 import UpdateNumberCapabilitiesResponse - from ._models_py3 import UpdatePhoneNumberCapabilitiesResponse + from ._models_py3 import CommunicationError + from ._models_py3 import CommunicationErrorResponse + from ._models_py3 import PhoneNumberCapabilities + from ._models_py3 import PhoneNumberCapabilitiesRequest + from ._models_py3 import PhoneNumberCost + from ._models_py3 import PhoneNumberOperation + from ._models_py3 import PhoneNumberPurchaseRequest + from ._models_py3 import PhoneNumberSearchRequest + from ._models_py3 import PhoneNumberSearchResult except (SyntaxError, ImportError): from ._models import AcquiredPhoneNumber # type: ignore from ._models import AcquiredPhoneNumbers # type: ignore - from ._models import AreaCodes # type: ignore - from ._models import CarrierDetails # type: ignore - from ._models import CreateSearchOptions # type: ignore - from ._models import CreateSearchResponse # type: ignore - from ._models import ErrorBody # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LocationOptions # type: ignore - from ._models import LocationOptionsDetails # type: ignore - from ._models import LocationOptionsQueries # type: ignore - from ._models import LocationOptionsQuery # type: ignore - from ._models import LocationOptionsResponse # type: ignore - from ._models import NumberConfiguration # type: ignore - from ._models import NumberConfigurationPhoneNumber # type: ignore - from ._models import NumberConfigurationResponse # type: ignore - from ._models import NumberUpdateCapabilities # type: ignore - from ._models import PhoneNumberCountries # type: ignore - from ._models import PhoneNumberCountry # type: ignore - from ._models import PhoneNumberEntities # type: ignore - from ._models import PhoneNumberEntity # type: ignore - from ._models import PhoneNumberRelease # type: ignore - from ._models import PhoneNumberReleaseDetails # type: ignore - from ._models import PhoneNumberReservation # type: ignore - from ._models import PhonePlan # type: ignore - from ._models import PhonePlanGroup # type: ignore - from ._models import PhonePlanGroups # type: ignore - from ._models import PhonePlansResponse # type: ignore - from ._models import PstnConfiguration # type: ignore - from ._models import RateInformation # type: ignore - from ._models import ReleaseRequest # type: ignore - from ._models import ReleaseResponse # type: ignore - from ._models import UpdateNumberCapabilitiesRequest # type: ignore - from ._models import UpdateNumberCapabilitiesResponse # type: ignore - from ._models import UpdatePhoneNumberCapabilitiesResponse # type: ignore + from ._models import CommunicationError # type: ignore + from ._models import CommunicationErrorResponse # type: ignore + from ._models import PhoneNumberCapabilities # type: ignore + from ._models import PhoneNumberCapabilitiesRequest # type: ignore + from ._models import PhoneNumberCost # type: ignore + from ._models import PhoneNumberOperation # type: ignore + from ._models import PhoneNumberPurchaseRequest # type: ignore + from ._models import PhoneNumberSearchRequest # type: ignore + from ._models import PhoneNumberSearchResult # type: ignore -from ._phone_number_administration_service_enums import ( - ActivationState, - AssignmentStatus, - CapabilitiesUpdateStatus, - Capability, - CurrencyType, - LocationType, - PhoneNumberReleaseStatus, +from ._phone_numbers_client_enums import ( + BillingFrequency, + PhoneNumberAssignmentType, + PhoneNumberCapabilityType, + PhoneNumberOperationStatus, + PhoneNumberOperationType, PhoneNumberType, - ReleaseStatus, - SearchStatus, ) __all__ = [ 'AcquiredPhoneNumber', 'AcquiredPhoneNumbers', - 'AreaCodes', - 'CarrierDetails', - 'CreateSearchOptions', - 'CreateSearchResponse', - 'ErrorBody', - 'ErrorResponse', - 'LocationOptions', - 'LocationOptionsDetails', - 'LocationOptionsQueries', - 'LocationOptionsQuery', - 'LocationOptionsResponse', - 'NumberConfiguration', - 'NumberConfigurationPhoneNumber', - 'NumberConfigurationResponse', - 'NumberUpdateCapabilities', - 'PhoneNumberCountries', - 'PhoneNumberCountry', - 'PhoneNumberEntities', - 'PhoneNumberEntity', - 'PhoneNumberRelease', - 'PhoneNumberReleaseDetails', - 'PhoneNumberReservation', - 'PhonePlan', - 'PhonePlanGroup', - 'PhonePlanGroups', - 'PhonePlansResponse', - 'PstnConfiguration', - 'RateInformation', - 'ReleaseRequest', - 'ReleaseResponse', - 'UpdateNumberCapabilitiesRequest', - 'UpdateNumberCapabilitiesResponse', - 'UpdatePhoneNumberCapabilitiesResponse', - 'ActivationState', - 'AssignmentStatus', - 'CapabilitiesUpdateStatus', - 'Capability', - 'CurrencyType', - 'LocationType', - 'PhoneNumberReleaseStatus', + 'CommunicationError', + 'CommunicationErrorResponse', + 'PhoneNumberCapabilities', + 'PhoneNumberCapabilitiesRequest', + 'PhoneNumberCost', + 'PhoneNumberOperation', + 'PhoneNumberPurchaseRequest', + 'PhoneNumberSearchRequest', + 'PhoneNumberSearchResult', + 'BillingFrequency', + 'PhoneNumberAssignmentType', + 'PhoneNumberCapabilityType', + 'PhoneNumberOperationStatus', + 'PhoneNumberOperationType', 'PhoneNumberType', - 'ReleaseStatus', - 'SearchStatus', ] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models.py index 743ffbf17273..2f56422efbef 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models.py @@ -15,39 +15,49 @@ class AcquiredPhoneNumber(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param phone_number: Required. String of the E.164 format of the phone number. + :param id: Required. The id of the phone number, e.g. 11234567890. + :type id: str + :param phone_number: Required. String of the E.164 format of the phone number, e.g. + +11234567890. :type phone_number: str - :param acquired_capabilities: Required. The set of all acquired capabilities of the phone - number. - :type acquired_capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param available_capabilities: Required. The set of all available capabilities that can be - acquired for this phone number. - :type available_capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param assignment_status: The assignment status of the phone number. Conveys what type of - entity the number is assigned to. Possible values include: "Unassigned", "Unknown", - "UserAssigned", "ConferenceAssigned", "FirstPartyAppAssigned", "ThirdPartyAppAssigned". - :type assignment_status: str or ~azure.communication.phonenumbers.models.AssignmentStatus - :param place_name: The name of the place of the phone number. - :type place_name: str - :param activation_state: The activation state of the phone number. Can be "Activated", - "AssignmentPending", "AssignmentFailed", "UpdatePending", "UpdateFailed". Possible values - include: "Activated", "AssignmentPending", "AssignmentFailed", "UpdatePending", "UpdateFailed". - :type activation_state: str or ~azure.communication.phonenumbers.models.ActivationState + :param country_code: Required. The ISO 3166-2 code of the phone number's country, e.g. US. + :type country_code: str + :param phone_number_type: Required. The phone number's type, e.g. Geographic, TollFree. + Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param assignment_type: Required. The assignment type of the phone number. A phone number can + be assigned to a person, or to an application. Possible values include: "person", + "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param purchase_date: Required. The date and time that the phone number was purchased. + :type purchase_date: ~datetime.datetime + :param cost: Required. The incurred cost for a single phone number. + :type cost: ~azure.communication.phonenumbers.models.PhoneNumberCost """ _validation = { + 'id': {'required': True}, 'phone_number': {'required': True}, - 'acquired_capabilities': {'required': True}, - 'available_capabilities': {'required': True}, + 'country_code': {'required': True}, + 'phone_number_type': {'required': True}, + 'capabilities': {'required': True}, + 'assignment_type': {'required': True}, + 'purchase_date': {'required': True}, + 'cost': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'acquired_capabilities': {'key': 'acquiredCapabilities', 'type': '[str]'}, - 'available_capabilities': {'key': 'availableCapabilities', 'type': '[str]'}, - 'assignment_status': {'key': 'assignmentStatus', 'type': 'str'}, - 'place_name': {'key': 'placeName', 'type': 'str'}, - 'activation_state': {'key': 'activationState', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'purchase_date': {'key': 'purchaseDate', 'type': 'iso-8601'}, + 'cost': {'key': 'cost', 'type': 'PhoneNumberCost'}, } def __init__( @@ -55,51 +65,33 @@ def __init__( **kwargs ): super(AcquiredPhoneNumber, self).__init__(**kwargs) + self.id = kwargs['id'] self.phone_number = kwargs['phone_number'] - self.acquired_capabilities = kwargs['acquired_capabilities'] - self.available_capabilities = kwargs['available_capabilities'] - self.assignment_status = kwargs.get('assignment_status', None) - self.place_name = kwargs.get('place_name', None) - self.activation_state = kwargs.get('activation_state', None) + self.country_code = kwargs['country_code'] + self.phone_number_type = kwargs['phone_number_type'] + self.capabilities = kwargs['capabilities'] + self.assignment_type = kwargs['assignment_type'] + self.purchase_date = kwargs['purchase_date'] + self.cost = kwargs['cost'] class AcquiredPhoneNumbers(msrest.serialization.Model): - """A wrapper of list of phone numbers. + """The list of acquired phone numbers. + + All required parameters must be populated in order to send to Azure. - :param phone_numbers: Represents a list of phone numbers. + :param phone_numbers: Required. Represents a list of phone numbers. :type phone_numbers: list[~azure.communication.phonenumbers.models.AcquiredPhoneNumber] - :param next_link: Represents the URL link to the next page. + :param next_link: Represents the URL link to the next page of phone number results. :type next_link: str """ - _attribute_map = { - 'phone_numbers': {'key': 'phoneNumbers', 'type': '[AcquiredPhoneNumber]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + _validation = { + 'phone_numbers': {'required': True}, } - def __init__( - self, - **kwargs - ): - super(AcquiredPhoneNumbers, self).__init__(**kwargs) - self.phone_numbers = kwargs.get('phone_numbers', None) - self.next_link = kwargs.get('next_link', None) - - -class AreaCodes(msrest.serialization.Model): - """Represents a list of area codes. - - :param primary_area_codes: Represents the list of primary area codes. - :type primary_area_codes: list[str] - :param secondary_area_codes: Represents the list of secondary area codes. - :type secondary_area_codes: list[str] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - _attribute_map = { - 'primary_area_codes': {'key': 'primaryAreaCodes', 'type': '[str]'}, - 'secondary_area_codes': {'key': 'secondaryAreaCodes', 'type': '[str]'}, + 'phone_numbers': {'key': 'phoneNumbers', 'type': '[AcquiredPhoneNumber]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } @@ -107,950 +99,356 @@ def __init__( self, **kwargs ): - super(AreaCodes, self).__init__(**kwargs) - self.primary_area_codes = kwargs.get('primary_area_codes', None) - self.secondary_area_codes = kwargs.get('secondary_area_codes', None) + super(AcquiredPhoneNumbers, self).__init__(**kwargs) + self.phone_numbers = kwargs['phone_numbers'] self.next_link = kwargs.get('next_link', None) -class CarrierDetails(msrest.serialization.Model): - """Represents carrier details. +class CommunicationError(msrest.serialization.Model): + """The Communication Services error. - :param name: Name of carrier details. - :type name: str - :param localized_name: Display name of carrier details. - :type localized_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CarrierDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.localized_name = kwargs.get('localized_name', None) - - -class CreateSearchOptions(msrest.serialization.Model): - """Represents a search creation option. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param display_name: Required. Display name of the search. - :type display_name: str - :param description: Required. Description of the search. - :type description: str - :param phone_plan_ids: Required. The plan subtype ids from which to create the search. - :type phone_plan_ids: list[str] - :param area_code: Required. The area code from which to create the search. - :type area_code: str - :param quantity: The quantity of phone numbers to request. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - """ - - _validation = { - 'display_name': {'required': True, 'max_length': 255, 'min_length': 0}, - 'description': {'required': True, 'max_length': 255, 'min_length': 0}, - 'phone_plan_ids': {'required': True}, - 'area_code': {'required': True}, - 'quantity': {'maximum': 2147483647, 'minimum': 1}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, - 'area_code': {'key': 'areaCode', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateSearchOptions, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.description = kwargs['description'] - self.phone_plan_ids = kwargs['phone_plan_ids'] - self.area_code = kwargs['area_code'] - self.quantity = kwargs.get('quantity', None) - self.location_options = kwargs.get('location_options', None) - - -class CreateSearchResponse(msrest.serialization.Model): - """Represents a search creation response. - - All required parameters must be populated in order to send to Azure. - - :param search_id: Required. The search id of the search that was created. - :type search_id: str - """ - - _validation = { - 'search_id': {'required': True}, - } - - _attribute_map = { - 'search_id': {'key': 'searchId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateSearchResponse, self).__init__(**kwargs) - self.search_id = kwargs['search_id'] - - -class ErrorBody(msrest.serialization.Model): - """Represents a service error response body. - - :param code: The error code in the error response. + :param code: Required. The error code. :type code: str - :param message: The error message in the error response. + :param message: Required. The error message. :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ErrorResponse(msrest.serialization.Model): - """Represents a service error response. - - :param error: Represents a service error response body. - :type error: ~azure.communication.phonenumbers.models.ErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorBody'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class LocationOptions(msrest.serialization.Model): - """Represents a location options. - - :param label_id: The label id of the location. - :type label_id: str - :param label_name: The display name of the location. - :type label_name: str - :param options: The underlying location option details. - :type options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'label_name': {'key': 'labelName', 'type': 'str'}, - 'options': {'key': 'options', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptions, self).__init__(**kwargs) - self.label_id = kwargs.get('label_id', None) - self.label_name = kwargs.get('label_name', None) - self.options = kwargs.get('options', None) - - -class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options details. - - :param name: The name of the location options. - :type name: str - :param value: The abbreviated name of the location options. - :type value: str - :param location_options: The underlying location options. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptions] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptions]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - self.location_options = kwargs.get('location_options', None) - - -class LocationOptionsQueries(msrest.serialization.Model): - """Represents a list of location option queries, used for fetching area codes. - - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsQuery] - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsQuery]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsQueries, self).__init__(**kwargs) - self.location_options = kwargs.get('location_options', None) - - -class LocationOptionsQuery(msrest.serialization.Model): - """Represents a location options parameter, used for fetching area codes. - - :param label_id: Represents the location option label id, returned from the GetLocationOptions - API. - :type label_id: str - :param options_value: Represents the location options value, returned from the - GetLocationOptions API. - :type options_value: str - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'options_value': {'key': 'optionsValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsQuery, self).__init__(**kwargs) - self.label_id = kwargs.get('label_id', None) - self.options_value = kwargs.get('options_value', None) - - -class LocationOptionsResponse(msrest.serialization.Model): - """Represents a wrapper around a list of location options. - - :param location_options: Represents a location options. - :type location_options: ~azure.communication.phonenumbers.models.LocationOptions - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': 'LocationOptions'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationOptionsResponse, self).__init__(**kwargs) - self.location_options = kwargs.get('location_options', None) - - -class NumberConfiguration(msrest.serialization.Model): - """Definition for number configuration. - - All required parameters must be populated in order to send to Azure. - - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration - :param phone_number: Required. The phone number to configure. - :type phone_number: str + :ivar target: The error target. + :vartype target: str + :ivar details: Further details about specific errors that led to this error. + :vartype details: list[~azure.communication.phonenumbers.models.CommunicationError] + :ivar inner_error: The inner error if any. + :vartype inner_error: ~azure.communication.phonenumbers.models.CommunicationError """ _validation = { - 'pstn_configuration': {'required': True}, - 'phone_number': {'required': True}, + 'code': {'required': True}, + 'message': {'required': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'inner_error': {'readonly': True}, } _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CommunicationError]'}, + 'inner_error': {'key': 'innererror', 'type': 'CommunicationError'}, } def __init__( self, **kwargs ): - super(NumberConfiguration, self).__init__(**kwargs) - self.pstn_configuration = kwargs['pstn_configuration'] - self.phone_number = kwargs['phone_number'] + super(CommunicationError, self).__init__(**kwargs) + self.code = kwargs['code'] + self.message = kwargs['message'] + self.target = None + self.details = None + self.inner_error = None -class NumberConfigurationPhoneNumber(msrest.serialization.Model): - """The phone number wrapper representing a number configuration request. +class CommunicationErrorResponse(msrest.serialization.Model): + """The Communication Services error. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. The phone number in the E.164 format. - :type phone_number: str + :param error: Required. The Communication Services error. + :type error: ~azure.communication.phonenumbers.models.CommunicationError """ _validation = { - 'phone_number': {'required': True}, + 'error': {'required': True}, } _attribute_map = { - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'CommunicationError'}, } def __init__( self, **kwargs ): - super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) - self.phone_number = kwargs['phone_number'] + super(CommunicationErrorResponse, self).__init__(**kwargs) + self.error = kwargs['error'] -class NumberConfigurationResponse(msrest.serialization.Model): - """Definition for number configuration. +class PhoneNumberCapabilities(msrest.serialization.Model): + """Capabilities of a phone number. All required parameters must be populated in order to send to Azure. - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration + :param calling: Required. Capability value for calling. Possible values include: "none", + "inbound", "outbound", "inbound+outbound". + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Required. Capability value for SMS. Possible values include: "none", "inbound", + "outbound", "inbound+outbound". + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType """ _validation = { - 'pstn_configuration': {'required': True}, - } - - _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + 'calling': {'required': True}, + 'sms': {'required': True}, } - def __init__( - self, - **kwargs - ): - super(NumberConfigurationResponse, self).__init__(**kwargs) - self.pstn_configuration = kwargs['pstn_configuration'] - - -class NumberUpdateCapabilities(msrest.serialization.Model): - """Represents an individual number capabilities update request. - - :param add: Capabilities to be added to a phone number. - :type add: list[str or ~azure.communication.phonenumbers.models.Capability] - :param remove: Capabilities to be removed from a phone number. - :type remove: list[str or ~azure.communication.phonenumbers.models.Capability] - """ - _attribute_map = { - 'add': {'key': 'add', 'type': '[str]'}, - 'remove': {'key': 'remove', 'type': '[str]'}, + 'calling': {'key': 'calling', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, } def __init__( self, **kwargs ): - super(NumberUpdateCapabilities, self).__init__(**kwargs) - self.add = kwargs.get('add', None) - self.remove = kwargs.get('remove', None) + super(PhoneNumberCapabilities, self).__init__(**kwargs) + self.calling = kwargs['calling'] + self.sms = kwargs['sms'] -class PhoneNumberCountries(msrest.serialization.Model): - """Represents a wrapper around a list of countries. +class PhoneNumberCapabilitiesRequest(msrest.serialization.Model): + """Capabilities of a phone number. - :param countries: Represents the underlying list of countries. - :type countries: list[~azure.communication.phonenumbers.models.PhoneNumberCountry] - :param next_link: Represents the URL link to the next page. - :type next_link: str + :param calling: Capability value for calling. Possible values include: "none", "inbound", + "outbound", "inbound+outbound". + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. Possible values include: "none", "inbound", "outbound", + "inbound+outbound". + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType """ _attribute_map = { - 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, } def __init__( self, **kwargs ): - super(PhoneNumberCountries, self).__init__(**kwargs) - self.countries = kwargs.get('countries', None) - self.next_link = kwargs.get('next_link', None) + super(PhoneNumberCapabilitiesRequest, self).__init__(**kwargs) + self.calling = kwargs.get('calling', None) + self.sms = kwargs.get('sms', None) -class PhoneNumberCountry(msrest.serialization.Model): - """Represents a country. +class PhoneNumberCost(msrest.serialization.Model): + """The incurred cost for a single phone number. All required parameters must be populated in order to send to Azure. - :param localized_name: Required. Represents the name of the country. - :type localized_name: str - :param country_code: Required. Represents the abbreviated name of the country. - :type country_code: str + :param amount: Required. The cost amount. + :type amount: float + :param currency_code: Required. The ISO 4217 currency code for the cost amount, e.g. USD. + :type currency_code: str + :param billing_frequency: Required. The frequency with which the cost gets billed. Possible + values include: "monthly". + :type billing_frequency: str or ~azure.communication.phonenumbers.models.BillingFrequency """ _validation = { - 'localized_name': {'required': True}, - 'country_code': {'required': True}, + 'amount': {'required': True}, + 'currency_code': {'required': True}, + 'billing_frequency': {'required': True}, } _attribute_map = { - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'billing_frequency': {'key': 'billingFrequency', 'type': 'str'}, } def __init__( self, **kwargs ): - super(PhoneNumberCountry, self).__init__(**kwargs) - self.localized_name = kwargs['localized_name'] - self.country_code = kwargs['country_code'] + super(PhoneNumberCost, self).__init__(**kwargs) + self.amount = kwargs['amount'] + self.currency_code = kwargs['currency_code'] + self.billing_frequency = kwargs['billing_frequency'] -class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searches or releases, as part of the response when fetching all searches or releases. +class PhoneNumberOperation(msrest.serialization.Model): + """Long running operation. - :param entities: The underlying list of entities. - :type entities: list[~azure.communication.phonenumbers.models.PhoneNumberEntity] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ + Variables are only populated by the server, and will be ignored when sending a request. - _attribute_map = { - 'entities': {'key': 'entities', 'type': '[PhoneNumberEntity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PhoneNumberEntities, self).__init__(**kwargs) - self.entities = kwargs.get('entities', None) - self.next_link = kwargs.get('next_link', None) - - -class PhoneNumberEntity(msrest.serialization.Model): - """Represents a phone number entity, as part of the response when calling get all searches or releases. + All required parameters must be populated in order to send to Azure. - :param id: The id of the entity. It is the search id of a search. It is the release id of a - release. + :param status: Required. Status of operation. Possible values include: "notStarted", "running", + "succeeded", "failed". + :type status: str or ~azure.communication.phonenumbers.models.PhoneNumberOperationStatus + :param resource_location: URL for retrieving the result of the operation, if any. + :type resource_location: str + :param created_date_time: Required. The date that the operation was created. + :type created_date_time: ~datetime.datetime + :param error: The Communication Services error. + :type error: ~azure.communication.phonenumbers.models.CommunicationError + :param id: Required. Id of operation. :type id: str - :param created_at: Date and time the entity is created. - :type created_at: ~datetime.datetime - :param display_name: Name of the entity. - :type display_name: str - :param quantity: Quantity of requested phone numbers in the entity. - :type quantity: int - :param quantity_obtained: Quantity of acquired phone numbers in the entity. - :type quantity_obtained: int - :param status: Status of the entity. - :type status: str - :param foc_date: The Firm Order Confirmation date of the phone number entity. - :type foc_date: ~datetime.datetime + :param operation_type: Required. The type of operation, e.g. Search. Possible values include: + "purchase", "releasePhoneNumber", "search", "updatePhoneNumberCapabilities". + :type operation_type: str or ~azure.communication.phonenumbers.models.PhoneNumberOperationType + :ivar last_action_date_time: The most recent date that the operation was changed. + :vartype last_action_date_time: ~datetime.datetime """ - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'quantity_obtained': {'key': 'quantityObtained', 'type': 'int'}, - 'status': {'key': 'status', 'type': 'str'}, - 'foc_date': {'key': 'focDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(PhoneNumberEntity, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.created_at = kwargs.get('created_at', None) - self.display_name = kwargs.get('display_name', None) - self.quantity = kwargs.get('quantity', None) - self.quantity_obtained = kwargs.get('quantity_obtained', None) - self.status = kwargs.get('status', None) - self.foc_date = kwargs.get('foc_date', None) - - -class PhoneNumberRelease(msrest.serialization.Model): - """Represents a release. - - :param release_id: The id of the release. - :type release_id: str - :param created_at: The creation time of the release. - :type created_at: ~datetime.datetime - :param status: The release status. Possible values include: "Pending", "InProgress", - "Complete", "Failed", "Expired". - :type status: str or ~azure.communication.phonenumbers.models.ReleaseStatus - :param error_message: The underlying error message of a release. - :type error_message: str - :param phone_number_release_status_details: The list of phone numbers in the release, mapped to - its individual statuses. - :type phone_number_release_status_details: dict[str, - ~azure.communication.phonenumbers.models.PhoneNumberReleaseDetails] - """ - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'phone_number_release_status_details': {'key': 'phoneNumberReleaseStatusDetails', 'type': '{PhoneNumberReleaseDetails}'}, - } - - def __init__( - self, - **kwargs - ): - super(PhoneNumberRelease, self).__init__(**kwargs) - self.release_id = kwargs.get('release_id', None) - self.created_at = kwargs.get('created_at', None) - self.status = kwargs.get('status', None) - self.error_message = kwargs.get('error_message', None) - self.phone_number_release_status_details = kwargs.get('phone_number_release_status_details', None) - - -class PhoneNumberReleaseDetails(msrest.serialization.Model): - """PhoneNumberReleaseDetails. - - :param status: The release status of a phone number. Possible values include: "Pending", - "Success", "Error", "InProgress". - :type status: str or ~azure.communication.phonenumbers.models.PhoneNumberReleaseStatus - :param error_code: The error code in the case the status is error. - :type error_code: int - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, + _validation = { + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'id': {'required': True}, + 'operation_type': {'required': True}, + 'last_action_date_time': {'readonly': True}, } - def __init__( - self, - **kwargs - ): - super(PhoneNumberReleaseDetails, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.error_code = kwargs.get('error_code', None) - - -class PhoneNumberReservation(msrest.serialization.Model): - """Represents a phone number search. - - :param reservation_id: The id of the search. - :type reservation_id: str - :param display_name: The name of the search. - :type display_name: str - :param created_at: The creation time of the search. - :type created_at: ~datetime.datetime - :param description: The description of the search. - :type description: str - :param phone_plan_ids: The phone plan ids of the search. - :type phone_plan_ids: list[str] - :param area_code: The area code of the search. - :type area_code: str - :param quantity: The quantity of phone numbers in the search. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - :param status: The status of the search. Possible values include: "Pending", "InProgress", - "Reserved", "Expired", "Expiring", "Completing", "Refreshing", "Success", "Manual", - "Cancelled", "Cancelling", "Error", "PurchasePending". - :type status: str or ~azure.communication.phonenumbers.models.SearchStatus - :param phone_numbers: The list of phone numbers in the search, in the case the status is - reserved or success. - :type phone_numbers: list[str] - :param reservation_expiry_date: The date that search expires and the numbers become available. - :type reservation_expiry_date: ~datetime.datetime - :param error_code: The error code of the search. - :type error_code: int - """ - _attribute_map = { - 'reservation_id': {'key': 'searchId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, - 'area_code': {'key': 'areaCode', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsDetails]'}, 'status': {'key': 'status', 'type': 'str'}, - 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, - 'reservation_expiry_date': {'key': 'reservationExpiryDate', 'type': 'iso-8601'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'CommunicationError'}, + 'id': {'key': 'id', 'type': 'str'}, + 'operation_type': {'key': 'operationType', 'type': 'str'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(PhoneNumberReservation, self).__init__(**kwargs) - self.reservation_id = kwargs.get('reservation_id', None) - self.display_name = kwargs.get('display_name', None) - self.created_at = kwargs.get('created_at', None) - self.description = kwargs.get('description', None) - self.phone_plan_ids = kwargs.get('phone_plan_ids', None) - self.area_code = kwargs.get('area_code', None) - self.quantity = kwargs.get('quantity', None) - self.location_options = kwargs.get('location_options', None) - self.status = kwargs.get('status', None) - self.phone_numbers = kwargs.get('phone_numbers', None) - self.reservation_expiry_date = kwargs.get('reservation_expiry_date', None) - self.error_code = kwargs.get('error_code', None) - + super(PhoneNumberOperation, self).__init__(**kwargs) + self.status = kwargs['status'] + self.resource_location = kwargs.get('resource_location', None) + self.created_date_time = kwargs['created_date_time'] + self.error = kwargs.get('error', None) + self.id = kwargs['id'] + self.operation_type = kwargs['operation_type'] + self.last_action_date_time = None -class PhonePlan(msrest.serialization.Model): - """Represents a phone plan. - All required parameters must be populated in order to send to Azure. +class PhoneNumberPurchaseRequest(msrest.serialization.Model): + """The phone number search purchase request. - :param phone_plan_id: Required. The phone plan id. - :type phone_plan_id: str - :param localized_name: Required. The name of the phone plan. - :type localized_name: str - :param location_type: Required. The location type of the phone plan. Possible values include: - "CivicAddress", "NotRequired", "Selection". - :type location_type: str or ~azure.communication.phonenumbers.models.LocationType - :param area_codes: The list of available area codes in the phone plan. - :type area_codes: list[str] - :param capabilities: Capabilities of the phone plan. - :type capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param maximum_search_size: The maximum number of phone numbers one can acquire in a search in - this phone plan. - :type maximum_search_size: int + :param search_id: The search id. + :type search_id: str """ - _validation = { - 'phone_plan_id': {'required': True}, - 'localized_name': {'required': True}, - 'location_type': {'required': True}, - } - _attribute_map = { - 'phone_plan_id': {'key': 'phonePlanId', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'location_type': {'key': 'locationType', 'type': 'str'}, - 'area_codes': {'key': 'areaCodes', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[str]'}, - 'maximum_search_size': {'key': 'maximumSearchSize', 'type': 'int'}, + 'search_id': {'key': 'searchId', 'type': 'str'}, } def __init__( self, **kwargs ): - super(PhonePlan, self).__init__(**kwargs) - self.phone_plan_id = kwargs['phone_plan_id'] - self.localized_name = kwargs['localized_name'] - self.location_type = kwargs['location_type'] - self.area_codes = kwargs.get('area_codes', None) - self.capabilities = kwargs.get('capabilities', None) - self.maximum_search_size = kwargs.get('maximum_search_size', None) + super(PhoneNumberPurchaseRequest, self).__init__(**kwargs) + self.search_id = kwargs.get('search_id', None) -class PhonePlanGroup(msrest.serialization.Model): - """Represents a plan group. +class PhoneNumberSearchRequest(msrest.serialization.Model): + """Represents a phone number search request to find phone numbers. Found phone numbers are temporarily held for a following purchase. All required parameters must be populated in order to send to Azure. - :param phone_plan_group_id: Required. The id of the plan group. - :type phone_plan_group_id: str - :param phone_number_type: The phone number type of the plan group. Possible values include: - "Unknown", "Geographic", "TollFree", "Indirect". + :param phone_number_type: Required. The type of phone numbers to search for, e.g. geographic, + or tollFree. Possible values include: "geographic", "tollFree". :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType - :param localized_name: Required. The name of the plan group. - :type localized_name: str - :param localized_description: Required. The description of the plan group. - :type localized_description: str - :param carrier_details: Represents carrier details. - :type carrier_details: ~azure.communication.phonenumbers.models.CarrierDetails - :param rate_information: Represents a wrapper of rate information. - :type rate_information: ~azure.communication.phonenumbers.models.RateInformation + :param assignment_type: Required. The assignment type of the phone numbers to search for. A + phone number can be assigned to a person, or to an application. Possible values include: + "person", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param area_code: The area code of the desired phone number, e.g. 425. + :type area_code: str + :param quantity: The quantity of desired phone numbers. The default value is 1. + :type quantity: int """ _validation = { - 'phone_plan_group_id': {'required': True}, - 'localized_name': {'required': True}, - 'localized_description': {'required': True}, + 'phone_number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'quantity': {'maximum': 2147483647, 'minimum': 1}, } _attribute_map = { - 'phone_plan_group_id': {'key': 'phonePlanGroupId', 'type': 'str'}, 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'localized_description': {'key': 'localizedDescription', 'type': 'str'}, - 'carrier_details': {'key': 'carrierDetails', 'type': 'CarrierDetails'}, - 'rate_information': {'key': 'rateInformation', 'type': 'RateInformation'}, - } - - def __init__( - self, - **kwargs - ): - super(PhonePlanGroup, self).__init__(**kwargs) - self.phone_plan_group_id = kwargs['phone_plan_group_id'] - self.phone_number_type = kwargs.get('phone_number_type', None) - self.localized_name = kwargs['localized_name'] - self.localized_description = kwargs['localized_description'] - self.carrier_details = kwargs.get('carrier_details', None) - self.rate_information = kwargs.get('rate_information', None) - - -class PhonePlanGroups(msrest.serialization.Model): - """Represents a wrapper of list of plan groups. - - :param phone_plan_groups: The underlying list of phone plan groups. - :type phone_plan_groups: list[~azure.communication.phonenumbers.models.PhonePlanGroup] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plan_groups': {'key': 'phonePlanGroups', 'type': '[PhonePlanGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PhonePlanGroups, self).__init__(**kwargs) - self.phone_plan_groups = kwargs.get('phone_plan_groups', None) - self.next_link = kwargs.get('next_link', None) - - -class PhonePlansResponse(msrest.serialization.Model): - """Represents a wrapper around a list of countries. - - :param phone_plans: Represents the underlying list of phone plans. - :type phone_plans: list[~azure.communication.phonenumbers.models.PhonePlan] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plans': {'key': 'phonePlans', 'type': '[PhonePlan]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PhonePlansResponse, self).__init__(**kwargs) - self.phone_plans = kwargs.get('phone_plans', None) - self.next_link = kwargs.get('next_link', None) - - -class PstnConfiguration(msrest.serialization.Model): - """Definition for pstn number configuration. - - All required parameters must be populated in order to send to Azure. - - :param callback_url: Required. The webhook URL on the phone number configuration. - :type callback_url: str - :param application_id: The application id of the application to which to configure. - :type application_id: str - """ - - _validation = { - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'application_id': {'key': 'applicationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PstnConfiguration, self).__init__(**kwargs) - self.callback_url = kwargs['callback_url'] - self.application_id = kwargs.get('application_id', None) - - -class RateInformation(msrest.serialization.Model): - """Represents a wrapper of rate information. - - :param monthly_rate: The monthly rate of a phone plan group. - :type monthly_rate: float - :param currency_type: The currency of a phone plan group. Possible values include: "USD". - :type currency_type: str or ~azure.communication.phonenumbers.models.CurrencyType - :param rate_error_message: The error code of a phone plan group. - :type rate_error_message: str - """ - - _attribute_map = { - 'monthly_rate': {'key': 'monthlyRate', 'type': 'float'}, - 'currency_type': {'key': 'currencyType', 'type': 'str'}, - 'rate_error_message': {'key': 'rateErrorMessage', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'area_code': {'key': 'areaCode', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, } def __init__( self, **kwargs ): - super(RateInformation, self).__init__(**kwargs) - self.monthly_rate = kwargs.get('monthly_rate', None) - self.currency_type = kwargs.get('currency_type', None) - self.rate_error_message = kwargs.get('rate_error_message', None) + super(PhoneNumberSearchRequest, self).__init__(**kwargs) + self.phone_number_type = kwargs['phone_number_type'] + self.assignment_type = kwargs['assignment_type'] + self.capabilities = kwargs['capabilities'] + self.area_code = kwargs.get('area_code', None) + self.quantity = kwargs.get('quantity', 1) -class ReleaseRequest(msrest.serialization.Model): - """Represents a release request. +class PhoneNumberSearchResult(msrest.serialization.Model): + """The result of a phone number search operation. All required parameters must be populated in order to send to Azure. - :param phone_numbers: Required. The list of phone numbers in the release request. + :param search_id: Required. The search id. + :type search_id: str + :param phone_numbers: Required. The phone numbers that are available. Can be fewer than the + desired search quantity. :type phone_numbers: list[str] + :param phone_number_type: Required. The phone number's type, e.g. geographic, or tollFree. + Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param assignment_type: Required. Phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param cost: Required. The incurred cost for a single phone number. + :type cost: ~azure.communication.phonenumbers.models.PhoneNumberCost + :param search_expires_by: Required. The date that this search result expires and phone numbers + are no longer on hold. A search result expires in less than 15min, e.g. + 2020-11-19T16:31:49.048Z. + :type search_expires_by: ~datetime.datetime """ _validation = { + 'search_id': {'required': True}, 'phone_numbers': {'required': True}, + 'phone_number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'cost': {'required': True}, + 'search_expires_by': {'required': True}, } _attribute_map = { + 'search_id': {'key': 'searchId', 'type': 'str'}, 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'cost': {'key': 'cost', 'type': 'PhoneNumberCost'}, + 'search_expires_by': {'key': 'searchExpiresBy', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(ReleaseRequest, self).__init__(**kwargs) + super(PhoneNumberSearchResult, self).__init__(**kwargs) + self.search_id = kwargs['search_id'] self.phone_numbers = kwargs['phone_numbers'] - - -class ReleaseResponse(msrest.serialization.Model): - """Represents a release response. - - All required parameters must be populated in order to send to Azure. - - :param release_id: Required. The release id of a created release. - :type release_id: str - """ - - _validation = { - 'release_id': {'required': True}, - } - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReleaseResponse, self).__init__(**kwargs) - self.release_id = kwargs['release_id'] - - -class UpdateNumberCapabilitiesRequest(msrest.serialization.Model): - """Represents a numbers capabilities update request. - - All required parameters must be populated in order to send to Azure. - - :param phone_number_capabilities_update: Required. The map of phone numbers to the capabilities - update applied to the phone number. - :type phone_number_capabilities_update: dict[str, - ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - """ - - _validation = { - 'phone_number_capabilities_update': {'required': True}, - } - - _attribute_map = { - 'phone_number_capabilities_update': {'key': 'phoneNumberCapabilitiesUpdate', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateNumberCapabilitiesRequest, self).__init__(**kwargs) - self.phone_number_capabilities_update = kwargs['phone_number_capabilities_update'] - - -class UpdateNumberCapabilitiesResponse(msrest.serialization.Model): - """Represents a number capability update response. - - All required parameters must be populated in order to send to Azure. - - :param capabilities_update_id: Required. The capabilities id. - :type capabilities_update_id: str - """ - - _validation = { - 'capabilities_update_id': {'required': True}, - } - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = kwargs['capabilities_update_id'] - - -class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): - """Response for getting a phone number update capabilities. - - :param capabilities_update_id: The id of the phone number capabilities update. - :type capabilities_update_id: str - :param created_at: The time the capabilities update was created. - :type created_at: ~datetime.datetime - :param capabilities_update_status: Status of the capabilities update. Possible values include: - "Pending", "InProgress", "Complete", "Error". - :type capabilities_update_status: str or - ~azure.communication.phonenumbers.models.CapabilitiesUpdateStatus - :param phone_number_capabilities_updates: The capabilities update for each of a set of phone - numbers. - :type phone_number_capabilities_updates: dict[str, - ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - """ - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'capabilities_update_status': {'key': 'capabilitiesUpdateStatus', 'type': 'str'}, - 'phone_number_capabilities_updates': {'key': 'phoneNumberCapabilitiesUpdates', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdatePhoneNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = kwargs.get('capabilities_update_id', None) - self.created_at = kwargs.get('created_at', None) - self.capabilities_update_status = kwargs.get('capabilities_update_status', None) - self.phone_number_capabilities_updates = kwargs.get('phone_number_capabilities_updates', None) + self.phone_number_type = kwargs['phone_number_type'] + self.assignment_type = kwargs['assignment_type'] + self.capabilities = kwargs['capabilities'] + self.cost = kwargs['cost'] + self.search_expires_by = kwargs['search_expires_by'] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models_py3.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models_py3.py index f9c9a56de98d..7c9e3386983b 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_models_py3.py @@ -7,12 +7,12 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._phone_number_administration_service_enums import * +from ._phone_numbers_client_enums import * class AcquiredPhoneNumber(msrest.serialization.Model): @@ -20,70 +20,90 @@ class AcquiredPhoneNumber(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param phone_number: Required. String of the E.164 format of the phone number. + :param id: Required. The id of the phone number, e.g. 11234567890. + :type id: str + :param phone_number: Required. String of the E.164 format of the phone number, e.g. + +11234567890. :type phone_number: str - :param acquired_capabilities: Required. The set of all acquired capabilities of the phone - number. - :type acquired_capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param available_capabilities: Required. The set of all available capabilities that can be - acquired for this phone number. - :type available_capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param assignment_status: The assignment status of the phone number. Conveys what type of - entity the number is assigned to. Possible values include: "Unassigned", "Unknown", - "UserAssigned", "ConferenceAssigned", "FirstPartyAppAssigned", "ThirdPartyAppAssigned". - :type assignment_status: str or ~azure.communication.phonenumbers.models.AssignmentStatus - :param place_name: The name of the place of the phone number. - :type place_name: str - :param activation_state: The activation state of the phone number. Can be "Activated", - "AssignmentPending", "AssignmentFailed", "UpdatePending", "UpdateFailed". Possible values - include: "Activated", "AssignmentPending", "AssignmentFailed", "UpdatePending", "UpdateFailed". - :type activation_state: str or ~azure.communication.phonenumbers.models.ActivationState + :param country_code: Required. The ISO 3166-2 code of the phone number's country, e.g. US. + :type country_code: str + :param phone_number_type: Required. The phone number's type, e.g. Geographic, TollFree. + Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param assignment_type: Required. The assignment type of the phone number. A phone number can + be assigned to a person, or to an application. Possible values include: "person", + "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param purchase_date: Required. The date and time that the phone number was purchased. + :type purchase_date: ~datetime.datetime + :param cost: Required. The incurred cost for a single phone number. + :type cost: ~azure.communication.phonenumbers.models.PhoneNumberCost """ _validation = { + 'id': {'required': True}, 'phone_number': {'required': True}, - 'acquired_capabilities': {'required': True}, - 'available_capabilities': {'required': True}, + 'country_code': {'required': True}, + 'phone_number_type': {'required': True}, + 'capabilities': {'required': True}, + 'assignment_type': {'required': True}, + 'purchase_date': {'required': True}, + 'cost': {'required': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'acquired_capabilities': {'key': 'acquiredCapabilities', 'type': '[str]'}, - 'available_capabilities': {'key': 'availableCapabilities', 'type': '[str]'}, - 'assignment_status': {'key': 'assignmentStatus', 'type': 'str'}, - 'place_name': {'key': 'placeName', 'type': 'str'}, - 'activation_state': {'key': 'activationState', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'purchase_date': {'key': 'purchaseDate', 'type': 'iso-8601'}, + 'cost': {'key': 'cost', 'type': 'PhoneNumberCost'}, } def __init__( self, *, + id: str, phone_number: str, - acquired_capabilities: List[Union[str, "Capability"]], - available_capabilities: List[Union[str, "Capability"]], - assignment_status: Optional[Union[str, "AssignmentStatus"]] = None, - place_name: Optional[str] = None, - activation_state: Optional[Union[str, "ActivationState"]] = None, + country_code: str, + phone_number_type: Union[str, "PhoneNumberType"], + capabilities: "PhoneNumberCapabilities", + assignment_type: Union[str, "PhoneNumberAssignmentType"], + purchase_date: datetime.datetime, + cost: "PhoneNumberCost", **kwargs ): super(AcquiredPhoneNumber, self).__init__(**kwargs) + self.id = id self.phone_number = phone_number - self.acquired_capabilities = acquired_capabilities - self.available_capabilities = available_capabilities - self.assignment_status = assignment_status - self.place_name = place_name - self.activation_state = activation_state + self.country_code = country_code + self.phone_number_type = phone_number_type + self.capabilities = capabilities + self.assignment_type = assignment_type + self.purchase_date = purchase_date + self.cost = cost class AcquiredPhoneNumbers(msrest.serialization.Model): - """A wrapper of list of phone numbers. + """The list of acquired phone numbers. - :param phone_numbers: Represents a list of phone numbers. + All required parameters must be populated in order to send to Azure. + + :param phone_numbers: Required. Represents a list of phone numbers. :type phone_numbers: list[~azure.communication.phonenumbers.models.AcquiredPhoneNumber] - :param next_link: Represents the URL link to the next page. + :param next_link: Represents the URL link to the next page of phone number results. :type next_link: str """ + _validation = { + 'phone_numbers': {'required': True}, + } + _attribute_map = { 'phone_numbers': {'key': 'phoneNumbers', 'type': '[AcquiredPhoneNumber]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, @@ -92,7 +112,7 @@ class AcquiredPhoneNumbers(msrest.serialization.Model): def __init__( self, *, - phone_numbers: Optional[List["AcquiredPhoneNumber"]] = None, + phone_numbers: List["AcquiredPhoneNumber"], next_link: Optional[str] = None, **kwargs ): @@ -101,1096 +121,389 @@ def __init__( self.next_link = next_link -class AreaCodes(msrest.serialization.Model): - """Represents a list of area codes. +class CommunicationError(msrest.serialization.Model): + """The Communication Services error. - :param primary_area_codes: Represents the list of primary area codes. - :type primary_area_codes: list[str] - :param secondary_area_codes: Represents the list of secondary area codes. - :type secondary_area_codes: list[str] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'primary_area_codes': {'key': 'primaryAreaCodes', 'type': '[str]'}, - 'secondary_area_codes': {'key': 'secondaryAreaCodes', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - primary_area_codes: Optional[List[str]] = None, - secondary_area_codes: Optional[List[str]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(AreaCodes, self).__init__(**kwargs) - self.primary_area_codes = primary_area_codes - self.secondary_area_codes = secondary_area_codes - self.next_link = next_link - - -class CarrierDetails(msrest.serialization.Model): - """Represents carrier details. - - :param name: Name of carrier details. - :type name: str - :param localized_name: Display name of carrier details. - :type localized_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - localized_name: Optional[str] = None, - **kwargs - ): - super(CarrierDetails, self).__init__(**kwargs) - self.name = name - self.localized_name = localized_name - - -class CreateSearchOptions(msrest.serialization.Model): - """Represents a search creation option. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param display_name: Required. Display name of the search. - :type display_name: str - :param description: Required. Description of the search. - :type description: str - :param phone_plan_ids: Required. The plan subtype ids from which to create the search. - :type phone_plan_ids: list[str] - :param area_code: Required. The area code from which to create the search. - :type area_code: str - :param quantity: The quantity of phone numbers to request. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - """ - - _validation = { - 'display_name': {'required': True, 'max_length': 255, 'min_length': 0}, - 'description': {'required': True, 'max_length': 255, 'min_length': 0}, - 'phone_plan_ids': {'required': True}, - 'area_code': {'required': True}, - 'quantity': {'maximum': 2147483647, 'minimum': 1}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, - 'area_code': {'key': 'areaCode', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - *, - display_name: str, - description: str, - phone_plan_ids: List[str], - area_code: str, - quantity: Optional[int] = None, - location_options: Optional[List["LocationOptionsDetails"]] = None, - **kwargs - ): - super(CreateSearchOptions, self).__init__(**kwargs) - self.display_name = display_name - self.description = description - self.phone_plan_ids = phone_plan_ids - self.area_code = area_code - self.quantity = quantity - self.location_options = location_options - - -class CreateSearchResponse(msrest.serialization.Model): - """Represents a search creation response. - - All required parameters must be populated in order to send to Azure. - - :param search_id: Required. The search id of the search that was created. - :type search_id: str + :param code: Required. The error code. + :type code: str + :param message: Required. The error message. + :type message: str + :ivar target: The error target. + :vartype target: str + :ivar details: Further details about specific errors that led to this error. + :vartype details: list[~azure.communication.phonenumbers.models.CommunicationError] + :ivar inner_error: The inner error if any. + :vartype inner_error: ~azure.communication.phonenumbers.models.CommunicationError """ _validation = { - 'search_id': {'required': True}, - } - - _attribute_map = { - 'search_id': {'key': 'searchId', 'type': 'str'}, + 'code': {'required': True}, + 'message': {'required': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'inner_error': {'readonly': True}, } - def __init__( - self, - *, - search_id: str, - **kwargs - ): - super(CreateSearchResponse, self).__init__(**kwargs) - self.search_id = search_id - - -class ErrorBody(msrest.serialization.Model): - """Represents a service error response body. - - :param code: The error code in the error response. - :type code: str - :param message: The error message in the error response. - :type message: str - """ - _attribute_map = { 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CommunicationError]'}, + 'inner_error': {'key': 'innererror', 'type': 'CommunicationError'}, } def __init__( self, *, - code: Optional[str] = None, - message: Optional[str] = None, + code: str, + message: str, **kwargs ): - super(ErrorBody, self).__init__(**kwargs) + super(CommunicationError, self).__init__(**kwargs) self.code = code self.message = message + self.target = None + self.details = None + self.inner_error = None -class ErrorResponse(msrest.serialization.Model): - """Represents a service error response. - - :param error: Represents a service error response body. - :type error: ~azure.communication.phonenumbers.models.ErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorBody'}, - } - - def __init__( - self, - *, - error: Optional["ErrorBody"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class LocationOptions(msrest.serialization.Model): - """Represents a location options. - - :param label_id: The label id of the location. - :type label_id: str - :param label_name: The display name of the location. - :type label_name: str - :param options: The underlying location option details. - :type options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'label_name': {'key': 'labelName', 'type': 'str'}, - 'options': {'key': 'options', 'type': '[LocationOptionsDetails]'}, - } - - def __init__( - self, - *, - label_id: Optional[str] = None, - label_name: Optional[str] = None, - options: Optional[List["LocationOptionsDetails"]] = None, - **kwargs - ): - super(LocationOptions, self).__init__(**kwargs) - self.label_id = label_id - self.label_name = label_name - self.options = options - - -class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options details. - - :param name: The name of the location options. - :type name: str - :param value: The abbreviated name of the location options. - :type value: str - :param location_options: The underlying location options. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptions] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptions]'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - location_options: Optional[List["LocationOptions"]] = None, - **kwargs - ): - super(LocationOptionsDetails, self).__init__(**kwargs) - self.name = name - self.value = value - self.location_options = location_options - - -class LocationOptionsQueries(msrest.serialization.Model): - """Represents a list of location option queries, used for fetching area codes. - - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsQuery] - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsQuery]'}, - } - - def __init__( - self, - *, - location_options: Optional[List["LocationOptionsQuery"]] = None, - **kwargs - ): - super(LocationOptionsQueries, self).__init__(**kwargs) - self.location_options = location_options - - -class LocationOptionsQuery(msrest.serialization.Model): - """Represents a location options parameter, used for fetching area codes. - - :param label_id: Represents the location option label id, returned from the GetLocationOptions - API. - :type label_id: str - :param options_value: Represents the location options value, returned from the - GetLocationOptions API. - :type options_value: str - """ - - _attribute_map = { - 'label_id': {'key': 'labelId', 'type': 'str'}, - 'options_value': {'key': 'optionsValue', 'type': 'str'}, - } - - def __init__( - self, - *, - label_id: Optional[str] = None, - options_value: Optional[str] = None, - **kwargs - ): - super(LocationOptionsQuery, self).__init__(**kwargs) - self.label_id = label_id - self.options_value = options_value - - -class LocationOptionsResponse(msrest.serialization.Model): - """Represents a wrapper around a list of location options. - - :param location_options: Represents a location options. - :type location_options: ~azure.communication.phonenumbers.models.LocationOptions - """ - - _attribute_map = { - 'location_options': {'key': 'locationOptions', 'type': 'LocationOptions'}, - } - - def __init__( - self, - *, - location_options: Optional["LocationOptions"] = None, - **kwargs - ): - super(LocationOptionsResponse, self).__init__(**kwargs) - self.location_options = location_options - - -class NumberConfiguration(msrest.serialization.Model): - """Definition for number configuration. - - All required parameters must be populated in order to send to Azure. - - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration - :param phone_number: Required. The phone number to configure. - :type phone_number: str - """ - - _validation = { - 'pstn_configuration': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - *, - pstn_configuration: "PstnConfiguration", - phone_number: str, - **kwargs - ): - super(NumberConfiguration, self).__init__(**kwargs) - self.pstn_configuration = pstn_configuration - self.phone_number = phone_number - - -class NumberConfigurationPhoneNumber(msrest.serialization.Model): - """The phone number wrapper representing a number configuration request. +class CommunicationErrorResponse(msrest.serialization.Model): + """The Communication Services error. All required parameters must be populated in order to send to Azure. - :param phone_number: Required. The phone number in the E.164 format. - :type phone_number: str + :param error: Required. The Communication Services error. + :type error: ~azure.communication.phonenumbers.models.CommunicationError """ _validation = { - 'phone_number': {'required': True}, + 'error': {'required': True}, } _attribute_map = { - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'CommunicationError'}, } def __init__( self, *, - phone_number: str, + error: "CommunicationError", **kwargs ): - super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) - self.phone_number = phone_number + super(CommunicationErrorResponse, self).__init__(**kwargs) + self.error = error -class NumberConfigurationResponse(msrest.serialization.Model): - """Definition for number configuration. +class PhoneNumberCapabilities(msrest.serialization.Model): + """Capabilities of a phone number. All required parameters must be populated in order to send to Azure. - :param pstn_configuration: Required. Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration + :param calling: Required. Capability value for calling. Possible values include: "none", + "inbound", "outbound", "inbound+outbound". + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Required. Capability value for SMS. Possible values include: "none", "inbound", + "outbound", "inbound+outbound". + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType """ _validation = { - 'pstn_configuration': {'required': True}, - } - - _attribute_map = { - 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + 'calling': {'required': True}, + 'sms': {'required': True}, } - def __init__( - self, - *, - pstn_configuration: "PstnConfiguration", - **kwargs - ): - super(NumberConfigurationResponse, self).__init__(**kwargs) - self.pstn_configuration = pstn_configuration - - -class NumberUpdateCapabilities(msrest.serialization.Model): - """Represents an individual number capabilities update request. - - :param add: Capabilities to be added to a phone number. - :type add: list[str or ~azure.communication.phonenumbers.models.Capability] - :param remove: Capabilities to be removed from a phone number. - :type remove: list[str or ~azure.communication.phonenumbers.models.Capability] - """ - _attribute_map = { - 'add': {'key': 'add', 'type': '[str]'}, - 'remove': {'key': 'remove', 'type': '[str]'}, + 'calling': {'key': 'calling', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, } def __init__( self, *, - add: Optional[List[Union[str, "Capability"]]] = None, - remove: Optional[List[Union[str, "Capability"]]] = None, + calling: Union[str, "PhoneNumberCapabilityType"], + sms: Union[str, "PhoneNumberCapabilityType"], **kwargs ): - super(NumberUpdateCapabilities, self).__init__(**kwargs) - self.add = add - self.remove = remove + super(PhoneNumberCapabilities, self).__init__(**kwargs) + self.calling = calling + self.sms = sms -class PhoneNumberCountries(msrest.serialization.Model): - """Represents a wrapper around a list of countries. +class PhoneNumberCapabilitiesRequest(msrest.serialization.Model): + """Capabilities of a phone number. - :param countries: Represents the underlying list of countries. - :type countries: list[~azure.communication.phonenumbers.models.PhoneNumberCountry] - :param next_link: Represents the URL link to the next page. - :type next_link: str + :param calling: Capability value for calling. Possible values include: "none", "inbound", + "outbound", "inbound+outbound". + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. Possible values include: "none", "inbound", "outbound", + "inbound+outbound". + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType """ _attribute_map = { - 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'calling': {'key': 'calling', 'type': 'str'}, + 'sms': {'key': 'sms', 'type': 'str'}, } def __init__( self, *, - countries: Optional[List["PhoneNumberCountry"]] = None, - next_link: Optional[str] = None, + calling: Optional[Union[str, "PhoneNumberCapabilityType"]] = None, + sms: Optional[Union[str, "PhoneNumberCapabilityType"]] = None, **kwargs ): - super(PhoneNumberCountries, self).__init__(**kwargs) - self.countries = countries - self.next_link = next_link + super(PhoneNumberCapabilitiesRequest, self).__init__(**kwargs) + self.calling = calling + self.sms = sms -class PhoneNumberCountry(msrest.serialization.Model): - """Represents a country. +class PhoneNumberCost(msrest.serialization.Model): + """The incurred cost for a single phone number. All required parameters must be populated in order to send to Azure. - :param localized_name: Required. Represents the name of the country. - :type localized_name: str - :param country_code: Required. Represents the abbreviated name of the country. - :type country_code: str + :param amount: Required. The cost amount. + :type amount: float + :param currency_code: Required. The ISO 4217 currency code for the cost amount, e.g. USD. + :type currency_code: str + :param billing_frequency: Required. The frequency with which the cost gets billed. Possible + values include: "monthly". + :type billing_frequency: str or ~azure.communication.phonenumbers.models.BillingFrequency """ _validation = { - 'localized_name': {'required': True}, - 'country_code': {'required': True}, + 'amount': {'required': True}, + 'currency_code': {'required': True}, + 'billing_frequency': {'required': True}, } _attribute_map = { - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'billing_frequency': {'key': 'billingFrequency', 'type': 'str'}, } def __init__( self, *, - localized_name: str, - country_code: str, + amount: float, + currency_code: str, + billing_frequency: Union[str, "BillingFrequency"], **kwargs ): - super(PhoneNumberCountry, self).__init__(**kwargs) - self.localized_name = localized_name - self.country_code = country_code - - -class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searches or releases, as part of the response when fetching all searches or releases. + super(PhoneNumberCost, self).__init__(**kwargs) + self.amount = amount + self.currency_code = currency_code + self.billing_frequency = billing_frequency - :param entities: The underlying list of entities. - :type entities: list[~azure.communication.phonenumbers.models.PhoneNumberEntity] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - _attribute_map = { - 'entities': {'key': 'entities', 'type': '[PhoneNumberEntity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } +class PhoneNumberOperation(msrest.serialization.Model): + """Long running operation. - def __init__( - self, - *, - entities: Optional[List["PhoneNumberEntity"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhoneNumberEntities, self).__init__(**kwargs) - self.entities = entities - self.next_link = next_link + 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. -class PhoneNumberEntity(msrest.serialization.Model): - """Represents a phone number entity, as part of the response when calling get all searches or releases. - - :param id: The id of the entity. It is the search id of a search. It is the release id of a - release. + :param status: Required. Status of operation. Possible values include: "notStarted", "running", + "succeeded", "failed". + :type status: str or ~azure.communication.phonenumbers.models.PhoneNumberOperationStatus + :param resource_location: URL for retrieving the result of the operation, if any. + :type resource_location: str + :param created_date_time: Required. The date that the operation was created. + :type created_date_time: ~datetime.datetime + :param error: The Communication Services error. + :type error: ~azure.communication.phonenumbers.models.CommunicationError + :param id: Required. Id of operation. :type id: str - :param created_at: Date and time the entity is created. - :type created_at: ~datetime.datetime - :param display_name: Name of the entity. - :type display_name: str - :param quantity: Quantity of requested phone numbers in the entity. - :type quantity: int - :param quantity_obtained: Quantity of acquired phone numbers in the entity. - :type quantity_obtained: int - :param status: Status of the entity. - :type status: str - :param foc_date: The Firm Order Confirmation date of the phone number entity. - :type foc_date: ~datetime.datetime + :param operation_type: Required. The type of operation, e.g. Search. Possible values include: + "purchase", "releasePhoneNumber", "search", "updatePhoneNumberCapabilities". + :type operation_type: str or ~azure.communication.phonenumbers.models.PhoneNumberOperationType + :ivar last_action_date_time: The most recent date that the operation was changed. + :vartype last_action_date_time: ~datetime.datetime """ - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'quantity_obtained': {'key': 'quantityObtained', 'type': 'int'}, - 'status': {'key': 'status', 'type': 'str'}, - 'foc_date': {'key': 'focDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - id: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - display_name: Optional[str] = None, - quantity: Optional[int] = None, - quantity_obtained: Optional[int] = None, - status: Optional[str] = None, - foc_date: Optional[datetime.datetime] = None, - **kwargs - ): - super(PhoneNumberEntity, self).__init__(**kwargs) - self.id = id - self.created_at = created_at - self.display_name = display_name - self.quantity = quantity - self.quantity_obtained = quantity_obtained - self.status = status - self.foc_date = foc_date - - -class PhoneNumberRelease(msrest.serialization.Model): - """Represents a release. - - :param release_id: The id of the release. - :type release_id: str - :param created_at: The creation time of the release. - :type created_at: ~datetime.datetime - :param status: The release status. Possible values include: "Pending", "InProgress", - "Complete", "Failed", "Expired". - :type status: str or ~azure.communication.phonenumbers.models.ReleaseStatus - :param error_message: The underlying error message of a release. - :type error_message: str - :param phone_number_release_status_details: The list of phone numbers in the release, mapped to - its individual statuses. - :type phone_number_release_status_details: dict[str, - ~azure.communication.phonenumbers.models.PhoneNumberReleaseDetails] - """ - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'phone_number_release_status_details': {'key': 'phoneNumberReleaseStatusDetails', 'type': '{PhoneNumberReleaseDetails}'}, + _validation = { + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'id': {'required': True}, + 'operation_type': {'required': True}, + 'last_action_date_time': {'readonly': True}, } - def __init__( - self, - *, - release_id: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - status: Optional[Union[str, "ReleaseStatus"]] = None, - error_message: Optional[str] = None, - phone_number_release_status_details: Optional[Dict[str, "PhoneNumberReleaseDetails"]] = None, - **kwargs - ): - super(PhoneNumberRelease, self).__init__(**kwargs) - self.release_id = release_id - self.created_at = created_at - self.status = status - self.error_message = error_message - self.phone_number_release_status_details = phone_number_release_status_details - - -class PhoneNumberReleaseDetails(msrest.serialization.Model): - """PhoneNumberReleaseDetails. - - :param status: The release status of a phone number. Possible values include: "Pending", - "Success", "Error", "InProgress". - :type status: str or ~azure.communication.phonenumbers.models.PhoneNumberReleaseStatus - :param error_code: The error code in the case the status is error. - :type error_code: int - """ - _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "PhoneNumberReleaseStatus"]] = None, - error_code: Optional[int] = None, - **kwargs - ): - super(PhoneNumberReleaseDetails, self).__init__(**kwargs) - self.status = status - self.error_code = error_code - - -class PhoneNumberReservation(msrest.serialization.Model): - """Represents a phone number search. - - :param reservation_id: The id of the search. - :type reservation_id: str - :param display_name: The name of the search. - :type display_name: str - :param created_at: The creation time of the search. - :type created_at: ~datetime.datetime - :param description: The description of the search. - :type description: str - :param phone_plan_ids: The phone plan ids of the search. - :type phone_plan_ids: list[str] - :param area_code: The area code of the search. - :type area_code: str - :param quantity: The quantity of phone numbers in the search. - :type quantity: int - :param location_options: The location options of the search. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsDetails] - :param status: The status of the search. Possible values include: "Pending", "InProgress", - "Reserved", "Expired", "Expiring", "Completing", "Refreshing", "Success", "Manual", - "Cancelled", "Cancelling", "Error", "PurchasePending". - :type status: str or ~azure.communication.phonenumbers.models.SearchStatus - :param phone_numbers: The list of phone numbers in the search, in the case the status is - reserved or success. - :type phone_numbers: list[str] - :param reservation_expiry_date: The date that search expires and the numbers become available. - :type reservation_expiry_date: ~datetime.datetime - :param error_code: The error code of the search. - :type error_code: int - """ - - _attribute_map = { - 'reservation_id': {'key': 'searchId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - 'phone_plan_ids': {'key': 'phonePlanIds', 'type': '[str]'}, - 'area_code': {'key': 'areaCode', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'int'}, - 'location_options': {'key': 'locationOptions', 'type': '[LocationOptionsDetails]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, - 'reservation_expiry_date': {'key': 'reservationExpiryDate', 'type': 'iso-8601'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'CommunicationError'}, + 'id': {'key': 'id', 'type': 'str'}, + 'operation_type': {'key': 'operationType', 'type': 'str'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, } def __init__( self, *, - reservation_id: Optional[str] = None, - display_name: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - description: Optional[str] = None, - phone_plan_ids: Optional[List[str]] = None, - area_code: Optional[str] = None, - quantity: Optional[int] = None, - location_options: Optional[List["LocationOptionsDetails"]] = None, - status: Optional[Union[str, "SearchStatus"]] = None, - phone_numbers: Optional[List[str]] = None, - reservation_expiry_date: Optional[datetime.datetime] = None, - error_code: Optional[int] = None, + status: Union[str, "PhoneNumberOperationStatus"], + created_date_time: datetime.datetime, + id: str, + operation_type: Union[str, "PhoneNumberOperationType"], + resource_location: Optional[str] = None, + error: Optional["CommunicationError"] = None, **kwargs ): - super(PhoneNumberReservation, self).__init__(**kwargs) - self.reservation_id = reservation_id - self.display_name = display_name - self.created_at = created_at - self.description = description - self.phone_plan_ids = phone_plan_ids - self.area_code = area_code - self.quantity = quantity - self.location_options = location_options + super(PhoneNumberOperation, self).__init__(**kwargs) self.status = status - self.phone_numbers = phone_numbers - self.reservation_expiry_date = reservation_expiry_date - self.error_code = error_code - + self.resource_location = resource_location + self.created_date_time = created_date_time + self.error = error + self.id = id + self.operation_type = operation_type + self.last_action_date_time = None -class PhonePlan(msrest.serialization.Model): - """Represents a phone plan. - All required parameters must be populated in order to send to Azure. +class PhoneNumberPurchaseRequest(msrest.serialization.Model): + """The phone number search purchase request. - :param phone_plan_id: Required. The phone plan id. - :type phone_plan_id: str - :param localized_name: Required. The name of the phone plan. - :type localized_name: str - :param location_type: Required. The location type of the phone plan. Possible values include: - "CivicAddress", "NotRequired", "Selection". - :type location_type: str or ~azure.communication.phonenumbers.models.LocationType - :param area_codes: The list of available area codes in the phone plan. - :type area_codes: list[str] - :param capabilities: Capabilities of the phone plan. - :type capabilities: list[str or ~azure.communication.phonenumbers.models.Capability] - :param maximum_search_size: The maximum number of phone numbers one can acquire in a search in - this phone plan. - :type maximum_search_size: int + :param search_id: The search id. + :type search_id: str """ - _validation = { - 'phone_plan_id': {'required': True}, - 'localized_name': {'required': True}, - 'location_type': {'required': True}, - } - _attribute_map = { - 'phone_plan_id': {'key': 'phonePlanId', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'location_type': {'key': 'locationType', 'type': 'str'}, - 'area_codes': {'key': 'areaCodes', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[str]'}, - 'maximum_search_size': {'key': 'maximumSearchSize', 'type': 'int'}, + 'search_id': {'key': 'searchId', 'type': 'str'}, } def __init__( self, *, - phone_plan_id: str, - localized_name: str, - location_type: Union[str, "LocationType"], - area_codes: Optional[List[str]] = None, - capabilities: Optional[List[Union[str, "Capability"]]] = None, - maximum_search_size: Optional[int] = None, + search_id: Optional[str] = None, **kwargs ): - super(PhonePlan, self).__init__(**kwargs) - self.phone_plan_id = phone_plan_id - self.localized_name = localized_name - self.location_type = location_type - self.area_codes = area_codes - self.capabilities = capabilities - self.maximum_search_size = maximum_search_size + super(PhoneNumberPurchaseRequest, self).__init__(**kwargs) + self.search_id = search_id -class PhonePlanGroup(msrest.serialization.Model): - """Represents a plan group. +class PhoneNumberSearchRequest(msrest.serialization.Model): + """Represents a phone number search request to find phone numbers. Found phone numbers are temporarily held for a following purchase. All required parameters must be populated in order to send to Azure. - :param phone_plan_group_id: Required. The id of the plan group. - :type phone_plan_group_id: str - :param phone_number_type: The phone number type of the plan group. Possible values include: - "Unknown", "Geographic", "TollFree", "Indirect". + :param phone_number_type: Required. The type of phone numbers to search for, e.g. geographic, + or tollFree. Possible values include: "geographic", "tollFree". :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType - :param localized_name: Required. The name of the plan group. - :type localized_name: str - :param localized_description: Required. The description of the plan group. - :type localized_description: str - :param carrier_details: Represents carrier details. - :type carrier_details: ~azure.communication.phonenumbers.models.CarrierDetails - :param rate_information: Represents a wrapper of rate information. - :type rate_information: ~azure.communication.phonenumbers.models.RateInformation + :param assignment_type: Required. The assignment type of the phone numbers to search for. A + phone number can be assigned to a person, or to an application. Possible values include: + "person", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param area_code: The area code of the desired phone number, e.g. 425. + :type area_code: str + :param quantity: The quantity of desired phone numbers. The default value is 1. + :type quantity: int """ _validation = { - 'phone_plan_group_id': {'required': True}, - 'localized_name': {'required': True}, - 'localized_description': {'required': True}, + 'phone_number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'quantity': {'maximum': 2147483647, 'minimum': 1}, } _attribute_map = { - 'phone_plan_group_id': {'key': 'phonePlanGroupId', 'type': 'str'}, 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, - 'localized_name': {'key': 'localizedName', 'type': 'str'}, - 'localized_description': {'key': 'localizedDescription', 'type': 'str'}, - 'carrier_details': {'key': 'carrierDetails', 'type': 'CarrierDetails'}, - 'rate_information': {'key': 'rateInformation', 'type': 'RateInformation'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'area_code': {'key': 'areaCode', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, } def __init__( self, *, - phone_plan_group_id: str, - localized_name: str, - localized_description: str, - phone_number_type: Optional[Union[str, "PhoneNumberType"]] = None, - carrier_details: Optional["CarrierDetails"] = None, - rate_information: Optional["RateInformation"] = None, + phone_number_type: Union[str, "PhoneNumberType"], + assignment_type: Union[str, "PhoneNumberAssignmentType"], + capabilities: "PhoneNumberCapabilities", + area_code: Optional[str] = None, + quantity: Optional[int] = 1, **kwargs ): - super(PhonePlanGroup, self).__init__(**kwargs) - self.phone_plan_group_id = phone_plan_group_id + super(PhoneNumberSearchRequest, self).__init__(**kwargs) self.phone_number_type = phone_number_type - self.localized_name = localized_name - self.localized_description = localized_description - self.carrier_details = carrier_details - self.rate_information = rate_information - - -class PhonePlanGroups(msrest.serialization.Model): - """Represents a wrapper of list of plan groups. - - :param phone_plan_groups: The underlying list of phone plan groups. - :type phone_plan_groups: list[~azure.communication.phonenumbers.models.PhonePlanGroup] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plan_groups': {'key': 'phonePlanGroups', 'type': '[PhonePlanGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - phone_plan_groups: Optional[List["PhonePlanGroup"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhonePlanGroups, self).__init__(**kwargs) - self.phone_plan_groups = phone_plan_groups - self.next_link = next_link - - -class PhonePlansResponse(msrest.serialization.Model): - """Represents a wrapper around a list of countries. - - :param phone_plans: Represents the underlying list of phone plans. - :type phone_plans: list[~azure.communication.phonenumbers.models.PhonePlan] - :param next_link: Represents the URL link to the next page. - :type next_link: str - """ - - _attribute_map = { - 'phone_plans': {'key': 'phonePlans', 'type': '[PhonePlan]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - phone_plans: Optional[List["PhonePlan"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(PhonePlansResponse, self).__init__(**kwargs) - self.phone_plans = phone_plans - self.next_link = next_link - - -class PstnConfiguration(msrest.serialization.Model): - """Definition for pstn number configuration. - - All required parameters must be populated in order to send to Azure. - - :param callback_url: Required. The webhook URL on the phone number configuration. - :type callback_url: str - :param application_id: The application id of the application to which to configure. - :type application_id: str - """ - - _validation = { - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'application_id': {'key': 'applicationId', 'type': 'str'}, - } - - def __init__( - self, - *, - callback_url: str, - application_id: Optional[str] = None, - **kwargs - ): - super(PstnConfiguration, self).__init__(**kwargs) - self.callback_url = callback_url - self.application_id = application_id - - -class RateInformation(msrest.serialization.Model): - """Represents a wrapper of rate information. - - :param monthly_rate: The monthly rate of a phone plan group. - :type monthly_rate: float - :param currency_type: The currency of a phone plan group. Possible values include: "USD". - :type currency_type: str or ~azure.communication.phonenumbers.models.CurrencyType - :param rate_error_message: The error code of a phone plan group. - :type rate_error_message: str - """ - - _attribute_map = { - 'monthly_rate': {'key': 'monthlyRate', 'type': 'float'}, - 'currency_type': {'key': 'currencyType', 'type': 'str'}, - 'rate_error_message': {'key': 'rateErrorMessage', 'type': 'str'}, - } - - def __init__( - self, - *, - monthly_rate: Optional[float] = None, - currency_type: Optional[Union[str, "CurrencyType"]] = None, - rate_error_message: Optional[str] = None, - **kwargs - ): - super(RateInformation, self).__init__(**kwargs) - self.monthly_rate = monthly_rate - self.currency_type = currency_type - self.rate_error_message = rate_error_message + self.assignment_type = assignment_type + self.capabilities = capabilities + self.area_code = area_code + self.quantity = quantity -class ReleaseRequest(msrest.serialization.Model): - """Represents a release request. +class PhoneNumberSearchResult(msrest.serialization.Model): + """The result of a phone number search operation. All required parameters must be populated in order to send to Azure. - :param phone_numbers: Required. The list of phone numbers in the release request. + :param search_id: Required. The search id. + :type search_id: str + :param phone_numbers: Required. The phone numbers that are available. Can be fewer than the + desired search quantity. :type phone_numbers: list[str] + :param phone_number_type: Required. The phone number's type, e.g. geographic, or tollFree. + Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param assignment_type: Required. Phone number's assignment type. Possible values include: + "person", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :param cost: Required. The incurred cost for a single phone number. + :type cost: ~azure.communication.phonenumbers.models.PhoneNumberCost + :param search_expires_by: Required. The date that this search result expires and phone numbers + are no longer on hold. A search result expires in less than 15min, e.g. + 2020-11-19T16:31:49.048Z. + :type search_expires_by: ~datetime.datetime """ _validation = { + 'search_id': {'required': True}, 'phone_numbers': {'required': True}, + 'phone_number_type': {'required': True}, + 'assignment_type': {'required': True}, + 'capabilities': {'required': True}, + 'cost': {'required': True}, + 'search_expires_by': {'required': True}, } _attribute_map = { + 'search_id': {'key': 'searchId', 'type': 'str'}, 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + 'phone_number_type': {'key': 'phoneNumberType', 'type': 'str'}, + 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': 'PhoneNumberCapabilities'}, + 'cost': {'key': 'cost', 'type': 'PhoneNumberCost'}, + 'search_expires_by': {'key': 'searchExpiresBy', 'type': 'iso-8601'}, } def __init__( self, *, + search_id: str, phone_numbers: List[str], + phone_number_type: Union[str, "PhoneNumberType"], + assignment_type: Union[str, "PhoneNumberAssignmentType"], + capabilities: "PhoneNumberCapabilities", + cost: "PhoneNumberCost", + search_expires_by: datetime.datetime, **kwargs ): - super(ReleaseRequest, self).__init__(**kwargs) + super(PhoneNumberSearchResult, self).__init__(**kwargs) + self.search_id = search_id self.phone_numbers = phone_numbers - - -class ReleaseResponse(msrest.serialization.Model): - """Represents a release response. - - All required parameters must be populated in order to send to Azure. - - :param release_id: Required. The release id of a created release. - :type release_id: str - """ - - _validation = { - 'release_id': {'required': True}, - } - - _attribute_map = { - 'release_id': {'key': 'releaseId', 'type': 'str'}, - } - - def __init__( - self, - *, - release_id: str, - **kwargs - ): - super(ReleaseResponse, self).__init__(**kwargs) - self.release_id = release_id - - -class UpdateNumberCapabilitiesRequest(msrest.serialization.Model): - """Represents a numbers capabilities update request. - - All required parameters must be populated in order to send to Azure. - - :param phone_number_capabilities_update: Required. The map of phone numbers to the capabilities - update applied to the phone number. - :type phone_number_capabilities_update: dict[str, - ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - """ - - _validation = { - 'phone_number_capabilities_update': {'required': True}, - } - - _attribute_map = { - 'phone_number_capabilities_update': {'key': 'phoneNumberCapabilitiesUpdate', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - *, - phone_number_capabilities_update: Dict[str, "NumberUpdateCapabilities"], - **kwargs - ): - super(UpdateNumberCapabilitiesRequest, self).__init__(**kwargs) - self.phone_number_capabilities_update = phone_number_capabilities_update - - -class UpdateNumberCapabilitiesResponse(msrest.serialization.Model): - """Represents a number capability update response. - - All required parameters must be populated in order to send to Azure. - - :param capabilities_update_id: Required. The capabilities id. - :type capabilities_update_id: str - """ - - _validation = { - 'capabilities_update_id': {'required': True}, - } - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - } - - def __init__( - self, - *, - capabilities_update_id: str, - **kwargs - ): - super(UpdateNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = capabilities_update_id - - -class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): - """Response for getting a phone number update capabilities. - - :param capabilities_update_id: The id of the phone number capabilities update. - :type capabilities_update_id: str - :param created_at: The time the capabilities update was created. - :type created_at: ~datetime.datetime - :param capabilities_update_status: Status of the capabilities update. Possible values include: - "Pending", "InProgress", "Complete", "Error". - :type capabilities_update_status: str or - ~azure.communication.phonenumbers.models.CapabilitiesUpdateStatus - :param phone_number_capabilities_updates: The capabilities update for each of a set of phone - numbers. - :type phone_number_capabilities_updates: dict[str, - ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - """ - - _attribute_map = { - 'capabilities_update_id': {'key': 'capabilitiesUpdateId', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'capabilities_update_status': {'key': 'capabilitiesUpdateStatus', 'type': 'str'}, - 'phone_number_capabilities_updates': {'key': 'phoneNumberCapabilitiesUpdates', 'type': '{NumberUpdateCapabilities}'}, - } - - def __init__( - self, - *, - capabilities_update_id: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - capabilities_update_status: Optional[Union[str, "CapabilitiesUpdateStatus"]] = None, - phone_number_capabilities_updates: Optional[Dict[str, "NumberUpdateCapabilities"]] = None, - **kwargs - ): - super(UpdatePhoneNumberCapabilitiesResponse, self).__init__(**kwargs) - self.capabilities_update_id = capabilities_update_id - self.created_at = created_at - self.capabilities_update_status = capabilities_update_status - self.phone_number_capabilities_updates = phone_number_capabilities_updates + self.phone_number_type = phone_number_type + self.assignment_type = assignment_type + self.capabilities = capabilities + self.cost = cost + self.search_expires_by = search_expires_by diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_number_administration_service_enums.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_number_administration_service_enums.py deleted file mode 100644 index 5b53cc8756be..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_number_administration_service_enums.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActivationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The activation state of the phone number. Can be "Activated", "AssignmentPending", - "AssignmentFailed", "UpdatePending", "UpdateFailed" - """ - - ACTIVATED = "Activated" - ASSIGNMENT_PENDING = "AssignmentPending" - ASSIGNMENT_FAILED = "AssignmentFailed" - UPDATE_PENDING = "UpdatePending" - UPDATE_FAILED = "UpdateFailed" - -class AssignmentStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The assignment status of the phone number. Conveys what type of entity the number is assigned - to. - """ - - UNASSIGNED = "Unassigned" - UNKNOWN = "Unknown" - USER_ASSIGNED = "UserAssigned" - CONFERENCE_ASSIGNED = "ConferenceAssigned" - FIRST_PARTY_APP_ASSIGNED = "FirstPartyAppAssigned" - THIRD_PARTY_APP_ASSIGNED = "ThirdPartyAppAssigned" - -class CapabilitiesUpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the capabilities update. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - COMPLETE = "Complete" - ERROR = "Error" - -class Capability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Represents the capabilities of a phone number. - """ - - USER_ASSIGNMENT = "UserAssignment" - FIRST_PARTY_VOICE_APP_ASSIGNMENT = "FirstPartyVoiceAppAssignment" - CONFERENCE_ASSIGNMENT = "ConferenceAssignment" - P2_P_SMS_ENABLED = "P2PSmsEnabled" - GEOGRAPHIC = "Geographic" - NON_GEOGRAPHIC = "NonGeographic" - TOLL_CALLING = "TollCalling" - TOLL_FREE_CALLING = "TollFreeCalling" - PREMIUM = "Premium" - P2_P_SMS_CAPABLE = "P2PSmsCapable" - A2_P_SMS_CAPABLE = "A2PSmsCapable" - A2_P_SMS_ENABLED = "A2PSmsEnabled" - CALLING = "Calling" - TOLL_FREE = "TollFree" - FIRST_PARTY_APP_ASSIGNMENT = "FirstPartyAppAssignment" - THIRD_PARTY_APP_ASSIGNMENT = "ThirdPartyAppAssignment" - AZURE = "Azure" - OFFICE365 = "Office365" - INBOUND_CALLING = "InboundCalling" - OUTBOUND_CALLING = "OutboundCalling" - INBOUND_A2_P_SMS = "InboundA2PSms" - OUTBOUND_A2_P_SMS = "OutboundA2PSms" - INBOUND_P2_P_SMS = "InboundP2PSms" - OUTBOUND_P2_P_SMS = "OutboundP2PSms" - -class CurrencyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The currency of a phone plan group - """ - - USD = "USD" - -class LocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The location type of the phone plan. - """ - - CIVIC_ADDRESS = "CivicAddress" - NOT_REQUIRED = "NotRequired" - SELECTION = "Selection" - -class PhoneNumberReleaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The release status of a phone number. - """ - - PENDING = "Pending" - SUCCESS = "Success" - ERROR = "Error" - IN_PROGRESS = "InProgress" - -class PhoneNumberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The phone number type of the plan group - """ - - UNKNOWN = "Unknown" - GEOGRAPHIC = "Geographic" - TOLL_FREE = "TollFree" - INDIRECT = "Indirect" - -class ReleaseStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The release status. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - COMPLETE = "Complete" - FAILED = "Failed" - EXPIRED = "Expired" - -class SearchStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the search. - """ - - PENDING = "Pending" - IN_PROGRESS = "InProgress" - RESERVED = "Reserved" - EXPIRED = "Expired" - EXPIRING = "Expiring" - COMPLETING = "Completing" - REFRESHING = "Refreshing" - SUCCESS = "Success" - MANUAL = "Manual" - CANCELLED = "Cancelled" - CANCELLING = "Cancelling" - ERROR = "Error" - PURCHASE_PENDING = "PurchasePending" diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_numbers_client_enums.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_numbers_client_enums.py new file mode 100644 index 000000000000..3e1c41cf5626 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/models/_phone_numbers_client_enums.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The frequency with which the cost gets billed. + """ + + MONTHLY = "monthly" + +class PhoneNumberAssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The assignment type of the phone numbers to search for. A phone number can be assigned to a + person, or to an application. + """ + + PERSON = "person" + APPLICATION = "application" + +class PhoneNumberCapabilityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Capability value for calling. + """ + + NONE = "none" + INBOUND = "inbound" + OUTBOUND = "outbound" + INBOUND_OUTBOUND = "inbound+outbound" + +class PhoneNumberOperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of operation. + """ + + NOT_STARTED = "notStarted" + RUNNING = "running" + SUCCEEDED = "succeeded" + FAILED = "failed" + +class PhoneNumberOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of operation, e.g. Search + """ + + PURCHASE = "purchase" + RELEASE_PHONE_NUMBER = "releasePhoneNumber" + SEARCH = "search" + UPDATE_PHONE_NUMBER_CAPABILITIES = "updatePhoneNumberCapabilities" + +class PhoneNumberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of phone numbers to search for, e.g. geographic, or tollFree. + """ + + GEOGRAPHIC = "geographic" + TOLL_FREE = "tollFree" diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/__init__.py index 50478d62d8d6..3da9bcb904f3 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/__init__.py @@ -6,8 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._phone_number_administration_operations import PhoneNumberAdministrationOperations +from ._phone_numbers_operations import PhoneNumbersOperations __all__ = [ - 'PhoneNumberAdministrationOperations', + 'PhoneNumbersOperations', ] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_number_administration_operations.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_number_administration_operations.py deleted file mode 100644 index 261f60112300..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_number_administration_operations.py +++ /dev/null @@ -1,1421 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class PhoneNumberAdministrationOperations(object): - """PhoneNumberAdministrationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.phonenumbers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get_all_phone_numbers( - self, - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AcquiredPhoneNumbers"] - """Gets the list of the acquired phone numbers. - - Gets the list of the acquired phone numbers. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumbers] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumbers"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) - list_of_elem = deserialized.phone_numbers - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_phone_numbers.metadata = {'url': '/administration/phonenumbers/phonenumbers'} # type: ignore - - def get_all_area_codes( - self, - location_type, # type: str - country_code, # type: str - phone_plan_id, # type: str - location_options=None, # type: Optional[List["_models.LocationOptionsQuery"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.AreaCodes" - """Gets a list of the supported area codes. - - Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :param location_options: Represents the underlying list of countries. - :type location_options: list[~azure.communication.phonenumbers.models.LocationOptionsQuery] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AreaCodes, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.AreaCodes - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AreaCodes"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.LocationOptionsQueries(location_options=location_options) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_all_area_codes.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['locationType'] = self._serialize.query("location_type", location_type, 'str') - query_parameters['phonePlanId'] = self._serialize.query("phone_plan_id", phone_plan_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'LocationOptionsQueries') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AreaCodes', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_all_area_codes.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/areacodes'} # type: ignore - - def get_capabilities_update( - self, - capabilities_update_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdatePhoneNumberCapabilitiesResponse" - """Get capabilities by capabilities update id. - - Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdatePhoneNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.UpdatePhoneNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdatePhoneNumberCapabilitiesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_capabilities_update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'capabilitiesUpdateId': self._serialize.url("capabilities_update_id", capabilities_update_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdatePhoneNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_capabilities_update.metadata = {'url': '/administration/phonenumbers/capabilities/{capabilitiesUpdateId}'} # type: ignore - - def update_capabilities( - self, - phone_number_capabilities_update, # type: Dict[str, "_models.NumberUpdateCapabilities"] - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateNumberCapabilitiesResponse" - """Adds or removes phone number capabilities. - - Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: dict[str, ~azure.communication.phonenumbers.models.NumberUpdateCapabilities] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateNumberCapabilitiesResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.UpdateNumberCapabilitiesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateNumberCapabilitiesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.UpdateNumberCapabilitiesRequest(phone_number_capabilities_update=phone_number_capabilities_update) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'UpdateNumberCapabilitiesRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateNumberCapabilitiesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_capabilities.metadata = {'url': '/administration/phonenumbers/capabilities'} # type: ignore - - def get_all_supported_countries( - self, - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PhoneNumberCountries"] - """Gets a list of supported countries. - - Gets a list of supported countries. - - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberCountries or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.PhoneNumberCountries] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberCountries"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_supported_countries.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberCountries', pipeline_response) - list_of_elem = deserialized.countries - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_supported_countries.metadata = {'url': '/administration/phonenumbers/countries'} # type: ignore - - def get_number_configuration( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NumberConfigurationResponse" - """Endpoint for getting number configurations. - - Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NumberConfigurationResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.NumberConfigurationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NumberConfigurationResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_number_configuration.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('NumberConfigurationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_number_configuration.metadata = {'url': '/administration/phonenumbers/numberconfiguration'} # type: ignore - - def configure_number( - self, - pstn_configuration, # type: "_models.PstnConfiguration" - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for configuring a pstn number. - - Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.phonenumbers.models.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfiguration(pstn_configuration=pstn_configuration, phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.configure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfiguration') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - configure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/configure'} # type: ignore - - def unconfigure_number( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for unconfiguring a pstn number by removing the configuration. - - Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.NumberConfigurationPhoneNumber(phone_number=phone_number) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.unconfigure_number.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'NumberConfigurationPhoneNumber') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - unconfigure_number.metadata = {'url': '/administration/phonenumbers/numberconfiguration/unconfigure'} # type: ignore - - def get_phone_plan_groups( - self, - country_code, # type: str - locale="en-US", # type: Optional[str] - include_rate_information=False, # type: Optional[bool] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PhonePlanGroups"] - """Gets a list of phone plan groups for the given country. - - Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param include_rate_information: - :type include_rate_information: bool - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlanGroups or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.PhonePlanGroups] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhonePlanGroups"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_phone_plan_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if include_rate_information is not None: - query_parameters['includeRateInformation'] = self._serialize.query("include_rate_information", include_rate_information, 'bool') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlanGroups', pipeline_response) - list_of_elem = deserialized.phone_plan_groups - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_phone_plan_groups.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups'} # type: ignore - - def get_phone_plans( - self, - country_code, # type: str - phone_plan_group_id, # type: str - locale="en-US", # type: Optional[str] - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PhonePlansResponse"] - """Gets a list of phone plans for a phone plan group. - - Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhonePlansResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.PhonePlansResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhonePlansResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_phone_plans.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhonePlansResponse', pipeline_response) - list_of_elem = deserialized.phone_plans - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_phone_plans.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans'} # type: ignore - - def get_phone_plan_location_options( - self, - country_code, # type: str - phone_plan_group_id, # type: str - phone_plan_id, # type: str - locale="en-US", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.LocationOptionsResponse" - """Gets a list of location options for a phone plan. - - Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :param locale: A language-locale pairing which will be used to localize the names of countries. - :type locale: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationOptionsResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.LocationOptionsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationOptionsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_phone_plan_location_options.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'countryCode': self._serialize.url("country_code", country_code, 'str'), - 'phonePlanGroupId': self._serialize.url("phone_plan_group_id", phone_plan_group_id, 'str'), - 'phonePlanId': self._serialize.url("phone_plan_id", phone_plan_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('LocationOptionsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_phone_plan_location_options.metadata = {'url': '/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions'} # type: ignore - - def get_release_by_id( - self, - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PhoneNumberRelease" - """Gets a release by a release id. - - Gets a release by a release id. - - :param release_id: Represents the release id. - :type release_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberRelease, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.PhoneNumberRelease - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberRelease"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_release_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'releaseId': self._serialize.url("release_id", release_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('PhoneNumberRelease', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_release_by_id.metadata = {'url': '/administration/phonenumbers/releases/{releaseId}'} # type: ignore - - def release_phone_numbers( - self, - phone_numbers, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ReleaseResponse" - """Creates a release for the given phone numbers. - - Creates a release for the given phone numbers. - - :param phone_numbers: The list of phone numbers in the release request. - :type phone_numbers: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReleaseResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.ReleaseResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReleaseResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = _models.ReleaseRequest(phone_numbers=phone_numbers) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.release_phone_numbers.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if _body is not None: - body_content = self._serialize.body(_body, 'ReleaseRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('ReleaseResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - release_phone_numbers.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore - - def get_all_releases( - self, - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PhoneNumberEntities"] - """Gets a list of all releases. - - Gets a list of all releases. - - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberEntities or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.PhoneNumberEntities] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberEntities"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_releases.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_releases.metadata = {'url': '/administration/phonenumbers/releases'} # type: ignore - - def get_search_by_id( - self, - search_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PhoneNumberReservation" - """Get search by search id. - - Get search by search id. - - :param search_id: The search id to be searched for. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PhoneNumberReservation, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.PhoneNumberReservation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberReservation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.get_search_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('PhoneNumberReservation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_search_by_id.metadata = {'url': '/administration/phonenumbers/searches/{searchId}'} # type: ignore - - def create_search( - self, - body=None, # type: Optional["_models.CreateSearchOptions"] - **kwargs # type: Any - ): - # type: (...) -> "_models.CreateSearchResponse" - """Creates a phone number search. - - Creates a phone number search. - - :param body: Defines the search options. - :type body: ~azure.communication.phonenumbers.models.CreateSearchOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CreateSearchResponse, or the result of cls(response) - :rtype: ~azure.communication.phonenumbers.models.CreateSearchResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CreateSearchResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'CreateSearchOptions') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('CreateSearchResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_search.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore - - def get_all_searches( - self, - skip=0, # type: Optional[int] - take=100, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PhoneNumberEntities"] - """Gets a list of all searches. - - Gets a list of all searches. - - :param skip: An optional parameter for how many entries to skip, for pagination purposes. - :type skip: int - :param take: An optional parameter for how many entries to return, for pagination purposes. - :type take: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PhoneNumberEntities or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.PhoneNumberEntities] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberEntities"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_all_searches.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip is not None: - query_parameters['skip'] = self._serialize.query("skip", skip, 'int') - if take is not None: - query_parameters['take'] = self._serialize.query("take", take, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('PhoneNumberEntities', pipeline_response) - list_of_elem = deserialized.entities - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_all_searches.metadata = {'url': '/administration/phonenumbers/searches'} # type: ignore - - def cancel_search( - self, - search_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Cancels the search. This means existing numbers in the search will be made available. - - Cancels the search. This means existing numbers in the search will be made available. - - :param search_id: The search id to be canceled. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.cancel_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - cancel_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/cancel'} # type: ignore - - def purchase_search( - self, - search_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Purchases the phone number search. - - Purchases the phone number search. - - :param search_id: The search id to be purchased. - :type search_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview1" - accept = "application/json" - - # Construct URL - url = self.purchase_search.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'searchId': self._serialize.url("search_id", search_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - purchase_search.metadata = {'url': '/administration/phonenumbers/searches/{searchId}/purchase'} # type: ignore diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_numbers_operations.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_numbers_operations.py new file mode 100644 index 000000000000..9c38f1c39bf1 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/operations/_phone_numbers_operations.py @@ -0,0 +1,869 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class PhoneNumbersOperations(object): + """PhoneNumbersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.communication.phonenumbers.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _search_available_phone_numbers_initial( + self, + country_code, # type: str + body, # type: "_models.PhoneNumberSearchRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.PhoneNumberSearchResult" + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._search_available_phone_numbers_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'countryCode': self._serialize.url("country_code", country_code, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PhoneNumberSearchRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['search-id']=self._deserialize('str', response.headers.get('search-id')) + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _search_available_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/:search'} # type: ignore + + def begin_search_available_phone_numbers( + self, + country_code, # type: str + body, # type: "_models.PhoneNumberSearchRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.PhoneNumberSearchResult"] + """Search for available phone numbers to purchase. + + Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code, e.g. US. + :type country_code: str + :param body: The phone number search request. + :type body: ~azure.communication.phonenumbers.models.PhoneNumberSearchRequest + :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: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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 PhoneNumberSearchResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._search_available_phone_numbers_initial( + country_code=country_code, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['search-id']=self._deserialize('str', response.headers.get('search-id')) + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'countryCode': self._serialize.url("country_code", country_code, 'str'), + } + + if polling is True: polling_method = LROBasePolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_search_available_phone_numbers.metadata = {'url': '/availablePhoneNumbers/countries/{countryCode}/:search'} # type: ignore + + def get_search_result( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PhoneNumberSearchResult" + """Gets a phone number search result by search id. + + Gets a phone number search result by search id. + + :param search_id: The search Id. + :type search_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhoneNumberSearchResult, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.PhoneNumberSearchResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberSearchResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_search_result.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'searchId': self._serialize.url("search_id", search_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PhoneNumberSearchResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_search_result.metadata = {'url': '/availablePhoneNumbers/searchResults/{searchId}'} # type: ignore + + def _purchase_phone_numbers_initial( + self, + search_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.PhoneNumberPurchaseRequest(search_id=search_id) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._purchase_phone_numbers_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PhoneNumberPurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['purchase-id']=self._deserialize('str', response.headers.get('purchase-id')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _purchase_phone_numbers_initial.metadata = {'url': '/availablePhoneNumbers/:purchase'} # type: ignore + + def begin_purchase_phone_numbers( + self, + search_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Purchases phone numbers. + + Purchases phone numbers. + + :param search_id: The search id. + :type search_id: 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: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._purchase_phone_numbers_initial( + search_id=search_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + + if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase_phone_numbers.metadata = {'url': '/availablePhoneNumbers/:purchase'} # type: ignore + + def get_operation( + self, + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PhoneNumberOperation" + """Gets an operation by its id. + + Gets an operation by its id. + + :param operation_id: The id of the operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PhoneNumberOperation, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.PhoneNumberOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PhoneNumberOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + deserialized = self._deserialize('PhoneNumberOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore + + def cancel_operation( + self, + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels an operation by its id. + + Cancels an operation by its id. + + :param operation_id: The id of the operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.cancel_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_operation.metadata = {'url': '/phoneNumbers/operations/{operationId}'} # type: ignore + + def get_by_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.AcquiredPhoneNumber" + """Gets the details of the given acquired phone number. + + Gets the details of the given acquired phone number. + + :param phone_number: The acquired phone number whose details are to be fetched in E.164 format, + e.g. +11234567890. + :type phone_number: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AcquiredPhoneNumber, or the result of cls(response) + :rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self.get_by_number.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def _release_phone_number_initial( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + # Construct URL + url = self._release_phone_number_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['release-id']=self._deserialize('str', response.headers.get('release-id')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _release_phone_number_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def begin_release_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Releases an acquired phone number. + + Releases an acquired phone number. + + :param phone_number: Phone number to be released, e.g. +11234567890. + :type phone_number: 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: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._release_phone_number_initial( + phone_number=phone_number, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + + if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_release_phone_number.metadata = {'url': '/phoneNumbers/{phoneNumber}'} # type: ignore + + def list_phone_numbers( + self, + skip=0, # type: Optional[int] + top=100, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AcquiredPhoneNumbers"] + """Gets the list of all acquired phone numbers. + + Gets the list of all acquired phone numbers. + + :param skip: An optional parameter for how many entries to skip, for pagination purposes. The + default value is 0. + :type skip: int + :param top: An optional parameter for how many entries to return, for pagination purposes. The + default value is 100. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AcquiredPhoneNumbers or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumbers] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumbers"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-07" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_phone_numbers.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AcquiredPhoneNumbers', pipeline_response) + list_of_elem = deserialized.phone_numbers + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_phone_numbers.metadata = {'url': '/phoneNumbers'} # type: ignore + + def _update_capabilities_initial( + self, + phone_number, # type: str + calling=None, # type: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] + sms=None, # type: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] + **kwargs # type: Any + ): + # type: (...) -> "_models.AcquiredPhoneNumber" + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.PhoneNumberCapabilitiesRequest(calling=calling, sms=sms) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + accept = "application/json" + + # Construct URL + url = self._update_capabilities_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'PhoneNumberCapabilitiesRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['capabilities-id']=self._deserialize('str', response.headers.get('capabilities-id')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _update_capabilities_initial.metadata = {'url': '/phoneNumbers/{phoneNumber}/capabilities'} # type: ignore + + def begin_update_capabilities( + self, + phone_number, # type: str + calling=None, # type: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] + sms=None, # type: Optional[Union[str, "_models.PhoneNumberCapabilityType"]] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.AcquiredPhoneNumber"] + """Updates the capabilities of a phone number. + + Updates the capabilities of a phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B, e.g. +11234567890. + :type phone_number: str + :param calling: Capability value for calling. + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :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: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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 AcquiredPhoneNumber or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.communication.phonenumbers.models.AcquiredPhoneNumber] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcquiredPhoneNumber"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_capabilities_initial( + phone_number=phone_number, + calling=calling, + sms=sms, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + response_headers['operation-id']=self._deserialize('str', response.headers.get('operation-id')) + response_headers['capabilities-id']=self._deserialize('str', response.headers.get('capabilities-id')) + deserialized = self._deserialize('AcquiredPhoneNumber', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'phoneNumber': self._serialize.url("phone_number", phone_number, 'str'), + } + + if polling is True: polling_method = LROBasePolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_capabilities.metadata = {'url': '/phoneNumbers/{phoneNumber}/capabilities'} # type: ignore diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_number_administration_client.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_number_administration_client.py deleted file mode 100644 index c2cc15d43596..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_number_administration_client.py +++ /dev/null @@ -1,598 +0,0 @@ -# pylint: disable=R0904 -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -from azure.communication.phonenumbers._generated.models import ReleaseStatus, CreateSearchOptions -from azure.core.tracing.decorator import distributed_trace -from azure.core.paging import ItemPaged -from azure.core.polling import LROPoller -from ._polling import ReleasePhoneNumberPolling, ReservePhoneNumberPolling, PurchaseReservationPolling - -from ._generated._phone_number_administration_service\ - import PhoneNumberAdministrationService as PhoneNumbersAdministrationClientGen - -from ._generated.models import ( - AcquiredPhoneNumbers, - AreaCodes, - LocationOptionsResponse, - NumberConfigurationResponse, - NumberUpdateCapabilities, - PhoneNumberCountries, - PhoneNumberEntities, - PhoneNumberRelease, - PhoneNumberReservation, - PhonePlanGroups, - PhonePlansResponse, - PstnConfiguration, - SearchStatus, - UpdateNumberCapabilitiesResponse, - UpdatePhoneNumberCapabilitiesResponse -) - -from ._shared.utils import parse_connection_str, get_authentication_policy -from ._version import SDK_MONIKER - -class PhoneNumbersAdministrationClient(object): - """Azure Communication Services Phone Numbers Management client. - - :param str endpoint: - The endpoint url for Azure Communication Service resource. - :param credential: - The credentials with which to authenticate. The value is an account - shared access key - """ - def __init__( - self, - endpoint, # type: str - credential, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - try: - if not endpoint.lower().startswith('http'): - endpoint = "https://" + endpoint - except AttributeError: - raise ValueError("Account URL must be a string.") - - if not credential: - raise ValueError( - "You need to provide account shared key to authenticate.") - - self._endpoint = endpoint - self._phone_number_administration_client = PhoneNumbersAdministrationClientGen( - self._endpoint, - authentication_policy=get_authentication_policy(endpoint, credential), - sdk_moniker=SDK_MONIKER, - **kwargs) - - @classmethod - def from_connection_string( - cls, conn_str, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumbersAdministrationClient - """Create PhoneNumbersAdministrationClient from a Connection String. - :param str conn_str: - A connection string to an Azure Communication Service resource. - :returns: Instance of PhoneNumbersAdministrationClient. - :rtype: ~azure.communication.PhoneNumbersAdministrationClient - """ - endpoint, access_key = parse_connection_str(conn_str) - - return cls(endpoint, access_key, **kwargs) - - @distributed_trace - def list_all_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[AcquiredPhoneNumbers] - """Gets the list of the acquired phone numbers. - - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.AcquiredPhoneNumbers] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_phone_numbers( - **kwargs - ) - - @distributed_trace - def get_all_area_codes( - self, - location_type, # type: str - country_code, # type: str - phone_plan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> AreaCodes - """Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :keyword List["LocationOptionsQuery"] location_options: - Represents the underlying list of countries. - :rtype: ~azure.communication.administration.AreaCodes - """ - return self._phone_number_administration_client.phone_number_administration.get_all_area_codes( - location_type=location_type, - country_code=country_code, - phone_plan_id=phone_plan_id, - **kwargs - ) - - @distributed_trace - def get_capabilities_update( - self, - capabilities_update_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> UpdatePhoneNumberCapabilitiesResponse - """Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :rtype: ~azure.communication.administration.UpdatePhoneNumberCapabilitiesResponse - """ - return self._phone_number_administration_client.phone_number_administration.get_capabilities_update( - capabilities_update_id, - **kwargs - ) - - @distributed_trace - def update_capabilities( - self, - phone_number_capabilities_update, # type: Dict[str, NumberUpdateCapabilities] - **kwargs # type: Any - ): - # type: (...) -> UpdateNumberCapabilitiesResponse - """Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: - dict[str, ~azure.communication.administration.NumberUpdateCapabilities] - :rtype: ~azure.communication.administration.UpdateNumberCapabilitiesResponse - """ - return self._phone_number_administration_client.phone_number_administration.update_capabilities( - phone_number_capabilities_update, - **kwargs - ) - - @distributed_trace - def list_all_supported_countries( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhoneNumberCountries] - """Gets a list of supported countries. - - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhoneNumberCountries] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_supported_countries( - **kwargs - ) - - @distributed_trace - def get_number_configuration( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> NumberConfigurationResponse - """Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :rtype: ~azure.communication.administration.NumberConfigurationResponse - """ - return self._phone_number_administration_client.phone_number_administration.get_number_configuration( - phone_number, - **kwargs - ) - - @distributed_trace - def configure_number( - self, - pstn_configuration, # type: PstnConfiguration - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :rtype: None - """ - return self._phone_number_administration_client.phone_number_administration.configure_number( - pstn_configuration, - phone_number, - **kwargs - ) - - @distributed_trace - def unconfigure_number( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :rtype: None - """ - return self._phone_number_administration_client.phone_number_administration.unconfigure_number( - phone_number, - **kwargs - ) - - @distributed_trace - def list_phone_plan_groups( - self, - country_code, # type: str - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhonePlanGroups] - """Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword include_rate_information bool: An optional boolean parameter for including rate information in result. - The default is False". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhonePlanGroups] - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plan_groups( - country_code, - **kwargs - ) - - @distributed_trace - def list_phone_plans( - self, - country_code, # type: str - phone_plan_group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhonePlansResponse] - """Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhonePlansResponse] - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plans( - country_code, - phone_plan_group_id, - **kwargs - ) - - @distributed_trace - def get_phone_plan_location_options( - self, - country_code, # type: str - phone_plan_group_id, # type: str - phone_plan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LocationOptionsResponse - """Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.communication.administration.LocationOptionsResponse - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plan_location_options( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id, - phone_plan_id=phone_plan_id, - **kwargs - ) - - @distributed_trace - def get_release_by_id( - self, - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberRelease - """Gets a release by a release id. - - :param release_id: Represents the release id. - :type release_id: str - :rtype: ~azure.communication.administration.PhoneNumberRelease - """ - return self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id, - **kwargs - ) - - @distributed_trace - def begin_release_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> LROPoller[PhoneNumberRelease] - """Begins creating a release for the given phone numbers. - Caller must provide either phone_numbers, or continuation_token keywords to use the method. - If both phone_numbers and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword phone_numbers will be ignored. - - :keyword list[str] phone_numbers: The list of phone numbers in the release request. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberRelease] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - release_polling = ReleasePhoneNumberPolling( - is_terminated=lambda status: status in [ - ReleaseStatus.Complete, - ReleaseStatus.Failed, - ReleaseStatus.Expired - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=release_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "phone_numbers" not in kwargs: - raise ValueError("Either kwarg 'phone_numbers' or 'continuation_token' needs to be specified") - - create_release_response = self._phone_number_administration_client.\ - phone_number_administration.release_phone_numbers( - **kwargs - ) - - initial_state = self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id=create_release_response.release_id - ) - - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=release_polling) - - @distributed_trace - def list_all_releases( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhoneNumberEntities] - """Gets a list of all releases. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_releases( - **kwargs - ) - - @distributed_trace - def get_reservation_by_id( - self, - reservation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberReservation - """Get reservation by reservation id. - - :param reservation_id: The reservation id to get reservation. - :type reservation_id: str - :rtype: ~azure.communication.administration.PhoneNumberReservation - """ - return self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id, - **kwargs - ) - - @distributed_trace - def begin_reserve_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> LROPoller[PhoneNumberReservation] - """Begins creating a phone number search to reserve phone numbers. - Caller must provide one of the following: - (1) all of keywords display_name, description, phone_plan_ids, area_code, quantity if all the phone plans - to reserve are toll-free plans. - (2) all of keywords display_name, description, phone_plan_ids, area_code, quantity, location_options - if at least one phone plan to reserve is not toll-free plans. - (3) only keyword continuation_token to restart a poller from a saved state. - If both continuation_token and other keywords are specified, only continuation_token will be used to - restart a poller from a saved state, and other keywords will be ignored. - :keyword str display_name: display name of the search. - :keyword str description: description of the search. - :keyword list[str] phone_plan_ids: the plan subtype ids from which to create the search. - :keyword str area_code: the area code from which to create the search. - :keyword int quantity: the quantity of phone numbers to request. - :keyword list[~azure.communication.administration.models.LocationOptionsDetails] location_options: - the location options of the search. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberReservation] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = ReservePhoneNumberPolling( - is_terminated=lambda status: status in [ - SearchStatus.Reserved, - SearchStatus.Expired, - SearchStatus.Success, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - required_kwargs = ['display_name', 'description', 'phone_plan_ids', 'area_code', 'quantity'] - for required_kwarg in required_kwargs: - if required_kwarg not in kwargs: - raise ValueError("Either kwarg 'continuation_token', or a set of kwargs " + - "'display_name', 'description', 'phone_plan_ids', " - "'area_code', 'quantity' needs to be specified") - - reservation_options = CreateSearchOptions( - display_name=kwargs.pop('display_name'), - description=kwargs.pop('description'), - phone_plan_ids=kwargs.pop('phone_plan_ids'), - area_code=kwargs.pop('area_code'), - quantity=kwargs.pop('quantity') - ) - - if 'location_options' in kwargs: - reservation_options.location_options = kwargs.pop('location_options') - - create_reservation_response = self._phone_number_administration_client.\ - phone_number_administration.create_search( - body=reservation_options, - **kwargs - ) - - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=create_reservation_response.search_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) - - @distributed_trace - def list_all_reservations( - self, - **kwargs # type: Any - ): - # type: (...) -> ItemPaged[PhoneNumberEntities] - """Gets a list of all reservations. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.paging.ItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_searches( - **kwargs - ) - - @distributed_trace - def cancel_reservation( - self, - reservation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Cancels the reservation. This means existing numbers in the reservation will be made available. - - :param reservation_id: The reservation id to be canceled. - :type reservation_id: str - :rtype: None - """ - return self._phone_number_administration_client.phone_number_administration.cancel_search( - search_id=reservation_id, - **kwargs - ) - - @distributed_trace - def begin_purchase_reservation( - self, - **kwargs # type: Any - ): - # type: (...) -> LROPoller[PhoneNumberReservation] - """Begins purchase the reserved phone numbers of a phone number search. - Caller must provide either reservation_id, or continuation_token keywords to use the method. - If both reservation_id and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword reservation_id will be ignored. - :keyword str reservation_id: The reservation id to be purchased. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberReservation] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = PurchaseReservationPolling( - is_terminated=lambda status: status in [ - SearchStatus.Success, - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "reservation_id" not in kwargs: - raise ValueError("Either kwarg 'reservation_id' or 'continuation_token' needs to be specified") - - reservation_id = kwargs.pop('reservation_id') # type: str - - self._phone_number_administration_client.phone_number_administration.purchase_search( - search_id=reservation_id, - **kwargs - ) - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) 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 new file mode 100644 index 000000000000..9fd9bcf079e1 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_phone_numbers_client.py @@ -0,0 +1,218 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from azure.core.tracing.decorator import distributed_trace +from azure.core.paging import ItemPaged +from azure.core.polling import LROPoller +from ._generated._phone_numbers_client import PhoneNumbersClient as PhoneNumbersClientGen +from ._generated.models import PhoneNumberSearchRequest +from ._shared.utils import parse_connection_str, get_authentication_policy +from ._version import SDK_MONIKER + +class PhoneNumbersClient(object): + def __init__( + self, + endpoint, # type: str + credential, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + try: + if not endpoint.lower().startswith('http'): + endpoint = "https://" + endpoint + except AttributeError: + raise ValueError("Account URL must be a string.") + + if not credential: + raise ValueError( + "You need to provide account shared key to authenticate.") + + self._endpoint = endpoint + self._phone_number_client = PhoneNumbersClientGen( + self._endpoint, + authentication_policy=get_authentication_policy(endpoint, credential), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): + # type: (...) -> PhoneNumbersClient + """Create PhoneNumbersClient from a Connection String. + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of PhoneNumbersClient. + :rtype: ~azure.communication.phonenumbers.PhoneNumbersClient + """ + endpoint, access_key = parse_connection_str(conn_str) + + return cls(endpoint, access_key, **kwargs) + + @distributed_trace + def begin_purchase_phone_numbers( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Purchases phone numbers. + + :param search_id: The search id. + :type search_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.LROPoller[None] + """ + return self._phone_number_client.phone_numbers.begin_purchase_phone_numbers( + search_id, + **kwargs + ) + + @distributed_trace + def begin_release_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Releases an acquired phone number. + + :param phone_number: Phone number to be released, e.g. +55534567890. + :type phone_number: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.LROPoller[None] + """ + return self._phone_number_client.phone_numbers.begin_release_phone_number( + phone_number, + **kwargs + ) + + @distributed_trace + def begin_search_available_phone_numbers( + self, + country_code, # type: str + phone_number_type, # type: str + assignment_type, # type: str + capabilities, # type: PhoneNumberCapabilities + **kwargs # type: Any + ): + # type: (...) -> LROPoller[PhoneNumberSearchResult] + """Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code, e.g. US. + :type country_code: str + :param phone_number_type: Required. The type of phone numbers to search for, e.g. geographic, + or tollFree. Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param assignment_type: Required. The assignment type of the phone numbers to search for. A + phone number can be assigned to a person, or to an application. Possible values include: + "user", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :keyword str area_code: The area code of the desired phone number, e.g. 425. If not set, + any area code could be used in the final search. + :keyword int quantity: The quantity of phone numbers in the search. Default is 1. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.LROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult] + """ + search_request = PhoneNumberSearchRequest( + phone_number_type=phone_number_type, + assignment_type=assignment_type, + capabilities=capabilities, + quantity=kwargs.pop('quantity', None), + area_code=kwargs.pop('area_code', None) + ) + return self._phone_number_client.phone_numbers.begin_search_available_phone_numbers( + country_code, + search_request, + **kwargs + ) + @distributed_trace + def begin_update_phone_number_capabilities( + self, + phone_number, # type: str + sms=None, #type: str or PhoneNumberCapabilityType + calling=None, #type: str or PhoneNumberCapabilityType + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.AcquiredPhoneNumber"] + """Updates the capabilities of a phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B, e.g. +55534567890. + :type phone_number: str + :param calling: Capability value for calling. + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.LROPoller[AcquiredPhoneNumber] + """ + return self._phone_number_client.phone_numbers.begin_update_capabilities( + phone_number, + calling=calling, + sms=sms, + **kwargs + ) + + @distributed_trace + def get_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> AcquiredPhoneNumber + """Gets the details of the given acquired phone number. + + :param phone_number: The acquired phone number whose details are to be fetched in E.164 format, + e.g. +11234567890. + :type phone_number: str + :rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber + """ + return self._phone_number_client.phone_numbers.get_by_number( + phone_number, + **kwargs + ) + + @distributed_trace + def list_acquired_phone_numbers( + self, + **kwargs # type: Any + ): + # type: (...) -> ItemPaged[AcquiredPhoneNumber] + """Gets the list of all acquired phone numbers. + + :param skip: An optional parameter for how many entries to skip, for pagination purposes. The + default value is 0. + :type skip: int + :rtype: ~azure.core.paging.ItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumber] + """ + return self._phone_number_client.phone_numbers.list_phone_numbers( + **kwargs + ) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_polling.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_polling.py deleted file mode 100644 index 8521c4cef85c..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_polling.py +++ /dev/null @@ -1,92 +0,0 @@ -# pylint: disable=W0231 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import base64 -import time -from typing import Union -from functools import partial -import pickle - -from azure.core.polling import ( - PollingMethod -) -from ._generated.models import ( - PhoneNumberReservation, - PhoneNumberRelease -) - -class PhoneNumberBasePolling(PollingMethod): - """ABC class for reserve/purchase/release phone number related polling. - """ - def __init__(self, is_terminated, polling_interval=5): - # type: (bool, int) -> None - self._response = None - self._client = None - self._query_status = None - self._is_terminated = is_terminated - self._polling_interval = polling_interval - - def _update_status(self): - # type: () -> None - if self._query_status is None: - raise Exception("this poller has not been initialized") - self._response = self._query_status() # pylint: disable=E1102 - - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - self._client = client - self._response = initial_response - - def run(self): - # type: () -> None - while not self.finished(): - self._update_status() - if not self.finished(): - time.sleep(self._polling_interval) - - def finished(self): - # type: () -> bool - if self._response.status is None: - return False - return self._is_terminated(self._response.status) - - def resource(self): - # type: () -> Union[PhoneNumberReservation, PhoneNumberRelease] - if not self.finished(): - return None - return self._response - - def status(self): - # type: () -> str - return self._response.status - - def get_continuation_token(self): - # type() -> str - return base64.b64encode(pickle.dumps(self._response)).decode('ascii') - - @classmethod - def from_continuation_token(cls, continuation_token, client, **kwargs): # pylint: disable=W0221 - # type(str, PhoneNumbersAdministrationClient, Any) -> Tuple - initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec - return client, initial_response, None - -class ReservePhoneNumberPolling(PhoneNumberBasePolling): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.reservation_id) - -class PurchaseReservationPolling(PhoneNumberBasePolling): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.reservation_id) - -class ReleasePhoneNumberPolling(PhoneNumberBasePolling): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_release_by_id, release_id=initial_response.release_id) diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/models.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/models.py index 67e0a1ff6e2b..07b45cf9275e 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/models.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/models.py @@ -43,7 +43,49 @@ class UnknownIdentifier(object): :type identifier: str """ def __init__(self, identifier): - self.raw_id = identifier + self.identifier = identifier + +class CommunicationIdentifierModel(msrest.serialization.Model): + """Communication Identifier Model. + All required parameters must be populated in order to send to Azure. + :param kind: Required. Kind of Communication Identifier. + :type kind: CommunicationIdentifierKind + :param id: Full id of the identifier. + :type id: str + :param phone_number: phone number in case the identifier is a phone number. + :type phone_number: str + :param is_anonymous: True if the identifier is anonymous. + :type is_anonymous: bool + :param microsoft_teams_user_id: Microsoft Teams user id. + :type microsoft_teams_user_id: str + :param communication_cloud_environment: Cloud environment that the user belongs to. + :type communication_cloud_environment: CommunicationCloudEnvironment + """ + + _validation = { + 'kind': {'required': True}, + } + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'is_anonymous': {'key': 'isAnonymous', 'type': 'bool'}, + 'microsoft_teams_user_id': {'key': 'microsoftTeamsUserId', 'type': 'str'}, + 'communication_cloud_environment': {'key': 'communicationCloudEnvironment', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationIdentifierModel, self).__init__(**kwargs) + self.kind = kwargs['kind'] + self.id = kwargs.get('id', None) + self.phone_number = kwargs.get('phone_number', None) + self.is_anonymous = kwargs.get('is_anonymous', None) + self.microsoft_teams_user_id = kwargs.get('microsoft_teams_user_id', None) + self.communication_cloud_environment = kwargs.get('communication_cloud_environment', None) class _CaseInsensitiveEnumMeta(EnumMeta): def __getitem__(cls, name): @@ -74,7 +116,7 @@ class CommunicationCloudEnvironment(with_metaclass(_CaseInsensitiveEnumMeta, str """ The cloud enviornment that the identifier belongs to """ - + Public = "PUBLIC" Dod = "DOD" Gcch = "GCCH" diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/utils.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/utils.py index 18da505150ba..e01f5291ba5e 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/utils.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_shared/utils.py @@ -77,14 +77,12 @@ def get_authentication_policy( # type: (...) -> BearerTokenCredentialPolicy or HMACCredentialPolicy """Returns the correct authentication policy based on which credential is being passed. - :param endpoint: The endpoint to which we are authenticating to. :type endpoint: str :param credential: The credential we use to authenticate to the service :type credential: TokenCredential or str :param isAsync: For async clients there is a need to decode the url :type bool: isAsync or str - :rtype: ~azure.core.pipeline.policies.BearerTokenCredentialPolicy ~HMACCredentialsPolicy """ diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/__init__.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/__init__.py index 2970318067d2..6c133642985f 100644 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/__init__.py +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/__init__.py @@ -1,11 +1,5 @@ -from ._phone_number_administration_client_async import PhoneNumbersAdministrationClient -from ._polling_async import ReservePhoneNumberPollingAsync, \ - PurchaseReservationPollingAsync, \ - ReleasePhoneNumberPollingAsync +from ._phone_numbers_client_async import PhoneNumbersClient __all__ = [ - 'PhoneNumbersAdministrationClient', - 'ReservePhoneNumberPollingAsync', - 'PurchaseReservationPollingAsync', - 'ReleasePhoneNumberPollingAsync' + 'PhoneNumbersClient', ] diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_number_administration_client_async.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_number_administration_client_async.py deleted file mode 100644 index 9564b866fd41..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_number_administration_client_async.py +++ /dev/null @@ -1,620 +0,0 @@ -# pylint: disable=R0904 -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -from typing import Dict - -from azure.communication.phonenumbers._generated.models import ReleaseStatus, CreateSearchOptions -from azure.core.async_paging import AsyncItemPaged -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.polling import AsyncLROPoller - -from .._version import SDK_MONIKER -from ._polling_async import ReleasePhoneNumberPollingAsync, \ - ReservePhoneNumberPollingAsync, \ - PurchaseReservationPollingAsync - -from .._generated.aio._phone_number_administration_service \ - import PhoneNumberAdministrationService as PhoneNumbersAdministrationClientGen - -from .._generated.models import ( - AcquiredPhoneNumbers, - AreaCodes, - LocationOptionsResponse, - NumberConfigurationResponse, - NumberUpdateCapabilities, - PhoneNumberCountries, - PhoneNumberEntities, - PhoneNumberRelease, - PhoneNumberReservation, - PhonePlanGroups, - PhonePlansResponse, - PstnConfiguration, - SearchStatus, - UpdateNumberCapabilitiesResponse, - UpdatePhoneNumberCapabilitiesResponse -) - -from .._shared.utils import parse_connection_str, get_authentication_policy - -class PhoneNumbersAdministrationClient(object): - """Azure Communication Services Phone Numbers Management client. - - :param str endpoint: - The endpoint url for Azure Communication Service resource. - :param credential: - The credentials with which to authenticate. The value is an account - shared access key - """ - def __init__( - self, - endpoint, # type: str - credential, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - try: - if not endpoint.lower().startswith('http'): - endpoint = "https://" + endpoint - except AttributeError: - raise ValueError("Account URL must be a string.") - - if not credential: - raise ValueError( - "You need to provide account shared key to authenticate.") - - self._endpoint = endpoint - self._phone_number_administration_client = PhoneNumbersAdministrationClientGen( - self._endpoint, - authentication_policy=get_authentication_policy(endpoint, credential, is_async=True), - sdk_moniker=SDK_MONIKER, - **kwargs) - - @classmethod - def from_connection_string( - cls, conn_str, # type: str - **kwargs # type: Any - ): # type: (...) -> PhoneNumbersAdministrationClient - """Create PhoneNumbersAdministrationClient from a Connection String. - - :param str conn_str: - A connection string to an Azure Communication Service resource. - :returns: Instance of PhoneNumbersAdministrationClient. - :rtype: ~azure.communication.PhoneNumbersAdministrationClient - """ - endpoint, access_key = parse_connection_str(conn_str) - - return cls(endpoint, access_key, **kwargs) - - @distributed_trace - def list_all_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[AcquiredPhoneNumbers] - """Gets the list of the acquired phone numbers. - - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.AcquiredPhoneNumbers] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_phone_numbers( - **kwargs - ) - - @distributed_trace_async - async def get_all_area_codes( - self, - location_type, # type: str - country_code, # type: str - phone_plan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> AreaCodes - """Gets a list of the supported area codes. - - :param location_type: The type of location information required by the plan. - :type location_type: str - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_id: The plan id from which to search area codes. - :type phone_plan_id: str - :keyword List["LocationOptionsQuery"] location_options: - Represents the underlying list of countries. - :rtype: ~azure.communication.administration.AreaCodes - """ - return await self._phone_number_administration_client.phone_number_administration.get_all_area_codes( - location_type, - country_code, - phone_plan_id, - **kwargs - ) - - @distributed_trace_async - async def get_capabilities_update( - self, - capabilities_update_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> UpdatePhoneNumberCapabilitiesResponse - """Get capabilities by capabilities update id. - - :param capabilities_update_id: - :type capabilities_update_id: str - :rtype: ~azure.communication.administration.UpdatePhoneNumberCapabilitiesResponse - """ - return await self._phone_number_administration_client.phone_number_administration.get_capabilities_update( - capabilities_update_id, - **kwargs - ) - - @distributed_trace_async - async def update_capabilities( - self, - phone_number_capabilities_update, # type: Dict[str, NumberUpdateCapabilities] - **kwargs # type: Any - ): - # type: (...) -> UpdateNumberCapabilitiesResponse - """Adds or removes phone number capabilities. - - :param phone_number_capabilities_update: The map of phone numbers to the capabilities update - applied to the phone number. - :type phone_number_capabilities_update: - dict[str, ~azure.communication.administration.NumberUpdateCapabilities] - :rtype: ~azure.communication.administration.UpdateNumberCapabilitiesResponse - """ - return await self._phone_number_administration_client.phone_number_administration.update_capabilities( - phone_number_capabilities_update, - **kwargs - ) - - @distributed_trace - def list_all_supported_countries( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[PhoneNumberCountries] - """Gets a list of supported countries. - - Gets a list of supported countries. - - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :return: An iterator like instance of either PhoneNumberCountries or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.PhoneNumberCountries] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_supported_countries( - **kwargs - ) - - @distributed_trace_async - async def get_number_configuration( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> NumberConfigurationResponse - """Endpoint for getting number configurations. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :rtype: ~azure.communication.administration.NumberConfigurationResponse - """ - return await self._phone_number_administration_client.phone_number_administration.get_number_configuration( - phone_number, - **kwargs - ) - - @distributed_trace_async - async def configure_number( - self, - pstn_configuration, # type: PstnConfiguration - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for configuring a pstn number. - - :param pstn_configuration: Definition for pstn number configuration. - :type pstn_configuration: ~azure.communication.administration.PstnConfiguration - :param phone_number: The phone number to configure. - :type phone_number: str - :rtype: None - """ - return await self._phone_number_administration_client.phone_number_administration.configure_number( - pstn_configuration, - phone_number, - **kwargs - ) - - @distributed_trace_async - async def unconfigure_number( - self, - phone_number, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Endpoint for unconfiguring a pstn number by removing the configuration. - - :param phone_number: The phone number in the E.164 format. - :type phone_number: str - :rtype: None - """ - return await self._phone_number_administration_client.phone_number_administration.unconfigure_number( - phone_number, - **kwargs - ) - - @distributed_trace - def list_phone_plan_groups( - self, - country_code, # type: str - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[PhonePlanGroups] - """Gets a list of phone plan groups for the given country. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword include_rate_information bool: An optional boolean parameter for including rate information in result. - The default is False". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.PhonePlanGroups] - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plan_groups( - country_code, - **kwargs - ) - - @distributed_trace - def list_phone_plans( - self, - country_code, # type: str - phone_plan_group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[PhonePlansResponse] - """Gets a list of phone plans for a phone plan group. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.PhonePlansResponse] - """ - return self._phone_number_administration_client.phone_number_administration.get_phone_plans( - country_code, - phone_plan_group_id, - **kwargs - ) - - @distributed_trace_async - async def get_phone_plan_location_options( - self, - country_code, # type: str - phone_plan_group_id, # type: str - phone_plan_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LocationOptionsResponse - """Gets a list of location options for a phone plan. - - :param country_code: The ISO 3166-2 country code. - :type country_code: str - :param phone_plan_group_id: - :type phone_plan_group_id: str - :param phone_plan_id: - :type phone_plan_id: str - :keyword str locale: A language-locale pairing which will be used to localise the names of countries. - The default is "en-US". - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: - ~azure.communication.administration.LocationOptionsResponse - """ - return await self._phone_number_administration_client.\ - phone_number_administration.get_phone_plan_location_options( - country_code, - phone_plan_group_id, - phone_plan_id, - **kwargs - ) - - @distributed_trace_async - async def get_release_by_id( - self, - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberRelease - """Gets a release by a release id. - - :param release_id: Represents the release id. - :type release_id: str - :rtype: ~azure.communication.administration.PhoneNumberRelease - """ - return await self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id, - **kwargs - ) - - @distributed_trace_async - async def begin_release_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncLROPoller[PhoneNumberRelease] - """Begins creating a release for the given phone numbers. - Caller must provide either phone_numbers, or continuation_token keywords to use the method. - If both phone_numbers and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword phone_numbers will be ignored. - - :keyword list[str] phone_numbers: The list of phone numbers in the release request. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberRelease] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - release_polling = ReleasePhoneNumberPollingAsync( - is_terminated=lambda status: status in [ - ReleaseStatus.Complete, - ReleaseStatus.Failed, - ReleaseStatus.Expired - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=release_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "phone_numbers" not in kwargs: - raise ValueError("Either kwarg 'phone_numbers' or 'continuation_token' needs to be specified") - - create_release_response = await self._phone_number_administration_client.\ - phone_number_administration.release_phone_numbers( - **kwargs - ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_release_by_id( - release_id=create_release_response.release_id - ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=release_polling) - - @distributed_trace - def list_all_releases( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[PhoneNumberEntities] - """Gets a list of all releases. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_releases( - **kwargs - ) - - @distributed_trace_async - async def get_reservation_by_id( - self, - reservation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> PhoneNumberReservation - """Get reservation by reservation id. - - :param reservation_id: The reservation id to get reservation. - :type reservation_id: str - :rtype: ~azure.communication.administration.PhoneNumberReservation - """ - return await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id, - **kwargs - ) - - - @distributed_trace_async - async def begin_reserve_phone_numbers( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncLROPoller[PhoneNumberReservation] - """Begins creating a phone number search to reserve phone numbers. - Caller must provide one of the following: - (1) all of keywords display_name, description, phone_plan_ids, area_code, quantity if all the phone plans - to reserve are toll-free plans. - (2) all of keywords display_name, description, phone_plan_ids, area_code, quantity, location_options - if at least one phone plan to reserve is not toll-free plans. - (3) only keyword continuation_token to restart a poller from a saved state. - If both continuation_token and other keywords are specified, only continuation_token will be used to - restart a poller from a saved state, and other keywords will be ignored. - :keyword str display_name: display name of the search. - :keyword str description: description of the search. - :keyword list[str] phone_plan_ids: the plan subtype ids from which to create the search. - :keyword str area_code: the area code from which to create the search. - :keyword int quantity: the quantity of phone numbers to request. - :keyword list[~azure.communication.administration.models.LocationOptionsDetails] location_options: - the location options of the search. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberReservation] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = ReservePhoneNumberPollingAsync( - is_terminated=lambda status: status in [ - SearchStatus.Reserved, - SearchStatus.Expired, - SearchStatus.Success, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - required_kwargs = ['display_name', 'description', 'phone_plan_ids', 'area_code', 'quantity'] - for required_kwarg in required_kwargs: - if required_kwarg not in kwargs: - raise ValueError("Either kwarg 'continuation_token', or a set of kwargs " + - "'display_name', 'description', 'phone_plan_ids', " - "'area_code', 'quantity' needs to be specified") - - reservation_options = CreateSearchOptions( - display_name=kwargs.pop('display_name'), - description=kwargs.pop('description'), - phone_plan_ids=kwargs.pop('phone_plan_ids'), - area_code=kwargs.pop('area_code'), - quantity=kwargs.pop('quantity') - ) - - if 'location_options' in kwargs: - reservation_options.location_options = kwargs.pop('location_options') - - create_reservation_response = await self._phone_number_administration_client.\ - phone_number_administration.create_search( - body=reservation_options, - **kwargs - ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=create_reservation_response.search_id - ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) - - @distributed_trace - def list_all_reservations( - self, - **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[PhoneNumberEntities] - """Gets a list of all reservations. - - :keyword int skip: An optional parameter for how many entries to skip, for pagination purposes. - The default is 0. - :keyword int take: An optional parameter for how many entries to return, for pagination purposes. - The default is 100. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.communication.administration.PhoneNumberEntities] - """ - return self._phone_number_administration_client.phone_number_administration.get_all_searches( - **kwargs - ) - - @distributed_trace_async - async def cancel_reservation( - self, - reservation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Cancels the reservation. This means existing numbers in the reservation will be made available. - - :param reservation_id: The reservation id to be canceled. - :type reservation_id: str - :rtype: None - """ - return await self._phone_number_administration_client.phone_number_administration.cancel_search( - search_id=reservation_id, - **kwargs - ) - - @distributed_trace_async - async def begin_purchase_reservation( - self, - **kwargs # type: Any - ): - - # type: (...) -> AsyncLROPoller[PhoneNumberReservation] - """Begins purchase the reserved phone numbers of a phone number search. - Caller must provide either reservation_id, or continuation_token keywords to use the method. - If both reservation_id and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword reservation_id will be ignored. - :keyword str reservation_id: The reservation id to be purchased. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberReservation] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - reservation_polling = PurchaseReservationPollingAsync( - is_terminated=lambda status: status in [ - SearchStatus.Success, - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=reservation_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - reservation_id = kwargs.pop('reservation_id', None) # type: str - if reservation_id is None: - raise ValueError("Either kwarg 'reservation_id' or 'continuation_token' needs to be specified") - - await self._phone_number_administration_client.phone_number_administration.purchase_search( - reservation_id, - **kwargs - ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=reservation_id - ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=reservation_polling) - - async def __aenter__(self) -> "PhoneNumbersAdministrationClient": - await self._phone_number_administration_client.__aenter__() - return self - - async def __aexit__(self, *args: "Any") -> None: - await self.close() - - async def close(self) -> None: - """Close the :class: - `~azure.communication.administration.aio.PhoneNumbersAdministrationClient` session. - """ - await self._phone_number_administration_client.__aexit__() 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 new file mode 100644 index 000000000000..92fe009fc369 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_phone_numbers_client_async.py @@ -0,0 +1,236 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.paging import ItemPaged +from azure.core.polling import LROPoller +from .._generated.aio._phone_numbers_client import PhoneNumbersClient as PhoneNumbersClientGen +from .._generated.models import PhoneNumberSearchRequest +from .._shared.utils import parse_connection_str, get_authentication_policy +from .._version import SDK_MONIKER + +class PhoneNumbersClient(object): + def __init__( + self, + endpoint, # type: str + credential, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + try: + if not endpoint.lower().startswith('http'): + endpoint = "https://" + endpoint + except AttributeError: + raise ValueError("Account URL must be a string.") + + if not credential: + raise ValueError( + "You need to provide account shared key to authenticate.") + + self._endpoint = endpoint + self._phone_number_client = PhoneNumbersClientGen( + self._endpoint, + authentication_policy=get_authentication_policy(endpoint, credential), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): + # type: (...) -> PhoneNumbersClient + """Create PhoneNumbersClient from a Connection String. + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of PhoneNumbersClient. + :rtype: ~azure.communication.phonenumbers.aio.PhoneNumbersClient + """ + endpoint, access_key = parse_connection_str(conn_str) + + return cls(endpoint, access_key, **kwargs) + + @distributed_trace_async + async def begin_purchase_phone_numbers( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> AsyncLROPoller[None] + """Purchases phone numbers. + + :param search_id: The search id. + :type search_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.AsyncLROPoller[None] + """ + return await self._phone_number_client.phone_numbers.begin_purchase_phone_numbers( + search_id, + **kwargs + ) + + @distributed_trace_async + async def begin_release_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> AsyncLROPoller[None] + """Releases an acquired phone number. + + :param phone_number: Phone number to be released, e.g. +11234567890. + :type phone_number: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.AsyncLROPoller[None] + """ + return await self._phone_number_client.phone_numbers.begin_release_phone_number( + phone_number, + **kwargs + ) + + @distributed_trace_async + async def begin_search_available_phone_numbers( + self, + country_code, # type: str + phone_number_type, # type: str + assignment_type, # type: str + capabilities, + **kwargs + ): + # type: (...) -> AsyncLROPoller[PhoneNumberSearchResult] + """Search for available phone numbers to purchase. + + :param country_code: The ISO 3166-2 country code, e.g. US. + :type country_code: str + :param phone_number_type: Required. The type of phone numbers to search for, e.g. geographic, + or tollFree. Possible values include: "geographic", "tollFree". + :type phone_number_type: str or ~azure.communication.phonenumbers.models.PhoneNumberType + :param assignment_type: Required. The assignment type of the phone numbers to search for. A + phone number can be assigned to a person, or to an application. Possible values include: + "user", "application". + :type assignment_type: str or + ~azure.communication.phonenumbers.models.PhoneNumberAssignmentType + :param capabilities: Required. Capabilities of a phone number. + :type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities + :keyword str area_code: The area code of the desired phone number, e.g. 425. If not set, + any area code could be used in the final search. + :keyword int quantity: The quantity of phone numbers in the search. Default is 1. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.phonenumbers.models.PhoneNumberSearchResult] + """ + search_request = PhoneNumberSearchRequest( + phone_number_type=phone_number_type, + assignment_type=assignment_type, + capabilities=capabilities, + quantity=kwargs.pop('quantity', None), + area_code=kwargs.pop('area_code', None) + ) + return await self._phone_number_client.phone_numbers.begin_search_available_phone_numbers( + country_code, + search_request, + **kwargs + ) + + @distributed_trace_async + async def begin_update_phone_number_capabilities( + self, + phone_number, # type: str + sms=None, # type: str + calling=None, # type: str + **kwargs # type: Any + ): + # type: (...) -> AsyncLROPoller["_models.AcquiredPhoneNumber"] + """Updates the capabilities of a phone number. + + :param phone_number: The phone number id in E.164 format. The leading plus can be either + or + encoded as %2B, e.g. +11234567890. + :type phone_number: str + :param calling: Capability value for calling. + :type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :param sms: Capability value for SMS. + :type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the LROBasePolling polling method, + False for no polling, or 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. + :rtype: ~azure.core.polling.AsyncLROPoller[AcquiredPhoneNumber] + """ + return await self._phone_number_client.phone_numbers.begin_update_capabilities( + phone_number, + calling, + sms, + **kwargs + ) + + @distributed_trace_async + async def get_phone_number( + self, + phone_number, # type: str + **kwargs # type: Any + ): + # type: (...) -> AcquiredPhoneNumber + """Gets the details of the given acquired phone number. + + :param phone_number: The acquired phone number whose details are to be fetched in E.164 format, + e.g. +11234567890. + :type phone_number: str + :rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber + """ + return await self._phone_number_client.phone_numbers.get_by_number( + phone_number, + **kwargs + ) + + @distributed_trace + def list_acquired_phone_numbers( + self, + **kwargs # type: Any + ): + # type: (...) -> AsyncItemPaged[AcquiredPhoneNumbers] + """Gets the list of all acquired phone numbers. + + :param skip: An optional parameter for how many entries to skip, for pagination purposes. The + default value is 0. + :type skip: int + :param top: An optional parameter for how many entries to return, for pagination purposes. The + default value is 100. + :type top: int + :rtype: ~azure.core.paging.AsyncItemPaged[~azure.communication.phonenumbers.models.AcquiredPhoneNumbers] + """ + return self._phone_number_client.phone_numbers.list_phone_numbers( + **kwargs + ) + + async def __aenter__(self) -> "PhoneNumbersClient": + await self._phone_number_client.__aenter__() + return self + + async def __aexit__(self, *args: "Any") -> None: + await self.close() + + async def close(self) -> None: + """Close the :class: + `~azure.communication.phonenumbers.aio.PhoneNumbersClient` session. + """ + await self._phone_number_client.__aexit__() diff --git a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_polling_async.py b/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_polling_async.py deleted file mode 100644 index ef22bbcdd74a..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/aio/_polling_async.py +++ /dev/null @@ -1,92 +0,0 @@ -# pylint: disable=W0231 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import asyncio -from typing import Union -import base64 -from functools import partial - -from azure.core.polling import AsyncPollingMethod - -from .._generated.models import ( - PhoneNumberReservation, - PhoneNumberRelease -) - -class PhoneNumberBasePollingAsync(AsyncPollingMethod): - """ABC class for reserve/purchase/release phone number related polling. - """ - def __init__(self, is_terminated, polling_interval=5): - # type: (bool, int) -> None - self._response = None - self._client = None - self._query_status = None - self._is_terminated = is_terminated - self._polling_interval = polling_interval - - async def _update_status(self): - # type: () -> None - if self._query_status is None: - raise Exception("this poller has not been initialized") - self._response = await self._query_status() # pylint: disable=E1102 - - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - self._client = client - self._response = initial_response - - async def run(self): - # type: () -> None - while not self.finished(): - await self._update_status() - if not self.finished(): - await asyncio.sleep(self._polling_interval) - - def finished(self): - # type: () -> bool - if self._response.status is None: - return False - return self._is_terminated(self._response.status) - - def resource(self): - # type: () -> Union[PhoneNumberReservation, PhoneNumberRelease] - if not self.finished(): - return None - return self._response - - def status(self): - # type: () -> str - return self._response.status - - def get_continuation_token(self): - # type() -> str - import pickle - return base64.b64encode(pickle.dumps(self._response)).decode('ascii') - - @classmethod - def from_continuation_token(cls, continuation_token, client, **kwargs): # pylint: disable=W0221 - # type(str, PhoneNumbersAdministrationClient, Any) -> Tuple - import pickle - initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec - return client, initial_response, None - -class ReservePhoneNumberPollingAsync(PhoneNumberBasePollingAsync): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.reservation_id) - -class PurchaseReservationPollingAsync(PhoneNumberBasePollingAsync): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.reservation_id) - -class ReleasePhoneNumberPollingAsync(PhoneNumberBasePollingAsync): - def initialize(self, client, initial_response, deserialization_callback): - # type: (Any, Any, Callable) -> None - super().initialize(client, initial_response, deserialization_callback) - self._query_status = partial(self._client.get_release_by_id, release_id=initial_response.release_id) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/get_phone_number_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/get_phone_number_sample.py new file mode 100644 index 000000000000..f09d43591120 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/get_phone_number_sample.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE:get_phone_number_sample.py +DESCRIPTION: + This sample demonstrates how to get the information from an acquired phone number using your connection string +USAGE: + python get_phone_number_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service + 2) AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER - The phone number you want to get its information +""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number = os.getenv("AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER") # e.g. "+18001234567" +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def get_phone_number_information(): + phone_number_information = phone_numbers_client.get_phone_number(phone_number) + print('Phone number information: ' + phone_number_information) + +if __name__ == '__main__': + get_phone_number_information() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/list_acquired_phone_numbers_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/list_acquired_phone_numbers_sample.py new file mode 100644 index 000000000000..7991282088bc --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/list_acquired_phone_numbers_sample.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE: list_acquired_phone_numbers_sample.py +DESCRIPTION: + This sample demonstrates how to get all off you acquired phone numbers using your connection string +USAGE: + python list_acquired_phone_numbers_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def list_acquired_phone_numbers(): + acquired_phone_numbers = phone_numbers_client.list_acquired_phone_numbers() + print('Acquired phone numbers:') + for acquired_phone_number in acquired_phone_numbers: + print(acquired_phone_number.phone_number) + + +if __name__ == '__main__': + list_acquired_phone_numbers() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample.py deleted file mode 100644 index ef576e784c81..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_area_codes_sample.py -DESCRIPTION: - This sample demonstrates how to get all area codes via a connection string, country code and phone plan id. -USAGE: - python phone_number_area_codes_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE - The country code you want to get area codes from - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES - The phone plan id you want to get area codes from -""" - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") -phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES', "phone-plan-id") - - -def get_all_area_codes(): - # [START get_all_area_codes] - all_area_codes = phone_number_administration_client.get_all_area_codes( - location_type="NotRequired", - country_code=country_code, - phone_plan_id=phone_plan_id_area_codes - ) - # [END get_all_area_codes] - print('all_area_codes:') - print(all_area_codes) - - -if __name__ == '__main__': - get_all_area_codes() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample_async.py deleted file mode 100644 index 6280bd576776..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_area_codes_sample_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_area_codes_sample_async.py -DESCRIPTION: - This sample demonstrates how to get all area codes via a connection string, country code and phone plan id. -USAGE: - python phone_number_area_codes_sample_async.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE - The country code you want to get area codes from - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES - The phone plan id you want to get area codes from -""" - -import os -import asyncio -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") -phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES', "phone-plan-id") - - -async def get_all_area_codes(): - # [START get_all_area_codes] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string( - connection_str) - async with phone_number_administration_client: - all_area_codes = await phone_number_administration_client.get_all_area_codes( - location_type="NotRequired", - country_code=country_code, - phone_plan_id=phone_plan_id_area_codes - ) - # [END get_all_area_codes] - print('all_area_codes:') - print(all_area_codes) - - -async def main(): - await get_all_area_codes() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample.py deleted file mode 100644 index ef4e0a7af6ee..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_capabilities_sample.py -DESCRIPTION: - This sample demonstrates how to get number capabilities via a connection string, capabilities update id and phone number for capabilities. -USAGE: - python phone_number_capabilities_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID - The capabilities id you want to get - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES - The phone number you want to update capabilities to -""" - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient, - NumberUpdateCapabilities -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID', "capabilities-id") -phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES', "+17771234567") - - -def list_all_phone_numbers(): - # [START list_all_phone_numbers] - list_all_phone_numbers_response = phone_number_administration_client.list_all_phone_numbers() - # [END list_all_phone_numbers] - print('list_all_phone_numbers_response:') - for phone_number in list_all_phone_numbers_response: - print(phone_number) - - -def get_capabilities_update(): - # [START get_capabilities_update] - capabilities_response = phone_number_administration_client.get_capabilities_update( - capabilities_update_id=capabilities_id - ) - # [END get_capabilities_update] - print('capabilities_response:') - print(capabilities_response) - - -def update_capabilities(): - # [START update_capabilities] - update = NumberUpdateCapabilities(add=iter(["InboundCalling"])) - - phone_number_capabilities_update = { - phonenumber_for_capabilities: update - } - - capabilities_response = phone_number_administration_client.update_capabilities( - phone_number_capabilities_update=phone_number_capabilities_update - ) - # [END update_capabilities] - print('capabilities_response:') - print(capabilities_response) - - -if __name__ == '__main__': - list_all_phone_numbers() - get_capabilities_update() - update_capabilities() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample_async.py deleted file mode 100644 index 9934680d9c6f..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_capabilities_sample_async.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_capabilities_sample_async.py -DESCRIPTION: - This sample demonstrates how to get number capabilities via a connection string, capabilities update id and phone number for capabilities. -USAGE: - python phone_number_capabilities_sample_async.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID - The capabilities id you want to get - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES - The phone number you want to update capabilities to -""" - -import asyncio -import os -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient -from azure.communication.phonenumbers import NumberUpdateCapabilities - - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID', "capabilities-id") -phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES', - "phone-number-for-capabilities") - - -async def list_all_phone_numbers(): - # [START list_all_phone_numbers] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - list_all_phone_numbers_response = phone_number_administration_client.list_all_phone_numbers() - print('list_all_phone_numbers_response:') - async for phone_number in list_all_phone_numbers_response: - print(phone_number) - # [END list_all_phone_numbers] - - -async def get_capabilities_update(): - # [START get_capabilities_update] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - capabilities_response = await phone_number_administration_client.get_capabilities_update( - capabilities_update_id=capabilities_id - ) - print('capabilities_response:') - print(capabilities_response) - # [END get_capabilities_update] - - -async def update_capabilities(): - # [START update_capabilities] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - update = NumberUpdateCapabilities(add=iter(["InboundCalling"])) - - phone_number_capabilities_update = { - phonenumber_for_capabilities: update - } - - async with phone_number_administration_client: - capabilities_response = await phone_number_administration_client.update_capabilities( - phone_number_capabilities_update=phone_number_capabilities_update - ) - print('capabilities_response:') - print(capabilities_response) - # [END update_capabilities] - - -async def main(): - await list_all_phone_numbers() - await get_capabilities_update() - await update_capabilities() - - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample.py deleted file mode 100644 index fac5b8bdf11a..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample.py +++ /dev/null @@ -1,58 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_configuration_sample.py -DESCRIPTION: - This sample demonstrates how to configure phone numbers and get phone number configuration via a connection string and phone number to configure -USAGE: - python phone_number_configuration_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE - The phone number you want to configure -""" - - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient, - PstnConfiguration -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE', - "phonenumber_to_configure") - - -def get_number_configuration(): - # [START get_number_configuration] - phone_number_configuration_response = phone_number_administration_client.get_number_configuration( - phone_number=phonenumber_to_configure - ) - # [END get_number_configuration] - print('phone_number_configuration_response:') - print(phone_number_configuration_response) - - -def configure_number(): - # [START configure_number] - pstn_config = PstnConfiguration( - callback_url="https://callbackurl", - application_id="ApplicationId" - ) - phone_number_administration_client.configure_number( - pstn_configuration=pstn_config, - phone_number=phonenumber_to_configure - ) - # [END configure_number] - - -if __name__ == '__main__': - get_number_configuration() - configure_number() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample_async.py deleted file mode 100644 index 824f981c53f0..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_configuration_sample_async.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_configuration_sample_async.py -DESCRIPTION: - This sample demonstrates how to configure phone numbers and get phone number configuration via a connection string and phone number to configure -USAGE: - python phone_number_configuration_sample_async.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE - The phone number you want to configure -""" - -import os -import asyncio -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient -from azure.communication.phonenumbers import PstnConfiguration - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE', - "phonenumber_to_configure") - - -async def get_number_configuration(): - # [START get_number_configuration] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - phone_number_configuration_response = await phone_number_administration_client.get_number_configuration( - phone_number=phonenumber_to_configure - ) - print('phone_number_configuration_response:') - print(phone_number_configuration_response) - # [END get_number_configuration] - - -async def configure_number(): - # [START configure_number] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - pstn_config = PstnConfiguration( - callback_url="https://callbackurl", - application_id="ApplicationId" - ) - async with phone_number_administration_client: - await phone_number_administration_client.configure_number( - pstn_configuration=pstn_config, - phone_number=phonenumber_to_configure - ) - # [END configure_number] - - -async def main(): - await get_number_configuration() - await configure_number() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample.py deleted file mode 100644 index c60c2663e574..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_orders_sample.py -DESCRIPTION: - This sample demonstrates how to list, acquire and cancel phone number orders via a connection string, - reservation id, phone plan id and and area code. -USAGE: - python phone_number_orders_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID - The release id you want to get info from - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID - The reservation id you want to get info from - 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION - The area code to create reservation - 5) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id - 6) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE - The reservation id you want to purchase - 7) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL - The reservation id you want to cancel -""" - - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient, - CreateSearchOptions -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID', "release-id") -reservation_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID', "reservation-id") -area_code_for_reservation = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION', "area-code") -phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") -reservation_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE', - "reservation-id") -reservation_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL', - "reservation-id") - - -def get_release_by_id(): - # [START get_release_by_id] - phone_number_release_response = phone_number_administration_client.get_release_by_id( - release_id=release_id - ) - # [END get_release_by_id] - print('phone_number_release_response:') - print(phone_number_release_response) - - -def list_all_releases(): - # [START get_release_by_id] - releases_response = phone_number_administration_client.list_all_releases() - # [END get_release_by_id] - print('releases_response:') - for release in releases_response: - print(release) - - -def get_reservation_by_id(): - # [START get_reservation_by_id] - phone_number_reservation_response = phone_number_administration_client.get_reservation_by_id( - reservation_id=reservation_id - ) - # [END get_reservation_by_id] - print('phone_number_reservation_response:') - print(phone_number_reservation_response) - - -def begin_reserve_phone_numbers(): - # [START begin_reserve_phone_numbers] - reserve_phone_numbers_poller = phone_number_administration_client.begin_reserve_phone_numbers( - area_code=area_code_for_reservation, - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[phone_plan_id], - quantity=1 - ) - # [END begin_reserve_phone_numbers] - print('reserve phone numbers status:') - print(reserve_phone_numbers_poller.status()) - - -def cancel_reservation(): - # [START cancel_reservation] - phone_number_administration_client.cancel_reservation( - reservation_id=reservation_id_to_cancel - ) - # [START cancel_reservation] - - -def begin_purchase_reservation(): - # [START begin_purchase_reservation] - phone_number_administration_client.begin_purchase_reservation( - reservation_id=reservation_id_to_purchase - ) - # [END begin_purchase_reservation] - - -if __name__ == '__main__': - get_release_by_id() - list_all_releases() - get_reservation_by_id() - begin_reserve_phone_numbers() - cancel_reservation() - # begin_purchase_reservation() #currently throws error if purchase an already purchased number diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample_async.py deleted file mode 100644 index 063ccd27cc6c..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_orders_sample_async.py +++ /dev/null @@ -1,132 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_orders_sample_async.py -DESCRIPTION: - This sample demonstrates how to list, acquire and cancel phone number orders via a connection string, - reservation id, phone plan id and and area code. -USAGE: - python phone_number_orders_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID - The release id you want to get info from - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID - The reservation id you want to get info from - 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION - The area code to create reservation - 5) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id - 6) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE - The reservation id you want to purchase - 7) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL - The reservation id you want to cancel -""" - -import os -import asyncio -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient -from azure.communication.phonenumbers import CreateSearchOptions - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID', "release-id") -reservation_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID', "reservation-id") -area_code_for_reservation = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION', "area-code") -phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") -reservation_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE', - "reservation-id") -reservation_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL', - "reservation-id") - - -async def get_release_by_id(): - # [START get_release_by_id] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - phone_number_release_response = await phone_number_administration_client.get_release_by_id( - release_id=release_id - ) - print('phone_number_release_response:') - print(phone_number_release_response) - # [END get_release_by_id] - - -async def list_all_releases(): - # [START list_all_releases] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - releases_response = phone_number_administration_client.list_all_releases() - print('releases_response:') - async for release in releases_response: - print(release) - # [END list_all_releases] - - -async def get_reservation_by_id(): - # [START get_reservation_by_id] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - phone_number_reservation_response = await phone_number_administration_client.get_reservation_by_id( - reservation_id=reservation_id - ) - print('phone_number_reservation_response:') - print(phone_number_reservation_response) - await phone_number_administration_client.close() - # [END get_reservation_by_id] - - -async def begin_reserve_phone_numbers(): - # [START begin_reserve_phone_numbers] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - reservationOptions = CreateSearchOptions( - area_code=area_code_for_reservation, - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[phone_plan_id], - quantity=1 - ) - async with phone_number_administration_client: - reserve_phone_numbers_poller = await phone_number_administration_client.begin_reserve_phone_numbers( - area_code=area_code_for_reservation, - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[phone_plan_id], - quantity=1 - ) - print('reserve phone numbers status:') - print(reserve_phone_numbers_poller.status()) - # [END begin_reserve_phone_numbers] - - -async def cancel_reservation(): - # [START cancel_reservation] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - await phone_number_administration_client.cancel_reservation( - reservation_id=reservation_id_to_cancel - ) - # [END cancel_reservation] - - -async def begin_purchase_reservation(): - # [START begin_purchase_reservation] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - await phone_number_administration_client.begin_purchase_reservation( - reservation_id=reservation_id_to_purchase - ) - # [END begin_purchase_reservation] - - -async def main(): - await get_release_by_id() - await list_all_releases() - await get_reservation_by_id() - await begin_reserve_phone_numbers() - await cancel_reservation() - # await begin_purchase_reservation() #currently throws error if purchase an already purchased number - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample.py deleted file mode 100644 index cbf0229ea18e..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_plans_sample.py -DESCRIPTION: - This sample demonstrates how to list phone plans via a connection string, country code, phone plan id and phone plan group id -USAGE: - python phone_number_plans_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE - The country code - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID - The phone plan group id you want to use to list phone plans - 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id you want to use to get location options -""" - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) -country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") -phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID', "phone-plan-group-id") -phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") - - -def list_phone_plan_groups(): - # [START list_phone_plan_groups] - phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups( - country_code=country_code - ) - # [END list_phone_plan_groups] - print('list_phone_plan_groups:') - for phone_plan_group in phone_plan_groups_response: - print(phone_plan_group) - - -def list_phone_plans(): - # [START list_phone_plans] - phone_plans_response = phone_number_administration_client.list_phone_plans( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id - ) - # [END list_phone_plans] - print('list_phone_plans:') - for phone_plan in phone_plans_response: - print(phone_plan) - - -def get_phone_plan_location_options(): - # [START get_phone_plan_location_options] - location_options_response = phone_number_administration_client.get_phone_plan_location_options( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id, - phone_plan_id=phone_plan_id - ) - # [END get_phone_plan_location_options] - print('get_phone_plan_location_options:') - print(location_options_response) - - -if __name__ == '__main__': - list_phone_plan_groups() - list_phone_plans() - get_phone_plan_location_options() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample_async.py deleted file mode 100644 index ea08bd6f3d00..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_plans_sample_async.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_plans_sample_async.py -DESCRIPTION: - This sample demonstrates how to list phone plans via a connection string, country code, phone plan id and phone plan group id -USAGE: - python phone_number_plans_sample_async.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service - 2) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE - The country code - 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID - The phone plan group id you want to use to list phone plans - 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id you want to use to get location options -""" - - -import os -import asyncio -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") -phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID', "phone-plan-group-id") -phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") - - -async def list_phone_plan_groups(): - # [START list_phone_plan_groups] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups( - country_code=country_code - ) - print('list_phone_plan_groups:') - async for phone_plan_group in phone_plan_groups_response: - print(phone_plan_group) - # [END list_phone_plan_groups] - - -async def list_phone_plans(): - # [START list_phone_plans] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - phone_plans_response = phone_number_administration_client.list_phone_plans( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id - ) - print('list_phone_plans:') - async for phone_plan in phone_plans_response: - print(phone_plan) - # [END list_phone_plans] - - -async def get_phone_plan_location_options(): - # [START get_phone_plan_location_options] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - location_options_response = await phone_number_administration_client.get_phone_plan_location_options( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id, - phone_plan_id=phone_plan_id - ) - print('get_phone_plan_location_options:') - print(location_options_response) - # [START get_phone_plan_location_options] - - -async def main(): - await list_phone_plan_groups() - await list_phone_plans() - await get_phone_plan_location_options() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample.py deleted file mode 100644 index e2510c3329a0..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_supported_countries_sample.py -DESCRIPTION: - This sample demonstrates how to get supported countries via a connection string -USAGE: - python phone_number_supported_countries_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service -""" - - -import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient -) - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - - -def list_all_supported_countries(): - # [START list_all_supported_countries] - supported_countries = phone_number_administration_client.list_all_supported_countries() - # [END list_all_supported_countries] - print('supported_countries:') - for supported_country in supported_countries: - print(supported_country) - - -if __name__ == '__main__': - list_all_supported_countries() diff --git a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample_async.py b/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample_async.py deleted file mode 100644 index 755e84d05a2c..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/samples/phone_number_supported_countries_sample_async.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding: utf-8 - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -""" -FILE: phone_number_supported_countries_sample.py -DESCRIPTION: - This sample demonstrates how to get supported countries via a connection string -USAGE: - python phone_number_supported_countries_sample.py - Set the environment variables with your own values before running the sample: - 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The endpoint of your Azure Communication Service -""" - - -import os -import asyncio -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - - -async def list_all_supported_countries(): - # [START list_all_supported_countries] - phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string(connection_str) - async with phone_number_administration_client: - supported_countries = phone_number_administration_client.list_all_supported_countries() - print('supported_countries:') - async for supported_country in supported_countries: - print(supported_country) - # [END list_all_supported_countries] - - -async def main(): - await list_all_supported_countries() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) 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 new file mode 100644 index 000000000000..ec16e3913222 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/purchase_phone_number_sample.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE: purchase_phone_number_sample.py +DESCRIPTION: + This sample demonstrates how to purchase a phone number using the search id you got from the search_available_phone_number API +USAGE: + python purchase_phone_number_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service 2) AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE - The search id for the phone number you reserved and want to purchase +""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +search_id = os.getenv("AZURE_COMMUNICATION_SERVICE_SEARCH_ID_TO_PURCHASE") +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def purchase_phone_number(): + poller = phone_numbers_client.begin_purchase_phone_numbers( + search_id, + polling = True + ) + poller.result() + print("Result from the purchase operation: " + poller.status()) + + +if __name__ == '__main__': + purchase_phone_number() 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 new file mode 100644 index 000000000000..a06804445d34 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/release_phone_number_sample.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE: release_phone_number_sample.py +DESCRIPTION: + This sample demonstrates how to release a previously acquired phone number using your connection string. +USAGE: + python release_phone_number_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service + 2) AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER_TO_RELEASE - The phone number you want to release +""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_to_release = os.getenv( + "AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER_TO_RELEASE" # e.g. "+18001234567" +) +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def release_phone_number(): + poller = phone_numbers_client.begin_release_phone_number(phone_number_to_release) + poller.result() + print('Status of the operation: ' + poller.status()) + +if __name__ == '__main__': + release_phone_number() 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 new file mode 100644 index 000000000000..61187bb07838 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/search_available_phone_numbers_sample.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE: search_available_phone_numbers_sample.py +DESCRIPTION: + This sample demonstrates how to search for available numbers you can buy with the respective API. +USAGE: + python search_available_phone_numbers_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service +""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient, + PhoneNumberType, + PhoneNumberAssignmentType, + PhoneNumberCapabilities, + PhoneNumberCapabilityType +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +area_code = os.getenv('AZURE_COMMUNICATION_SERVICE_AREA_CODE') +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def search_available_phone_numbers(): + capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND + ) + poller = phone_numbers_client.begin_search_available_phone_numbers( + "US", + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + polling = True + ) + print('Acquired phone numbers: ' + poller.result()) + + +if __name__ == '__main__': + search_available_phone_numbers() 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 new file mode 100644 index 000000000000..fc7fefac08bb --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/samples/update_phone_number_capabilities_sample.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +""" +FILE: update_phone_number_capabilities_sample.py +DESCRIPTION: + This sample demonstrates how to updtae the capabilities of a phone number using your connection string. +USAGE: + python update_phone_number_capabilities_sample.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - The connection string including your endpoint and + access key of your Azure Communication Service + 2) AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER_TO_UPDATE - The phone number you want to update +""" + +import os +from azure.communication.phonenumbers import ( + PhoneNumbersClient, + PhoneNumberCapabilityType +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_to_release = os.getenv( + "AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER_TO_UPDATE" # e.g. "+18001234567" +) +phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_str) + +def update_phone_number_capabilities(): + poller = phone_numbers_client.begin_update_phone_number_capabilities( + "+18335260208", + PhoneNumberCapabilityType.OUTBOUND, + PhoneNumberCapabilityType.INBOUND_OUTBOUND, + polling = True + ) + poller.result() + print('Status of the operation: ' + poller.status()) + +if __name__ == '__main__': + update_phone_number_capabilities() diff --git a/sdk/communication/azure-communication-phonenumbers/setup.py b/sdk/communication/azure-communication-phonenumbers/setup.py index f25bf8764c33..f5d560282c3b 100644 --- a/sdk/communication/azure-communication-phonenumbers/setup.py +++ b/sdk/communication/azure-communication-phonenumbers/setup.py @@ -49,7 +49,6 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/PHONE_NUMBER_SWAGGER.md b/sdk/communication/azure-communication-phonenumbers/swagger/PHONE_NUMBER_SWAGGER.md index cda635961f5b..908729754762 100644 --- a/sdk/communication/azure-communication-phonenumbers/swagger/PHONE_NUMBER_SWAGGER.md +++ b/sdk/communication/azure-communication-phonenumbers/swagger/PHONE_NUMBER_SWAGGER.md @@ -10,7 +10,7 @@ autorest ./PHONE_NUMBER_SWAGGER.md ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/257f060be8b60d8468584682aa2d71b1faa5f82c/specification/communication/data-plane/Microsoft.CommunicationServicesAdministration/preview/2020-07-20-preview1/communicationservicesadministration.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/a4d1e1516433894fca89f9600a6ac8a5471fc598/specification/communication/data-plane/Microsoft.CommunicationServicesPhoneNumbers/stable/2021-03-07/phonenumbers.json output-folder: ../azure/communication/phonenumbers/_generated namespace: azure.communication.phonenumbers license-header: MICROSOFT_MIT_NO_VERSION @@ -20,23 +20,3 @@ clear-output-folder: true v3: true python: true ``` - -### Rename searchId to reservationId -```yaml -directive: - - from: swagger-document - where: $.definitions.PhoneNumberSearch.properties.searchId - transform: > - $["x-ms-client-name"] = "reservationId"; -``` - -### Rename PhoneNumberSearch to PhoneNumberReservation -```yaml -custom-types-subpackage: models -custom-types: PhoneNumberReservation -required-fields-as-ctor-args: true -directive: - - rename-model: - from: PhoneNumberSearch - to: PhoneNumberReservation -``` \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateReleaseAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateReleaseAsync.json deleted file mode 100644 index 063a85f5aeac..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateReleaseAsync.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "body": { - "telephoneNumbers": [ "+11234567890" ] - } - }, - "responses": { - "200": { - "headers": {}, - "body": { - "id": "0cc077cd-333a-39fd-90f7-560b1e06c63e" - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateSearchOrderAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateSearchOrderAsync.json deleted file mode 100644 index 7242d8403f3d..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/CreateSearchOrderAsync.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "body": { - "name": "Name", - "description": "Search Order Description", - "planSubTypeIds": ["0cc077cd-333a-39fd-90f7-560b1e06c63e"], - "areaCode": "604", - "quantity": 2, - "civicAddressId": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "requestingUser": { - "firstName": "John", - "lastName": "Smith", - "emailAddress": "johnsmith@contoso.com", - "phoneNumber": "12345", - "displayName": "John Smith" - } - } - }, - "responses": { - "201": { - "headers": {}, - "body": { - "id": "0cc077cd-5337-7msf-964e-560b1e06c63e" - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAcquiredTelephoneNumbersAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAcquiredTelephoneNumbersAsync.json deleted file mode 100644 index 48b4666c6e38..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAcquiredTelephoneNumbersAsync.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "locale": "en-us" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "items": [ - { - "telephoneNumber": "+11234567890", - "numberType": "Cloud", - "civicAddressId": null, - "acquiredCapabilities": null, - "availableCapabilities": null, - "blockId": null, - "rangeId": null, - "assignmentStatus": "Unassigned", - "placeName": "Toll-Free, United States", - "activationState": "Activated" - }, - { - "telephoneNumber": "+10123456789", - "numberType": "Cloud", - "civicAddressId": null, - "acquiredCapabilities": null, - "availableCapabilities": null, - "blockId": null, - "rangeId": null, - "assignmentStatus": "Unassigned", - "placeName": "Toll-Free, United States", - "activationState": "Activated" - } - ] - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAreaCodesAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAreaCodesAsync.json deleted file mode 100644 index 0cc7ce546ca0..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetAreaCodesAsync.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "addressId": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "locationType": "CivicAddress", - "country": "CA", - "planSubTypeId": "0cc077cd-333a-39fd-90f7-560b1e06c63e" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "primaryAreaCodes": [ - "236", - "604", - "778" - ], - "secondaryAreaCodes": [] - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetCountriesAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetCountriesAsync.json deleted file mode 100644 index eee04b0bd0c8..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetCountriesAsync.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "locale": "en-us" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "items": [ - { - "name": "Australia", - "value": "AU" - }, - { - "name": "Japan", - "value": "JP" - }, - { - "name": "United States", - "value": "US" - } - ] - } - - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetNumberConfigurationAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetNumberConfigurationAsync.json deleted file mode 100644 index 3cfd910129cb..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetNumberConfigurationAsync.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "phoneNumber": "+11234567890" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "pstnConfiguration": { - "callbackUrl": "www.callback.com", - "applicationId": "abc123" - } - } - } - } - } diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetOrdersAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetOrdersAsync.json deleted file mode 100644 index 4ef8ad59fc4d..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetOrdersAsync.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "items": [] - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetPlansAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetPlansAsync.json deleted file mode 100644 index a6b541386b08..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetPlansAsync.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "country": "US", - "locale": "en-us" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "items": [ - { - "id": "671ee064-662f-4c3b-82a9-af2ab200dd5c", - "type": "Direct", - "name": "Geographic", - "description": "These are inbound and outbound numbers.", - "subTypes": [ - { - "id": "27b53eec-8ff4-4070-8900-fbeaabfd158a", - "name": "Outbound Only PSTN - Geographic", - "locationType": "CivicAddress", - "areaCodes": null, - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "Azure", "OutboundCalling", "ThirdPartyAppAssignment", "Geographic" ], - "maximumSearchSize": 100 - }, - { - "id": "d0d438e7-923f-4210-8e05-365979e30414", - "name": "Inbound Only PSTN - Geographic", - "locationType": "CivicAddress", - "areaCodes": null, - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "Azure", "InboundCalling", "ThirdPartyAppAssignment", "Geographic" ], - "maximumSearchSize": 100 - } - ], - "carrierDetails": null - }, - { - "id": "d47a0cdc-8dc1-4e82-a29b-39067f7fc317", - "type": "Direct", - "name": "Toll Free", - "description": "These are toll free numbers.", - "subTypes": [ - { - "id": "0fad67fb-b455-439b-9f1c-3f22bb1ea350", - "name": "2-way SMS (A2P) & Outbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "OutboundCalling", "ThirdPartyAppAssignment", "InboundA2PSms", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "a06000d2-6ec2-4202-b9ce-e6963bed12f5", - "name": "2-way SMS (A2P) & Inbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "InboundCalling", "ThirdPartyAppAssignment", "InboundA2PSms", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "3865f174-c45b-4854-a04f-90ad5c8393ed", - "name": "2-way SMS (A2P) & 2-way PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "InboundCalling", "OutboundCalling", "ThirdPartyAppAssignment", "InboundA2PSms", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "4b6d0bbb-ce5e-4937-b8c4-f04a6d74822b", - "name": "Outbound Only SMS (A2P) & Outbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "OutboundCalling", "ThirdPartyAppAssignment", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "2eb579fc-0c41-46f4-a2cc-8c550b581b7b", - "name": "Outbound Only SMS (A2P) & Inbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "InboundCalling", "ThirdPartyAppAssignment", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "0ff321c3-7320-4f64-b3db-5b5c1a363d35", - "name": "2-way SMS (A2P) - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "ThirdPartyAppAssignment", "InboundA2PSms", "OutboundA2PSms", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "fff1fa3a-e10c-40ee-9db4-178d43336757", - "name": "Outbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "ThirdPartyAppAssignment", "OutboundCalling", "TollFree" ], - "maximumSearchSize": 100 - }, - { - "id": "7c618af1-60f1-4285-ba7e-aca89a5922a5", - "name": "Inbound Only PSTN - Toll Free", - "locationType": "NotRequired", - "areaCodes": [ "888", "877", "866", "855", "844", "800", "833" ], - "locationOptions": null, - "requiresCivicAddress": false, - "blockSizes": [ 1 ], - "capabilities": [ "ThirdPartyAppAssignment", "InboundCalling", "TollFree" ], - "maximumSearchSize": 100 - } - ], - "carrierDetails": null - } - ] - } - } - } -} - diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetReleaseByIdAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetReleaseByIdAsync.json deleted file mode 100644 index 8e2d80f841a1..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetReleaseByIdAsync.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "orderId": "0cc077cd-333a-39fd-90f7-560b1e06c63e" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "id": "0cc077cd-333a-39fd-90f7-560b1e06c63e" - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetSearchOrderAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetSearchOrderAsync.json deleted file mode 100644 index 97976bfaad90..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/GetSearchOrderAsync.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "orderId": "0cc077cd-333a-39fd-90f7-560b1e06c63e" - }, - "responses": { - "200": { - "headers": {}, - "body": { - "id": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "name": "Numbers for Vancouver Office", - "createdAt": "2020-06-18T17:11:52.5005818+00:00", - "createdBy": "sfbmra-dev.mtls-client.skype.net", - "description": "Get some new numbers for our office in Vancouver", - "planSubTypeId": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "areaCode": "604", - "quantity": 1, - "civicAddressId": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "locationOptions": [], - "status": "Manual", - "telephoneNumbers": [], - "reservationExpiryDate": null, - "errorCode": null, - "jobIds": [ "0cc077cd-333a-39fd-90f7-560b1e06c63e" ] - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/RemoveNumberConfigurationAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/RemoveNumberConfigurationAsync.json deleted file mode 100644 index 44e7c2e8e6c2..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/RemoveNumberConfigurationAsync.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "phoneNumber": "+11234567890", - }, - "responses": { - "204": {} - } - } diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberCapabilitiesAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberCapabilitiesAsync.json deleted file mode 100644 index 502bb6e5a1cb..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberCapabilitiesAsync.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "body": { - "phoneNumbers": { - "12345878981": { - "add": [ - "InboundA2PSms", - "OutboundA2PSms" - ], - "remove": [] - }, - "12345878991": { - "add": [], - "remove": [ - "InboundA2PSms", - "OutboundA2PSms" - ] - } - } - } - }, - "responses": { - "200": { - "headers": {}, - "body": { - "id": "0cc077cd-5337-7msf-964e-560b1e06c63e" - } - } - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberConfigurationAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberConfigurationAsync.json deleted file mode 100644 index 9e0a34149e23..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateNumberConfigurationAsync.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "phoneNumber": "+11234567890", - "body": { - "pstnConfiguration": { - "callbackUrl": "www.callback.com", - "applicationId": "abc123" - } - } - }, - "responses": { - "204": {} - } - } diff --git a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateSearchOrderAsync.json b/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateSearchOrderAsync.json deleted file mode 100644 index 139fb9ee0b1f..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/swagger/examples/UpdateSearchOrderAsync.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "api-version": "2020-07-20-preview1", - "orderId": "0cc077cd-333a-39fd-90f7-560b1e06c63e", - "body": { - "action": 2 - } - }, - "responses": { - "204": {} - } -} diff --git a/sdk/communication/azure-communication-phonenumbers/test/_shared/asynctestcase.py b/sdk/communication/azure-communication-phonenumbers/test/_shared/asynctestcase.py index 197c48e0079b..4c331bb79598 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/_shared/asynctestcase.py +++ b/sdk/communication/azure-communication-phonenumbers/test/_shared/asynctestcase.py @@ -1,4 +1,3 @@ - # coding: utf-8 # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,4 +23,4 @@ def run(test_class_instance, *args, **kwargs): loop = asyncio.get_event_loop() return loop.run_until_complete(test_fn(test_class_instance, **kwargs)) - return run + return run \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/test/_shared/communication_service_preparer.py b/sdk/communication/azure-communication-phonenumbers/test/_shared/communication_service_preparer.py deleted file mode 100644 index e3907ff011e0..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/_shared/communication_service_preparer.py +++ /dev/null @@ -1,89 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -import datetime - -from azure.mgmt.communication import CommunicationServiceManagementClient -from azure.mgmt.communication.models import CommunicationServiceResource -from devtools_testutils import( - AzureMgmtPreparer, - ResourceGroupPreparer, - FakeResource -) -from devtools_testutils.resource_testcase import RESOURCE_GROUP_PARAM -from azure_devtools.scenario_tests.exceptions import AzureTestError - -class CommunicationServicePreparer(AzureMgmtPreparer): - """Communication Service Preparer. - Creating and destroying test resources on demand - """ - def __init__( - self, - name_prefix="communication", - resource_group_parameter_name=RESOURCE_GROUP_PARAM, - disable_recording=True, - use_cache=False, - playback_fake_resource=None, - client_kwargs=None, - ): - super(CommunicationServicePreparer, self).__init__( - name_prefix, - random_name_length=24, - disable_recording=disable_recording, - playback_fake_resource=playback_fake_resource, - client_kwargs=client_kwargs, - ) - self.resource_group_parameter_name = resource_group_parameter_name - self.random_name_enabled = True - self.service_name = "TEST-SERVICE-NAME" - self.mgmt_client = None - self.set_cache(use_cache) - self.scrubbed_resource_name = "communicationegrcrs" - - def _get_resource_group(self, **kwargs): - try: - return kwargs[self.resource_group_parameter_name] - except KeyError: - template = ( - "To create a communication service a resource group is required. Please add " - "decorator @{} in front of this preparer." - ) - raise AzureTestError(template.format(ResourceGroupPreparer.__name__)) - - def create_resource(self, name, **kwargs): - if not self.is_live: - self.resource = FakeResource(name=self.scrubbed_resource_name, id=name) - - return { - "connection_string": "endpoint=https://{}.communication.azure.com/;accesskey=fake===".format(self.resource.name), - } - - self.test_class_instance.scrubber.register_name_pair(name, self.scrubbed_resource_name) - group_name = self._get_resource_group(**kwargs).name - - self.client = self.create_mgmt_client(CommunicationServiceManagementClient, polling_interval=30) - - self.resource = self.client.communication_service.begin_create_or_update( - group_name, - name, - CommunicationServiceResource(location="global", data_location="UnitedStates") - ).result() - - self.service_name = self.resource.name - - primary_connection_string = self.client.communication_service.list_keys( - group_name, - self.resource.name).primary_connection_string - - return { - "connection_string": primary_connection_string, - } - - def remove_resource(self, name, **kwargs): - if not self.is_live: - return - - group_name = self._get_resource_group(**kwargs).name - self.client.communication_service.begin_delete(group_name, self.service_name).wait() diff --git a/sdk/communication/azure-communication-phonenumbers/test/_shared/fake_token_credential.py b/sdk/communication/azure-communication-phonenumbers/test/_shared/fake_token_credential.py index b4fc2e6eaccf..eac266e8ed5c 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/_shared/fake_token_credential.py +++ b/sdk/communication/azure-communication-phonenumbers/test/_shared/fake_token_credential.py @@ -1,3 +1,4 @@ + # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -10,4 +11,4 @@ def __init__(self): self.token = AccessToken("Fake Token", 0) def get_token(self, *args): - return self.token \ No newline at end of file + return self.token diff --git a/sdk/communication/azure-communication-phonenumbers/test/_shared/helper.py b/sdk/communication/azure-communication-phonenumbers/test/_shared/helper.py deleted file mode 100644 index 7338f10940a0..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/_shared/helper.py +++ /dev/null @@ -1,19 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from azure_devtools.scenario_tests import RecordingProcessor - -class URIIdentityReplacer(RecordingProcessor): - """Replace the identity in request uri""" - def process_request(self, request): - import re - request.uri = re.sub('/identities/([^/?]+)', '/identities/sanitized', request.uri) - return request - - def process_response(self, response): - import re - if 'url' in response: - response['url'] = re.sub('/identities/([^/?]+)', '/identities/sanitized', response['url']) - return response \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/test/_shared/testcase.py b/sdk/communication/azure-communication-phonenumbers/test/_shared/testcase.py index f56f17e56a46..5ec27d644d24 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/_shared/testcase.py +++ b/sdk/communication/azure-communication-phonenumbers/test/_shared/testcase.py @@ -5,9 +5,11 @@ # license information. # -------------------------------------------------------------------------- import re +import os from devtools_testutils import AzureTestCase from azure_devtools.scenario_tests import RecordingProcessor, ReplayableTest from azure_devtools.scenario_tests.utilities import is_text_payload +from azure.communication.phonenumbers._shared.utils import parse_connection_str class ResponseReplacerProcessor(RecordingProcessor): def __init__(self, keys=None, replacement="sanitized"): @@ -15,20 +17,23 @@ def __init__(self, keys=None, replacement="sanitized"): self._replacement = replacement def process_response(self, response): - def sanitize_dict(dictionary): - for key in dictionary: - value = dictionary[key] - if isinstance(value, str): - dictionary[key] = re.sub( - r"("+'|'.join(self._keys)+r")", - self._replacement, - dictionary[key]) - elif isinstance(value, dict): - sanitize_dict(value) - - sanitize_dict(response) - - return response + import json + try: + body = json.loads(response['body']['string']) + if 'phoneNumbers' in body: + for item in body["phoneNumbers"]: + if isinstance(item, str): + body["phoneNumbers"] = [self._replacement] + break + elif "phoneNumber" in item: + item['phoneNumber'] = self._replacement + elif "id" in item: + item['id'] = self._replacement + response['body']['string'] = json.dumps(body) + response['url'] = self._replacement + return response + except (KeyError, ValueError): + return response class BodyReplacerProcessor(RecordingProcessor): """Sanitize the sensitive info inside request or response bodies""" @@ -64,6 +69,16 @@ def _replace_keys(self, body): class CommunicationTestCase(AzureTestCase): FILTER_HEADERS = ReplayableTest.FILTER_HEADERS + ['x-azure-ref', 'x-ms-content-sha256', 'location'] - def __init__(self, method_name, *args, **kwargs): - super(CommunicationTestCase, self).__init__(method_name, *args, **kwargs) \ No newline at end of file + super(CommunicationTestCase, self).__init__(method_name, *args, **kwargs) + + def setUp(self): + super(CommunicationTestCase, self).setUp() + + if self.is_playback(): + self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===" + else: + self.connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') + endpoint, _ = parse_connection_str(self.connection_str) + self._resource_name = endpoint.split(".")[0] + self.scrubber.register_name_pair(self._resource_name, "sanitized") \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/test/phone_number_helper.py b/sdk/communication/azure-communication-phonenumbers/test/phone_number_helper.py index 445632f40c97..970b73a467bf 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/phone_number_helper.py +++ b/sdk/communication/azure-communication-phonenumbers/test/phone_number_helper.py @@ -10,17 +10,15 @@ class PhoneNumberUriReplacer(RecordingProcessor): def process_request(self, request): import re - request.uri = re.sub('/identities/([^/?]+)', '/identities/sanitized', request.uri) + request.uri = re.sub('phoneNumbers/[%2B\d]+', 'phoneNumbers/sanitized', request.uri) return request def process_response(self, response): import re if 'url' in response: - response['url'] = re.sub('/identities/([^/?]+)', '/identities/sanitized', response['url']) - response['url'] = re.sub('phonePlanId=([^/?&]+)', 'phonePlanId=sanitized', response['url']) response['url'] = re.sub('capabilities/([^/?&]+)', 'capabilities/sanitized', response['url']) - response['url'] = re.sub('phoneplangroups/([^/?&]+)', 'phoneplangroups/sanitized', response['url']) - response['url'] = re.sub('phoneplans/([^/?&]+)', 'phoneplans/sanitized', response['url']) response['url'] = re.sub('releases/([^/?&]+)', 'releases/sanitized', response['url']) response['url'] = re.sub('searches/([^/?&]+)', 'searches/sanitized', response['url']) - return response \ No newline at end of file + response['url'] = re.sub('phoneNumbers/[%2B\d]+', 'phoneNumbers/sanitized', response['url']) + response['url'] = re.sub('^(.*?)\.communication.azure.com', 'https://sanitized.communication.azure.com', response['url']) + return response \ No newline at end of file diff --git a/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase.py b/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase.py deleted file mode 100644 index 29fc052e3764..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import os -from azure.communication.phonenumbers._shared.utils import parse_connection_str -from _shared.testcase import CommunicationTestCase - -class PhoneNumberCommunicationTestCase(CommunicationTestCase): - def setUp(self): - super(PhoneNumberCommunicationTestCase, self).setUp() - - if self.is_playback(): - self.connection_str = "endpoint=https://sanitized/;accesskey=fake===" - else: - self.connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - endpoint, _ = parse_connection_str(self.connection_str) - self._resource_name = endpoint.split(".")[0] - self.scrubber.register_name_pair(self._resource_name, "sanitized") diff --git a/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase_async.py b/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase_async.py deleted file mode 100644 index b6354fcfa35c..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/phone_number_testcase_async.py +++ /dev/null @@ -1,13 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import os -from azure.communication.phonenumbers._shared.utils import parse_connection_str -from phone_number_testcase import PhoneNumberCommunicationTestCase -from _shared.asynctestcase import AsyncCommunicationTestCase - -class AsyncPhoneNumberCommunicationTestCase(PhoneNumberCommunicationTestCase, AsyncCommunicationTestCase): - def setUp(self): - super(AsyncPhoneNumberCommunicationTestCase, self).setUp() diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_cancel_reservation.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_cancel_reservation.yaml deleted file mode 100644 index cd8e3ca107b6..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_cancel_reservation.yaml +++ /dev/null @@ -1,36 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Mon, 23 Nov 2020 22:11:17 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id_to_cancel/cancel?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 23 Nov 2020 22:11:17 GMT - ms-cv: - - mbCpJZCKiUK4caapFCbzQg.0 - x-processing-time: - - 258ms - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_configure_number.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_configure_number.yaml deleted file mode 100644 index 86df837dc773..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_configure_number.yaml +++ /dev/null @@ -1,39 +0,0 @@ -interactions: -- request: - body: 'b''{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": - "ApplicationId"}, "phoneNumber": "+1area_code_for_reservation4501240"}''' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '126' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:17 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: PATCH - uri: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration/configure?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 23 Nov 2020 22:11:18 GMT - ms-cv: - - G9imTJyYkkSUmuTD6LmwNg.0 - x-processing-time: - - 886ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_create_search.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_create_search.yaml deleted file mode 100644 index a2e75ba52d07..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_create_search.yaml +++ /dev/null @@ -1,186 +0,0 @@ -interactions: -- request: - body: 'b''b\''{"displayName": "testreservation20200014", "description": "testreservation20200014", - "phonePlanIds": ["phone_plan_id"], "areaCode": "area_code_for_reservation", - "quantity": 1}\''''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '176' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:08:38 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:08:39 GMT - ms-cv: - - HTqHTEW+FESz3w+S699+5g.0 - transfer-encoding: - - chunked - x-processing-time: - - 771ms - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:08:39 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/1aa3199c-2448-4734-8f8e-96330c8f6caa?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:08:38.6944708+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:08:39 GMT - ms-cv: - - lbxsJisVC0CUsQNU7JT2Eg.0 - transfer-encoding: - - chunked - x-processing-time: - - 293ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:08:39 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/1aa3199c-2448-4734-8f8e-96330c8f6caa?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:08:38.6944708+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:08:39 GMT - ms-cv: - - R0qCoiwGdEu/iH8sS5ViZw.0 - transfer-encoding: - - chunked - x-processing-time: - - 408ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:08:45 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/1aa3199c-2448-4734-8f8e-96330c8f6caa?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:08:38.6944708+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:08:45 GMT - ms-cv: - - cx/vg1Ggike+C0L6hX+BEg.0 - transfer-encoding: - - chunked - x-processing-time: - - 263ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:08:50 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/1aa3199c-2448-4734-8f8e-96330c8f6caa?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:08:38.6944708+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Error", "phoneNumbers": "sanitized", "errorCode": - 1000}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:08:50 GMT - ms-cv: - - jHWx/MVzNUudhIJdiQMyWg.0 - transfer-encoding: - - chunked - x-processing-time: - - 266ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml deleted file mode 100644 index cfcf405f1688..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml +++ /dev/null @@ -1,40 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:18 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/areacodes?locationType=NotRequired&phonePlanId=phone_plan_id_area_codes&api-version=2020-07-20-preview1 - response: - body: '{"primaryAreaCodes": ["area_code_for_reservation"], "secondaryAreaCodes": - [], "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:18 GMT - ms-cv: - - 7EdJRpBmQkyxpwPMjLC0aA.0 - transfer-encoding: - - chunked - x-processing-time: - - 262ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml deleted file mode 100644 index 38b88c38b27e..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml +++ /dev/null @@ -1,36 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:19 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities/capabilities_id?api-version=2020-07-20-preview1 - response: - body: '{"capabilitiesUpdateId": "sanitized", "createdAt": "2020-09-28T17:49:13.2696607+00:00", - "capabilitiesUpdateStatus": "Complete", "phoneNumberCapabilitiesUpdates": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:18 GMT - ms-cv: - - EzXo3vmXrkGjsGovhnBqPw.0 - transfer-encoding: - - chunked - x-processing-time: - - 266ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml deleted file mode 100644 index b2b568fe6fbb..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml +++ /dev/null @@ -1,40 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumber": "+1area_code_for_reservation4501240"}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '31' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:19 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 - response: - body: '{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": - "ApplicationId", "azurePstnTargetId": "85c9239f-0b81-47e6-b25e-95ccaf48581f"}}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:19 GMT - ms-cv: - - B7d4g2aBsEy/41s1bLygcA.0 - transfer-encoding: - - chunked - x-processing-time: - - 327ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_number.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_number.yaml new file mode 100644 index 000000000000..542ecd2ce24e --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_number.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:19:58 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07 + response: + body: + string: '{"id": "sanitized", "phoneNumber": "sanitized", "countryCode": "US", + "phoneNumberType": "TollFree", "capabilities": {"calling": "inbound", "sms": + "inbound+outbound"}, "assignmentType": "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:20:00 GMT + ms-cv: + - aa2xk97xc06kIOakrLVlZQ.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 1617ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml deleted file mode 100644 index 85fdb9178888..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml +++ /dev/null @@ -1,250 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:20 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/phone_plan_group_id/phoneplans/phone_plan_id/locationoptions?locale=en-US&api-version=2020-07-20-preview1 - response: - body: '{"locationOptions": {"labelId": "state", "labelName": "State", "options": - [{"name": "AK", "value": "AK", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Anchorage", "value": "NOAM-US-AK-AN", "locationOptions": - []}]}]}, {"name": "AL", "value": "AL", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Birmingham", "value": "NOAM-US-AL-BI", - "locationOptions": []}, {"name": "Huntsville", "value": "NOAM-US-AL-HN", "locationOptions": - []}, {"name": "Mobile", "value": "NOAM-US-AL-MO", "locationOptions": []}, {"name": - "Montgomery", "value": "NOAM-US-AL-MN", "locationOptions": []}]}]}, {"name": - "AR", "value": "AR", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Fort Smith", "value": "NOAM-US-AR-FS", "locationOptions": - []}, {"name": "Jonesboro", "value": "NOAM-US-AR-JO", "locationOptions": []}, - {"name": "Little Rock", "value": "NOAM-US-AR-LR", "locationOptions": []}]}]}, - {"name": "AZ", "value": "AZ", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Phoenix", "value": "NOAM-US-AZ-PH", "locationOptions": - []}]}]}, {"name": "CA", "value": "CA", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Anaheim", "value": "NOAM-US-CA-AN", - "locationOptions": []}, {"name": "Burbank", "value": "NOAM-US-CA-BU", "locationOptions": - []}, {"name": "Fresno", "value": "NOAM-US-CA-FR", "locationOptions": []}, {"name": - "Irvine", "value": "NOAM-US-CA-IR", "locationOptions": []}, {"name": "Los Angeles", - "value": "NOAM-US-CA-LA", "locationOptions": []}, {"name": "Riverside", "value": - "NOAM-US-CA-RI", "locationOptions": []}, {"name": "Sacramento", "value": "NOAM-US-CA-SA", - "locationOptions": []}, {"name": "Salinas", "value": "NOAM-US-CA-SL", "locationOptions": - []}, {"name": "San Diego", "value": "NOAM-US-CA-SD", "locationOptions": []}, - {"name": "San Jose", "value": "NOAM-US-CA-SJ", "locationOptions": []}, {"name": - "Santa Barbara", "value": "NOAM-US-CA-SB", "locationOptions": []}, {"name": - "Santa Clarita", "value": "NOAM-US-CA-SC", "locationOptions": []}, {"name": - "Santa Rosa", "value": "NOAM-US-CA-SR", "locationOptions": []}, {"name": "Stockton", - "value": "NOAM-US-CA-ST", "locationOptions": []}]}]}, {"name": "CL", "value": - "CL", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Washington DC", "value": "NOAM-US-CL-DC", "locationOptions": []}]}]}, - {"name": "CO", "value": "CO", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Denver", "value": "NOAM-US-CO-DE", "locationOptions": - []}, {"name": "Grand Junction", "value": "NOAM-US-CO-GJ", "locationOptions": - []}, {"name": "Pueblo", "value": "NOAM-US-CO-PU", "locationOptions": []}]}]}, - {"name": "CT", "value": "CT", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Bridgeport", "value": "NOAM-US-CT-BR", "locationOptions": - []}]}]}, {"name": "DE", "value": "DE", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Wilmington", "value": "NOAM-US-DE-WI", - "locationOptions": []}]}]}, {"name": "FL", "value": "FL", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Cape Coral", - "value": "NOAM-US-FL-CC", "locationOptions": []}, {"name": "Daytona Beach", - "value": "NOAM-US-FL-DB", "locationOptions": []}, {"name": "Fort Lauderdale", - "value": "NOAM-US-FL-FL", "locationOptions": []}, {"name": "Gainesville", "value": - "NOAM-US-FL-GA", "locationOptions": []}, {"name": "Jacksonville", "value": "NOAM-US-FL-JA", - "locationOptions": []}, {"name": "Lakeland", "value": "NOAM-US-FL-LA", "locationOptions": - []}, {"name": "Miami", "value": "NOAM-US-FL-MI", "locationOptions": []}, {"name": - "Orlando", "value": "NOAM-US-FL-OR", "locationOptions": []}, {"name": "Port - St Lucie", "value": "NOAM-US-FL-PS", "locationOptions": []}, {"name": "Sarasota", - "value": "NOAM-US-FL-SA", "locationOptions": []}, {"name": "Tallahassee", "value": - "NOAM-US-FL-TA", "locationOptions": []}, {"name": "West Palm Beach", "value": - "NOAM-US-FL-WP", "locationOptions": []}]}]}, {"name": "GA", "value": "GA", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Albany", "value": - "NOAM-US-GA-AL", "locationOptions": []}, {"name": "Atlanta", "value": "NOAM-US-GA-AT", - "locationOptions": []}, {"name": "Augusta", "value": "NOAM-US-GA-AU", "locationOptions": - []}, {"name": "Macon", "value": "NOAM-US-GA-MA", "locationOptions": []}, {"name": - "Savannah", "value": "NOAM-US-GA-SA", "locationOptions": []}]}]}, {"name": "HI", - "value": "HI", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Honolulu", "value": "NOAM-US-HI-HO", "locationOptions": - []}]}]}, {"name": "IA", "value": "IA", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Cedar Rapids", "value": "NOAM-US-IA-CR", - "locationOptions": []}, {"name": "Davenport", "value": "NOAM-US-IA-DA", "locationOptions": - []}, {"name": "Mason City", "value": "NOAM-US-IA-MC", "locationOptions": []}]}]}, - {"name": "ID", "value": "ID", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Boise", "value": "NOAM-US-ID-BO", "locationOptions": - []}]}]}, {"name": "IL", "value": "IL", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Alton", "value": "NOAM-US-IL-AL", - "locationOptions": []}, {"name": "Aurora", "value": "NOAM-US-IL-AU", "locationOptions": - []}, {"name": "Big Rock", "value": "NOAM-US-IL-BK", "locationOptions": []}, - {"name": "Champaign", "value": "NOAM-US-IL-CA", "locationOptions": []}, {"name": - "Chicago", "value": "NOAM-US-IL-CH", "locationOptions": []}, {"name": "Cicero", - "value": "NOAM-US-IL-CI", "locationOptions": []}, {"name": "Rock Island", "value": - "NOAM-US-IL-RI", "locationOptions": []}, {"name": "Waukegan", "value": "NOAM-US-IL-WK", - "locationOptions": []}]}]}, {"name": "IN", "value": "IN", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Evansville", - "value": "NOAM-US-IN-EV", "locationOptions": []}, {"name": "Fort Wayne", "value": - "NOAM-US-IN-FW", "locationOptions": []}, {"name": "Gary", "value": "NOAM-US-IN-GA", - "locationOptions": []}, {"name": "Indianapolis", "value": "NOAM-US-IN-IN", "locationOptions": - []}, {"name": "South Bend", "value": "NOAM-US-IN-SB", "locationOptions": []}]}]}, - {"name": "KS", "value": "KS", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Dodge City", "value": "NOAM-US-KS-DC", "locationOptions": - []}, {"name": "Kansas City", "value": "NOAM-US-KS-KS", "locationOptions": []}, - {"name": "Topeka", "value": "NOAM-US-KS-TO", "locationOptions": []}, {"name": - "Wichita", "value": "NOAM-US-KS-WI", "locationOptions": []}]}]}, {"name": "KY", - "value": "KY", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Ashland", "value": "NOAM-US-KY-AS", "locationOptions": - []}, {"name": "Lexington", "value": "NOAM-US-KY-LE", "locationOptions": []}, - {"name": "Louisville", "value": "NOAM-US-KY-LO", "locationOptions": []}]}]}, - {"name": "LA", "value": "LA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Baton Rouge", "value": "NOAM-US-LA-BR", "locationOptions": - []}, {"name": "Lafayette", "value": "NOAM-US-LA-LA", "locationOptions": []}, - {"name": "New Orleans", "value": "NOAM-US-LA-NO", "locationOptions": []}, {"name": - "Shreveport", "value": "NOAM-US-LA-SH", "locationOptions": []}]}]}, {"name": - "MA", "value": "MA", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Boston", "value": "NOAM-US-MA-BO", "locationOptions": - []}, {"name": "Chicopee", "value": "NOAM-US-MA-CH", "locationOptions": []}]}]}, - {"name": "MD", "value": "MD", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Baltimore", "value": "NOAM-US-MD-BA", "locationOptions": - []}]}]}, {"name": "ME", "value": "ME", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Portland", "value": "NOAM-US-ME-PO", - "locationOptions": []}]}]}, {"name": "MI", "value": "MI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Detroit", "value": - "NOAM-US-MI-DE", "locationOptions": []}, {"name": "Flint", "value": "NOAM-US-MI-FL", - "locationOptions": []}, {"name": "Grand Rapids", "value": "NOAM-US-MI-GP", "locationOptions": - []}, {"name": "Grant", "value": "NOAM-US-MI-GR", "locationOptions": []}, {"name": - "Lansing", "value": "NOAM-US-MI-LA", "locationOptions": []}, {"name": "Saginaw", - "value": "NOAM-US-MI-SA", "locationOptions": []}, {"name": "Sault Ste Marie", - "value": "NOAM-US-MI-SS", "locationOptions": []}, {"name": "Troy", "value": - "NOAM-US-MI-TR", "locationOptions": []}]}]}, {"name": "MN", "value": "MN", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Duluth", "value": - "NOAM-US-MN-DU", "locationOptions": []}, {"name": "Minneapolis", "value": "NOAM-US-MN-MI", - "locationOptions": []}]}]}, {"name": "MO", "value": "MO", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Kansas City", - "value": "NOAM-US-MO-KS", "locationOptions": []}, {"name": "Marshall", "value": - "NOAM-US-MO-MA", "locationOptions": []}, {"name": "Springfield", "value": "NOAM-US-MO-SP", - "locationOptions": []}, {"name": "St. Charles", "value": "NOAM-US-MO-SC", "locationOptions": - []}, {"name": "St. Louis", "value": "NOAM-US-MO-SL", "locationOptions": []}]}]}, - {"name": "MS", "value": "MS", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Biloxi", "value": "NOAM-US-MS-BI", "locationOptions": - []}, {"name": "Jackson", "value": "NOAM-US-MS-JA", "locationOptions": []}, {"name": - "Starkville", "value": "NOAM-US-MS-ST", "locationOptions": []}]}]}, {"name": - "MT", "value": "MT", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Billings", "value": "NOAM-US-MT-BI", "locationOptions": - []}]}]}, {"name": "NC", "value": "NC", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Charlotte", "value": "NOAM-US-NC-CH", - "locationOptions": []}, {"name": "Fayetteville", "value": "NOAM-US-NC-FA", "locationOptions": - []}, {"name": "Greensboro", "value": "NOAM-US-NC-GR", "locationOptions": []}, - {"name": "Raleigh", "value": "NOAM-US-NC-RA", "locationOptions": []}]}]}, {"name": - "NE", "value": "NE", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Kearney", "value": "NOAM-US-NE-KE", "locationOptions": - []}, {"name": "Omaha", "value": "NOAM-US-NE-OM", "locationOptions": []}]}]}, - {"name": "NJ", "value": "NJ", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Atlantic City", "value": "NOAM-US-NJ-AC", "locationOptions": - []}, {"name": "Camden", "value": "NOAM-US-NJ-CA", "locationOptions": []}, {"name": - "Elizabeth", "value": "NOAM-US-NJ-EL", "locationOptions": []}, {"name": "Jersey - City", "value": "NOAM-US-NJ-JC", "locationOptions": []}, {"name": "Newark", - "value": "NOAM-US-NJ-NE", "locationOptions": []}]}]}, {"name": "NM", "value": - "NM", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Las Cruces", "value": "NOAM-US-NM-LC", "locationOptions": []}]}]}, - {"name": "NV", "value": "NV", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Las Vegas", "value": "NOAM-US-NV-LV", "locationOptions": - []}, {"name": "Reno", "value": "NOAM-US-NV-RE", "locationOptions": []}]}]}, - {"name": "NY", "value": "NY", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Albany", "value": "NOAM-US-NY-AL", "locationOptions": - []}, {"name": "Elmira", "value": "NOAM-US-NY-EL", "locationOptions": []}, {"name": - "Kingston", "value": "NOAM-US-NY-KI", "locationOptions": []}, {"name": "New - York City", "value": "NOAM-US-NY-NY", "locationOptions": []}, {"name": "Niagara - Falls", "value": "NOAM-US-NY-NF", "locationOptions": []}, {"name": "Rochester", - "value": "NOAM-US-NY-RO", "locationOptions": []}, {"name": "Syracuse", "value": - "NOAM-US-NY-SY", "locationOptions": []}]}]}, {"name": "OH", "value": "OH", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Akron", "value": - "NOAM-US-OH-AK", "locationOptions": []}, {"name": "Cincinnati", "value": "NOAM-US-OH-CI", - "locationOptions": []}, {"name": "Cleveland", "value": "NOAM-US-OH-CL", "locationOptions": - []}, {"name": "Columbus", "value": "NOAM-US-OH-CO", "locationOptions": []}, - {"name": "Dayton", "value": "NOAM-US-OH-DA", "locationOptions": []}, {"name": - "Toledo", "value": "NOAM-US-OH-TO", "locationOptions": []}]}]}, {"name": "OK", - "value": "OK", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Lawton", "value": "NOAM-US-OK-LA", "locationOptions": - []}, {"name": "Oklahoma City", "value": "NOAM-US-OK-OC", "locationOptions": - []}, {"name": "Tulsa", "value": "NOAM-US-OK-TU", "locationOptions": []}]}]}, - {"name": "PA", "value": "PA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Erie", "value": "NOAM-US-PA-ER", "locationOptions": - []}, {"name": "Lancaster", "value": "NOAM-US-PA-LA", "locationOptions": []}, - {"name": "New Castle", "value": "NOAM-US-PA-NC", "locationOptions": []}, {"name": - "Philadelphia", "value": "NOAM-US-PA-PI", "locationOptions": []}, {"name": "Pittsburgh", - "value": "NOAM-US-PA-PT", "locationOptions": []}, {"name": "Scranton", "value": - "NOAM-US-PA-SC", "locationOptions": []}]}]}, {"name": "RI", "value": "RI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Providence", - "value": "NOAM-US-RI-PR", "locationOptions": []}]}]}, {"name": "SC", "value": - "SC", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Charleston", "value": "NOAM-US-SC-CH", "locationOptions": []}, {"name": - "Columbia", "value": "NOAM-US-SC-CO", "locationOptions": []}, {"name": "Greenville", - "value": "NOAM-US-SC-GR", "locationOptions": []}]}]}, {"name": "SD", "value": - "SD", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Sioux Falls", "value": "NOAM-US-SD-SF", "locationOptions": []}]}]}, - {"name": "TN", "value": "TN", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Chattanooga", "value": "NOAM-US-TN-CH", "locationOptions": - []}, {"name": "Clarksville", "value": "NOAM-US-TN-CL", "locationOptions": []}, - {"name": "Jackson", "value": "NOAM-US-TN-JA", "locationOptions": []}, {"name": - "Knoxville", "value": "NOAM-US-TN-KN", "locationOptions": []}, {"name": "Memphis", - "value": "NOAM-US-TN-ME", "locationOptions": []}, {"name": "Nashville", "value": - "NOAM-US-TN-NA", "locationOptions": []}]}]}, {"name": "TX", "value": "TX", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Abilene", "value": - "NOAM-US-TX-AB", "locationOptions": []}, {"name": "Austin", "value": "NOAM-US-TX-AU", - "locationOptions": []}, {"name": "Bryan", "value": "NOAM-US-TX-BR", "locationOptions": - []}, {"name": "Corpus Christi", "value": "NOAM-US-TX-CC", "locationOptions": - []}, {"name": "Dallas", "value": "NOAM-US-TX-DA", "locationOptions": []}, {"name": - "Denton", "value": "NOAM-US-TX-DE", "locationOptions": []}, {"name": "El Paso", - "value": "NOAM-US-TX-EP", "locationOptions": []}, {"name": "Fort Worth", "value": - "NOAM-US-TX-FW", "locationOptions": []}, {"name": "Galveston", "value": "NOAM-US-TX-GA", - "locationOptions": []}, {"name": "Houston", "value": "NOAM-US-TX-HO", "locationOptions": - []}, {"name": "Huntsville", "value": "NOAM-US-TX-HU", "locationOptions": []}, - {"name": "Lubbock", "value": "NOAM-US-TX-LU", "locationOptions": []}, {"name": - "Tyler", "value": "NOAM-US-TX-TY", "locationOptions": []}]}]}, {"name": "UT", - "value": "UT", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Salt Lake City", "value": "NOAM-US-UT-SL", "locationOptions": - []}, {"name": "St. George", "value": "NOAM-US-UT-SG", "locationOptions": []}]}]}, - {"name": "VA", "value": "VA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Lynchburg", "value": "NOAM-US-VA-LY", "locationOptions": - []}, {"name": "Richmond", "value": "NOAM-US-VA-RI", "locationOptions": []}, - {"name": "Virginia Beach", "value": "NOAM-US-VA-VB", "locationOptions": []}]}]}, - {"name": "VT", "value": "VT", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Bennington", "value": "NOAM-US-VT-BE", "locationOptions": - []}, {"name": "Brattleboro", "value": "NOAM-US-VT-BR", "locationOptions": []}, - {"name": "Burlington", "value": "NOAM-US-VT-BU", "locationOptions": []}, {"name": - "Middlebury", "value": "NOAM-US-VT-MB", "locationOptions": []}, {"name": "Montpelier", - "value": "NOAM-US-VT-MP", "locationOptions": []}, {"name": "Newport", "value": - "NOAM-US-VT-NE", "locationOptions": []}]}]}, {"name": "WI", "value": "WI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Green Bay", - "value": "NOAM-US-WI-GB", "locationOptions": []}, {"name": "Kenosha", "value": - "NOAM-US-WI-KE", "locationOptions": []}, {"name": "Madison", "value": "NOAM-US-WI-MA", - "locationOptions": []}, {"name": "Milwaukee", "value": "NOAM-US-WI-MI", "locationOptions": - []}]}]}, {"name": "WV", "value": "WV", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Charleston", "value": "NOAM-US-WV-CH", - "locationOptions": []}]}]}, {"name": "WY", "value": "WY", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Laramie", "value": - "NOAM-US-WY-LA", "locationOptions": []}]}]}]}}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:20 GMT - ms-cv: - - dFVVFMtfcEKwq/v6c+upYg.0 - transfer-encoding: - - chunked - x-processing-time: - - 634ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml deleted file mode 100644 index dcc2f789fdd5..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml +++ /dev/null @@ -1,37 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:21 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/release_id?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-09-28T20:09:36.2701214+00:00", - "status": "Failed", "errorMessage": "All numbers in Failed state after BVD call", - "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:20 GMT - ms-cv: - - iHfbGOpIvUmr6FaCORS7IA.0 - transfer-encoding: - - chunked - x-processing-time: - - 189ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_reservation_by_id.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_reservation_by_id.yaml deleted file mode 100644 index 79ac4a5380ed..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_get_reservation_by_id.yaml +++ /dev/null @@ -1,39 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:21 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": - "2020-10-02T21:39:32.6878583+00:00", "description": "mydescription", "phonePlanIds": - "sanitized", "areaCode": "area_code_for_reservation", "quantity": 1, "locationOptions": - [], "status": "Success", "phoneNumbers": "sanitized", "reservationExpiryDate": - "2020-10-02T21:55:47.9734151+00:00"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:20 GMT - ms-cv: - - GEcLTOZhcE+beY8tntswXQ.0 - transfer-encoding: - - chunked - x-processing-time: - - 273ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers.yaml new file mode 100644 index 000000000000..949938277bd2 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:20:00 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07 + response: + body: + string: '{"phoneNumbers": [{"id": "16194895581", "phoneNumber": "sanitized", + "countryCode": "US", "phoneNumberType": "Geographic", "capabilities": {"calling": + "outbound", "sms": "none"}, "assignmentType": "Person", "purchaseDate": "2021-01-13T20:01:52.0795301+00:00", + "cost": {"amount": 1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "16194895593", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "Geographic", "capabilities": {"calling": "outbound", "sms": "none"}, "assignmentType": + "Person", "purchaseDate": "2021-01-13T20:57:24.5482566+00:00", "cost": {"amount": + 1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332143261", + "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": + "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": + "18443281555", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2020-11-12T21:53:12.2088187+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18445492606", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-03-04T19:24:10.3004481+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:20:04 GMT + ms-cv: + - PcsdnL23aEGt6Y89OREU2w.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 3504ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers_from_managed_identity.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers_from_managed_identity.yaml new file mode 100644 index 000000000000..4c5dc58319b5 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_acquired_phone_numbers_from_managed_identity.yaml @@ -0,0 +1,67 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07 + response: + body: + string: '{"phoneNumbers": [{"id": "18332272412", "phoneNumber": "sanitized", + "countryCode": "US", "phoneNumberType": "TollFree", "capabilities": {"calling": + "inbound", "sms": "inbound+outbound"}, "assignmentType": "Application", "purchaseDate": + "2021-02-09T23:00:10.4372681+00:00", "cost": {"amount": 2.0, "currencyCode": + "USD", "billingFrequency": "Monthly"}}, {"id": "18332272430", "phoneNumber": + "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": "Application", + "purchaseDate": "2021-02-09T22:58:41.2504122+00:00", "cost": {"amount": 2.0, + "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332272445", + "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": + "Application", "purchaseDate": "2021-02-09T23:03:57.6969271+00:00", "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": + "18332321209", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T17:51:13.4876763+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18332321221", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T17:52:41.818335+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18332321226", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T18:01:46.4199999+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18335260208", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2000-01-01T00:00:00+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18336369501", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound+outbound", "sms": "none"}, + "assignmentType": "Application", "purchaseDate": "2020-09-18T15:03:19.5370985+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 19:23:21 GMT + ms-cv: + - 71j4bfMWu0emybxhaM3JNA.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 5338ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml deleted file mode 100644 index cafe58c71c37..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml +++ /dev/null @@ -1,35 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:21 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phoneNumbers": "sanitized", "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:21 GMT - ms-cv: - - GdjTF54N3EGXupN74+JPoA.0 - transfer-encoding: - - chunked - x-processing-time: - - 381ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers_from_managed_identity.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers_from_managed_identity.yaml deleted file mode 100644 index fbfeb1fcc4de..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_phone_numbers_from_managed_identity.yaml +++ /dev/null @@ -1,34 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: - string: '{"phoneNumbers": "sanitized", "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Thu, 28 Jan 2021 18:48:48 GMT - ms-cv: - - /rMw3sZH40i74G71li+lDA.0 - request-context: - - appId= - transfer-encoding: - - chunked - x-processing-time: - - 1124ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_releases.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_releases.yaml deleted file mode 100644 index 3758a111fc3f..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_releases.yaml +++ /dev/null @@ -1,35 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:22 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases?skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"entities": "sanitized", "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:21 GMT - ms-cv: - - jlH34pUZ8EmaRUyZ8PdkUA.0 - transfer-encoding: - - chunked - x-processing-time: - - 284ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml deleted file mode 100644 index 21acc8e670dd..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml +++ /dev/null @@ -1,36 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:22 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"countries": [{"localizedName": "Canada", "countryCode": "CA"}, {"localizedName": - "United States", "countryCode": "US"}], "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:22 GMT - ms-cv: - - S3uepNKcDU+QjHoOeHSwvw.0 - transfer-encoding: - - chunked - x-processing-time: - - 470ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml deleted file mode 100644 index 7c3a63e7043e..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml +++ /dev/null @@ -1,35 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:23 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups?locale=en-US&includeRateInformation=false&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phonePlanGroups": "sanitized", "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:22 GMT - ms-cv: - - GoJpZDxc60iIeEWJCxLbwQ.0 - transfer-encoding: - - chunked - x-processing-time: - - 275ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml deleted file mode 100644 index e48e9bfb60e4..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml +++ /dev/null @@ -1,35 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:23 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/phone_plan_group_id/phoneplans?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phonePlans": "sanitized", "nextLink": null}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:23 GMT - ms-cv: - - PZtnMx1DpEyQdC4vCh0ghA.0 - transfer-encoding: - - chunked - x-processing-time: - - 240ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_phone_numbers.yaml new file mode 100644 index 000000000000..bc4181a1e29c --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_phone_numbers.yaml @@ -0,0 +1,260 @@ +interactions: +- request: + body: '{"phoneNumberType": "tollFree", "assignmentType": "application", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '131' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:37:27 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Location,Operation-Location,operation-id,search-id + content-length: + - '0' + date: + - Fri, 05 Mar 2021 22:37:30 GMT + ms-cv: + - VhMuFqxihkaysW9imFiPuw.0 + operation-id: + - search_ffd97d84-b129-42bc-a61c-5017ad455ca9 + operation-location: + - /phoneNumbers/operations/search_ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07 + request-context: + - appId= + search-id: + - ffd97d84-b129-42bc-a61c-5017ad455ca9 + x-processing-time: + - 3134ms + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:38:00 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/search_ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": "/availablePhoneNumbers/searchResults/ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07", + "createdDateTime": "2021-03-05T22:37:30.7635903+00:00", "id": "sanitized", + "operationType": "Search", "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + access-control-expose-headers: + - Location + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:38:01 GMT + ms-cv: + - T3yVAofuCEuelpDd35xMKw.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 285ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:38:01 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/searchResults/ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07 + response: + body: + string: '{"searchId": "ffd97d84-b129-42bc-a61c-5017ad455ca9", "phoneNumbers": + ["sanitized"], "phoneNumberType": "TollFree", "assignmentType": "Application", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}, "searchExpiresBy": + "2021-03-05T22:53:36.8689765+00:00"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:38:02 GMT + ms-cv: + - jL4EmsUh2kOE79pfuKfEOg.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 1041ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: '{"searchId": "ffd97d84-b129-42bc-a61c-5017ad455ca9"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '52' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:38:02 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/:purchase?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Operation-Location,operation-id,purchase-id + content-length: + - '0' + date: + - Fri, 05 Mar 2021 22:38:04 GMT + ms-cv: + - YScv4qTh00iygWp6FH6vVQ.0 + operation-id: + - purchase_ffd97d84-b129-42bc-a61c-5017ad455ca9 + operation-location: + - /phoneNumbers/operations/purchase_ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07 + purchase-id: + - ffd97d84-b129-42bc-a61c-5017ad455ca9 + request-context: + - appId= + x-processing-time: + - 1831ms + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:38:34 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/purchase_ffd97d84-b129-42bc-a61c-5017ad455ca9?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": null, "createdDateTime": + "2021-03-05T22:37:30.7635903+00:00", "id": "sanitized", "operationType": "Purchase", + "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:38:34 GMT + ms-cv: + - XBQActeVX0OyNZznJoJlAA.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 427ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Fri, 05 Mar 2021 22:38:34 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: DELETE + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Operation-Location,operation-id,release-id + content-length: + - '0' + date: + - Fri, 05 Mar 2021 22:38:36 GMT + ms-cv: + - l3EH+DWVGU+VZvw9SFZx8g.0 + operation-id: + - release_1e3b87e0-9991-41d8-ade7-cf7f26e7c00f + operation-location: + - /phoneNumbers/operations/release_1e3b87e0-9991-41d8-ade7-cf7f26e7c00f?api-version=2021-03-07 + release-id: + - 1e3b87e0-9991-41d8-ade7-cf7f26e7c00f + request-context: + - appId= + x-processing-time: + - 1331ms + status: + code: 202 + message: Accepted +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_reservation.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_reservation.yaml deleted file mode 100644 index 35f93df0f022..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_purchase_reservation.yaml +++ /dev/null @@ -1,73 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Mon, 23 Nov 2020 22:11:24 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id/purchase?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 23 Nov 2020 22:11:23 GMT - ms-cv: - - fPAQ8fmvQU6WIzTu7zXQfw.0 - x-processing-time: - - 308ms - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:24 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": - "2020-10-02T21:39:32.6878583+00:00", "description": "mydescription", "phonePlanIds": - "sanitized", "areaCode": "area_code_for_reservation", "quantity": 1, "locationOptions": - [], "status": "Success", "phoneNumbers": "sanitized", "reservationExpiryDate": - "2020-10-02T21:55:47.9734151+00:00"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:24 GMT - ms-cv: - - SjlnGOq18E2MQ7uNxBB0fQ.0 - transfer-encoding: - - chunked - x-processing-time: - - 263ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml deleted file mode 100644 index 18fa6791abfd..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml +++ /dev/null @@ -1,143 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumbers": ["+1area_code_for_reservation7840394"]}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '34' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:25 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:25 GMT - ms-cv: - - BgfaXNx4rkexq6yjjBA3Qw.0 - transfer-encoding: - - chunked - x-processing-time: - - 602ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:25 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/d9c3f4a8-3352-45f0-ad74-52b04698d78d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:11:25.2859582+00:00", - "status": "Pending", "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:25 GMT - ms-cv: - - qvL3hMhQlUmS92HYE/uBFQ.0 - transfer-encoding: - - chunked - x-processing-time: - - 179ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:26 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/d9c3f4a8-3352-45f0-ad74-52b04698d78d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:11:25.2859582+00:00", - "status": "Pending", "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:25 GMT - ms-cv: - - FRleW4iP7Ue74EGn6NV4lw.0 - transfer-encoding: - - chunked - x-processing-time: - - 178ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:31 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/d9c3f4a8-3352-45f0-ad74-52b04698d78d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:11:25.2859582+00:00", - "status": "Failed", "errorMessage": "Unknown exception in BeginReleaseQueueProcessor - : Cannot Process Order since phone number(s) do not belong to tenant:ec53533e-7d3b-4ad0-bf10-7222b049eb8e", - "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:31 GMT - ms-cv: - - IHoEJYxmyUqqT8V6isY9cQ.0 - transfer-encoding: - - chunked - x-processing-time: - - 181ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_reserve_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_reserve_phone_numbers.yaml deleted file mode 100644 index c2ec6d187f53..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_reserve_phone_numbers.yaml +++ /dev/null @@ -1,150 +0,0 @@ -interactions: -- request: - body: 'b''b\''{"displayName": "testreservation20200014", "description": "testreservation20200014", - "phonePlanIds": ["phone_plan_id"], "areaCode": "area_code_for_reservation", - "quantity": 1}\''''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '176' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:31 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:31 GMT - ms-cv: - - 3zxwvfI1D0WBkknksFDVVg.0 - transfer-encoding: - - chunked - x-processing-time: - - 1082ms - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:32 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/ae359f26-6a39-4d83-a4ea-612d6e851f15?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:11:32.1671461+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:32 GMT - ms-cv: - - N6cJ9bQtd0mIRCtv2YiCQg.0 - transfer-encoding: - - chunked - x-processing-time: - - 328ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:33 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/ae359f26-6a39-4d83-a4ea-612d6e851f15?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:11:32.1671461+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:32 GMT - ms-cv: - - v+24/t7ilUqlQQS8d9BDNA.0 - transfer-encoding: - - chunked - x-processing-time: - - 257ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Date: - - Mon, 23 Nov 2020 22:11:38 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/ae359f26-6a39-4d83-a4ea-612d6e851f15?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:11:32.1671461+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Error", "phoneNumbers": "sanitized", "errorCode": - 1000}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:37 GMT - ms-cv: - - En3nEYmrU0i9swm5SyH7qg.0 - transfer-encoding: - - chunked - x-processing-time: - - 261ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_search_available_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_search_available_phone_numbers.yaml new file mode 100644 index 000000000000..acccd805e6d9 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_search_available_phone_numbers.yaml @@ -0,0 +1,131 @@ +interactions: +- request: + body: '{"phoneNumberType": "tollFree", "assignmentType": "application", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '131' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:20:06 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Location,Operation-Location,operation-id,search-id + content-length: + - '0' + date: + - Fri, 05 Mar 2021 22:20:10 GMT + ms-cv: + - lzRA3VrAnEC+gMwWY5/d5w.0 + operation-id: + - search_c7deaed5-e41e-4fe5-91a6-a21e7210cbe4 + operation-location: + - /phoneNumbers/operations/search_c7deaed5-e41e-4fe5-91a6-a21e7210cbe4?api-version=2021-03-07 + request-context: + - appId= + search-id: + - c7deaed5-e41e-4fe5-91a6-a21e7210cbe4 + x-processing-time: + - 4133ms + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:20:41 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/search_c7deaed5-e41e-4fe5-91a6-a21e7210cbe4?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": "/availablePhoneNumbers/searchResults/c7deaed5-e41e-4fe5-91a6-a21e7210cbe4?api-version=2021-03-07", + "createdDateTime": "2021-03-05T22:20:11.001373+00:00", "id": "sanitized", + "operationType": "Search", "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + access-control-expose-headers: + - Location + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:20:41 GMT + ms-cv: + - AbkHLPOGRUirq1KzJ53Qlw.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 670ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:20:41 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/searchResults/c7deaed5-e41e-4fe5-91a6-a21e7210cbe4?api-version=2021-03-07 + response: + body: + string: '{"searchId": "c7deaed5-e41e-4fe5-91a6-a21e7210cbe4", "phoneNumbers": + ["sanitized"], "phoneNumberType": "TollFree", "assignmentType": "Application", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}, "searchExpiresBy": + "2021-03-05T22:36:18.4979540+00:00"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:20:42 GMT + ms-cv: + - Rn4DVw7s5UOVfiCFfiXCOQ.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 997ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_capabilities.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_capabilities.yaml deleted file mode 100644 index d975594f14dd..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_capabilities.yaml +++ /dev/null @@ -1,40 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumberCapabilitiesUpdate": {"+1area_code_for_reservation4501240": - {"add": []}}}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '64' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:11:38 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities?api-version=2020-07-20-preview1 - response: - body: '{"capabilitiesUpdateId": "sanitized"}' - headers: - content-type: - - application/json; charset=utf-8 - date: - - Mon, 23 Nov 2020 22:11:39 GMT - ms-cv: - - duZmwAa0FEKqQcP3eY0Z1w.0 - transfer-encoding: - - chunked - x-processing-time: - - 860ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_phone_number_capabilities.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_phone_number_capabilities.yaml new file mode 100644 index 000000000000..47a2ab186c0a --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client.test_update_phone_number_capabilities.yaml @@ -0,0 +1,132 @@ +interactions: +- request: + body: '{"calling": "inbound", "sms": "inbound+outbound"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '49' + Content-Type: + - application/merge-patch+json + Date: + - Fri, 05 Mar 2021 22:20:43 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: PATCH + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized/capabilities?api-version=2021-03-07 + response: + body: + string: '{"capabilitiesUpdateId": "a8589969-1d09-4ad3-9b5a-39ce067ea535"}' + headers: + access-control-expose-headers: + - Operation-Location,Location,operation-id,capabilities-id + capabilities-id: + - a8589969-1d09-4ad3-9b5a-39ce067ea535 + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:20:44 GMT + ms-cv: + - KjGZkSHB5kCrsxscH9ibgQ.0 + operation-id: + - capabilities_a8589969-1d09-4ad3-9b5a-39ce067ea535 + operation-location: + - /phoneNumbers/operations/capabilities_a8589969-1d09-4ad3-9b5a-39ce067ea535?api-version=2021-03-07 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 987ms + status: + code: 202 + message: Accepted + url: sanitized +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:21:14 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/capabilities_a8589969-1d09-4ad3-9b5a-39ce067ea535?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": "/phoneNumbers/+18332143261?api-version=2021-03-07", + "createdDateTime": "2021-03-05T22:20:44.5342481+00:00", "id": "sanitized", + "operationType": "UpdatePhoneNumberCapabilities", "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + access-control-expose-headers: + - Location + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:21:14 GMT + ms-cv: + - I5gz/NLH7kWVu9cfp44HpQ.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 254ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Fri, 05 Mar 2021 22:21:14 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/+18332143261?api-version=2021-03-07 + response: + body: + string: '{"id": "sanitized", "phoneNumber": "sanitized", "countryCode": "US", + "phoneNumberType": "TollFree", "capabilities": {"calling": "inbound", "sms": + "inbound+outbound"}, "assignmentType": "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 05 Mar 2021 22:21:15 GMT + ms-cv: + - VbgvUURuDkyiQ4llLoXMPA.0 + request-context: + - appId= + transfer-encoding: + - chunked + x-processing-time: + - 1201ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_cancel_reservation.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_cancel_reservation.yaml deleted file mode 100644 index 93db36adc237..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_cancel_reservation.yaml +++ /dev/null @@ -1,25 +0,0 @@ -interactions: -- request: - body: '' - headers: - Date: - - Mon, 23 Nov 2020 22:14:46 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id_to_cancel/cancel?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: '0' - date: Mon, 23 Nov 2020 22:14:46 GMT - ms-cv: HI79prVtXkW5jqOrJGJWRw.0 - x-processing-time: 521ms - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized/cancel?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_configure_number.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_configure_number.yaml deleted file mode 100644 index 7a2dc2423a82..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_configure_number.yaml +++ /dev/null @@ -1,30 +0,0 @@ -interactions: -- request: - body: 'b''{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": - "ApplicationId"}, "phoneNumber": "+1area_code_for_reservation4501240"}''' - headers: - Content-Length: - - '126' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:47 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: PATCH - uri: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration/configure?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: '0' - date: Mon, 23 Nov 2020 22:14:48 GMT - ms-cv: gkH/fRlDTkKsBLC5WTNKFg.0 - x-processing-time: 953ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration/configure?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml deleted file mode 100644 index 4fe7e57101c2..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml +++ /dev/null @@ -1,32 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Content-Length: - - '2' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:48 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/areacodes?locationType=NotRequired&phonePlanId=phone_plan_id_area_codes&api-version=2020-07-20-preview1 - response: - body: '{"primaryAreaCodes": ["area_code_for_reservation"], "secondaryAreaCodes": - [], "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:48 GMT - ms-cv: t5ZSuiiwCEe0L7XH6nksWA.0 - transfer-encoding: chunked - x-processing-time: 347ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/areacodes?locationType=NotRequired&phonePlanId=sanitized&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml deleted file mode 100644 index 9cea23a757ed..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml +++ /dev/null @@ -1,28 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:49 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities/capabilities_id?api-version=2020-07-20-preview1 - response: - body: '{"capabilitiesUpdateId": "sanitized", "createdAt": "2020-09-28T17:49:13.2696607+00:00", - "capabilitiesUpdateStatus": "Complete", "phoneNumberCapabilitiesUpdates": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:53 GMT - ms-cv: 9Nc5gaDqzkWSizDfDt3f3A.0 - transfer-encoding: chunked - x-processing-time: 607ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml deleted file mode 100644 index 679d691bfb23..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml +++ /dev/null @@ -1,32 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumber": "+1area_code_for_reservation4501240"}''' - headers: - Accept: - - application/json - Content-Length: - - '31' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:53 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 - response: - body: '{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": - "ApplicationId", "azurePstnTargetId": "85c9239f-0b81-47e6-b25e-95ccaf48581f"}}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:54 GMT - ms-cv: FuDCzDwaikSDMeCKWEIxeQ.0 - transfer-encoding: chunked - x-processing-time: 343ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_number.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_number.yaml new file mode 100644 index 000000000000..dbc6f9dcbe97 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_number.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Fri, 05 Mar 2021 22:21:16 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07 + response: + body: + string: '{"id": "sanitized", "phoneNumber": "sanitized", "countryCode": "US", + "phoneNumberType": "TollFree", "capabilities": {"calling": "inbound", "sms": + "inbound+outbound"}, "assignmentType": "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:21:18 GMT + ms-cv: jkDUEFxq6E2BFPuvbj9mvw.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 1670ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml deleted file mode 100644 index de690eaa2551..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml +++ /dev/null @@ -1,242 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:54 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/phone_plan_group_id/phoneplans/phone_plan_id/locationoptions?locale=en-US&api-version=2020-07-20-preview1 - response: - body: '{"locationOptions": {"labelId": "state", "labelName": "State", "options": - [{"name": "AK", "value": "AK", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Anchorage", "value": "NOAM-US-AK-AN", "locationOptions": - []}]}]}, {"name": "AL", "value": "AL", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Birmingham", "value": "NOAM-US-AL-BI", - "locationOptions": []}, {"name": "Huntsville", "value": "NOAM-US-AL-HN", "locationOptions": - []}, {"name": "Mobile", "value": "NOAM-US-AL-MO", "locationOptions": []}, {"name": - "Montgomery", "value": "NOAM-US-AL-MN", "locationOptions": []}]}]}, {"name": - "AR", "value": "AR", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Fort Smith", "value": "NOAM-US-AR-FS", "locationOptions": - []}, {"name": "Jonesboro", "value": "NOAM-US-AR-JO", "locationOptions": []}, - {"name": "Little Rock", "value": "NOAM-US-AR-LR", "locationOptions": []}]}]}, - {"name": "AZ", "value": "AZ", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Phoenix", "value": "NOAM-US-AZ-PH", "locationOptions": - []}]}]}, {"name": "CA", "value": "CA", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Anaheim", "value": "NOAM-US-CA-AN", - "locationOptions": []}, {"name": "Burbank", "value": "NOAM-US-CA-BU", "locationOptions": - []}, {"name": "Fresno", "value": "NOAM-US-CA-FR", "locationOptions": []}, {"name": - "Irvine", "value": "NOAM-US-CA-IR", "locationOptions": []}, {"name": "Los Angeles", - "value": "NOAM-US-CA-LA", "locationOptions": []}, {"name": "Riverside", "value": - "NOAM-US-CA-RI", "locationOptions": []}, {"name": "Sacramento", "value": "NOAM-US-CA-SA", - "locationOptions": []}, {"name": "Salinas", "value": "NOAM-US-CA-SL", "locationOptions": - []}, {"name": "San Diego", "value": "NOAM-US-CA-SD", "locationOptions": []}, - {"name": "San Jose", "value": "NOAM-US-CA-SJ", "locationOptions": []}, {"name": - "Santa Barbara", "value": "NOAM-US-CA-SB", "locationOptions": []}, {"name": - "Santa Clarita", "value": "NOAM-US-CA-SC", "locationOptions": []}, {"name": - "Santa Rosa", "value": "NOAM-US-CA-SR", "locationOptions": []}, {"name": "Stockton", - "value": "NOAM-US-CA-ST", "locationOptions": []}]}]}, {"name": "CL", "value": - "CL", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Washington DC", "value": "NOAM-US-CL-DC", "locationOptions": []}]}]}, - {"name": "CO", "value": "CO", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Denver", "value": "NOAM-US-CO-DE", "locationOptions": - []}, {"name": "Grand Junction", "value": "NOAM-US-CO-GJ", "locationOptions": - []}, {"name": "Pueblo", "value": "NOAM-US-CO-PU", "locationOptions": []}]}]}, - {"name": "CT", "value": "CT", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Bridgeport", "value": "NOAM-US-CT-BR", "locationOptions": - []}]}]}, {"name": "DE", "value": "DE", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Wilmington", "value": "NOAM-US-DE-WI", - "locationOptions": []}]}]}, {"name": "FL", "value": "FL", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Cape Coral", - "value": "NOAM-US-FL-CC", "locationOptions": []}, {"name": "Daytona Beach", - "value": "NOAM-US-FL-DB", "locationOptions": []}, {"name": "Fort Lauderdale", - "value": "NOAM-US-FL-FL", "locationOptions": []}, {"name": "Gainesville", "value": - "NOAM-US-FL-GA", "locationOptions": []}, {"name": "Jacksonville", "value": "NOAM-US-FL-JA", - "locationOptions": []}, {"name": "Lakeland", "value": "NOAM-US-FL-LA", "locationOptions": - []}, {"name": "Miami", "value": "NOAM-US-FL-MI", "locationOptions": []}, {"name": - "Orlando", "value": "NOAM-US-FL-OR", "locationOptions": []}, {"name": "Port - St Lucie", "value": "NOAM-US-FL-PS", "locationOptions": []}, {"name": "Sarasota", - "value": "NOAM-US-FL-SA", "locationOptions": []}, {"name": "Tallahassee", "value": - "NOAM-US-FL-TA", "locationOptions": []}, {"name": "West Palm Beach", "value": - "NOAM-US-FL-WP", "locationOptions": []}]}]}, {"name": "GA", "value": "GA", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Albany", "value": - "NOAM-US-GA-AL", "locationOptions": []}, {"name": "Atlanta", "value": "NOAM-US-GA-AT", - "locationOptions": []}, {"name": "Augusta", "value": "NOAM-US-GA-AU", "locationOptions": - []}, {"name": "Macon", "value": "NOAM-US-GA-MA", "locationOptions": []}, {"name": - "Savannah", "value": "NOAM-US-GA-SA", "locationOptions": []}]}]}, {"name": "HI", - "value": "HI", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Honolulu", "value": "NOAM-US-HI-HO", "locationOptions": - []}]}]}, {"name": "IA", "value": "IA", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Cedar Rapids", "value": "NOAM-US-IA-CR", - "locationOptions": []}, {"name": "Davenport", "value": "NOAM-US-IA-DA", "locationOptions": - []}, {"name": "Mason City", "value": "NOAM-US-IA-MC", "locationOptions": []}]}]}, - {"name": "ID", "value": "ID", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Boise", "value": "NOAM-US-ID-BO", "locationOptions": - []}]}]}, {"name": "IL", "value": "IL", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Alton", "value": "NOAM-US-IL-AL", - "locationOptions": []}, {"name": "Aurora", "value": "NOAM-US-IL-AU", "locationOptions": - []}, {"name": "Big Rock", "value": "NOAM-US-IL-BK", "locationOptions": []}, - {"name": "Champaign", "value": "NOAM-US-IL-CA", "locationOptions": []}, {"name": - "Chicago", "value": "NOAM-US-IL-CH", "locationOptions": []}, {"name": "Cicero", - "value": "NOAM-US-IL-CI", "locationOptions": []}, {"name": "Rock Island", "value": - "NOAM-US-IL-RI", "locationOptions": []}, {"name": "Waukegan", "value": "NOAM-US-IL-WK", - "locationOptions": []}]}]}, {"name": "IN", "value": "IN", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Evansville", - "value": "NOAM-US-IN-EV", "locationOptions": []}, {"name": "Fort Wayne", "value": - "NOAM-US-IN-FW", "locationOptions": []}, {"name": "Gary", "value": "NOAM-US-IN-GA", - "locationOptions": []}, {"name": "Indianapolis", "value": "NOAM-US-IN-IN", "locationOptions": - []}, {"name": "South Bend", "value": "NOAM-US-IN-SB", "locationOptions": []}]}]}, - {"name": "KS", "value": "KS", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Dodge City", "value": "NOAM-US-KS-DC", "locationOptions": - []}, {"name": "Kansas City", "value": "NOAM-US-KS-KS", "locationOptions": []}, - {"name": "Topeka", "value": "NOAM-US-KS-TO", "locationOptions": []}, {"name": - "Wichita", "value": "NOAM-US-KS-WI", "locationOptions": []}]}]}, {"name": "KY", - "value": "KY", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Ashland", "value": "NOAM-US-KY-AS", "locationOptions": - []}, {"name": "Lexington", "value": "NOAM-US-KY-LE", "locationOptions": []}, - {"name": "Louisville", "value": "NOAM-US-KY-LO", "locationOptions": []}]}]}, - {"name": "LA", "value": "LA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Baton Rouge", "value": "NOAM-US-LA-BR", "locationOptions": - []}, {"name": "Lafayette", "value": "NOAM-US-LA-LA", "locationOptions": []}, - {"name": "New Orleans", "value": "NOAM-US-LA-NO", "locationOptions": []}, {"name": - "Shreveport", "value": "NOAM-US-LA-SH", "locationOptions": []}]}]}, {"name": - "MA", "value": "MA", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Boston", "value": "NOAM-US-MA-BO", "locationOptions": - []}, {"name": "Chicopee", "value": "NOAM-US-MA-CH", "locationOptions": []}]}]}, - {"name": "MD", "value": "MD", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Baltimore", "value": "NOAM-US-MD-BA", "locationOptions": - []}]}]}, {"name": "ME", "value": "ME", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Portland", "value": "NOAM-US-ME-PO", - "locationOptions": []}]}]}, {"name": "MI", "value": "MI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Detroit", "value": - "NOAM-US-MI-DE", "locationOptions": []}, {"name": "Flint", "value": "NOAM-US-MI-FL", - "locationOptions": []}, {"name": "Grand Rapids", "value": "NOAM-US-MI-GP", "locationOptions": - []}, {"name": "Grant", "value": "NOAM-US-MI-GR", "locationOptions": []}, {"name": - "Lansing", "value": "NOAM-US-MI-LA", "locationOptions": []}, {"name": "Saginaw", - "value": "NOAM-US-MI-SA", "locationOptions": []}, {"name": "Sault Ste Marie", - "value": "NOAM-US-MI-SS", "locationOptions": []}, {"name": "Troy", "value": - "NOAM-US-MI-TR", "locationOptions": []}]}]}, {"name": "MN", "value": "MN", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Duluth", "value": - "NOAM-US-MN-DU", "locationOptions": []}, {"name": "Minneapolis", "value": "NOAM-US-MN-MI", - "locationOptions": []}]}]}, {"name": "MO", "value": "MO", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Kansas City", - "value": "NOAM-US-MO-KS", "locationOptions": []}, {"name": "Marshall", "value": - "NOAM-US-MO-MA", "locationOptions": []}, {"name": "Springfield", "value": "NOAM-US-MO-SP", - "locationOptions": []}, {"name": "St. Charles", "value": "NOAM-US-MO-SC", "locationOptions": - []}, {"name": "St. Louis", "value": "NOAM-US-MO-SL", "locationOptions": []}]}]}, - {"name": "MS", "value": "MS", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Biloxi", "value": "NOAM-US-MS-BI", "locationOptions": - []}, {"name": "Jackson", "value": "NOAM-US-MS-JA", "locationOptions": []}, {"name": - "Starkville", "value": "NOAM-US-MS-ST", "locationOptions": []}]}]}, {"name": - "MT", "value": "MT", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Billings", "value": "NOAM-US-MT-BI", "locationOptions": - []}]}]}, {"name": "NC", "value": "NC", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Charlotte", "value": "NOAM-US-NC-CH", - "locationOptions": []}, {"name": "Fayetteville", "value": "NOAM-US-NC-FA", "locationOptions": - []}, {"name": "Greensboro", "value": "NOAM-US-NC-GR", "locationOptions": []}, - {"name": "Raleigh", "value": "NOAM-US-NC-RA", "locationOptions": []}]}]}, {"name": - "NE", "value": "NE", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Kearney", "value": "NOAM-US-NE-KE", "locationOptions": - []}, {"name": "Omaha", "value": "NOAM-US-NE-OM", "locationOptions": []}]}]}, - {"name": "NJ", "value": "NJ", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Atlantic City", "value": "NOAM-US-NJ-AC", "locationOptions": - []}, {"name": "Camden", "value": "NOAM-US-NJ-CA", "locationOptions": []}, {"name": - "Elizabeth", "value": "NOAM-US-NJ-EL", "locationOptions": []}, {"name": "Jersey - City", "value": "NOAM-US-NJ-JC", "locationOptions": []}, {"name": "Newark", - "value": "NOAM-US-NJ-NE", "locationOptions": []}]}]}, {"name": "NM", "value": - "NM", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Las Cruces", "value": "NOAM-US-NM-LC", "locationOptions": []}]}]}, - {"name": "NV", "value": "NV", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Las Vegas", "value": "NOAM-US-NV-LV", "locationOptions": - []}, {"name": "Reno", "value": "NOAM-US-NV-RE", "locationOptions": []}]}]}, - {"name": "NY", "value": "NY", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Albany", "value": "NOAM-US-NY-AL", "locationOptions": - []}, {"name": "Elmira", "value": "NOAM-US-NY-EL", "locationOptions": []}, {"name": - "Kingston", "value": "NOAM-US-NY-KI", "locationOptions": []}, {"name": "New - York City", "value": "NOAM-US-NY-NY", "locationOptions": []}, {"name": "Niagara - Falls", "value": "NOAM-US-NY-NF", "locationOptions": []}, {"name": "Rochester", - "value": "NOAM-US-NY-RO", "locationOptions": []}, {"name": "Syracuse", "value": - "NOAM-US-NY-SY", "locationOptions": []}]}]}, {"name": "OH", "value": "OH", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Akron", "value": - "NOAM-US-OH-AK", "locationOptions": []}, {"name": "Cincinnati", "value": "NOAM-US-OH-CI", - "locationOptions": []}, {"name": "Cleveland", "value": "NOAM-US-OH-CL", "locationOptions": - []}, {"name": "Columbus", "value": "NOAM-US-OH-CO", "locationOptions": []}, - {"name": "Dayton", "value": "NOAM-US-OH-DA", "locationOptions": []}, {"name": - "Toledo", "value": "NOAM-US-OH-TO", "locationOptions": []}]}]}, {"name": "OK", - "value": "OK", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Lawton", "value": "NOAM-US-OK-LA", "locationOptions": - []}, {"name": "Oklahoma City", "value": "NOAM-US-OK-OC", "locationOptions": - []}, {"name": "Tulsa", "value": "NOAM-US-OK-TU", "locationOptions": []}]}]}, - {"name": "PA", "value": "PA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Erie", "value": "NOAM-US-PA-ER", "locationOptions": - []}, {"name": "Lancaster", "value": "NOAM-US-PA-LA", "locationOptions": []}, - {"name": "New Castle", "value": "NOAM-US-PA-NC", "locationOptions": []}, {"name": - "Philadelphia", "value": "NOAM-US-PA-PI", "locationOptions": []}, {"name": "Pittsburgh", - "value": "NOAM-US-PA-PT", "locationOptions": []}, {"name": "Scranton", "value": - "NOAM-US-PA-SC", "locationOptions": []}]}]}, {"name": "RI", "value": "RI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Providence", - "value": "NOAM-US-RI-PR", "locationOptions": []}]}]}, {"name": "SC", "value": - "SC", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Charleston", "value": "NOAM-US-SC-CH", "locationOptions": []}, {"name": - "Columbia", "value": "NOAM-US-SC-CO", "locationOptions": []}, {"name": "Greenville", - "value": "NOAM-US-SC-GR", "locationOptions": []}]}]}, {"name": "SD", "value": - "SD", "locationOptions": [{"labelId": "city", "labelName": "City", "options": - [{"name": "Sioux Falls", "value": "NOAM-US-SD-SF", "locationOptions": []}]}]}, - {"name": "TN", "value": "TN", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Chattanooga", "value": "NOAM-US-TN-CH", "locationOptions": - []}, {"name": "Clarksville", "value": "NOAM-US-TN-CL", "locationOptions": []}, - {"name": "Jackson", "value": "NOAM-US-TN-JA", "locationOptions": []}, {"name": - "Knoxville", "value": "NOAM-US-TN-KN", "locationOptions": []}, {"name": "Memphis", - "value": "NOAM-US-TN-ME", "locationOptions": []}, {"name": "Nashville", "value": - "NOAM-US-TN-NA", "locationOptions": []}]}]}, {"name": "TX", "value": "TX", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Abilene", "value": - "NOAM-US-TX-AB", "locationOptions": []}, {"name": "Austin", "value": "NOAM-US-TX-AU", - "locationOptions": []}, {"name": "Bryan", "value": "NOAM-US-TX-BR", "locationOptions": - []}, {"name": "Corpus Christi", "value": "NOAM-US-TX-CC", "locationOptions": - []}, {"name": "Dallas", "value": "NOAM-US-TX-DA", "locationOptions": []}, {"name": - "Denton", "value": "NOAM-US-TX-DE", "locationOptions": []}, {"name": "El Paso", - "value": "NOAM-US-TX-EP", "locationOptions": []}, {"name": "Fort Worth", "value": - "NOAM-US-TX-FW", "locationOptions": []}, {"name": "Galveston", "value": "NOAM-US-TX-GA", - "locationOptions": []}, {"name": "Houston", "value": "NOAM-US-TX-HO", "locationOptions": - []}, {"name": "Huntsville", "value": "NOAM-US-TX-HU", "locationOptions": []}, - {"name": "Lubbock", "value": "NOAM-US-TX-LU", "locationOptions": []}, {"name": - "Tyler", "value": "NOAM-US-TX-TY", "locationOptions": []}]}]}, {"name": "UT", - "value": "UT", "locationOptions": [{"labelId": "city", "labelName": "City", - "options": [{"name": "Salt Lake City", "value": "NOAM-US-UT-SL", "locationOptions": - []}, {"name": "St. George", "value": "NOAM-US-UT-SG", "locationOptions": []}]}]}, - {"name": "VA", "value": "VA", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Lynchburg", "value": "NOAM-US-VA-LY", "locationOptions": - []}, {"name": "Richmond", "value": "NOAM-US-VA-RI", "locationOptions": []}, - {"name": "Virginia Beach", "value": "NOAM-US-VA-VB", "locationOptions": []}]}]}, - {"name": "VT", "value": "VT", "locationOptions": [{"labelId": "city", "labelName": - "City", "options": [{"name": "Bennington", "value": "NOAM-US-VT-BE", "locationOptions": - []}, {"name": "Brattleboro", "value": "NOAM-US-VT-BR", "locationOptions": []}, - {"name": "Burlington", "value": "NOAM-US-VT-BU", "locationOptions": []}, {"name": - "Middlebury", "value": "NOAM-US-VT-MB", "locationOptions": []}, {"name": "Montpelier", - "value": "NOAM-US-VT-MP", "locationOptions": []}, {"name": "Newport", "value": - "NOAM-US-VT-NE", "locationOptions": []}]}]}, {"name": "WI", "value": "WI", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Green Bay", - "value": "NOAM-US-WI-GB", "locationOptions": []}, {"name": "Kenosha", "value": - "NOAM-US-WI-KE", "locationOptions": []}, {"name": "Madison", "value": "NOAM-US-WI-MA", - "locationOptions": []}, {"name": "Milwaukee", "value": "NOAM-US-WI-MI", "locationOptions": - []}]}]}, {"name": "WV", "value": "WV", "locationOptions": [{"labelId": "city", - "labelName": "City", "options": [{"name": "Charleston", "value": "NOAM-US-WV-CH", - "locationOptions": []}]}]}, {"name": "WY", "value": "WY", "locationOptions": - [{"labelId": "city", "labelName": "City", "options": [{"name": "Laramie", "value": - "NOAM-US-WY-LA", "locationOptions": []}]}]}]}}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:56 GMT - ms-cv: kJvwrGRCM0e2ipPNM0gSVg.0 - transfer-encoding: chunked - x-processing-time: 371ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/sanitized/phoneplans/sanitized/locationoptions?locale=en-US&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml deleted file mode 100644 index 353177013bea..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml +++ /dev/null @@ -1,29 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:57 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/release_id?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-09-28T20:09:36.2701214+00:00", - "status": "Failed", "errorMessage": "All numbers in Failed state after BVD call", - "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:57 GMT - ms-cv: thMMTFXbZEKNJWphHbZokg.0 - transfer-encoding: chunked - x-processing-time: 469ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_reservation_by_id.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_reservation_by_id.yaml deleted file mode 100644 index f2a79cb410b8..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_get_reservation_by_id.yaml +++ /dev/null @@ -1,31 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:58 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": - "2020-10-02T21:39:32.6878583+00:00", "description": "mydescription", "phonePlanIds": - "sanitized", "areaCode": "area_code_for_reservation", "quantity": 1, "locationOptions": - [], "status": "Success", "phoneNumbers": "sanitized", "reservationExpiryDate": - "2020-10-02T21:55:47.9734151+00:00"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:57 GMT - ms-cv: BG/74cPPNUGIVKPwJs2gKw.0 - transfer-encoding: chunked - x-processing-time: 310ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers.yaml new file mode 100644 index 000000000000..3ec83d977845 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers.yaml @@ -0,0 +1,48 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Fri, 05 Mar 2021 22:21:18 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07 + response: + body: + string: '{"phoneNumbers": [{"id": "16194895581", "phoneNumber": "sanitized", + "countryCode": "US", "phoneNumberType": "Geographic", "capabilities": {"calling": + "outbound", "sms": "none"}, "assignmentType": "Person", "purchaseDate": "2021-01-13T20:01:52.0795301+00:00", + "cost": {"amount": 1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "16194895593", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "Geographic", "capabilities": {"calling": "outbound", "sms": "none"}, "assignmentType": + "Person", "purchaseDate": "2021-01-13T20:57:24.5482566+00:00", "cost": {"amount": + 1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332143261", + "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": + "Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": + "18443281555", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2020-11-12T21:53:12.2088187+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18445492606", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-03-04T19:24:10.3004481+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:21:22 GMT + ms-cv: US5P4qB/KEOB9kd4FEf70w.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 4347ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers_from_managed_identity.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers_from_managed_identity.yaml new file mode 100644 index 000000000000..67e3898a0d3a --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_acquired_phone_numbers_from_managed_identity.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07 + response: + body: + string: '{"phoneNumbers": [{"id": "18332272412", "phoneNumber": "sanitized", + "countryCode": "US", "phoneNumberType": "TollFree", "capabilities": {"calling": + "inbound", "sms": "inbound+outbound"}, "assignmentType": "Application", "purchaseDate": + "2021-02-09T23:00:10.4372681+00:00", "cost": {"amount": 2.0, "currencyCode": + "USD", "billingFrequency": "Monthly"}}, {"id": "18332272430", "phoneNumber": + "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": "Application", + "purchaseDate": "2021-02-09T22:58:41.2504122+00:00", "cost": {"amount": 2.0, + "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332272445", + "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree", + "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": + "Application", "purchaseDate": "2021-02-09T23:03:57.6969271+00:00", "cost": + {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": + "18332321209", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T17:51:13.4876763+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18332321221", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T17:52:41.818335+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18332321226", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2021-02-10T18:01:46.4199999+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18335260208", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, + "assignmentType": "Application", "purchaseDate": "2000-01-01T00:00:00+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, + {"id": "18336369501", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": + "TollFree", "capabilities": {"calling": "inbound+outbound", "sms": "none"}, + "assignmentType": "Application", "purchaseDate": "2020-09-18T15:03:19.5370985+00:00", + "cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 19:23:36 GMT + ms-cv: ShclAXnIdUmr25TTZUkiUg.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 4685ms + status: + code: 200 + message: OK + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml deleted file mode 100644 index 37e61c8e4e32..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml +++ /dev/null @@ -1,27 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:58 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phoneNumbers": "sanitized", "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:59 GMT - ms-cv: Du1G8mMBDEyacpYn33iUJg.0 - transfer-encoding: chunked - x-processing-time: 649ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers_from_managed_identity.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers_from_managed_identity.yaml deleted file mode 100644 index 4ad1a112d86c..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers_from_managed_identity.yaml +++ /dev/null @@ -1,25 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: - string: '{"phoneNumbers": "sanitized", "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Thu, 28 Jan 2021 18:49:47 GMT - ms-cv: jqpEP/JsFUKDau9Y0tMhbw.0 - request-context: appId= - transfer-encoding: chunked - x-processing-time: 765ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/phonenumbers?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml deleted file mode 100644 index d7cb62a5676a..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml +++ /dev/null @@ -1,27 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:14:59 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases?skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"entities": "sanitized", "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:59 GMT - ms-cv: 4PD9pQr43kKolsoYwM2Bgw.0 - transfer-encoding: chunked - x-processing-time: 357ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases?skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml deleted file mode 100644 index 1f2143ae8e33..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml +++ /dev/null @@ -1,28 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:00 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"countries": [{"localizedName": "Canada", "countryCode": "CA"}, {"localizedName": - "United States", "countryCode": "US"}], "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:14:59 GMT - ms-cv: 7tEvn8UWqEiFscQy1auozg.0 - transfer-encoding: chunked - x-processing-time: 488ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/countries?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml deleted file mode 100644 index d6424d373b40..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml +++ /dev/null @@ -1,27 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:00 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups?locale=en-US&includeRateInformation=false&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phonePlanGroups": "sanitized", "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:01 GMT - ms-cv: fl11HT80PkG+GKZqDsSbfQ.0 - transfer-encoding: chunked - x-processing-time: 762ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups?locale=en-US&includeRateInformation=false&skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml deleted file mode 100644 index b9bbb45f59bb..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml +++ /dev/null @@ -1,27 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:01 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/phone_plan_group_id/phoneplans?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 - response: - body: '{"phonePlans": "sanitized", "nextLink": null}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:01 GMT - ms-cv: anGjQcg2C0WcRKun92ShUw.0 - transfer-encoding: chunked - x-processing-time: 354ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/countries/US/phoneplangroups/sanitized/phoneplans?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_phone_numbers.yaml new file mode 100644 index 000000000000..3d0180913d84 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_phone_numbers.yaml @@ -0,0 +1,184 @@ +interactions: +- request: + body: '{"phoneNumberType": "tollFree", "assignmentType": "application", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}}' + headers: + Accept: + - application/json + Content-Length: + - '131' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:35:23 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: Location,Operation-Location,operation-id,search-id + content-length: '0' + date: Fri, 05 Mar 2021 22:35:27 GMT + ms-cv: gRWIpKbT+kmke+2n5126eQ.0 + operation-id: search_bb432956-3ef1-4c0f-b5d9-b6879db9815e + operation-location: /phoneNumbers/operations/search_bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07 + request-context: appId= + search-id: bb432956-3ef1-4c0f-b5d9-b6879db9815e + x-processing-time: 3810ms + status: + code: 202 + message: Accepted + url: https://sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 +- request: + body: '' + headers: + Date: + - Fri, 05 Mar 2021 22:35:57 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/search_bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": "/availablePhoneNumbers/searchResults/bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07", + "createdDateTime": "2021-03-05T22:35:27.2958238+00:00", "id": "sanitized", + "operationType": "Search", "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + access-control-expose-headers: Location + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:35:58 GMT + ms-cv: ATBr7EqjekGNk1Wb/IhNug.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 490ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: '' + headers: + Date: + - Fri, 05 Mar 2021 22:35:58 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/searchResults/bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07 + response: + body: + string: '{"searchId": "sanitized", "phoneNumbers": ["sanitized"], "phoneNumberType": + "TollFree", "assignmentType": "Application", "capabilities": {"calling": "inbound", + "sms": "inbound+outbound"}, "cost": {"amount": 2.0, "currencyCode": "USD", + "billingFrequency": "Monthly"}, "searchExpiresBy": "2021-03-05T22:51:34.5337238+00:00"}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:35:59 GMT + ms-cv: y12bsIrEV06zDF8jFb3ong.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 1045ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: '{"searchId": "sanitized"}' + headers: + Accept: + - application/json + Content-Length: + - '52' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:35:59 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/:purchase?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: Operation-Location,operation-id,purchase-id + content-length: '0' + date: Fri, 05 Mar 2021 22:36:01 GMT + ms-cv: 4h5c14zJiE253OeHRw0Wsg.0 + operation-id: purchase_bb432956-3ef1-4c0f-b5d9-b6879db9815e + operation-location: /phoneNumbers/operations/purchase_bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07 + purchase-id: bb432956-3ef1-4c0f-b5d9-b6879db9815e + request-context: appId= + x-processing-time: 2008ms + status: + code: 202 + message: Accepted + url: https://sanitized.communication.azure.com/availablePhoneNumbers/:purchase?api-version=2021-03-07 +- request: + body: '' + headers: + Date: + - Fri, 05 Mar 2021 22:36:31 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: GET + uri: https://sanitized.communication.azure.com/phoneNumbers/operations/purchase_bb432956-3ef1-4c0f-b5d9-b6879db9815e?api-version=2021-03-07 + response: + body: + string: '{"status": "Succeeded", "resourceLocation": null, "createdDateTime": + "2021-03-05T22:35:27.2958238+00:00", "id": "sanitized", "operationType": "Purchase", + "lastActionDateTime": "0001-01-01T00:00:00+00:00"}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:36:32 GMT + ms-cv: jhCr06bwNE+lcTBxGKenjA.0 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 496ms + status: + code: 200 + message: OK + url: sanitized +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Fri, 05 Mar 2021 22:36:32 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: DELETE + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: Operation-Location,operation-id,release-id + content-length: '0' + date: Fri, 05 Mar 2021 22:36:34 GMT + ms-cv: YaASgzOV90Kwo1U5RYtDew.0 + operation-id: release_dd96b4c4-bc64-4728-9973-0d4ab4b6ba94 + operation-location: /phoneNumbers/operations/release_dd96b4c4-bc64-4728-9973-0d4ab4b6ba94?api-version=2021-03-07 + release-id: dd96b4c4-bc64-4728-9973-0d4ab4b6ba94 + request-context: appId= + x-processing-time: 1258ms + status: + code: 202 + message: Accepted + url: https://sanitized.communication.azure.com/phoneNumbers/sanitized?api-version=2021-03-07 +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_reservation.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_reservation.yaml deleted file mode 100644 index 0cccf09cbf02..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_purchase_reservation.yaml +++ /dev/null @@ -1,54 +0,0 @@ -interactions: -- request: - body: '' - headers: - Date: - - Mon, 23 Nov 2020 22:15:02 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id/purchase?api-version=2020-07-20-preview1 - response: - body: - string: '' - headers: - content-length: '0' - date: Mon, 23 Nov 2020 22:15:02 GMT - ms-cv: bHM865RpP0SiUNt4qxdlDw.0 - x-processing-time: 529ms - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized/purchase?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:02 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/reservation_id?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": - "2020-10-02T21:39:32.6878583+00:00", "description": "mydescription", "phonePlanIds": - "sanitized", "areaCode": "area_code_for_reservation", "quantity": 1, "locationOptions": - [], "status": "Success", "phoneNumbers": "sanitized", "reservationExpiryDate": - "2020-10-02T21:55:47.9734151+00:00"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:02 GMT - ms-cv: yPreFWnm30S6Zotx337N/Q.0 - transfer-encoding: chunked - x-processing-time: 563ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml deleted file mode 100644 index 8ddf05ce5f35..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml +++ /dev/null @@ -1,111 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumbers": ["+1area_code_for_reservation7840394"]}''' - headers: - Accept: - - application/json - Content-Length: - - '34' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:03 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:03 GMT - ms-cv: C+e6Bsl04EOYzASUKe+jWA.0 - transfer-encoding: chunked - x-processing-time: 719ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:04 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/ffff1f34-bcdd-42c3-8281-d7dc9b79264d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:15:03.8078455+00:00", - "status": "Pending", "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:03 GMT - ms-cv: v8ERLmL2JUqitcrp28xrxg.0 - transfer-encoding: chunked - x-processing-time: 191ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases/sanitized?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:04 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/ffff1f34-bcdd-42c3-8281-d7dc9b79264d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:15:03.8078455+00:00", - "status": "Pending", "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:04 GMT - ms-cv: nFuzE/NYDEOntsaMNmdJSw.0 - transfer-encoding: chunked - x-processing-time: 288ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases/sanitized?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:10 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/releases/ffff1f34-bcdd-42c3-8281-d7dc9b79264d?api-version=2020-07-20-preview1 - response: - body: '{"releaseId": "sanitized", "createdAt": "2020-11-23T22:15:03.8078455+00:00", - "status": "Failed", "errorMessage": "Unknown exception in BeginReleaseQueueProcessor - : Cannot Process Order since phone number(s) do not belong to tenant:ec53533e-7d3b-4ad0-bf10-7222b049eb8e", - "phoneNumberReleaseStatusDetails": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:09 GMT - ms-cv: qpn1QSP33kO2OqJnvbwHew.0 - transfer-encoding: chunked - x-processing-time: 195ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/releases/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_reserve_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_reserve_phone_numbers.yaml deleted file mode 100644 index 2b53d7788bc6..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_reserve_phone_numbers.yaml +++ /dev/null @@ -1,146 +0,0 @@ -interactions: -- request: - body: 'b''b\''{"displayName": "testreservation20200014", "description": "testreservation20200014", - "phonePlanIds": ["phone_plan_id"], "areaCode": "area_code_for_reservation", - "quantity": 1}\''''' - headers: - Accept: - - application/json - Content-Length: - - '176' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:10 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:11 GMT - ms-cv: wHNKvhhrIEmoyxIvpQtpVQ.0 - transfer-encoding: chunked - x-processing-time: 1050ms - status: - code: 201 - message: Created - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:11 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/6ec3963c-33a1-4d99-ad49-8f455205bf24?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:15:10.79994+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:11 GMT - ms-cv: 1uEUtAIVP0ixbJJ6at1t6w.0 - transfer-encoding: chunked - x-processing-time: 353ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:11 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/6ec3963c-33a1-4d99-ad49-8f455205bf24?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:15:10.79994+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Pending", "phoneNumbers": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:12 GMT - ms-cv: ahwC8rgZdEODKQ3PFclPiA.0 - transfer-encoding: chunked - x-processing-time: 268ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:17 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/6ec3963c-33a1-4d99-ad49-8f455205bf24?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:15:10.79994+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "InProgress", "phoneNumbers": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:17 GMT - ms-cv: cy0GEqT0NUewZf2v3XLVcw.0 - transfer-encoding: chunked - x-processing-time: 271ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:22 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://sanitized.communication.azure.com/administration/phonenumbers/searches/6ec3963c-33a1-4d99-ad49-8f455205bf24?api-version=2020-07-20-preview1 - response: - body: '{"searchId": "sanitized", "displayName": "testreservation20200014", "createdAt": - "2020-11-23T22:15:10.79994+00:00", "description": "testreservation20200014", - "phonePlanIds": "sanitized", "areaCode": "area_code_for_reservation", "quantity": - 1, "locationOptions": [], "status": "Error", "phoneNumbers": "sanitized", "errorCode": - 1000}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:22 GMT - ms-cv: ormTTpdelUe7v7WzL6x7mw.0 - transfer-encoding: chunked - x-processing-time: 265ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_search_available_phone_numbers.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_search_available_phone_numbers.yaml new file mode 100644 index 000000000000..a544ea22a494 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_search_available_phone_numbers.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: '{"phoneNumberType": "tollFree", "assignmentType": "application", "capabilities": + {"calling": "inbound", "sms": "inbound+outbound"}}' + headers: + Accept: + - application/json + Content-Length: + - '131' + Content-Type: + - application/json + Date: + - Fri, 05 Mar 2021 22:21:24 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 + response: + body: + string: '' + headers: + access-control-expose-headers: Location,Operation-Location,operation-id,search-id + content-length: '0' + date: Fri, 05 Mar 2021 22:21:26 GMT + ms-cv: GqHHQ9p7T06x81w+XWm1Rw.0 + operation-id: search_f29ce617-6079-4be4-b947-1832b96a93a2 + operation-location: /phoneNumbers/operations/search_f29ce617-6079-4be4-b947-1832b96a93a2?api-version=2021-03-07 + request-context: appId= + search-id: f29ce617-6079-4be4-b947-1832b96a93a2 + x-processing-time: 2514ms + status: + code: 202 + message: Accepted + url: sanitized.communication.azure.com/availablePhoneNumbers/countries/US/:search?api-version=2021-03-07 +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml deleted file mode 100644 index 0f12b8d77b9e..000000000000 --- a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml +++ /dev/null @@ -1,32 +0,0 @@ -interactions: -- request: - body: 'b''{"phoneNumberCapabilitiesUpdate": {"+1area_code_for_reservation4501240": - {"add": []}}}''' - headers: - Accept: - - application/json - Content-Length: - - '64' - Content-Type: - - application/json - Date: - - Mon, 23 Nov 2020 22:15:22 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b2 Python/3.6.9 (Linux-5.4.0-48-generic-x86_64-with-Ubuntu-18.04-bionic) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities?api-version=2020-07-20-preview1 - response: - body: '{"capabilitiesUpdateId": "sanitized"}' - headers: - content-type: application/json; charset=utf-8 - date: Mon, 23 Nov 2020 22:15:23 GMT - ms-cv: lCj9rXv4rkWJUHX1XbaQog.0 - transfer-encoding: chunked - x-processing-time: 1068ms - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/administration/phonenumbers/capabilities?api-version=2020-07-20-preview1 -version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_phone_number_capabilities.yaml b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_phone_number_capabilities.yaml new file mode 100644 index 000000000000..1871eac99f84 --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/test/recordings/test_phone_number_administration_client_async.test_update_phone_number_capabilities.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: '{"calling": "inbound", "sms": "inbound+outbound"}' + headers: + Accept: + - application/json + Content-Length: + - '49' + Content-Type: + - application/merge-patch+json + Date: + - Fri, 05 Mar 2021 22:21:26 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: PATCH + uri: https://sanitized.communication.azure.com/phoneNumbers/sanitized/capabilities?api-version=2021-03-07 + response: + body: + string: '{"capabilitiesUpdateId": "d44aa3e8-32ba-4ee4-b887-842c24752059"}' + headers: + access-control-expose-headers: Operation-Location,Location,operation-id,capabilities-id + capabilities-id: d44aa3e8-32ba-4ee4-b887-842c24752059 + content-type: application/json; charset=utf-8 + date: Fri, 05 Mar 2021 22:21:27 GMT + ms-cv: ABRb4DZXnkOpl1LmEQgSmQ.0 + operation-id: capabilities_d44aa3e8-32ba-4ee4-b887-842c24752059 + operation-location: /phoneNumbers/operations/capabilities_d44aa3e8-32ba-4ee4-b887-842c24752059?api-version=2021-03-07 + request-context: appId= + transfer-encoding: chunked + x-processing-time: 1084ms + status: + code: 202 + message: Accepted + url: sanitized +version: 1 diff --git a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py index 4823221226d8..f9becc7e332a 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py +++ b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py @@ -1,293 +1,86 @@ -# coding: utf-8 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import pytest import os -from azure.communication.phonenumbers import ( - PhoneNumbersAdministrationClient, - PstnConfiguration, - NumberUpdateCapabilities, - CreateSearchOptions -) -from azure.core.credentials import AccessToken -from phone_number_helper import PhoneNumberUriReplacer -from phone_number_testcase import PhoneNumberCommunicationTestCase -from _shared.testcase import BodyReplacerProcessor +import pytest +from azure.communication.phonenumbers import PhoneNumbersClient +from _shared.testcase import CommunicationTestCase, ResponseReplacerProcessor, BodyReplacerProcessor from _shared.utils import create_token_credential +from azure.communication.phonenumbers import PhoneNumberAssignmentType, PhoneNumberCapabilities, PhoneNumberCapabilityType, PhoneNumberType from azure.communication.phonenumbers._shared.utils import parse_connection_str +from phone_number_helper import PhoneNumberUriReplacer -SKIP_PHONE_NUMBER_TESTS = True -PHONE_NUMBER_TEST_SKIP_REASON= "Phone Numbers Administration live tests infra not ready yet" +SKIP_PURCHASE_PHONE_NUMBER_TESTS = True +PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON = "Phone numbers shouldn't be purchased in live tests" -class PhoneNumbersAdministrationClientTest(PhoneNumberCommunicationTestCase): +class PhoneNumbersClientTest(CommunicationTestCase): def setUp(self): - super(PhoneNumbersAdministrationClientTest, self).setUp() + super(PhoneNumbersClientTest, self).setUp() + if self.is_playback(): + self.phone_number = "sanitized" + self.country_code = "US" + else: + self.phone_number = os.getenv("AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER") + self.country_code = os.getenv("AZURE_COMMUNICATION_SERVICE_COUNTRY_CODE", "US") + self.phone_number_client = PhoneNumbersClient.from_connection_string(self.connection_str) self.recording_processors.extend([ BodyReplacerProcessor( - keys=["id", "token", "capabilitiesUpdateId", "phoneNumber", "phonePlanIds", - "phoneNumberCapabilitiesUpdates", "releaseId", - "phoneNumberReleaseStatusDetails", "searchId", "phoneNumbers", - "entities", "phonePlanGroups", "phonePlans", "phoneNumberCapabilitiesUpdate"] + keys=["id", "token", "phoneNumber"] ), - PhoneNumberUriReplacer()]) - self._phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string( - self.connection_str) - if self.is_live: - self.country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE') - self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_LOCALE') - self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID') - self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID') - self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES') - self.area_code_for_reservation = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION') - self.reservation_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID') - self.reservation_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE') - self.reservation_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL') - self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE') - self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_GET_CONFIG') - self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_UNCONFIGURE') - self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES') - self.phonenumber_to_release = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_RELEASE') - self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID') - self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID') - self.scrubber.register_name_pair( - self.phone_plan_group_id, - "phone_plan_group_id" - ) - self.scrubber.register_name_pair( - self.phone_plan_id, - "phone_plan_id" - ) - self.scrubber.register_name_pair( - self.phone_plan_id_area_codes, - "phone_plan_id_area_codes" - ) - self.scrubber.register_name_pair( - self.area_code_for_reservation, - "area_code_for_reservation" - ) - self.scrubber.register_name_pair( - self.reservation_id, - "reservation_id" - ) - self.scrubber.register_name_pair( - self.reservation_id_to_purchase, - "reservation_id_to_purchase" - ) - self.scrubber.register_name_pair( - self.reservation_id_to_cancel, - "reservation_id_to_cancel" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_configure, - "phonenumber_to_configure" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_get_config, - "phonenumber_to_get_config" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_unconfigure, - "phonenumber_to_unconfigure" - ) - self.scrubber.register_name_pair( - self.phonenumber_for_capabilities, - "phonenumber_for_capabilities" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_release, - "phonenumber_to_release" - ) - self.scrubber.register_name_pair( - self.capabilities_id, - "capabilities_id" - ) - self.scrubber.register_name_pair( - self.release_id, - "release_id" - ) - else: - self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===" - self.country_code = "US" - self.locale = "en-us" - self.phone_plan_group_id = "phone_plan_group_id" - self.phone_plan_id = "phone_plan_id" - self.phone_plan_id_area_codes = "phone_plan_id_area_codes" - self.area_code_for_reservation = "area_code_for_reservation" - self.reservation_id = "reservation_id" - self.reservation_id_to_purchase = "reservation_id_to_purchase" - self.reservation_id_to_cancel = "reservation_id_to_cancel" - self.phonenumber_to_configure = "phonenumber_to_configure" - self.phonenumber_to_get_config = "phonenumber_to_get_config" - self.phonenumber_to_unconfigure = "phonenumber_to_unconfigure" - self.phonenumber_for_capabilities = "phonenumber_for_capabilities" - self.phonenumber_to_release = "phonenumber_to_release" - self.capabilities_id = "capabilities_id" - self.release_id = "release_id" + PhoneNumberUriReplacer(), + ResponseReplacerProcessor()]) - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_all_phone_numbers_from_managed_identity(self): + def test_list_acquired_phone_numbers_from_managed_identity(self): endpoint, access_key = parse_connection_str(self.connection_str) credential = create_token_credential() - phone_number_client = PhoneNumbersAdministrationClient(endpoint, credential) - pages = phone_number_client.list_all_phone_numbers() - assert pages.next() - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_all_phone_numbers(self): - pages = self._phone_number_administration_client.list_all_phone_numbers() - assert pages.next() - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_all_area_codes(self): - area_codes = self._phone_number_administration_client.get_all_area_codes( - location_type="NotRequired", - country_code=self.country_code, - phone_plan_id=self.phone_plan_id_area_codes + phone_number_client = PhoneNumbersClient(endpoint, credential) + phone_numbers = phone_number_client.list_acquired_phone_numbers() + assert phone_numbers.next() + + def test_list_acquired_phone_numbers(self): + phone_numbers = self.phone_number_client.list_acquired_phone_numbers() + assert phone_numbers.next() + + def test_get_phone_number(self): + phone_number = self.phone_number_client.get_phone_number(self.phone_number) + assert phone_number.phone_number == self.phone_number + + @pytest.mark.skipif(SKIP_PURCHASE_PHONE_NUMBER_TESTS, reason=PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON) + def test_search_available_phone_numbers(self): + capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND ) - assert area_codes.primary_area_codes - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_capabilities_update(self): - capability_response = self._phone_number_administration_client.get_capabilities_update( - capabilities_update_id=self.capabilities_id - ) - assert capability_response.capabilities_update_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_update_capabilities(self): - update = NumberUpdateCapabilities(add=iter(["InboundCalling"])) - - phone_number_capabilities_update = { - self.phonenumber_for_capabilities: update - } - - capability_response = self._phone_number_administration_client.update_capabilities( - phone_number_capabilities_update=phone_number_capabilities_update - ) - assert capability_response.capabilities_update_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_all_supported_countries(self): - countries = self._phone_number_administration_client.list_all_supported_countries() - assert countries.next().localized_name - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_number_configuration(self): - phone_number_response = self._phone_number_administration_client.get_number_configuration( - phone_number=self.phonenumber_to_get_config - ) - assert phone_number_response.pstn_configuration - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_configure_number(self): - pstnConfig = PstnConfiguration( - callback_url="https://callbackurl", - application_id="ApplicationId" - ) - configure_number_response = self._phone_number_administration_client.configure_number( - pstn_configuration=pstnConfig, - phone_number=self.phonenumber_to_configure - ) - assert not configure_number_response - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_phone_plan_groups(self): - phone_plan_group_response = self._phone_number_administration_client.list_phone_plan_groups( - country_code=self.country_code - ) - assert phone_plan_group_response.next().phone_plan_group_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_phone_plans(self): - phone_plan_response = self._phone_number_administration_client.list_phone_plans( - country_code=self.country_code, - phone_plan_group_id=self.phone_plan_group_id - ) - assert phone_plan_response.next().phone_plan_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_phone_plan_location_options(self): - location_options_response = self._phone_number_administration_client.get_phone_plan_location_options( - country_code=self.country_code, - phone_plan_group_id=self.phone_plan_group_id, - phone_plan_id=self.phone_plan_id - ) - assert location_options_response.location_options.label_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_release_by_id(self): - phone_number_release_response = self._phone_number_administration_client.get_release_by_id( - release_id=self.release_id - ) - assert phone_number_release_response.release_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_all_releases(self): - releases_response = self._phone_number_administration_client.list_all_releases() - assert releases_response.next().id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_release_phone_numbers(self): - poller = self._phone_number_administration_client.begin_release_phone_numbers( - phone_numbers=[self.phonenumber_to_release] + poller = self.phone_number_client.begin_search_available_phone_numbers( + self.country_code, + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + polling = True ) assert poller.result() - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_get_reservation_by_id(self): - phone_number_reservation_response = self._phone_number_administration_client.get_reservation_by_id( - reservation_id=self.reservation_id - ) - assert phone_number_reservation_response.reservation_id - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_reserve_phone_numbers(self): - poller = self._phone_number_administration_client.begin_reserve_phone_numbers( - area_code=self.area_code_for_reservation, - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[self.phone_plan_id], - quantity=1 + def test_update_phone_number_capabilities(self): + poller = self.phone_number_client.begin_update_phone_number_capabilities( + self.phone_number, + PhoneNumberCapabilityType.INBOUND_OUTBOUND, + PhoneNumberCapabilityType.INBOUND, + polling = True ) assert poller.result() - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_cancel_reservation(self): - cancel_reservation_response = self._phone_number_administration_client.cancel_reservation( - reservation_id=self.reservation_id_to_cancel + @pytest.mark.skipif(SKIP_PURCHASE_PHONE_NUMBER_TESTS, reason=PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON) + def test_purchase_phone_numbers(self): + capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND ) - assert not cancel_reservation_response - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_purchase_reservation(self): - poller = self._phone_number_administration_client.begin_purchase_reservation( - reservation_id=self.reservation_id_to_purchase + search_poller = self.phone_number_client.begin_search_available_phone_numbers( + self.country_code, + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + polling = True ) - assert poller.result() - - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - def test_list_reservations(self): - pages = self._phone_number_administration_client.list_all_reservations() - assert pages.next() \ No newline at end of file + phone_number_to_buy = search_poller.result() + purchase_poller = self.phone_number_client.begin_purchase_phone_numbers(phone_number_to_buy.search_id, polling=True) + purchase_poller.result() + release_poller = self.phone_number_client.begin_release_phone_number(phone_number_to_buy.phone_numbers[0]) + assert release_poller.status() == 'succeeded' diff --git a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py index 6c3db58a5a77..ad74a2a1a284 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py +++ b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py @@ -1,364 +1,105 @@ -# coding: utf-8 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- +import os import pytest -from azure.communication.phonenumbers.aio import PhoneNumbersAdministrationClient +from azure.communication.phonenumbers.aio import PhoneNumbersClient +from _shared.asynctestcase import AsyncCommunicationTestCase +from _shared.testcase import ResponseReplacerProcessor, BodyReplacerProcessor +from _shared.utils import create_token_credential +from azure.communication.phonenumbers import PhoneNumberAssignmentType, PhoneNumberCapabilities, PhoneNumberCapabilityType, PhoneNumberType from azure.communication.phonenumbers._shared.utils import parse_connection_str -from azure.communication.phonenumbers import ( - PstnConfiguration, - NumberUpdateCapabilities, - CreateSearchOptions -) from phone_number_helper import PhoneNumberUriReplacer -from phone_number_testcase_async import AsyncPhoneNumberCommunicationTestCase -from _shared.testcase import BodyReplacerProcessor, ResponseReplacerProcessor -from _shared.utils import create_token_credential -import os - -SKIP_PHONE_NUMBER_TESTS = True -PHONE_NUMBER_TEST_SKIP_REASON= "Phone Numbers Administration live tests infra not ready yet" -class PhoneNumbersAdministrationClientTestAsync(AsyncPhoneNumberCommunicationTestCase): +SKIP_PURCHASE_PHONE_NUMBER_TESTS = True +PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON = "Phone numbers shouldn't be purchased in live tests" +class PhoneNumbersClientTestAsync(AsyncCommunicationTestCase): def setUp(self): - super(PhoneNumbersAdministrationClientTestAsync, self).setUp() + super(PhoneNumbersClientTestAsync, self).setUp() + if self.is_playback(): + self.phone_number = "sanitized" + self.country_code = "US" + else: + self.phone_number = os.getenv("AZURE_COMMUNICATION_SERVICE_PHONE_NUMBER") + self.country_code = os.getenv("AZURE_COMMUNICATION_SERVICE_COUNTRY_CODE", "US") + self.phone_number_client = PhoneNumbersClient.from_connection_string(self.connection_str) self.recording_processors.extend([ BodyReplacerProcessor( - keys=["id", "token", "capabilitiesUpdateId", "phoneNumber", "phonePlanIds", - "phoneNumberCapabilitiesUpdates", "releaseId", - "phoneNumberReleaseStatusDetails", "searchId", "phoneNumbers", - "entities", "phonePlanGroups", "phonePlans", "phoneNumberCapabilitiesUpdate"] + keys=["id", "token", "phoneNumber", "searchId"] ), PhoneNumberUriReplacer(), - ResponseReplacerProcessor(keys=[self._resource_name])]) - self._phone_number_administration_client = PhoneNumbersAdministrationClient.from_connection_string( - self.connection_str) - if self.is_live: - self.country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE') - self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_LOCALE') - self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_GROUP_ID') - self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID') - self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID_AREA_CODES') - self.area_code_for_reservation = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_RESERVATION') - self.reservation_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID') - self.reservation_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_PURCHASE') - self.reservation_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RESERVATION_ID_TO_CANCEL') - self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_CONFIGURE') - self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_GET_CONFIG') - self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_UNCONFIGURE') - self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_FOR_CAPABILITIES') - self.phonenumber_to_release = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONENUMBER_TO_RELEASE') - self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_CAPABILITIES_ID') - self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID') - self.scrubber.register_name_pair( - self.phone_plan_group_id, - "phone_plan_group_id" - ) - self.scrubber.register_name_pair( - self.phone_plan_id, - "phone_plan_id" - ) - self.scrubber.register_name_pair( - self.phone_plan_id_area_codes, - "phone_plan_id_area_codes" - ) - self.scrubber.register_name_pair( - self.area_code_for_reservation, - "area_code_for_reservation" - ) - self.scrubber.register_name_pair( - self.reservation_id, - "reservation_id" - ) - self.scrubber.register_name_pair( - self.reservation_id_to_purchase, - "reservation_id_to_purchase" - ) - self.scrubber.register_name_pair( - self.reservation_id_to_cancel, - "reservation_id_to_cancel" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_configure, - "phonenumber_to_configure" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_get_config, - "phonenumber_to_get_config" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_unconfigure, - "phonenumber_to_unconfigure" - ) - self.scrubber.register_name_pair( - self.phonenumber_for_capabilities, - "phonenumber_for_capabilities" - ) - self.scrubber.register_name_pair( - self.phonenumber_to_release, - "phonenumber_to_release" - ) - self.scrubber.register_name_pair( - self.capabilities_id, - "capabilities_id" - ) - self.scrubber.register_name_pair( - self.release_id, - "release_id" - ) - else: - self.connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake===" - self.country_code = "US" - self.locale = "en-us" - self.phone_plan_group_id = "phone_plan_group_id" - self.phone_plan_id = "phone_plan_id" - self.phone_plan_id_area_codes = "phone_plan_id_area_codes" - self.area_code_for_reservation = "area_code_for_reservation" - self.reservation_id = "reservation_id" - self.reservation_id_to_purchase = "reservation_id_to_purchase" - self.reservation_id_to_cancel = "reservation_id_to_cancel" - self.phonenumber_to_configure = "phonenumber_to_configure" - self.phonenumber_to_get_config = "phonenumber_to_get_config" - self.phonenumber_to_unconfigure = "phonenumber_to_unconfigure" - self.phonenumber_for_capabilities = "phonenumber_for_capabilities" - self.phonenumber_to_release = "phonenumber_to_release" - self.capabilities_id = "capabilities_id" - self.release_id = "release_id" - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_all_phone_numbers_from_managed_identity(self): + ResponseReplacerProcessor()]) + + @AsyncCommunicationTestCase.await_prepared_test + async def test_list_acquired_phone_numbers_from_managed_identity(self): endpoint, access_key = parse_connection_str(self.connection_str) credential = create_token_credential() - phone_number_client = PhoneNumbersAdministrationClient(endpoint, credential) - async with phone_number_client: - pages = phone_number_client.list_all_phone_numbers() + phone_number_client = PhoneNumbersClient(endpoint, credential) + async with self.phone_number_client: + phone_numbers = phone_number_client.list_acquired_phone_numbers() items = [] - async for item in pages: + async for item in phone_numbers: items.append(item) assert len(items) > 0 - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_all_phone_numbers(self): - async with self._phone_number_administration_client: - pages = self._phone_number_administration_client.list_all_phone_numbers() + @AsyncCommunicationTestCase.await_prepared_test + async def test_list_acquired_phone_numbers(self): + async with self.phone_number_client: + phone_numbers = self.phone_number_client.list_acquired_phone_numbers() items = [] - async for item in pages: + async for item in phone_numbers: items.append(item) assert len(items) > 0 - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_all_area_codes(self): - async with self._phone_number_administration_client: - area_codes = await self._phone_number_administration_client.get_all_area_codes( - location_type="NotRequired", - country_code=self.country_code, - phone_plan_id=self.phone_plan_id_area_codes - ) - assert area_codes.primary_area_codes - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_capabilities_update(self): - async with self._phone_number_administration_client: - capability_response = await self._phone_number_administration_client.get_capabilities_update( - capabilities_update_id=self.capabilities_id - ) - assert capability_response.capabilities_update_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_update_capabilities(self): - update = NumberUpdateCapabilities(add=iter(["InboundCalling"])) - - phone_number_capabilities_update = { - self.phonenumber_for_capabilities: update - } - - async with self._phone_number_administration_client: - capability_response = await self._phone_number_administration_client.update_capabilities( - phone_number_capabilities_update=phone_number_capabilities_update - ) - assert capability_response.capabilities_update_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_all_supported_countries(self): - async with self._phone_number_administration_client: - countries = self._phone_number_administration_client.list_all_supported_countries() - items = [] - async for item in countries: - items.append(item) - self.assertGreater(len(items), 0) - assert items[0].localized_name - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_number_configuration(self): - async with self._phone_number_administration_client: - phone_number_response = await self._phone_number_administration_client.get_number_configuration( - phone_number=self.phonenumber_to_get_config - ) - assert phone_number_response.pstn_configuration - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_configure_number(self): - pstnConfig = PstnConfiguration( - callback_url="https://callbackurl", - application_id="ApplicationId" + + @AsyncCommunicationTestCase.await_prepared_test + async def test_get_phone_number(self): + async with self.phone_number_client: + phone_number = await self.phone_number_client.get_phone_number(self.phone_number) + assert phone_number.phone_number == self.phone_number + + @pytest.mark.skipif(SKIP_PURCHASE_PHONE_NUMBER_TESTS, reason=PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON) + @AsyncCommunicationTestCase.await_prepared_test + async def test_search_available_phone_numbers(self): + capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND ) - async with self._phone_number_administration_client: - configure_number_response = await self._phone_number_administration_client.configure_number( - pstn_configuration=pstnConfig, - phone_number=self.phonenumber_to_configure - ) - assert not configure_number_response - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_phone_plan_groups(self): - async with self._phone_number_administration_client: - phone_plan_group_response = self._phone_number_administration_client.list_phone_plan_groups( - country_code=self.country_code - ) - - items = [] - async for item in phone_plan_group_response: - items.append(item) - assert len(items) > 0 - assert items[0].phone_plan_group_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_phone_plans(self): - async with self._phone_number_administration_client: - phone_plan_response = self._phone_number_administration_client.list_phone_plans( - country_code=self.country_code, - phone_plan_group_id=self.phone_plan_group_id - ) - - items = [] - async for item in phone_plan_response: - items.append(item) - assert len(items) > 0 - assert items[0].phone_plan_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_phone_plan_location_options(self): - async with self._phone_number_administration_client: - location_options_response = await self._phone_number_administration_client.get_phone_plan_location_options( - country_code=self.country_code, - phone_plan_group_id=self.phone_plan_group_id, - phone_plan_id=self.phone_plan_id - ) - assert location_options_response.location_options.label_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_release_by_id(self): - async with self._phone_number_administration_client: - phone_number_release_response = await self._phone_number_administration_client.get_release_by_id( - release_id=self.release_id - ) - assert phone_number_release_response.release_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_all_releases(self): - async with self._phone_number_administration_client: - releases_response = self._phone_number_administration_client.list_all_releases() - - items = [] - async for item in releases_response: - items.append(item) - self.assertGreater(len(items), 0) - assert items[0].id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_release_phone_numbers(self): - async with self._phone_number_administration_client: - poller = await self._phone_number_administration_client.begin_release_phone_numbers( - phone_numbers=[self.phonenumber_to_release] - ) - result = await poller.result() - assert result - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_get_reservation_by_id(self): - async with self._phone_number_administration_client: - phone_number_reservation_response = await self._phone_number_administration_client.get_reservation_by_id( - reservation_id=self.reservation_id - ) - assert phone_number_reservation_response.reservation_id - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_reserve_phone_numbers(self): - async with self._phone_number_administration_client: - poller = await self._phone_number_administration_client.begin_reserve_phone_numbers( - area_code=self.area_code_for_reservation, - description="testreservation20200014", - display_name="testreservation20200014", - phone_plan_ids=[self.phone_plan_id], - quantity=1 - ) - result = await poller.result() - assert result - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_cancel_reservation(self): - async with self._phone_number_administration_client: - cancel_reservation_response = await self._phone_number_administration_client.cancel_reservation( - reservation_id=self.reservation_id_to_cancel - ) - assert not cancel_reservation_response - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_purchase_reservation(self): - async with self._phone_number_administration_client: - poller = await self._phone_number_administration_client.begin_purchase_reservation( - reservation_id=self.reservation_id_to_purchase - ) - result = await poller.result() - assert result - - @AsyncPhoneNumberCommunicationTestCase.await_prepared_test - @pytest.mark.live_test_only - @pytest.mark.skipif(SKIP_PHONE_NUMBER_TESTS, reason=PHONE_NUMBER_TEST_SKIP_REASON) - async def test_list_reservations(self): - async with self._phone_number_administration_client: - pages = self._phone_number_administration_client.list_all_reservations() - items = [] - async for item in pages: - items.append(item) - assert len(items) > 0 \ No newline at end of file + async with self.phone_number_client: + poller = await self.phone_number_client.begin_search_available_phone_numbers( + self.country_code, + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + polling = True + ) + assert poller.result() + + @AsyncCommunicationTestCase.await_prepared_test + async def test_update_phone_number_capabilities(self): + async with self.phone_number_client: + poller = await self.phone_number_client.begin_update_phone_number_capabilities( + self.phone_number, + PhoneNumberCapabilityType.INBOUND_OUTBOUND, + PhoneNumberCapabilityType.INBOUND, + polling = True + ) + assert poller.result() + + @pytest.mark.skipif(SKIP_PURCHASE_PHONE_NUMBER_TESTS, reason=PURCHASE_PHONE_NUMBER_TEST_SKIP_REASON) + @AsyncCommunicationTestCase.await_prepared_test + async def test_purchase_phone_numbers(self): + capabilities = PhoneNumberCapabilities( + calling = PhoneNumberCapabilityType.INBOUND, + sms = PhoneNumberCapabilityType.INBOUND_OUTBOUND + ) + async with self.phone_number_client: + search_poller = await self.phone_number_client.begin_search_available_phone_numbers( + self.country_code, + PhoneNumberType.TOLL_FREE, + PhoneNumberAssignmentType.APPLICATION, + capabilities, + polling = True + ) + phone_number_to_buy = await search_poller.result() + purchase_poller = await self.phone_number_client.begin_purchase_phone_numbers(phone_number_to_buy.search_id, polling=True) + await purchase_poller.result() + release_poller = await self.phone_number_client.begin_release_phone_number(phone_number_to_buy.phone_numbers[0]) + assert release_poller.status() == 'succeeded'