diff --git a/sdk/communication/azure-communication-administration/README.md b/sdk/communication/azure-communication-administration/README.md index 2eb861105c87..a5c953dc6772 100644 --- a/sdk/communication/azure-communication-administration/README.md +++ b/sdk/communication/azure-communication-administration/README.md @@ -24,6 +24,30 @@ pip install azure-communication-administration - Create/revoke scoped user access tokens to access services such as chat, calling, sms. Tokens are issued for a valid Azure Communication identity and can be revoked at any time. +## CommunicationPhoneNumberClient +### Initializing Phone Number Client +```python +# You can find your endpoint and access token from your resource in the Azure Portal +import os +from azure.communication.administration import PhoneNumberAdministrationClient + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) +``` +### Phone plans 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. + +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 Acquiring numbers + +Phone numbers search can be search through the search creation 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 search of phone numbers can either be cancelled or purchased. If the search is cancelled, then the phone numbers will become available to others. If the search is purchased, then the phone numbers are acquired for the Azure resources. + +### Configuring / Assigning numbers + +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. + # Examples The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including: @@ -31,6 +55,115 @@ The following section provides several code snippets covering some of the most c [Create/revoke scoped user access tokens][identitysamples] +## Communication Phone number +### Get Countries + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + +supported_countries = phone_number_administration_client.list_all_supported_countries() +for supported_country in supported_countries: + print(supported_country) +``` + +### Get Phone Plan Groups + +Phone plan groups come in two types, Geographic and Toll-Free. + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.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) +``` + +### Get Phone Plans + +Unlike Toll-Free phone plans, area codes for Geographic Phone Plans are empty. Area codes are found in the Area Codes API. + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.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 + +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. + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.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='' +) +print(location_options_response) +``` + +### Get Area Codes + +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. + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + +all_area_codes = phone_number_administration_client.get_all_area_codes( + location_type="NotRequired", + country_code='', + phone_plan_id='' +) +print(all_area_codes) +``` + +### Create Search + +```python +from azure.communication.administration import CreateSearchOptions +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + +searchOptions = CreateSearchOptions( + area_code='', + description="testsearch20200014", + display_name="testsearch20200014", + phone_plan_ids=[''], + quantity=1 +) +search_response = phone_number_administration_client.create_search( + body=searchOptions +) +print(search_response) +``` + +### Get search by id +```python +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + +phone_number_search_response = phone_number_administration_client.get_search_by_id( + search_id='' +) +print(phone_number_search_response) +``` + +### Purchase Search + +```python +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + +phone_number_administration_client.purchase_search( + search_id='' +) +``` + # Troubleshooting The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py index f50d95b3094b..2864e79e5e5e 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -5,12 +5,35 @@ # -------------------------------------------------------------------------- from ._communication_identity_client import CommunicationIdentityClient +from ._phone_number_administration_client import PhoneNumberAdministrationClient from ._identity._generated.models import ( CommunicationTokenRequest, CommunicationIdentityToken ) +from ._phonenumber._generated.models import ( + AcquiredPhoneNumber, + AcquiredPhoneNumbers, + AreaCodes, + CreateSearchResponse, + LocationOptionsQuery, + LocationOptionsResponse, + NumberConfigurationResponse, + NumberUpdateCapabilities, + PhoneNumberCountries, + PhoneNumberEntities, + PhoneNumberRelease, + PhoneNumberSearch, + PhonePlanGroups, + PhonePlansResponse, + PstnConfiguration, + ReleaseResponse, + UpdateNumberCapabilitiesResponse, + UpdatePhoneNumberCapabilitiesResponse, + CreateSearchOptions +) + from ._shared.models import ( CommunicationUser, PhoneNumber, @@ -19,11 +42,33 @@ __all__ = [ 'CommunicationIdentityClient', + 'PhoneNumberAdministrationClient', # from _identity 'CommunicationTokenRequest', 'CommunicationIdentityToken', + # from _phonenumber + 'AcquiredPhoneNumber', + 'AcquiredPhoneNumbers', + 'AreaCodes', + 'CreateSearchResponse', + 'LocationOptionsQuery', + 'LocationOptionsResponse', + 'NumberConfigurationResponse', + 'NumberUpdateCapabilities', + 'PhoneNumberCountries', + 'PhoneNumberEntities', + 'PhoneNumberRelease', + 'PhoneNumberSearch', + 'PhonePlanGroups', + 'PhonePlansResponse', + 'PstnConfiguration', + 'ReleaseResponse', + 'UpdateNumberCapabilitiesResponse', + 'UpdatePhoneNumberCapabilitiesResponse', + 'CreateSearchOptions', + # from _shared 'CommunicationUser', 'PhoneNumber', diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phone_number_administration_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phone_number_administration_client.py new file mode 100644 index 000000000000..edc0a5657235 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phone_number_administration_client.py @@ -0,0 +1,476 @@ +# pylint: disable=R0904 +# coding=utf-8 +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +from azure.core.tracing.decorator import distributed_trace +from azure.core.paging import ItemPaged + +from ._phonenumber._generated._phone_number_administration_service\ + import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen + +from ._phonenumber._generated.models import ( + AcquiredPhoneNumbers, + AreaCodes, + CreateSearchResponse, + LocationOptionsResponse, + NumberConfigurationResponse, + NumberUpdateCapabilities, + PhoneNumberCountries, + PhoneNumberEntities, + PhoneNumberRelease, + PhoneNumberSearch, + PhonePlanGroups, + PhonePlansResponse, + PstnConfiguration, + ReleaseResponse, + UpdateNumberCapabilitiesResponse, + UpdatePhoneNumberCapabilitiesResponse +) + +from ._shared.utils import parse_connection_str +from ._shared.policy import HMACCredentialsPolicy +from ._version import SDK_MONIKER + +class PhoneNumberAdministrationClient(object): + """Azure Communication Services Phone Number 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 = PhoneNumberAdministrationClientGen( + self._endpoint, + authentication_policy=HMACCredentialsPolicy(endpoint, credential), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): + # type: (...) -> PhoneNumberAdministrationClient + """Create PhoneNumberAdministrationClient from a Connection String. + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of PhoneNumberAdministrationClient. + :rtype: ~azure.communication.PhoneNumberAdministrationClient + """ + 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 release_phone_numbers( + self, + phone_numbers, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> ReleaseResponse + """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] + :rtype: ~azure.communication.administration.ReleaseResponse + """ + return self._phone_number_administration_client.phone_number_administration.release_phone_numbers( + phone_numbers, + **kwargs + ) + + @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_search_by_id( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> PhoneNumberSearch + """Get search by search id. + + :param search_id: The search id to be searched for. + :type search_id: str + :rtype: ~azure.communication.administration.PhoneNumberSearch + """ + return self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id, + **kwargs + ) + + @distributed_trace + def create_search( + self, + **kwargs # type: Any + ): + # type: (...) -> CreateSearchResponse + """Creates a phone number search. + + :keyword azure.communication.administration.CreateSearchOptions body: + An optional parameter for defining the search options. + The default is None. + :rtype: ~azure.communication.administration.CreateSearchResponse + """ + return self._phone_number_administration_client.phone_number_administration.create_search( + **kwargs + ) + + @distributed_trace + def list_all_searches( + self, + **kwargs # type: Any + ): + # type: (...) -> ItemPaged[PhoneNumberEntities] + """Gets a list of all searches. + + :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_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. + + :param search_id: The search id to be canceled. + :type search_id: str + :rtype: None + """ + return self._phone_number_administration_client.phone_number_administration.cancel_search( + search_id, + **kwargs + ) + + @distributed_trace + def purchase_search( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Purchases the phone number search. + + :param search_id: The search id to be purchased. + :type search_id: str + :rtype: None + """ + return self._phone_number_administration_client.phone_number_administration.purchase_search( + search_id, + **kwargs + ) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py new file mode 100644 index 000000000000..13fcd7af35ce --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py @@ -0,0 +1,16 @@ +# 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 ._phone_number_administration_service import PhoneNumberAdministrationService +__all__ = ['PhoneNumberAdministrationService'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_configuration.py new file mode 100644 index 000000000000..2043f061b4f2 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_configuration.py @@ -0,0 +1,58 @@ +# 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.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +VERSION = "unknown" + +class PhoneNumberAdministrationServiceConfiguration(Configuration): + """Configuration for PhoneNumberAdministrationService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The endpoint of the Azure Communication resource. + :type endpoint: str + """ + + def __init__( + self, + endpoint, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.api_version = "2020-07-20-preview1" + kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_service.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_service.py new file mode 100644 index 000000000000..49830756eba4 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_service.py @@ -0,0 +1,60 @@ +# 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.administration.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._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-administration/azure/communication/administration/_phonenumber/_generated/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/__init__.py new file mode 100644 index 000000000000..6ec72fc665b1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._phone_number_administration_service_async import PhoneNumberAdministrationService +__all__ = ['PhoneNumberAdministrationService'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_configuration_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_configuration_async.py new file mode 100644 index 000000000000..7a46556ea91d --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_configuration_async.py @@ -0,0 +1,52 @@ +# 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.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class PhoneNumberAdministrationServiceConfiguration(Configuration): + """Configuration for PhoneNumberAdministrationService. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The endpoint of the Azure Communication resource. + :type endpoint: str + """ + + def __init__( + self, + endpoint: str, + **kwargs: Any + ) -> None: + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(PhoneNumberAdministrationServiceConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.api_version = "2020-07-20-preview1" + kwargs.setdefault('sdk_moniker', 'phonenumberadministrationservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_service_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_service_async.py new file mode 100644 index 000000000000..4c6d33b7c250 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_service_async.py @@ -0,0 +1,52 @@ +# 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_async import PhoneNumberAdministrationServiceConfiguration +from .operations_async import PhoneNumberAdministrationOperations +from .. import models + + +class PhoneNumberAdministrationService(object): + """Phone Number Administration Service. + + :ivar phone_number_administration: PhoneNumberAdministrationOperations operations + :vartype phone_number_administration: azure.communication.administration.aio.operations_async.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._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-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/__init__.py new file mode 100644 index 000000000000..d34a375da534 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/__init__.py @@ -0,0 +1,13 @@ +# 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 ._phone_number_administration_operations_async import PhoneNumberAdministrationOperations + +__all__ = [ + 'PhoneNumberAdministrationOperations', +] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/_phone_number_administration_operations_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/_phone_number_administration_operations_async.py new file mode 100644 index 000000000000..2e4075a2f4bc --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/_phone_number_administration_operations_async.py @@ -0,0 +1,1344 @@ +# 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import 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.administration.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.administration.models.AcquiredPhoneNumbers] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumbers"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.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.administration.models.AreaCodes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AreaCodes"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.UpdatePhoneNumberCapabilitiesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UpdatePhoneNumberCapabilitiesResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.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.administration.models.UpdateNumberCapabilitiesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UpdateNumberCapabilitiesResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberCountries] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberCountries"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.NumberConfigurationResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NumberConfigurationResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.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 = {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") + + # 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') + + 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(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 = {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") + + # 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') + + 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(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.administration.models.PhonePlanGroups] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlanGroups"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.PhonePlansResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlansResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.LocationOptionsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationOptionsResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberRelease + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberRelease"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.models.ReleaseResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReleaseResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberEntities] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberEntities"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.PhoneNumberSearch": + """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: PhoneNumberSearch, or the result of cls(response) + :rtype: ~azure.communication.administration.models.PhoneNumberSearch + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberSearch"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PhoneNumberSearch', 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.administration.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.administration.models.CreateSearchResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CreateSearchResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberEntities] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberEntities"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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 = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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] + + 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(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 = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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] + + 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(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-administration/azure/communication/administration/_phonenumber/_generated/models/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/__init__.py new file mode 100644 index 000000000000..95f1084c4297 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/__init__.py @@ -0,0 +1,141 @@ +# 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. +# -------------------------------------------------------------------------- + +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 PhoneNumberSearch + 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 +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 PhoneNumberSearch # 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 ._phone_number_administration_service_enums import ( + ActivationState, + AssignmentStatus, + CapabilitiesUpdateStatus, + Capability, + CurrencyType, + LocationType, + PhoneNumberReleaseStatus, + 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', + 'PhoneNumberSearch', + 'PhonePlan', + 'PhonePlanGroup', + 'PhonePlanGroups', + 'PhonePlansResponse', + 'PstnConfiguration', + 'RateInformation', + 'ReleaseRequest', + 'ReleaseResponse', + 'UpdateNumberCapabilitiesRequest', + 'UpdateNumberCapabilitiesResponse', + 'UpdatePhoneNumberCapabilitiesResponse', + 'ActivationState', + 'AssignmentStatus', + 'CapabilitiesUpdateStatus', + 'Capability', + 'CurrencyType', + 'LocationType', + 'PhoneNumberReleaseStatus', + 'PhoneNumberType', + 'ReleaseStatus', + 'SearchStatus', +] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models.py new file mode 100644 index 000000000000..0f9531291bae --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models.py @@ -0,0 +1,1057 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class AcquiredPhoneNumber(msrest.serialization.Model): + """Represents an acquired phone number. + + 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. + :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.administration.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.administration.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.administration.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.administration.models.ActivationState + """ + + _validation = { + 'phone_number': {'required': True}, + 'acquired_capabilities': {'required': True}, + 'available_capabilities': {'required': True}, + } + + _attribute_map = { + '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'}, + } + + def __init__( + self, + **kwargs + ): + super(AcquiredPhoneNumber, self).__init__(**kwargs) + 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) + + +class AcquiredPhoneNumbers(msrest.serialization.Model): + """A wrapper of list of phone numbers. + + :param phone_numbers: Represents a list of phone numbers. + :type phone_numbers: list[~azure.communication.administration.models.AcquiredPhoneNumber] + :param next_link: Represents the URL link to the next page. + :type next_link: str + """ + + _attribute_map = { + 'phone_numbers': {'key': 'phoneNumbers', 'type': '[AcquiredPhoneNumber]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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) + self.next_link = kwargs.get('next_link', None) + + +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, + **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. + + 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.administration.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. + :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'}, + } + + 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.administration.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.administration.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.administration.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.administration.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.administration.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.administration.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, + **kwargs + ): + super(NumberConfiguration, self).__init__(**kwargs) + self.pstn_configuration = kwargs['pstn_configuration'] + self.phone_number = kwargs['phone_number'] + + +class NumberConfigurationPhoneNumber(msrest.serialization.Model): + """The phone number wrapper representing a number configuration request. + + 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 + """ + + _validation = { + 'phone_number': {'required': True}, + } + + _attribute_map = { + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) + self.phone_number = kwargs['phone_number'] + + +class NumberConfigurationResponse(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.administration.models.PstnConfiguration + """ + + _validation = { + 'pstn_configuration': {'required': True}, + } + + _attribute_map = { + 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + } + + 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.administration.models.Capability] + :param remove: Capabilities to be removed from a phone number. + :type remove: list[str or ~azure.communication.administration.models.Capability] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'remove': {'key': 'remove', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(NumberUpdateCapabilities, self).__init__(**kwargs) + self.add = kwargs.get('add', None) + self.remove = kwargs.get('remove', None) + + +class PhoneNumberCountries(msrest.serialization.Model): + """Represents a wrapper around a list of countries. + + :param countries: Represents the underlying list of countries. + :type countries: list[~azure.communication.administration.models.PhoneNumberCountry] + :param next_link: Represents the URL link to the next page. + :type next_link: str + """ + + _attribute_map = { + 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, + 'next_link': {'key': 'nextLink', '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) + + +class PhoneNumberCountry(msrest.serialization.Model): + """Represents a country. + + 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 + """ + + _validation = { + 'localized_name': {'required': True}, + 'country_code': {'required': True}, + } + + _attribute_map = { + 'localized_name': {'key': 'localizedName', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PhoneNumberCountry, self).__init__(**kwargs) + self.localized_name = kwargs['localized_name'] + self.country_code = kwargs['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. + + :param entities: The underlying list of entities. + :type entities: list[~azure.communication.administration.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'}, + } + + 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. + + :param id: The id of the entity. It is the search id of a search. It is the release id of a + release. + :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 + """ + + _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.administration.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.administration.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.administration.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, + **kwargs + ): + super(PhoneNumberReleaseDetails, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.error_code = kwargs.get('error_code', None) + + +class PhoneNumberSearch(msrest.serialization.Model): + """Represents a phone number search. + + :param search_id: The id of the search. + :type search_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.administration.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.administration.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 = { + 'search_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'}, + } + + def __init__( + self, + **kwargs + ): + super(PhoneNumberSearch, self).__init__(**kwargs) + self.search_id = kwargs.get('search_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) + + +class PhonePlan(msrest.serialization.Model): + """Represents a phone plan. + + All required parameters must be populated in order to send to Azure. + + :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.administration.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.administration.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 + """ + + _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'}, + } + + 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) + + +class PhonePlanGroup(msrest.serialization.Model): + """Represents a plan group. + + 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". + :type phone_number_type: str or ~azure.communication.administration.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.administration.models.CarrierDetails + :param rate_information: Represents a wrapper of rate information. + :type rate_information: ~azure.communication.administration.models.RateInformation + """ + + _validation = { + 'phone_plan_group_id': {'required': True}, + 'localized_name': {'required': True}, + 'localized_description': {'required': True}, + } + + _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.administration.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.administration.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.administration.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, + **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) + + +class ReleaseRequest(msrest.serialization.Model): + """Represents a release request. + + 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. + :type phone_numbers: list[str] + """ + + _validation = { + 'phone_numbers': {'required': True}, + } + + _attribute_map = { + 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ReleaseRequest, self).__init__(**kwargs) + 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.administration.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.administration.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.administration.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) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models_py3.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models_py3.py new file mode 100644 index 000000000000..78a269c7f21c --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models_py3.py @@ -0,0 +1,1197 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._phone_number_administration_service_enums import * + + +class AcquiredPhoneNumber(msrest.serialization.Model): + """Represents an acquired phone number. + + 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. + :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.administration.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.administration.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.administration.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.administration.models.ActivationState + """ + + _validation = { + 'phone_number': {'required': True}, + 'acquired_capabilities': {'required': True}, + 'available_capabilities': {'required': True}, + } + + _attribute_map = { + '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'}, + } + + def __init__( + self, + *, + 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, + **kwargs + ): + super(AcquiredPhoneNumber, self).__init__(**kwargs) + 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 + + +class AcquiredPhoneNumbers(msrest.serialization.Model): + """A wrapper of list of phone numbers. + + :param phone_numbers: Represents a list of phone numbers. + :type phone_numbers: list[~azure.communication.administration.models.AcquiredPhoneNumber] + :param next_link: Represents the URL link to the next page. + :type next_link: str + """ + + _attribute_map = { + 'phone_numbers': {'key': 'phoneNumbers', 'type': '[AcquiredPhoneNumber]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + phone_numbers: Optional[List["AcquiredPhoneNumber"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(AcquiredPhoneNumbers, self).__init__(**kwargs) + self.phone_numbers = phone_numbers + self.next_link = next_link + + +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]'}, + '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. + + 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.administration.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 + """ + + _validation = { + 'search_id': {'required': True}, + } + + _attribute_map = { + 'search_id': {'key': 'searchId', 'type': 'str'}, + } + + 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'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(ErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponse(msrest.serialization.Model): + """Represents a service error response. + + :param error: Represents a service error response body. + :type error: ~azure.communication.administration.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.administration.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.administration.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.administration.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.administration.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.administration.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. + + 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 + """ + + _validation = { + 'phone_number': {'required': True}, + } + + _attribute_map = { + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + phone_number: str, + **kwargs + ): + super(NumberConfigurationPhoneNumber, self).__init__(**kwargs) + self.phone_number = phone_number + + +class NumberConfigurationResponse(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.administration.models.PstnConfiguration + """ + + _validation = { + 'pstn_configuration': {'required': True}, + } + + _attribute_map = { + 'pstn_configuration': {'key': 'pstnConfiguration', 'type': 'PstnConfiguration'}, + } + + 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.administration.models.Capability] + :param remove: Capabilities to be removed from a phone number. + :type remove: list[str or ~azure.communication.administration.models.Capability] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'remove': {'key': 'remove', 'type': '[str]'}, + } + + def __init__( + self, + *, + add: Optional[List[Union[str, "Capability"]]] = None, + remove: Optional[List[Union[str, "Capability"]]] = None, + **kwargs + ): + super(NumberUpdateCapabilities, self).__init__(**kwargs) + self.add = add + self.remove = remove + + +class PhoneNumberCountries(msrest.serialization.Model): + """Represents a wrapper around a list of countries. + + :param countries: Represents the underlying list of countries. + :type countries: list[~azure.communication.administration.models.PhoneNumberCountry] + :param next_link: Represents the URL link to the next page. + :type next_link: str + """ + + _attribute_map = { + 'countries': {'key': 'countries', 'type': '[PhoneNumberCountry]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + countries: Optional[List["PhoneNumberCountry"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PhoneNumberCountries, self).__init__(**kwargs) + self.countries = countries + self.next_link = next_link + + +class PhoneNumberCountry(msrest.serialization.Model): + """Represents a country. + + 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 + """ + + _validation = { + 'localized_name': {'required': True}, + 'country_code': {'required': True}, + } + + _attribute_map = { + 'localized_name': {'key': 'localizedName', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + } + + def __init__( + self, + *, + localized_name: str, + country_code: str, + **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. + + :param entities: The underlying list of entities. + :type entities: list[~azure.communication.administration.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'}, + } + + 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 + + +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. + :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 + """ + + _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.administration.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.administration.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, + *, + 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.administration.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 PhoneNumberSearch(msrest.serialization.Model): + """Represents a phone number search. + + :param search_id: The id of the search. + :type search_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.administration.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.administration.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 = { + 'search_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'}, + } + + def __init__( + self, + *, + search_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, + **kwargs + ): + super(PhoneNumberSearch, self).__init__(**kwargs) + self.search_id = search_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 + self.status = status + self.phone_numbers = phone_numbers + self.reservation_expiry_date = reservation_expiry_date + self.error_code = error_code + + +class PhonePlan(msrest.serialization.Model): + """Represents a phone plan. + + All required parameters must be populated in order to send to Azure. + + :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.administration.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.administration.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 + """ + + _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'}, + } + + 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, + **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 + + +class PhonePlanGroup(msrest.serialization.Model): + """Represents a plan group. + + 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". + :type phone_number_type: str or ~azure.communication.administration.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.administration.models.CarrierDetails + :param rate_information: Represents a wrapper of rate information. + :type rate_information: ~azure.communication.administration.models.RateInformation + """ + + _validation = { + 'phone_plan_group_id': {'required': True}, + 'localized_name': {'required': True}, + 'localized_description': {'required': True}, + } + + _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, + *, + 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, + **kwargs + ): + super(PhonePlanGroup, self).__init__(**kwargs) + self.phone_plan_group_id = phone_plan_group_id + 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.administration.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.administration.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.administration.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 + + +class ReleaseRequest(msrest.serialization.Model): + """Represents a release request. + + 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. + :type phone_numbers: list[str] + """ + + _validation = { + 'phone_numbers': {'required': True}, + } + + _attribute_map = { + 'phone_numbers': {'key': 'phoneNumbers', 'type': '[str]'}, + } + + def __init__( + self, + *, + phone_numbers: List[str], + **kwargs + ): + super(ReleaseRequest, self).__init__(**kwargs) + 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.administration.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.administration.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.administration.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 diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_service_enums.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_service_enums.py new file mode 100644 index 000000000000..5b53cc8756be --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_service_enums.py @@ -0,0 +1,148 @@ +# 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-administration/azure/communication/administration/_phonenumber/_generated/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/__init__.py new file mode 100644 index 000000000000..50478d62d8d6 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/__init__.py @@ -0,0 +1,13 @@ +# 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 ._phone_number_administration_operations import PhoneNumberAdministrationOperations + +__all__ = [ + 'PhoneNumberAdministrationOperations', +] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/_phone_number_administration_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/_phone_number_administration_operations.py new file mode 100644 index 000000000000..9357db8f9280 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/_phone_number_administration_operations.py @@ -0,0 +1,1367 @@ +# 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 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 + +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.administration.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.administration.models.AcquiredPhoneNumbers] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AcquiredPhoneNumbers"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.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.administration.models.AreaCodes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AreaCodes"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.UpdatePhoneNumberCapabilitiesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UpdatePhoneNumberCapabilitiesResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.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.administration.models.UpdateNumberCapabilitiesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UpdateNumberCapabilitiesResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberCountries] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberCountries"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.NumberConfigurationResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NumberConfigurationResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.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 = {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") + + # 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') + + 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(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 = {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") + + # 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') + + 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(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.administration.models.PhonePlanGroups] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlanGroups"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.PhonePlansResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhonePlansResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.administration.models.LocationOptionsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationOptionsResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberRelease + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberRelease"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(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.administration.models.ReleaseResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReleaseResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberEntities] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberEntities"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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.PhoneNumberSearch" + """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: PhoneNumberSearch, or the result of cls(response) + :rtype: ~azure.communication.administration.models.PhoneNumberSearch + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberSearch"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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'] = 'application/json' + + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PhoneNumberSearch', 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.administration.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.administration.models.CreateSearchResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CreateSearchResponse"] + error_map = {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") + + # 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'] = 'application/json' + + 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(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.administration.models.PhoneNumberEntities] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PhoneNumberEntities"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + 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(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 = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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] + + 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(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 = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview1" + + # 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] + + 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(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-administration/azure/communication/administration/_phonenumber/_generated/py.typed b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py index 383c5e75f78e..f647dfa8f506 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py @@ -1,5 +1,7 @@ from ._communication_identity_client_async import CommunicationIdentityClient +from ._phone_number_administration_client_async import PhoneNumberAdministrationClient __all__ = [ 'CommunicationIdentityClient', + 'PhoneNumberAdministrationClient' ] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py new file mode 100644 index 000000000000..50637b8ce729 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py @@ -0,0 +1,496 @@ +# pylint: disable=R0904 +# coding=utf-8 +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +from typing import Dict, List +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 .._version import SDK_MONIKER + +from .._phonenumber._generated.aio._phone_number_administration_service_async\ + import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen + +from .._phonenumber._generated.models import ( + AcquiredPhoneNumbers, + AreaCodes, + CreateSearchResponse, + LocationOptionsResponse, + NumberConfigurationResponse, + NumberUpdateCapabilities, + PhoneNumberCountries, + PhoneNumberEntities, + PhoneNumberRelease, + PhoneNumberSearch, + PhonePlanGroups, + PhonePlansResponse, + PstnConfiguration, + ReleaseResponse, + UpdateNumberCapabilitiesResponse, + UpdatePhoneNumberCapabilitiesResponse +) + +from .._shared.utils import parse_connection_str +from .._shared.policy import HMACCredentialsPolicy + +class PhoneNumberAdministrationClient(object): + """Azure Communication Services Phone Number 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 = PhoneNumberAdministrationClientGen( + self._endpoint, + authentication_policy=HMACCredentialsPolicy(endpoint, credential), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): # type: (...) -> PhoneNumberAdministrationClient + """Create PhoneNumberAdministrationClient from a Connection String. + + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of PhoneNumberAdministrationClient. + :rtype: ~azure.communication.PhoneNumberAdministrationClient + """ + 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 release_phone_numbers( + self, + phone_numbers, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> ReleaseResponse + """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] + :rtype: ~azure.communication.administration.ReleaseResponse + """ + return await self._phone_number_administration_client.phone_number_administration.release_phone_numbers( + phone_numbers, + **kwargs + ) + + @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_search_by_id( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> PhoneNumberSearch + """Get search by search id. + + :param search_id: The search id to be searched for. + :type search_id: str + :rtype: ~azure.communication.administration.PhoneNumberSearch + """ + return await self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id, + **kwargs + ) + + @distributed_trace_async + async def create_search( + self, + **kwargs # type: Any + ): + # type: (...) -> CreateSearchResponse + """Creates a phone number search. + + :keyword azure.communication.administration.CreateSearchOptions body: + An optional parameter for defining the search options. + The default is None. + :rtype: ~azure.communication.administration.CreateSearchResponse + """ + return await self._phone_number_administration_client.phone_number_administration.create_search( + **kwargs + ) + + @distributed_trace + def list_all_searches( + self, + **kwargs # type: Any + ): + # type: (...) -> AsyncItemPaged[PhoneNumberEntities] + """Gets a list of all searches. + + :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_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. + + :param search_id: The search id to be canceled. + :type search_id: str + :rtype: None + """ + return await self._phone_number_administration_client.phone_number_administration.cancel_search( + search_id, + **kwargs + ) + + @distributed_trace_async + async def purchase_search( + self, + search_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Purchases the phone number search. + + :param search_id: The search id to be purchased. + :type search_id: str + :rtype: None + """ + return await self._phone_number_administration_client.phone_number_administration.purchase_search( + search_id, + **kwargs + ) + + async def __aenter__(self) -> "PhoneNumberAdministrationClient": + 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.PhoneNumberAdministrationClient` session. + """ + await self._phone_number_administration_client.__aexit__() diff --git a/sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample.py new file mode 100644 index 000000000000..009c008abcea --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample.py @@ -0,0 +1,45 @@ +# 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.administration import ( + PhoneNumberAdministrationClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/samples/phone_number_area_codes_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample_async.py new file mode 100644 index 000000000000..0cc953b9d1e1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample_async.py @@ -0,0 +1,50 @@ +# 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.administration.aio import PhoneNumberAdministrationClient + +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 = PhoneNumberAdministrationClient.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-administration/samples/phone_number_capabilities_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample.py new file mode 100644 index 000000000000..44b9dcb1a879 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample.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. +# -------------------------------------------------------------------------- + +""" +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.administration import ( + PhoneNumberAdministrationClient, + NumberUpdateCapabilities +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/samples/phone_number_capabilities_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample_async.py new file mode 100644 index 000000000000..f45c6a430f04 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample_async.py @@ -0,0 +1,82 @@ +# 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.administration.aio import PhoneNumberAdministrationClient +from azure.communication.administration 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 = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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-administration/samples/phone_number_configuration_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample.py new file mode 100644 index 000000000000..d66dea3258f1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample.py @@ -0,0 +1,58 @@ +# 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.administration import ( + PhoneNumberAdministrationClient, + PstnConfiguration +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/samples/phone_number_configuration_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample_async.py new file mode 100644 index 000000000000..917d3992bd8c --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample_async.py @@ -0,0 +1,63 @@ +# 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.administration.aio import PhoneNumberAdministrationClient +from azure.communication.administration 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 = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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-administration/samples/phone_number_orders_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample.py new file mode 100644 index 000000000000..82489f73e916 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample.py @@ -0,0 +1,110 @@ +# 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, search 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_SEARCH_ID - The search id you want to get info from + 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH - The phone number you want to create search + 5) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id + 6) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE - The search id you want to purchase + 7) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_CANCEL - The search id you want to cancel +""" + + +import os +from azure.communication.administration import ( + PhoneNumberAdministrationClient, + CreateSearchOptions +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) +release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID', "release-id") +search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID', "search-id") +area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH', "area-code") +phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") +search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE', "search-id") +search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_CANCEL', "search-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_search_by_id(): + # [START get_search_by_id] + phone_number_search_response = phone_number_administration_client.get_search_by_id( + search_id=search_id + ) + # [END get_search_by_id] + print('phone_number_search_response:') + print(phone_number_search_response) + + +def create_search(): + # [START create_search] + searchOptions = CreateSearchOptions( + area_code=area_code_for_search, + description="testsearch20200014", + display_name="testsearch20200014", + phone_plan_ids=[phone_plan_id], + quantity=1 + ) + search_response = phone_number_administration_client.create_search( + body=searchOptions + ) + # [END create_search] + print('search_response:') + print(search_response) + + +def cancel_search(): + # [START cancel_search] + phone_number_administration_client.cancel_search( + search_id=search_id_to_cancel + ) + # [START cancel_search] + + +def purchase_search(): + # [START cancel_search] + phone_number_administration_client.purchase_search( + search_id=search_id_to_purchase + ) + # [END cancel_search] + + +if __name__ == '__main__': + get_release_by_id() + list_all_releases() + get_search_by_id() + create_search() + cancel_search() + # purchase_search() #currently throws error if purchase an already purchased number diff --git a/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample_async.py new file mode 100644 index 000000000000..88aae29b372b --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample_async.py @@ -0,0 +1,124 @@ +# 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, search id, phone plan id and and area code +USAGE: + python phone_number_orders_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_RELEASE_ID - The release id you want to get info from + 3) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID - The search id you want to get info from + 4) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH - The phone number you want to create search + 5) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID - The phone plan id + 6) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE - The search id you want to purchase + 7) AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_CANCEL - The search id you want to cancel +""" + +import os +import asyncio +from azure.communication.administration.aio import PhoneNumberAdministrationClient +from azure.communication.administration import CreateSearchOptions + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_RELEASE_ID', "release-id") +search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID', "search-id") +area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH', "area-code") +phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") +search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE', "search-id") +search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_CANCEL', "search-id") + + +async def get_release_by_id(): + # [START get_release_by_id] + phone_number_administration_client = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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_search_by_id(): + # [START get_search_by_id] + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + async with phone_number_administration_client: + phone_number_search_response = await phone_number_administration_client.get_search_by_id( + search_id=search_id + ) + print('phone_number_search_response:') + print(phone_number_search_response) + await phone_number_administration_client.close() + # [END get_search_by_id] + + +async def create_search(): + # [START create_search] + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + searchOptions = CreateSearchOptions( + area_code=area_code_for_search, + description="testsearch20200014", + display_name="testsearch20200014", + phone_plan_ids=[phone_plan_id], + quantity=1 + ) + async with phone_number_administration_client: + search_response = await phone_number_administration_client.create_search( + body=searchOptions + ) + print('search_response:') + print(search_response) + # [END create_search] + + +async def cancel_search(): + # [START cancel_search] + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + async with phone_number_administration_client: + await phone_number_administration_client.cancel_search( + search_id=search_id_to_cancel + ) + # [END cancel_search] + + +async def purchase_search(): + # [START purchase_search] + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + async with phone_number_administration_client: + await phone_number_administration_client.purchase_search( + search_id=search_id_to_purchase + ) + # [END purchase_search] + + +async def main(): + await get_release_by_id() + await list_all_releases() + await get_search_by_id() + await create_search() + await cancel_search() + # await purchase_search() #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-administration/samples/phone_number_plans_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_plans_sample.py new file mode 100644 index 000000000000..360c07f099a6 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_plans_sample.py @@ -0,0 +1,72 @@ +# 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.administration import ( + PhoneNumberAdministrationClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/samples/phone_number_plans_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_plans_sample_async.py new file mode 100644 index 000000000000..4460686c8bce --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_plans_sample_async.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. +# -------------------------------------------------------------------------- + +""" +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.administration.aio import PhoneNumberAdministrationClient + +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 = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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 = PhoneNumberAdministrationClient.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-administration/samples/phone_number_supported_countries_sample.py b/sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_sample.py new file mode 100644 index 000000000000..40489c488c84 --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_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: 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.administration import ( + PhoneNumberAdministrationClient +) + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/samples/phone_number_supported_countries_sample_async.py b/sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_sample_async.py new file mode 100644 index 000000000000..0069bbe5ec4f --- /dev/null +++ b/sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_sample_async.py @@ -0,0 +1,43 @@ +# 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.administration.aio import PhoneNumberAdministrationClient + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') + + +async def list_all_supported_countries(): + # [START list_all_supported_countries] + phone_number_administration_client = PhoneNumberAdministrationClient.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-administration/swagger/PHONE_NUMBER_SWAGGER.md b/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md new file mode 100644 index 000000000000..328a5058cf13 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md @@ -0,0 +1,22 @@ +# Azure Communication Phone Number Administration for Python + +> see https://aka.ms/autorest + +### Generation +```ps +cd +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 +output-folder: ../azure/communication/administration/_phonenumber/_generated +namespace: azure.communication.administration +license-header: MICROSOFT_MIT_NO_VERSION +payload-flattening-threshold: 3 +no-namespace-folders: true +clear-output-folder: true +v3: true +python: true +``` \ No newline at end of file diff --git a/sdk/communication/azure-communication-administration/swagger/examples/CreateReleaseAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/CreateReleaseAsync.json new file mode 100644 index 000000000000..063a85f5aeac --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/CreateReleaseAsync.json @@ -0,0 +1,16 @@ +{ + "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-administration/swagger/examples/CreateSearchOrderAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/CreateSearchOrderAsync.json new file mode 100644 index 000000000000..7242d8403f3d --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/CreateSearchOrderAsync.json @@ -0,0 +1,28 @@ +{ + "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-administration/swagger/examples/GetAcquiredTelephoneNumbersAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetAcquiredTelephoneNumbersAsync.json new file mode 100644 index 000000000000..48b4666c6e38 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetAcquiredTelephoneNumbersAsync.json @@ -0,0 +1,39 @@ +{ + "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-administration/swagger/examples/GetAreaCodesAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetAreaCodesAsync.json new file mode 100644 index 000000000000..0cc7ce546ca0 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetAreaCodesAsync.json @@ -0,0 +1,22 @@ +{ + "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-administration/swagger/examples/GetCountriesAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetCountriesAsync.json new file mode 100644 index 000000000000..eee04b0bd0c8 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetCountriesAsync.json @@ -0,0 +1,28 @@ +{ + "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-administration/swagger/examples/GetNumberConfigurationAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetNumberConfigurationAsync.json new file mode 100644 index 000000000000..3cfd910129cb --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetNumberConfigurationAsync.json @@ -0,0 +1,17 @@ +{ + "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-administration/swagger/examples/GetOrdersAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetOrdersAsync.json new file mode 100644 index 000000000000..4ef8ad59fc4d --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetOrdersAsync.json @@ -0,0 +1,13 @@ +{ + "parameters": { + "api-version": "2020-07-20-preview1" + }, + "responses": { + "200": { + "headers": {}, + "body": { + "items": [] + } + } + } +} diff --git a/sdk/communication/azure-communication-administration/swagger/examples/GetPlansAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetPlansAsync.json new file mode 100644 index 000000000000..a6b541386b08 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetPlansAsync.json @@ -0,0 +1,145 @@ +{ + "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-administration/swagger/examples/GetReleaseByIdAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetReleaseByIdAsync.json new file mode 100644 index 000000000000..8e2d80f841a1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetReleaseByIdAsync.json @@ -0,0 +1,14 @@ +{ + "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-administration/swagger/examples/GetSearchOrderAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/GetSearchOrderAsync.json new file mode 100644 index 000000000000..97976bfaad90 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/GetSearchOrderAsync.json @@ -0,0 +1,28 @@ +{ + "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-administration/swagger/examples/RemoveNumberConfigurationAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/RemoveNumberConfigurationAsync.json new file mode 100644 index 000000000000..44e7c2e8e6c2 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/RemoveNumberConfigurationAsync.json @@ -0,0 +1,9 @@ +{ + "parameters": { + "api-version": "2020-07-20-preview1", + "phoneNumber": "+11234567890", + }, + "responses": { + "204": {} + } + } diff --git a/sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberCapabilitiesAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberCapabilitiesAsync.json new file mode 100644 index 000000000000..502bb6e5a1cb --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberCapabilitiesAsync.json @@ -0,0 +1,31 @@ +{ + "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-administration/swagger/examples/UpdateNumberConfigurationAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberConfigurationAsync.json new file mode 100644 index 000000000000..9e0a34149e23 --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberConfigurationAsync.json @@ -0,0 +1,15 @@ +{ + "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-administration/swagger/examples/UpdateSearchOrderAsync.json b/sdk/communication/azure-communication-administration/swagger/examples/UpdateSearchOrderAsync.json new file mode 100644 index 000000000000..139fb9ee0b1f --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/examples/UpdateSearchOrderAsync.json @@ -0,0 +1,12 @@ +{ + "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-administration/tests/phone_number_helper.py b/sdk/communication/azure-communication-administration/tests/phone_number_helper.py new file mode 100644 index 000000000000..445632f40c97 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/phone_number_helper.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------- +# 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 PhoneNumberUriReplacer(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']) + 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 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_cancel_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_cancel_search.yaml new file mode 100644 index 000000000000..16e182f33468 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_cancel_search.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 28 Sep 2020 21:07:45 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id_to_cancel/cancel?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Mon, 28 Sep 2020 21:07:46 GMT + ms-cv: + - QzclZYQsuk2dhRGLgFRISw.0 + x-processing-time: + - 1272ms + status: + code: 202 + message: Accepted +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_configure_number.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_configure_number.yaml new file mode 100644 index 000000000000..8f491bb6ab4a --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_configure_number.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: 'b''{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": + "ApplicationId", "azurePstnTargetId": "AzurePstnTargetId"}, "phoneNumber": "+1area_code_for_search4864953"}''' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '168' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 20:52:31 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/numberconfiguration/configure?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Mon, 28 Sep 2020 20:52:31 GMT + ms-cv: + - WNXx3LNakU6tV8xeGv33uA.0 + x-processing-time: + - 337ms + status: + code: 202 + message: Accepted +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_create_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_create_search.yaml new file mode 100644 index 000000000000..05ee0bd63076 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_create_search.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: 'b''b\''{"displayName": "testsearch20200014", "description": "testsearch20200014", + "phonePlanIds": ["phone_plan_id"], "areaCode": "area_code_for_search", "quantity": + 1}\''''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '166' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 20:58:50 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches?api-version=2020-07-20-preview1 + response: + body: '{"searchId": "sanitized"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:58:51 GMT + ms-cv: + - zBQqWRmiSEyC+AsrLoxytg.0 + transfer-encoding: + - chunked + x-processing-time: + - 1555ms + status: + code: 201 + message: Created +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml new file mode 100644 index 000000000000..ac47214be402 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 20:52:31 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/countries/US/areacodes?locationType=NotRequired&phonePlanId=phone_plan_id_area_codes&api-version=2020-07-20-preview1 + response: + body: '{"primaryAreaCodes": ["833"], "secondaryAreaCodes": [], "nextLink": null}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:52:31 GMT + ms-cv: + - s1K8bpPuzUG5W6OtrZE6hw.0 + transfer-encoding: + - chunked + x-processing-time: + - 570ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml new file mode 100644 index 000000000000..daf8996d7d83 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:32 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:32 GMT + ms-cv: + - T6S8W/xhekOa5x30VjpWOw.0 + transfer-encoding: + - chunked + x-processing-time: + - 562ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml new file mode 100644 index 000000000000..d5fc206076d1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: 'b''{"phoneNumber": "+1area_code_for_search4864953"}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '31' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 20:52:33 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 + response: + body: '{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": + "ApplicationId", "azurePstnTargetId": "AzurePstnTargetId"}}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:52:32 GMT + ms-cv: + - ISrlnWt250eHg9H0U7B6gA.0 + transfer-encoding: + - chunked + x-processing-time: + - 436ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml new file mode 100644 index 000000000000..912a36aa9f0a --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml @@ -0,0 +1,250 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:34 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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": "Concord", "value": "NOAM-US-CA-CO", + "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 Francisco", "value": "NOAM-US-CA-SF", "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": "Hartford", "value": "NOAM-US-CT-HA", "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": "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": "Chicopee", "value": "NOAM-US-MA-CH", "locationOptions": + []}]}]}, {"name": "MD", "value": "MD", "locationOptions": [{"labelId": "city", + "labelName": "City", "options": [{"name": "Bethesda", "value": "NOAM-US-MD-BE", + "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": "Alexandria", + "value": "NOAM-US-MN-AL", "locationOptions": []}, {"name": "Duluth", "value": + "NOAM-US-MN-DU", "locationOptions": []}, {"name": "Minneapolis", "value": "NOAM-US-MN-MI", + "locationOptions": []}, {"name": "St. Paul", "value": "NOAM-US-MN-SP", "locationOptions": + []}]}]}, {"name": "MO", "value": "MO", "locationOptions": [{"labelId": "city", + "labelName": "City", "options": [{"name": "Columbia", "value": "NOAM-US-MO-CO", + "locationOptions": []}, {"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": + "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": "Brentwood", "value": "NOAM-US-NY-BR", "locationOptions": + []}, {"name": "Elmira", "value": "NOAM-US-NY-EL", "locationOptions": []}, {"name": + "Hempstead", "value": "NOAM-US-NY-HE", "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": "Yonkers", "value": "NOAM-US-NY-YO", "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": "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": "Austin", "value": + "NOAM-US-TX-AU", "locationOptions": []}, {"name": "Corpus Christi", "value": + "NOAM-US-TX-CC", "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": "Lubbock", + "value": "NOAM-US-TX-LU", "locationOptions": []}, {"name": "Odessa", "value": + "NOAM-US-TX-OD", "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, 28 Sep 2020 20:52:34 GMT + ms-cv: + - TCixofN+fEuJbhQiyFlpQw.0 + transfer-encoding: + - chunked + x-processing-time: + - 787ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml new file mode 100644 index 000000000000..7f9cbf2b510a --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:35 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:35 GMT + ms-cv: + - aDDYFuvWA0C5m8vxbQZa7g.0 + transfer-encoding: + - chunked + x-processing-time: + - 350ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_search_by_id.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_search_by_id.yaml new file mode 100644 index 000000000000..ffde5892579c --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_search_by_id.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:36 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id?api-version=2020-07-20-preview1 + response: + body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": + "2020-09-28T19:51:03.7045074+00:00", "description": "mydescription", "phonePlanIds": + "sanitized", "areaCode": "area_code_for_search", "quantity": 1, "locationOptions": + [], "status": "Error", "phoneNumbers": "sanitized", "reservationExpiryDate": + "2020-09-28T20:07:15.1891834+00:00", "errorCode": 1011}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:52:36 GMT + ms-cv: + - rR2LYefRZUqEC64QM4XUtA.0 + transfer-encoding: + - chunked + x-processing-time: + - 540ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml new file mode 100644 index 000000000000..e2dc5adaffd9 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:36 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:36 GMT + ms-cv: + - ZrnIo+1IWUm2rr4BXwpD9Q.0 + transfer-encoding: + - chunked + x-processing-time: + - 621ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_releases.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_releases.yaml new file mode 100644 index 000000000000..5a2fdf532df1 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_releases.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:37 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:37 GMT + ms-cv: + - O7UjJU4tlkuR+ohvj2AJWw.0 + transfer-encoding: + - chunked + x-processing-time: + - 507ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml new file mode 100644 index 000000000000..b3b529132fe2 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:38 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/countries?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 + response: + body: '{"countries": [{"localizedName": "Australia", "countryCode": "AU"}, {"localizedName": + "Japan", "countryCode": "JP"}, {"localizedName": "United States", "countryCode": + "US"}], "nextLink": null}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:52:39 GMT + ms-cv: + - lTXki58ix0GoWp1Q+s7suw.0 + transfer-encoding: + - chunked + x-processing-time: + - 747ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml new file mode 100644 index 000000000000..c64cf8f9b087 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:39 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:40 GMT + ms-cv: + - CV4dPbtIc0KVqCsKbegUFw.0 + transfer-encoding: + - chunked + x-processing-time: + - 600ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml new file mode 100644 index 000000000000..4161b96c1d4e --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Date: + - Mon, 28 Sep 2020 20:52:40 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 20:52:40 GMT + ms-cv: + - hM4twEJ1hkelj8JvXL9vbA.0 + transfer-encoding: + - chunked + x-processing-time: + - 545ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_purchase_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_purchase_search.yaml new file mode 100644 index 000000000000..b0c435a51250 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_purchase_search.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Mon, 28 Sep 2020 21:05:56 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id_to_purchase/purchase?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Mon, 28 Sep 2020 21:05:56 GMT + ms-cv: + - xwaQWMyPXkmZISlt39/8sQ.0 + x-processing-time: + - 1104ms + status: + code: 202 + message: Accepted +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml new file mode 100644 index 000000000000..6523c0d0d697 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: '{"phoneNumbers": "sanitized"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + Date: + - Fri, 02 Oct 2020 22:26:28 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b2 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/administration/phonenumbers/releases?api-version=2020-07-20-preview1 + response: + body: '{"releaseId": "sanitized"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Fri, 02 Oct 2020 22:26:27 GMT + ms-cv: + - NlxnpgC8uU2r3FctCKo4VA.0 + transfer-encoding: + - chunked + x-processing-time: + - 735ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_update_capabilities.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_update_capabilities.yaml new file mode 100644 index 000000000000..2841aff8d502 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_update_capabilities.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: 'b''{"phoneNumberCapabilitiesUpdate": {"+1area_code_for_search4864953": + {"add": []}}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '64' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 20:52:41 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/capabilities?api-version=2020-07-20-preview1 + response: + body: '{"capabilitiesUpdateId": "sanitized"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Mon, 28 Sep 2020 20:52:42 GMT + ms-cv: + - 2wG6ECtNVUWh9yTw1e0F1Q.0 + transfer-encoding: + - chunked + x-processing-time: + - 882ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_cancel_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_cancel_search.yaml new file mode 100644 index 000000000000..b1c09cffa120 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_cancel_search.yaml @@ -0,0 +1,25 @@ +interactions: +- request: + body: '' + headers: + Date: + - Mon, 28 Sep 2020 22:29:32 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id/cancel?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: '0' + date: Mon, 28 Sep 2020 22:29:33 GMT + ms-cv: Br5JTlNBNE66iA7S70L1xg.0 + x-processing-time: 894ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_configure_number.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_configure_number.yaml new file mode 100644 index 000000000000..54437a5a0e4d --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_configure_number.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: 'b''{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": + "ApplicationId", "azurePstnTargetId": "AzurePstnTargetId"}, "phoneNumber": "+1area_code_for_search4866306"}''' + headers: + Content-Length: + - '168' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:20 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/numberconfiguration/configure?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: '0' + date: Mon, 28 Sep 2020 23:36:22 GMT + ms-cv: DaWW0P2dX0uW3zxujdXNZQ.0 + x-processing-time: 2855ms + status: + code: 202 + message: Accepted + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_create_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_create_search.yaml new file mode 100644 index 000000000000..e22e20d79e0c --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_create_search.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: 'b''b\''{"displayName": "testsearch20200014", "description": "testsearch20200014", + "phonePlanIds": ["phone_plan_id"], "areaCode": "area_code_for_search", "quantity": + 1}\''''' + headers: + Accept: + - application/json + Content-Length: + - '166' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:41:10 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches?api-version=2020-07-20-preview1 + response: + body: '{"searchId": "sanitized"}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:41:11 GMT + ms-cv: GgMka9ljgU6YI/sJAkla6A.0 + transfer-encoding: chunked + x-processing-time: 2452ms + status: + code: 201 + message: Created + url: https://sanitized.communication.azure.com/administration/phonenumbers/searches?api-version=2020-07-20-preview1 +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml new file mode 100644 index 000000000000..c7b1ea1b95c0 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:23 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/countries/US/areacodes?locationType=NotRequired&phonePlanId=phone_plan_id_area_codes&api-version=2020-07-20-preview1 + response: + body: '{"primaryAreaCodes": ["833"], "secondaryAreaCodes": [], "nextLink": null}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:36:24 GMT + ms-cv: xH2LI3yX8Uq7vldnjshP0g.0 + transfer-encoding: chunked + x-processing-time: 762ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml new file mode 100644 index 000000000000..5bb55438d9d3 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml @@ -0,0 +1,28 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:24 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:25 GMT + ms-cv: LDKKttbI10OoFujUhG/HEw.0 + transfer-encoding: chunked + x-processing-time: 936ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml new file mode 100644 index 000000000000..28d480278262 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml @@ -0,0 +1,61 @@ +interactions: +- request: + body: 'b''{"phoneNumber": "+1area_code_for_search4866306"}''' + headers: + Accept: + - application/json + Content-Length: + - '31' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:26 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: '0' + date: Mon, 28 Sep 2020 23:36:35 GMT + ms-cv: qMAd5RJcGUScTUQawpDqaA.0 + x-processing-time: 9353ms + status: + code: 500 + message: Internal Server Error + url: https://sanitized.communication.azure.com/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 +- request: + body: 'b''{"phoneNumber": "+1area_code_for_search4866306"}''' + headers: + Accept: + - application/json + Content-Length: + - '31' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:35 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/numberconfiguration?api-version=2020-07-20-preview1 + response: + body: '{"pstnConfiguration": {"callbackUrl": "https://callbackurl", "applicationId": + "ApplicationId", "azurePstnTargetId": "AzurePstnTargetId"}}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:36:40 GMT + ms-cv: oSC8jj4poEK70ADvTtkOAA.0 + transfer-encoding: chunked + x-processing-time: 5461ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml new file mode 100644 index 000000000000..647556757ed4 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml @@ -0,0 +1,240 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:41 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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": "Concord", "value": "NOAM-US-CA-CO", + "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": "Hartford", "value": "NOAM-US-CT-HA", "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": "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": "Chicopee", "value": "NOAM-US-MA-CH", "locationOptions": + []}]}]}, {"name": "MD", "value": "MD", "locationOptions": [{"labelId": "city", + "labelName": "City", "options": [{"name": "Bethesda", "value": "NOAM-US-MD-BE", + "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": "Alexandria", + "value": "NOAM-US-MN-AL", "locationOptions": []}, {"name": "Duluth", "value": + "NOAM-US-MN-DU", "locationOptions": []}, {"name": "Minneapolis", "value": "NOAM-US-MN-MI", + "locationOptions": []}, {"name": "St. Paul", "value": "NOAM-US-MN-SP", "locationOptions": + []}]}]}, {"name": "MO", "value": "MO", "locationOptions": [{"labelId": "city", + "labelName": "City", "options": [{"name": "Columbia", "value": "NOAM-US-MO-CO", + "locationOptions": []}, {"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": + "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": "Brentwood", "value": "NOAM-US-NY-BR", "locationOptions": + []}, {"name": "Elmira", "value": "NOAM-US-NY-EL", "locationOptions": []}, {"name": + "Hempstead", "value": "NOAM-US-NY-HE", "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": "Yonkers", "value": "NOAM-US-NY-YO", "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": "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": "Austin", "value": + "NOAM-US-TX-AU", "locationOptions": []}, {"name": "Corpus Christi", "value": + "NOAM-US-TX-CC", "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": "Lubbock", + "value": "NOAM-US-TX-LU", "locationOptions": []}, {"name": "Odessa", "value": + "NOAM-US-TX-OD", "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, 28 Sep 2020 23:36:41 GMT + ms-cv: 8nUq6GVatEacy/p8kiqRCw.0 + transfer-encoding: chunked + x-processing-time: 686ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml new file mode 100644 index 000000000000..8c436e502d75 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:42 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:42 GMT + ms-cv: yVEMC2mXsEyHauZmq0ZFPA.0 + transfer-encoding: chunked + x-processing-time: 459ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_get_search_by_id.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_search_by_id.yaml new file mode 100644 index 000000000000..2ca06363cb93 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_search_by_id.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:43 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id?api-version=2020-07-20-preview1 + response: + body: '{"searchId": "sanitized", "displayName": "mysearch20200928", "createdAt": + "2020-09-28T23:34:32.3360015+00:00", "description": "mydescription", "phonePlanIds": + "sanitized", "areaCode": "area_code_for_search", "quantity": 1, "locationOptions": + [], "status": "Reserved", "phoneNumbers": "sanitized", "reservationExpiryDate": + "2020-09-28T23:50:49.3839544+00:00"}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:36:43 GMT + ms-cv: P1zGoqpgT06fkeq8C6+pcw.0 + transfer-encoding: chunked + x-processing-time: 742ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml new file mode 100644 index 000000000000..d7800f27b062 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml @@ -0,0 +1,27 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:44 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:44 GMT + ms-cv: EH2E1Zka+EGFjbPr6TUNYA.0 + transfer-encoding: chunked + x-processing-time: 595ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml new file mode 100644 index 000000000000..aa78b029dece --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml @@ -0,0 +1,27 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:44 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:45 GMT + ms-cv: II5poJgvcUGGyAE6o/9qOA.0 + transfer-encoding: chunked + x-processing-time: 706ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml new file mode 100644 index 000000000000..c97cec973db3 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:45 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/countries?locale=en-US&skip=0&take=100&api-version=2020-07-20-preview1 + response: + body: '{"countries": [{"localizedName": "Australia", "countryCode": "AU"}, {"localizedName": + "Japan", "countryCode": "JP"}, {"localizedName": "United States", "countryCode": + "US"}], "nextLink": null}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:36:46 GMT + ms-cv: CVi9HTPzcEeEqH7obRf9tA.0 + transfer-encoding: chunked + x-processing-time: 901ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml new file mode 100644 index 000000000000..1138d9616585 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml @@ -0,0 +1,27 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:47 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:47 GMT + ms-cv: 2JfFR8NjR06p3+cz6Rcc4w.0 + transfer-encoding: chunked + x-processing-time: 519ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml new file mode 100644 index 000000000000..23f015234396 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml @@ -0,0 +1,27 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:48 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/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, 28 Sep 2020 23:36:48 GMT + ms-cv: qCvIQBx7mEev7YmmcSTSPQ.0 + transfer-encoding: chunked + x-processing-time: 583ms + 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-administration/tests/recordings/test_phone_number_administration_client_async.test_purchase_search.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_purchase_search.yaml new file mode 100644 index 000000000000..57b89ebc1547 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_purchase_search.yaml @@ -0,0 +1,25 @@ +interactions: +- request: + body: '' + headers: + Date: + - Mon, 28 Sep 2020 23:23:44 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/searches/search_id_to_purchase/purchase?api-version=2020-07-20-preview1 + response: + body: + string: '' + headers: + content-length: '0' + date: Mon, 28 Sep 2020 23:23:45 GMT + ms-cv: vznK/aE7iECofyT07WWRFQ.0 + x-processing-time: 1402ms + status: + code: 202 + message: Accepted + url: https://sanitized.communication.azure.com/administration/phonenumbers/searches/sanitized/purchase?api-version=2020-07-20-preview1 +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml new file mode 100644 index 000000000000..555ece0bf35d --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: '{"phoneNumbers": "sanitized"}' + headers: + Accept: + - application/json + Content-Length: + - '34' + Content-Type: + - application/json + Date: + - Fri, 02 Oct 2020 22:24:33 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b2 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/administration/phonenumbers/releases?api-version=2020-07-20-preview1 + response: + body: '{"releaseId": "sanitized"}' + headers: + content-type: application/json; charset=utf-8 + date: Fri, 02 Oct 2020 22:24:32 GMT + ms-cv: m6zSFyuKqkaYNOWKqeSZRg.0 + transfer-encoding: chunked + x-processing-time: 606ms + status: + code: 200 + message: OK + url: https://sanitized.communication.azure.com/administration/phonenumbers/releases?api-version=2020-07-20-preview1 +version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml new file mode 100644 index 000000000000..d851620517bd --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: 'b''{"phoneNumberCapabilitiesUpdate": {"+1area_code_for_search4866306": + {"add": []}}}''' + headers: + Accept: + - application/json + Content-Length: + - '64' + Content-Type: + - application/json + Date: + - Mon, 28 Sep 2020 23:36:48 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b1 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/administration/phonenumbers/capabilities?api-version=2020-07-20-preview1 + response: + body: '{"capabilitiesUpdateId": "sanitized"}' + headers: + content-type: application/json; charset=utf-8 + date: Mon, 28 Sep 2020 23:36:49 GMT + ms-cv: 6rr7snA3ek6iPySfBZZvHw.0 + transfer-encoding: chunked + x-processing-time: 1177ms + 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-administration/tests/test_phone_number_administration_client.py b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py new file mode 100644 index 000000000000..2f09606584ae --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py @@ -0,0 +1,261 @@ +# 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.administration import ( + PhoneNumberAdministrationClient, + PstnConfiguration, + NumberUpdateCapabilities, + CreateSearchOptions +) +from phone_number_helper import PhoneNumberUriReplacer +from _shared.testcase import ( + CommunicationTestCase, + BodyReplacerProcessor +) + +class PhoneNumberAdministrationClientTest(CommunicationTestCase): + + def setUp(self): + super(PhoneNumberAdministrationClientTest, self).setUp() + self.recording_processors.extend([ + BodyReplacerProcessor( + keys=["id", "token", "capabilitiesUpdateId", "phoneNumber", "phonePlanIds", + "phoneNumberCapabilitiesUpdates", "releaseId", + "phoneNumberReleaseStatusDetails", "searchId", "phoneNumbers", + "entities", "phonePlanGroups", "phonePlans", "phoneNumberCapabilitiesUpdate"] + ), + PhoneNumberUriReplacer()]) + self._phone_number_administration_client = PhoneNumberAdministrationClient.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_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH') + self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID') + self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE') + self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_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_search, + "area_code_for_search" + ) + self.scrubber.register_name_pair( + self.search_id, + "search_id" + ) + self.scrubber.register_name_pair( + self.search_id_to_purchase, + "search_id_to_purchase" + ) + self.scrubber.register_name_pair( + self.search_id_to_cancel, + "search_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_search = "area_code_for_search" + self.search_id = "search_id" + self.search_id_to_purchase = "search_id_to_purchase" + self.search_id_to_cancel = "search_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" + + @pytest.mark.live_test_only + 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 + 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 + ) + assert area_codes.primary_area_codes + + @pytest.mark.live_test_only + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + def test_release_phone_numbers(self): + releases_response = self._phone_number_administration_client.release_phone_numbers( + [self.phonenumber_to_release] + ) + assert releases_response.release_id + + @pytest.mark.live_test_only + def test_get_search_by_id(self): + phone_number_search_response = self._phone_number_administration_client.get_search_by_id( + search_id=self.search_id + ) + assert phone_number_search_response.search_id + + @pytest.mark.live_test_only + def test_create_search(self): + searchOptions = CreateSearchOptions( + area_code=self.area_code_for_search, + description="testsearch20200014", + display_name="testsearch20200014", + phone_plan_ids=[self.phone_plan_id], + quantity=1 + ) + search_response = self._phone_number_administration_client.create_search( + body=searchOptions + ) + assert search_response.search_id + + @pytest.mark.live_test_only + def test_cancel_search(self): + cancel_search_response = self._phone_number_administration_client.cancel_search( + search_id=self.search_id_to_cancel + ) + assert not cancel_search_response + + @pytest.mark.live_test_only + def test_purchase_search(self): + purchase_search_response = self._phone_number_administration_client.purchase_search( + search_id=self.search_id_to_purchase + ) + assert not purchase_search_response diff --git a/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py new file mode 100644 index 000000000000..f831124390d0 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py @@ -0,0 +1,319 @@ +# 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 +from azure.communication.administration.aio import PhoneNumberAdministrationClient +from azure.communication.administration import ( + PstnConfiguration, + NumberUpdateCapabilities, + CreateSearchOptions +) +from phone_number_helper import PhoneNumberUriReplacer +from _shared.asynctestcase import ( + AsyncCommunicationTestCase +) +from _shared.testcase import BodyReplacerProcessor, ResponseReplacerProcessor +import os + +class PhoneNumberAdministrationClientTestAsync(AsyncCommunicationTestCase): + + def setUp(self): + super(PhoneNumberAdministrationClientTestAsync, self).setUp() + self.recording_processors.extend([ + BodyReplacerProcessor( + keys=["id", "token", "capabilitiesUpdateId", "phoneNumber", "phonePlanIds", + "phoneNumberCapabilitiesUpdates", "releaseId", + "phoneNumberReleaseStatusDetails", "searchId", "phoneNumbers", + "entities", "phonePlanGroups", "phonePlans", "phoneNumberCapabilitiesUpdate"] + ), + PhoneNumberUriReplacer(), + ResponseReplacerProcessor(keys=[self._resource_name])]) + self._phone_number_administration_client = PhoneNumberAdministrationClient.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_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH') + self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID') + self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE') + self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_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_search, + "area_code_for_search" + ) + self.scrubber.register_name_pair( + self.search_id, + "search_id" + ) + self.scrubber.register_name_pair( + self.search_id_to_purchase, + "search_id_to_purchase" + ) + self.scrubber.register_name_pair( + self.search_id_to_cancel, + "search_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_search = "area_code_for_search" + self.search_id = "search_id" + self.search_id_to_purchase = "search_id_to_purchase" + self.search_id_to_cancel = "search_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" + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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() + + items = [] + async for item in pages: + items.append(item) + assert len(items) > 0 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_configure_number(self): + pstnConfig = PstnConfiguration( + callback_url="https://callbackurl", + application_id="ApplicationId" + ) + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + 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 + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_release_phone_numbers(self): + async with self._phone_number_administration_client: + releases_response = await self._phone_number_administration_client.release_phone_numbers( + [self.phonenumber_to_release] + ) + assert releases_response.release_id + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_get_search_by_id(self): + async with self._phone_number_administration_client: + phone_number_search_response = await self._phone_number_administration_client.get_search_by_id( + search_id=self.search_id + ) + assert phone_number_search_response.search_id + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_create_search(self): + searchOptions = CreateSearchOptions( + area_code=self.area_code_for_search, + description="testsearch20200014", + display_name="testsearch20200014", + phone_plan_ids=[self.phone_plan_id], + quantity=1 + ) + async with self._phone_number_administration_client: + search_response = await self._phone_number_administration_client.create_search( + body=searchOptions + ) + assert search_response.search_id + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_cancel_search(self): + async with self._phone_number_administration_client: + cancel_search_response = await self._phone_number_administration_client.cancel_search( + search_id=self.search_id_to_cancel + ) + assert not cancel_search_response + + @AsyncCommunicationTestCase.await_prepared_test + @pytest.mark.live_test_only + async def test_purchase_search(self): + async with self._phone_number_administration_client: + purchase_search_response = await self._phone_number_administration_client.purchase_search( + search_id=self.search_id_to_purchase + ) + assert not purchase_search_response diff --git a/sdk/communication/tests.yml b/sdk/communication/tests.yml index 34a16acfea6c..dfa72f6c02f7 100644 --- a/sdk/communication/tests.yml +++ b/sdk/communication/tests.yml @@ -9,4 +9,3 @@ jobs: EnvVars: AZURE_TEST_RUN_LIVE: 'true' AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING: $(python-communication-connection-string) - PHONE_NUMBER: $(python-communication-phone-number) \ No newline at end of file