From d6f002b5f115f9d14683bd216a74cb7196d0eb5f Mon Sep 17 00:00:00 2001 From: tural farhadov Date: Mon, 28 Sep 2020 13:02:44 -0700 Subject: [PATCH 01/11] Add tnm --- .../communication/administration/__init__.py | 43 + .../_phone_number_administration_client.py | 476 ++++ .../administration/_phonenumber/__init__.py | 0 .../_phonenumber/_generated/__init__.py | 16 + .../_phonenumber/_generated/_configuration.py | 58 + .../_phone_number_administration_service.py | 60 + .../_phonenumber/_generated/aio/__init__.py | 10 + .../_generated/aio/_configuration_async.py | 52 + ...one_number_administration_service_async.py | 52 + .../aio/operations_async/__init__.py | 13 + ..._number_administration_operations_async.py | 1344 +++++++++++ .../_generated/models/__init__.py | 141 ++ .../_phonenumber/_generated/models/_models.py | 1061 +++++++++ .../_generated/models/_models_py3.py | 1202 ++++++++++ ...one_number_administration_service_enums.py | 148 ++ .../_generated/operations/__init__.py | 13 + ..._phone_number_administration_operations.py | 1367 +++++++++++ .../_phonenumber/_generated/py.typed | 1 + .../administration/aio/__init__.py | 2 + ...hone_number_administration_client_async.py | 496 ++++ .../swagger/PHONE_NUMBER_SWAGGER.md | 22 + .../swagger/examples/CreateReleaseAsync.json | 16 + .../examples/CreateSearchOrderAsync.json | 28 + .../GetAcquiredTelephoneNumbersAsync.json | 39 + .../swagger/examples/GetAreaCodesAsync.json | 22 + .../swagger/examples/GetCountriesAsync.json | 28 + .../examples/GetNumberConfigurationAsync.json | 17 + .../swagger/examples/GetOrdersAsync.json | 13 + .../swagger/examples/GetPlansAsync.json | 145 ++ .../swagger/examples/GetReleaseByIdAsync.json | 14 + .../swagger/examples/GetSearchOrderAsync.json | 28 + .../RemoveNumberConfigurationAsync.json | 9 + .../UpdateNumberCapabilitiesAsync.json | 31 + .../UpdateNumberConfigurationAsync.json | 15 + .../examples/UpdateSearchOrderAsync.json | 12 + .../swagger/phone_number_swagger.json | 2060 +++++++++++++++++ sdk/communication/tests.yml | 1 - 37 files changed, 9054 insertions(+), 1 deletion(-) create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phone_number_administration_client.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_configuration.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/_phone_number_administration_service.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_configuration_async.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/_phone_number_administration_service_async.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/aio/operations_async/_phone_number_administration_operations_async.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models_py3.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_phone_number_administration_service_enums.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/__init__.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/operations/_phone_number_administration_operations.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/py.typed create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py create mode 100644 sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/CreateReleaseAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/CreateSearchOrderAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetAcquiredTelephoneNumbersAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetAreaCodesAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetCountriesAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetNumberConfigurationAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetOrdersAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetPlansAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetReleaseByIdAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/GetSearchOrderAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/RemoveNumberConfigurationAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberCapabilitiesAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/UpdateNumberConfigurationAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/examples/UpdateSearchOrderAsync.json create mode 100644 sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json 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 f50d95b3094ba..af00af53f3545 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,34 @@ # -------------------------------------------------------------------------- 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, +) + from ._shared.models import ( CommunicationUser, PhoneNumber, @@ -19,11 +41,32 @@ __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', + # 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 0000000000000..edc0a5657235f --- /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 0000000000000..e69de29bb2d1d 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 0000000000000..13fcd7af35ce0 --- /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 0000000000000..2043f061b4f2e --- /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 0000000000000..49830756eba47 --- /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 0000000000000..6ec72fc665b13 --- /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 0000000000000..7a46556ea91df --- /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 0000000000000..4c6d33b7c2507 --- /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 0000000000000..d34a375da5348 --- /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 0000000000000..ece0f7ad680c3 --- /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 localise 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 localise 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 [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, {}) + + 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 [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, {}) + + 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 localise 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 localise 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 localise 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 0000000000000..95f1084c42978 --- /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 0000000000000..d42c375ef60f5 --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models.py @@ -0,0 +1,1061 @@ +# 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 deatils. + + :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 searchs 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 searc. 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 + :param azure_pstn_target_id: Routable TargetId for the ACS Number. + :type azure_pstn_target_id: str + """ + + _validation = { + 'callback_url': {'required': True}, + } + + _attribute_map = { + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'azure_pstn_target_id': {'key': 'azurePstnTargetId', '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) + self.azure_pstn_target_id = kwargs.get('azure_pstn_target_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 capabilties 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 0000000000000..75166f982f1dc --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_phonenumber/_generated/models/_models_py3.py @@ -0,0 +1,1202 @@ +# 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 deatils. + + :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 searchs 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 searc. 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 + :param azure_pstn_target_id: Routable TargetId for the ACS Number. + :type azure_pstn_target_id: str + """ + + _validation = { + 'callback_url': {'required': True}, + } + + _attribute_map = { + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'application_id': {'key': 'applicationId', 'type': 'str'}, + 'azure_pstn_target_id': {'key': 'azurePstnTargetId', 'type': 'str'}, + } + + def __init__( + self, + *, + callback_url: str, + application_id: Optional[str] = None, + azure_pstn_target_id: Optional[str] = None, + **kwargs + ): + super(PstnConfiguration, self).__init__(**kwargs) + self.callback_url = callback_url + self.application_id = application_id + self.azure_pstn_target_id = azure_pstn_target_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 capabilties 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 0000000000000..5b53cc8756beb --- /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 0000000000000..50478d62d8d6f --- /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 0000000000000..e6e3bbe83f437 --- /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 localise 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 localise 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 [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, {}) + + 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 [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, {}) + + 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 localise 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 localise 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 localise 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 0000000000000..e5aff4f83af86 --- /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 383c5e75f78ee..f647dfa8f5060 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 0000000000000..50637b8ce7298 --- /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/swagger/PHONE_NUMBER_SWAGGER.md b/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md new file mode 100644 index 0000000000000..0948bd41e91b3 --- /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: ./phone_number_swagger.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 0000000000000..063a85f5aeac3 --- /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 0000000000000..7242d8403f3d9 --- /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 0000000000000..48b4666c6e38e --- /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 0000000000000..0cc7ce546ca05 --- /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 0000000000000..eee04b0bd0c8a --- /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 0000000000000..3cfd910129cb5 --- /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 0000000000000..4ef8ad59fc4d2 --- /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 0000000000000..a6b541386b089 --- /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 0000000000000..8e2d80f841a19 --- /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 0000000000000..97976bfaad900 --- /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 0000000000000..44e7c2e8e6c22 --- /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 0000000000000..502bb6e5a1cb3 --- /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 0000000000000..9e0a34149e23e --- /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 0000000000000..139fb9ee0b1f7 --- /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/swagger/phone_number_swagger.json b/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json new file mode 100644 index 0000000000000..c4e9f78440b9a --- /dev/null +++ b/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json @@ -0,0 +1,2060 @@ +{ + "swagger": "2.0", + "info": { + "title": "Phone Number Administration Service", + "description": "Phone Number Administration Service", + "contact": { + "email": "acsdevexdisc@microsoft.com" + }, + "version": "2020-07-20-preview1" + }, + "paths": { + "/administration/phonenumbers/phonenumbers": { + "get": { + "tags": [ + "AcquiredNumbers" + ], + "summary": "Gets the list of the acquired phone numbers.", + "operationId": "PhoneNumberAdministration_GetAllPhoneNumbers", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/AcquiredPhoneNumbers" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phoneNumbers" + }, + "x-ms-examples": { + "List acquired phone numbers": { + "$ref": "./examples/GetAcquiredPhoneNumbersAsync.json" + } + } + } + }, + "/administration/phonenumbers/countries/{countryCode}/areacodes": { + "post": { + "tags": [ + "AreaCodes" + ], + "summary": "Gets a list of the supported area codes", + "operationId": "PhoneNumberAdministration_GetAllAreaCodes", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locationType", + "description": "The type of location information required by the plan.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "phonePlanId", + "description": "The plan id from which to search area codes.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Location options for when location type is selection.", + "schema": { + "$ref": "#/definitions/LocationOptionsQueries" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/AreaCodes" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get area codes": { + "$ref": "./examples/GetAreaCodesAsync.json" + } + } + } + }, + "/administration/phonenumbers/capabilities/{capabilitiesUpdateId}": { + "get": { + "tags": [ + "Capabilities" + ], + "summary": "Get capabilities by capabilities update id.", + "operationId": "PhoneNumberAdministration_GetCapabilitiesUpdate", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "capabilitiesUpdateId", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/UpdatePhoneNumberCapabilitiesResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get number capabilities update": { + "$ref": "./examples/GetNumberCapabilitiesUpdateAsync.json" + } + } + } + }, + "/administration/phonenumbers/capabilities": { + "post": { + "tags": [ + "Capabilities" + ], + "summary": "Adds or removes phone number capabilities", + "operationId": "PhoneNumberAdministration_UpdateCapabilities", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "", + "schema": { + "$ref": "#/definitions/UpdateNumberCapabilitiesRequest" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/UpdateNumberCapabilitiesResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update number capabilities": { + "$ref": "./examples/UpdateNumberCapabilitiesAsync.json" + } + } + } + }, + "/administration/phonenumbers/countries": { + "get": { + "tags": [ + "Countries" + ], + "summary": "Gets a list of supported countries", + "operationId": "PhoneNumberAdministration_GetAllSupportedCountries", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberCountries" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "countries" + }, + "x-ms-examples": { + "Get countries": { + "$ref": "./examples/GetCountriesAsync.json" + } + } + } + }, + "/administration/phonenumbers/numberconfiguration": { + "post": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for getting number configurations", + "operationId": "PhoneNumberAdministration_GetNumberConfiguration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "The phone number whose configuration is to be fetched", + "schema": { + "$ref": "#/definitions/NumberConfigurationPhoneNumber" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/NumberConfigurationResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get number configuration for phone number": { + "$ref": "./examples/GetNumberConfigurationAsync.json" + } + } + } + }, + "/administration/phonenumbers/numberconfiguration/configure": { + "patch": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for configuring a pstn number", + "operationId": "PhoneNumberAdministration_ConfigureNumber", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Details of pstn number configuration of the given phoneNumber", + "schema": { + "$ref": "#/definitions/NumberConfiguration" + } + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Configure phone number": { + "$ref": "./examples/ConfigurePhoneNumberAsync.json" + } + } + } + }, + "/administration/phonenumbers/numberconfiguration/unconfigure": { + "patch": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for unconfiguring a pstn number by removing the configuration", + "operationId": "PhoneNumberAdministration_UnconfigureNumber", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "The phone number to un-configure", + "schema": { + "$ref": "#/definitions/NumberConfigurationPhoneNumber" + } + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Unconfigure phone number": { + "$ref": "./examples/UnconfigurePhoneNumberAsync.json" + } + } + } + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of phone plan groups for the given country", + "operationId": "PhoneNumberAdministration_GetPhonePlanGroups", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "includeRateInformation", + "type": "boolean", + "default": false + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhonePlanGroups" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phonePlanGroups" + }, + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetPhonePlanGroupsAsync.json" + } + } + } + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of phone plans for a phone plan group", + "operationId": "PhoneNumberAdministration_GetPhonePlans", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanGroupId", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhonePlansResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phonePlans" + }, + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetPhonePlansAsync.json" + } + } + } + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of location options for a phone plan", + "operationId": "PhoneNumberAdministration_GetPhonePlanLocationOptions", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanGroupId", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanId", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/LocationOptionsResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetLocationOptionsAsync.json" + } + } + } + }, + "/administration/phonenumbers/releases/{releaseId}": { + "get": { + "tags": [ + "Release" + ], + "summary": "Gets a release by a release id", + "operationId": "PhoneNumberAdministration_GetReleaseById", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "releaseId", + "description": "Represents the release id", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberRelease" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get release by id": { + "$ref": "./examples/GetReleaseByIdAsync.json" + } + } + } + }, + "/administration/phonenumbers/releases": { + "post": { + "tags": [ + "Release" + ], + "summary": "Creates a release for the given phone numbers", + "operationId": "PhoneNumberAdministration_ReleasePhoneNumbers", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Config api Release request", + "schema": { + "$ref": "#/definitions/ReleaseRequest" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReleaseResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get release": { + "$ref": "./examples/CreateReleaseAsync.json" + } + } + }, + "get": { + "tags": [ + "Release" + ], + "summary": "Gets a list of all releases", + "operationId": "PhoneNumberAdministration_GetAllReleases", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberEntities" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "entities" + }, + "x-ms-examples": { + "Get all releases": { + "$ref": "./examples/GetAllReleasesAsync.json" + } + } + } + }, + "/administration/phonenumbers/searches/{searchId}": { + "get": { + "tags": [ + "Search" + ], + "summary": "Get search by search id", + "operationId": "PhoneNumberAdministration_GetSearchById", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be searched for", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberSearch" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get search by search id": { + "$ref": "./examples/GetSearchByIdAsync.json" + } + } + } + }, + "/administration/phonenumbers/searches": { + "post": { + "tags": [ + "Search" + ], + "summary": "Creates a phone number search", + "operationId": "PhoneNumberAdministration_CreateSearch", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Defines the search options", + "schema": { + "$ref": "#/definitions/CreateSearchOptions" + } + } + ], + "responses": { + "201": { + "description": "Success", + "schema": { + "$ref": "#/definitions/CreateSearchResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create search": { + "$ref": "./examples/CreateSearchAsync.json" + } + } + }, + "get": { + "tags": [ + "Search" + ], + "summary": "Gets a list of all searches", + "operationId": "PhoneNumberAdministration_GetAllSearches", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberEntities" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "entities" + }, + "x-ms-examples": { + "Get all searches": { + "$ref": "./examples/GetAllSearchesAsync.json" + } + } + } + }, + "/administration/phonenumbers/searches/{searchId}/cancel": { + "post": { + "tags": [ + "Search" + ], + "summary": "Cancels the search. This means existing numbers in the search will be made available.", + "operationId": "PhoneNumberAdministration_CancelSearch", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be canceled", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Cancel phone number search": { + "$ref": "./examples/CancelSearchAsync.json" + } + } + } + }, + "/administration/phonenumbers/searches/{searchId}/purchase": { + "post": { + "tags": [ + "Search" + ], + "summary": "Purchases the phone number search.", + "operationId": "PhoneNumberAdministration_PurchaseSearch", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be purchased", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Purchase phone number search": { + "$ref": "./examples/PurchaseSearchAsync.json" + } + } + } + } + }, + "definitions": { + "AcquiredPhoneNumber": { + "description": "Represents an acquired phone number.", + "required": [ + "acquiredCapabilities", + "availableCapabilities", + "phoneNumber" + ], + "type": "object", + "properties": { + "phoneNumber": { + "description": "String of the E.164 format of the phone number", + "type": "string" + }, + "acquiredCapabilities": { + "description": "The set of all acquired capabilities of the phone number.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + }, + "availableCapabilities": { + "description": "The set of all available capabilities that can be acquired for this phone number.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + }, + "assignmentStatus": { + "description": "The assignment status of the phone number. Conveys what type of entity the number is assigned to.", + "enum": [ + "Unassigned", + "Unknown", + "UserAssigned", + "ConferenceAssigned", + "FirstPartyAppAssigned", + "ThirdPartyAppAssigned" + ], + "type": "string", + "x-ms-enum": { + "name": "AssignmentStatus", + "modelAsString": true + } + }, + "placeName": { + "description": "The name of the place of the phone number.", + "type": "string" + }, + "activationState": { + "description": "The activation state of the phone number. Can be \"Activated\", \"AssignmentPending\", \"AssignmentFailed\", \"UpdatePending\", \"UpdateFailed\"", + "enum": [ + "Activated", + "AssignmentPending", + "AssignmentFailed", + "UpdatePending", + "UpdateFailed" + ], + "type": "string", + "x-ms-enum": { + "name": "ActivationState", + "modelAsString": true + } + } + } + }, + "AcquiredPhoneNumbers": { + "description": "A wrapper of list of phone numbers", + "type": "object", + "properties": { + "phoneNumbers": { + "description": "Represents a list of phone numbers", + "type": "array", + "items": { + "$ref": "#/definitions/AcquiredPhoneNumber" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "ErrorBody": { + "description": "Represents a service error response body.", + "type": "object", + "properties": { + "code": { + "description": "The error code in the error response.", + "type": "string" + }, + "message": { + "description": "The error message in the error response.", + "type": "string" + } + } + }, + "ErrorResponse": { + "description": "Represents a service error response.", + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/ErrorBody" + } + } + }, + "LocationOptionsQuery": { + "description": "Represents a location options parameter, used for fetching area codes.", + "type": "object", + "properties": { + "labelId": { + "description": "Represents the location option label id, returned from the GetLocationOptions API.", + "type": "string" + }, + "optionsValue": { + "description": "Represents the location options value, returned from the GetLocationOptions API.", + "type": "string" + } + } + }, + "LocationOptionsQueries": { + "description": "Represents a list of location option queries, used for fetching area codes.", + "type": "object", + "properties": { + "locationOptions": { + "description": "Represents the underlying list of countries.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsQuery" + } + } + } + }, + "AreaCodes": { + "description": "Represents a list of area codes.", + "type": "object", + "properties": { + "primaryAreaCodes": { + "description": "Represents the list of primary area codes.", + "type": "array", + "items": { + "type": "string" + } + }, + "secondaryAreaCodes": { + "description": "Represents the list of secondary area codes.", + "type": "array", + "items": { + "type": "string" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "NumberUpdateCapabilities": { + "description": "Represents an individual number capabilities update request", + "type": "object", + "properties": { + "add": { + "description": "Capabilities to be added to a phone number", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + }, + "remove": { + "description": "Capabilities to be removed from a phone number", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + } + } + }, + "UpdatePhoneNumberCapabilitiesResponse": { + "description": "Response for getting a phone number update capabilities.", + "type": "object", + "properties": { + "capabilitiesUpdateId": { + "description": "The id of the phone number capabilties update", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "The time the capabilities update was created", + "type": "string" + }, + "capabilitiesUpdateStatus": { + "description": "Status of the capabilities update.", + "enum": [ + "Pending", + "InProgress", + "Complete", + "Error" + ], + "type": "string", + "x-ms-enum": { + "name": "CapabilitiesUpdateStatus", + "modelAsString": true + } + }, + "phoneNumberCapabilitiesUpdates": { + "description": "The capabilities update for each of a set of phone numbers.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NumberUpdateCapabilities" + } + } + } + }, + "UpdateNumberCapabilitiesRequest": { + "description": "Represents a numbers capabilities update request", + "required": [ + "phoneNumberCapabilitiesUpdate" + ], + "type": "object", + "properties": { + "phoneNumberCapabilitiesUpdate": { + "description": "The map of phone numbers to the capabilities update applied to the phone number.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NumberUpdateCapabilities" + } + } + } + }, + "UpdateNumberCapabilitiesResponse": { + "description": "Represents a number capability update response.", + "required": [ + "capabilitiesUpdateId" + ], + "type": "object", + "properties": { + "capabilitiesUpdateId": { + "description": "The capabilities id", + "type": "string" + } + } + }, + "PhoneNumberCountry": { + "description": "Represents a country.", + "required": [ + "countryCode", + "localizedName" + ], + "type": "object", + "properties": { + "localizedName": { + "description": "Represents the name of the country.", + "type": "string" + }, + "countryCode": { + "description": "Represents the abbreviated name of the country.", + "type": "string" + } + } + }, + "PhoneNumberCountries": { + "description": "Represents a wrapper around a list of countries.", + "type": "object", + "properties": { + "countries": { + "description": "Represents the underlying list of countries.", + "type": "array", + "items": { + "$ref": "#/definitions/PhoneNumberCountry" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "NumberConfigurationPhoneNumber": { + "description": "The phone number wrapper representing a number configuration request", + "required": [ + "phoneNumber" + ], + "type": "object", + "properties": { + "phoneNumber": { + "description": "The phone number in the E.164 format", + "type": "string" + } + } + }, + "PstnConfiguration": { + "description": "Definition for pstn number configuration", + "required": [ + "callbackUrl" + ], + "type": "object", + "properties": { + "callbackUrl": { + "description": "The webhook URL on the phone number configuration.", + "type": "string" + }, + "applicationId": { + "description": "The application id of the application to which to configure", + "type": "string" + }, + "azurePstnTargetId": { + "description": "Routable TargetId for the ACS Number", + "type": "string" + } + } + }, + "NumberConfigurationResponse": { + "description": "Definition for number configuration", + "required": [ + "pstnConfiguration" + ], + "type": "object", + "properties": { + "pstnConfiguration": { + "$ref": "#/definitions/PstnConfiguration" + } + } + }, + "NumberConfiguration": { + "description": "Definition for number configuration", + "required": [ + "phoneNumber", + "pstnConfiguration" + ], + "type": "object", + "properties": { + "pstnConfiguration": { + "$ref": "#/definitions/PstnConfiguration" + }, + "phoneNumber": { + "description": "The phone number to configure", + "type": "string" + } + } + }, + "CarrierDetails": { + "description": "Represents carrier details.", + "type": "object", + "properties": { + "name": { + "description": "Name of carrier details", + "type": "string" + }, + "localizedName": { + "description": "Display name of carrier details", + "type": "string" + } + } + }, + "RateInformation": { + "description": "Represents a wrapper of rate information", + "type": "object", + "properties": { + "monthlyRate": { + "format": "double", + "description": "The monthly rate of a phone plan group", + "type": "number" + }, + "currencyType": { + "description": "The currency of a phone plan group", + "enum": [ + "USD" + ], + "type": "string", + "x-ms-enum": { + "name": "CurrencyType", + "modelAsString": true + } + }, + "rateErrorMessage": { + "description": "The error code of a phone plan group", + "type": "string" + } + } + }, + "PhonePlanGroup": { + "description": "Represents a plan group.", + "required": [ + "localizedDescription", + "localizedName", + "phonePlanGroupId" + ], + "type": "object", + "properties": { + "phonePlanGroupId": { + "description": "The id of the plan group", + "type": "string" + }, + "phoneNumberType": { + "description": "The phone number type of the plan group", + "enum": [ + "Unknown", + "Geographic", + "TollFree", + "Indirect" + ], + "type": "string", + "x-ms-enum": { + "name": "PhoneNumberType", + "modelAsString": true + } + }, + "localizedName": { + "description": "The name of the plan group.", + "type": "string" + }, + "localizedDescription": { + "description": "The description of the plan group.", + "type": "string" + }, + "carrierDetails": { + "$ref": "#/definitions/CarrierDetails" + }, + "rateInformation": { + "$ref": "#/definitions/RateInformation" + } + } + }, + "PhonePlanGroups": { + "description": "Represents a wrapper of list of plan groups.", + "type": "object", + "properties": { + "phonePlanGroups": { + "description": "The underlying list of phone plan groups.", + "type": "array", + "items": { + "$ref": "#/definitions/PhonePlanGroup" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "PhonePlan": { + "description": "Represents a phone plan.", + "required": [ + "localizedName", + "locationType", + "phonePlanId" + ], + "type": "object", + "properties": { + "phonePlanId": { + "description": "The phone plan id", + "type": "string" + }, + "localizedName": { + "description": "The name of the phone plan", + "type": "string" + }, + "locationType": { + "description": "The location type of the phone plan.", + "enum": [ + "CivicAddress", + "NotRequired", + "Selection" + ], + "type": "string", + "x-ms-enum": { + "name": "LocationType", + "modelAsString": true + } + }, + "areaCodes": { + "description": "The list of available area codes in the phone plan.", + "type": "array", + "items": { + "type": "string" + } + }, + "capabilities": { + "description": "Capabilities of the phone plan.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + }, + "maximumSearchSize": { + "format": "int32", + "description": "The maximum number of phone numbers one can acquire in a search in this phone plan.", + "type": "integer" + } + } + }, + "PhonePlansResponse": { + "description": "Represents a wrapper around a list of countries.", + "type": "object", + "properties": { + "phonePlans": { + "description": "Represents the underlying list of phone plans.", + "type": "array", + "items": { + "$ref": "#/definitions/PhonePlan" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "LocationOptionsDetails": { + "description": "Represents location options deatils.", + "type": "object", + "properties": { + "name": { + "description": "The name of the location options", + "type": "string" + }, + "value": { + "description": "The abbreviated name of the location options", + "type": "string" + }, + "locationOptions": { + "description": "The underlying location options", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptions" + } + } + } + }, + "LocationOptions": { + "description": "Represents a location options.", + "type": "object", + "properties": { + "labelId": { + "description": "The label id of the location.", + "type": "string" + }, + "labelName": { + "description": "The display name of the location.", + "type": "string" + }, + "options": { + "description": "The underlying location option details.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } + } + } + }, + "LocationOptionsResponse": { + "description": "Represents a wrapper around a list of location options.", + "type": "object", + "properties": { + "locationOptions": { + "$ref": "#/definitions/LocationOptions" + } + } + }, + "PhoneNumberReleaseDetails": { + "type": "object", + "properties": { + "status": { + "description": "The release status of a phone number.", + "enum": [ + "Pending", + "Success", + "Error", + "InProgress" + ], + "type": "string", + "x-ms-enum": { + "name": "PhoneNumberReleaseStatus", + "modelAsString": true + } + }, + "errorCode": { + "format": "int32", + "description": "The error code in the case the status is error.", + "type": "integer" + } + } + }, + "PhoneNumberRelease": { + "description": "Represents a release", + "type": "object", + "properties": { + "releaseId": { + "description": "The id of the release.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "The creation time of the release.", + "type": "string" + }, + "status": { + "description": "The release status.", + "enum": [ + "Pending", + "InProgress", + "Complete", + "Failed", + "Expired" + ], + "type": "string", + "x-ms-enum": { + "name": "ReleaseStatus", + "modelAsString": true + } + }, + "errorMessage": { + "description": "The underlying error message of a release.", + "type": "string" + }, + "phoneNumberReleaseStatusDetails": { + "description": "The list of phone numbers in the release, mapped to its individual statuses.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/PhoneNumberReleaseDetails" + } + } + } + }, + "ReleaseRequest": { + "description": "Represents a release request.", + "required": [ + "phoneNumbers" + ], + "type": "object", + "properties": { + "phoneNumbers": { + "description": "The list of phone numbers in the release request.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "ReleaseResponse": { + "description": "Represents a release response.", + "required": [ + "releaseId" + ], + "type": "object", + "properties": { + "releaseId": { + "description": "The release id of a created release.", + "type": "string" + } + } + }, + "PhoneNumberEntity": { + "description": "Represents a phone number entity, as part of the response when calling get all searches or releases.", + "type": "object", + "properties": { + "id": { + "description": "The id of the entity. It is the search id of a searc. It is the release id of a release.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "Date and time the entity is created.", + "type": "string" + }, + "displayName": { + "description": "Name of the entity.", + "type": "string" + }, + "quantity": { + "format": "int32", + "description": "Quantity of requested phone numbers in the entity.", + "type": "integer" + }, + "quantityObtained": { + "format": "int32", + "description": "Quantity of acquired phone numbers in the entity.", + "type": "integer" + }, + "status": { + "description": "Status of the entity.", + "type": "string" + }, + "focDate": { + "format": "date-time", + "description": "The Firm Order Confirmation date of the phone number entity.", + "type": "string" + } + } + }, + "PhoneNumberEntities": { + "description": "Represents a list of searchs or releases, as part of the response when fetching all searches or releases.", + "type": "object", + "properties": { + "entities": { + "description": "The underlying list of entities.", + "type": "array", + "items": { + "$ref": "#/definitions/PhoneNumberEntity" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "PhoneNumberSearch": { + "description": "Represents a phone number search", + "type": "object", + "properties": { + "searchId": { + "description": "The id of the search.", + "type": "string" + }, + "displayName": { + "description": "The name of the search.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "The creation time of the search.", + "type": "string" + }, + "description": { + "description": "The description of the search.", + "type": "string" + }, + "phonePlanIds": { + "description": "The phone plan ids of the search.", + "type": "array", + "items": { + "type": "string" + } + }, + "areaCode": { + "description": "The area code of the search.", + "type": "string" + }, + "quantity": { + "format": "int32", + "description": "The quantity of phone numbers in the search.", + "type": "integer" + }, + "locationOptions": { + "description": "The location options of the search.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } + }, + "status": { + "description": "The status of the search.", + "enum": [ + "Pending", + "InProgress", + "Reserved", + "Expired", + "Expiring", + "Completing", + "Refreshing", + "Success", + "Manual", + "Cancelled", + "Cancelling", + "Error", + "PurchasePending" + ], + "type": "string", + "x-ms-enum": { + "name": "SearchStatus", + "modelAsString": true + } + }, + "phoneNumbers": { + "description": "The list of phone numbers in the search, in the case the status is reserved or success.", + "type": "array", + "items": { + "type": "string" + } + }, + "reservationExpiryDate": { + "format": "date-time", + "description": "The date that search expires and the numbers become available.", + "type": "string" + }, + "errorCode": { + "format": "int32", + "description": "The error code of the search.", + "type": "integer" + } + } + }, + "CreateSearchOptions": { + "description": "Represents a search creation option.", + "required": [ + "areaCode", + "description", + "displayName", + "phonePlanIds" + ], + "type": "object", + "properties": { + "displayName": { + "description": "Display name of the search.", + "maxLength": 255, + "type": "string" + }, + "description": { + "description": "Description of the search.", + "maxLength": 255, + "type": "string" + }, + "phonePlanIds": { + "description": "The plan subtype ids from which to create the search.", + "type": "array", + "items": { + "type": "string" + } + }, + "areaCode": { + "description": "The area code from which to create the search.", + "type": "string" + }, + "quantity": { + "format": "int32", + "description": "The quantity of phone numbers to request.", + "maximum": 2147483647, + "minimum": 1, + "type": "integer" + }, + "locationOptions": { + "description": "The location options of the search.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } + } + } + }, + "CreateSearchResponse": { + "description": "Represents a search creation response.", + "required": [ + "searchId" + ], + "type": "object", + "properties": { + "searchId": { + "description": "The search id of the search that was created.", + "type": "string" + } + } + } + }, + "parameters": { + "ApiVersionParameter": { + "in": "query", + "name": "api-version", + "description": "Version of API to invoke", + "required": true, + "type": "string" + }, + "Endpoint": { + "in": "path", + "name": "endpoint", + "description": "The endpoint of the Azure Communication resource.", + "required": true, + "type": "string", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client" + } + }, + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + }, + "description": "Azure Active Directory OAuth2 Flow" + } + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + } +} \ No newline at end of file diff --git a/sdk/communication/tests.yml b/sdk/communication/tests.yml index 34a16acfea6cb..dfa72f6c02f76 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 From fe6a534ed00c55764ecfbcc809e58f9a0896a874 Mon Sep 17 00:00:00 2001 From: Eason Date: Wed, 30 Sep 2020 11:39:29 -0700 Subject: [PATCH 02/11] Azure Communication Service - Phone Number Administration - Live Test (#14109) * add tnm live tests and recordings * address comments * assert functions returning none * sync srubbed config and playback config Co-authored-by: Eason Yang --- .../communication/administration/__init__.py | 2 + .../tests/phone_number_helper.py | 26 ++ ...inistration_client.test_cancel_search.yaml | 36 +++ ...stration_client.test_configure_number.yaml | 39 +++ ...inistration_client.test_create_search.yaml | 41 +++ ...ration_client.test_get_all_area_codes.yaml | 39 +++ ...n_client.test_get_capabilities_update.yaml | 36 +++ ..._client.test_get_number_configuration.yaml | 40 +++ ....test_get_phone_plan_location_options.yaml | 250 ++++++++++++++ ...tration_client.test_get_release_by_id.yaml | 37 +++ ...stration_client.test_get_search_by_id.yaml | 39 +++ ...on_client.test_list_all_phone_numbers.yaml | 35 ++ ...tration_client.test_list_all_releases.yaml | 35 ++ ...ent.test_list_all_supported_countries.yaml | 37 +++ ...on_client.test_list_phone_plan_groups.yaml | 35 ++ ...stration_client.test_list_phone_plans.yaml | 35 ++ ...istration_client.test_purchase_search.yaml | 36 +++ ...ation_client.test_update_capabilities.yaml | 40 +++ ...ation_client_async.test_cancel_search.yaml | 25 ++ ...on_client_async.test_configure_number.yaml | 30 ++ ...ation_client_async.test_create_search.yaml | 33 ++ ..._client_async.test_get_all_area_codes.yaml | 31 ++ ...nt_async.test_get_capabilities_update.yaml | 28 ++ ...t_async.test_get_number_configuration.yaml | 61 ++++ ....test_get_phone_plan_location_options.yaml | 240 ++++++++++++++ ...n_client_async.test_get_release_by_id.yaml | 29 ++ ...on_client_async.test_get_search_by_id.yaml | 31 ++ ...ent_async.test_list_all_phone_numbers.yaml | 27 ++ ...n_client_async.test_list_all_releases.yaml | 27 ++ ...ync.test_list_all_supported_countries.yaml | 29 ++ ...ent_async.test_list_phone_plan_groups.yaml | 27 ++ ...on_client_async.test_list_phone_plans.yaml | 27 ++ ...ion_client_async.test_purchase_search.yaml | 25 ++ ...client_async.test_update_capabilities.yaml | 32 ++ ...test_phone_number_administration_client.py | 249 ++++++++++++++ ...hone_number_administration_client_async.py | 305 ++++++++++++++++++ 36 files changed, 2094 insertions(+) create mode 100644 sdk/communication/azure-communication-administration/tests/phone_number_helper.py create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_cancel_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_configure_number.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_create_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_all_area_codes.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_capabilities_update.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_number_configuration.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_phone_plan_location_options.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_release_by_id.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_get_search_by_id.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_phone_numbers.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_releases.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_all_supported_countries.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plan_groups.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_list_phone_plans.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_purchase_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_update_capabilities.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_cancel_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_configure_number.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_create_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_all_area_codes.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_capabilities_update.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_number_configuration.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_phone_plan_location_options.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_release_by_id.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_get_search_by_id.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_phone_numbers.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_releases.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_all_supported_countries.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plan_groups.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_list_phone_plans.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_purchase_search.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_update_capabilities.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py create mode 100644 sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py 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 af00af53f3545..2864e79e5e5e0 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -31,6 +31,7 @@ ReleaseResponse, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse, + CreateSearchOptions ) from ._shared.models import ( @@ -66,6 +67,7 @@ 'ReleaseResponse', 'UpdateNumberCapabilitiesResponse', 'UpdatePhoneNumberCapabilitiesResponse', + 'CreateSearchOptions', # from _shared 'CommunicationUser', 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 0000000000000..445632f40c971 --- /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 0000000000000..16e182f33468c --- /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 0000000000000..8f491bb6ab4a5 --- /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 0000000000000..05ee0bd63076a --- /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 0000000000000..ac47214be402f --- /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 0000000000000..daf8996d7d836 --- /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 0000000000000..d5fc206076d16 --- /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 0000000000000..912a36aa9f0ad --- /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 0000000000000..7f9cbf2b510a3 --- /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 0000000000000..ffde5892579cb --- /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 0000000000000..e2dc5adaffd96 --- /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 0000000000000..5a2fdf532df18 --- /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 0000000000000..b3b529132fe29 --- /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 0000000000000..c64cf8f9b0875 --- /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 0000000000000..4161b96c1d4ec --- /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 0000000000000..b0c435a512502 --- /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_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 0000000000000..2841aff8d5024 --- /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 0000000000000..b1c09cffa120d --- /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 0000000000000..54437a5a0e4d6 --- /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 0000000000000..e22e20d79e0cb --- /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 0000000000000..c7b1ea1b95c0e --- /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 0000000000000..5bb55438d9d32 --- /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 0000000000000..28d480278262d --- /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 0000000000000..647556757ed46 --- /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 0000000000000..8c436e502d759 --- /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 0000000000000..2ca06363cb93b --- /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 0000000000000..d7800f27b0622 --- /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 0000000000000..aa78b029deced --- /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 0000000000000..c97cec973db3d --- /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 0000000000000..1138d96165853 --- /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 0000000000000..23f0152343964 --- /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 0000000000000..57b89ebc1547d --- /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_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 0000000000000..d851620517bd5 --- /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 0000000000000..90b6b50f35ecf --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py @@ -0,0 +1,249 @@ +# 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_TNM_COUNTRY_CODE') + self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_LOCALE') + self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_GROUP_ID') + self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID') + self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID_AREA_CODES') + self.area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_AREA_CODE_FOR_SEARCH') + self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID') + self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_PURCHASE') + self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_CANCEL') + self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_CONFIGURE') + self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_GET_CONFIG') + self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_UNCONFIGURE') + self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_FOR_CAPABILITIES') + self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_CAPABILITIES_ID') + self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_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.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.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_unconfigure + ) + 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", + azure_pstn_target_id="AzurePstnTargetId" + ) + configure_number_response = self._phone_number_administration_client.configure_number( + pstn_configuration=pstnConfig, + phone_number=self.phonenumber_to_unconfigure + ) + 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_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 0000000000000..178515f52e047 --- /dev/null +++ b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client_async.py @@ -0,0 +1,305 @@ +# 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_TNM_COUNTRY_CODE') + self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_LOCALE') + self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_GROUP_ID') + self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID') + self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID_AREA_CODES') + self.area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_AREA_CODE_FOR_SEARCH') + self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID') + self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_PURCHASE') + self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_CANCEL') + self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_CONFIGURE') + self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_GET_CONFIG') + self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_UNCONFIGURE') + self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_FOR_CAPABILITIES') + self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_CAPABILITIES_ID') + self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_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.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.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", + azure_pstn_target_id="AzurePstnTargetId" + ) + 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_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 From f0fe19ea0707af65234fefd99e20e5c469a9d405 Mon Sep 17 00:00:00 2001 From: Heli Wang Date: Thu, 1 Oct 2020 10:51:58 -0700 Subject: [PATCH 03/11] Azure Communication Services - Phone Number Admin - Implementing long running operations for phone number search (#14157) * Implementing long running operations for phone number search --- .../communication/administration/__init__.py | 10 +- .../_phone_number_administration_client.py | 149 +++++++++++++---- .../communication/administration/_polling.py | 76 +++++++++ .../administration/aio/__init__.py | 4 +- ...hone_number_administration_client_async.py | 151 +++++++++++++++--- .../administration/aio/_polling_async.py | 76 +++++++++ 6 files changed, 408 insertions(+), 58 deletions(-) create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py create mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py 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 2864e79e5e5e0..ecd289cb703fc 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -6,6 +6,7 @@ from ._communication_identity_client import CommunicationIdentityClient from ._phone_number_administration_client import PhoneNumberAdministrationClient +from ._polling import PhoneNumberPolling from ._identity._generated.models import ( CommunicationTokenRequest, @@ -16,6 +17,7 @@ AcquiredPhoneNumber, AcquiredPhoneNumbers, AreaCodes, + CreateSearchOptions, CreateSearchResponse, LocationOptionsQuery, LocationOptionsResponse, @@ -31,7 +33,7 @@ ReleaseResponse, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse, - CreateSearchOptions + SearchStatus ) from ._shared.models import ( @@ -43,6 +45,7 @@ __all__ = [ 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', + 'PhoneNumberPolling', # from _identity 'CommunicationTokenRequest', @@ -52,6 +55,7 @@ 'AcquiredPhoneNumber', 'AcquiredPhoneNumbers', 'AreaCodes', + 'CreateSearchOptions', 'CreateSearchResponse', 'LocationOptionsQuery', 'LocationOptionsResponse', @@ -59,15 +63,15 @@ 'NumberUpdateCapabilities', 'PhoneNumberCountries', 'PhoneNumberEntities', - 'PhoneNumberRelease', 'PhoneNumberSearch', + 'PhoneNumberRelease', 'PhonePlanGroups', 'PhonePlansResponse', 'PstnConfiguration', 'ReleaseResponse', + 'SearchStatus', 'UpdateNumberCapabilitiesResponse', 'UpdatePhoneNumberCapabilitiesResponse', - 'CreateSearchOptions', # from _shared 'CommunicationUser', 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 index edc0a5657235f..ee393fac84aed 100644 --- 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 @@ -6,6 +6,8 @@ # ------------------------------------ from azure.core.tracing.decorator import distributed_trace from azure.core.paging import ItemPaged +from azure.core.polling import LROPoller +from ._polling import PhoneNumberPolling from ._phonenumber._generated._phone_number_administration_service\ import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen @@ -13,7 +15,6 @@ from ._phonenumber._generated.models import ( AcquiredPhoneNumbers, AreaCodes, - CreateSearchResponse, LocationOptionsResponse, NumberConfigurationResponse, NumberUpdateCapabilities, @@ -25,6 +26,7 @@ PhonePlansResponse, PstnConfiguration, ReleaseResponse, + SearchStatus, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse ) @@ -405,21 +407,53 @@ def get_search_by_id( ) @distributed_trace - def create_search( + def begin_create_search( self, **kwargs # type: Any ): - # type: (...) -> CreateSearchResponse - """Creates a phone number search. + # type: (...) -> LROPoller + """Begins creating a phone number search. + Caller must provide either body, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword body will be ignored. :keyword azure.communication.administration.CreateSearchOptions body: - An optional parameter for defining the search options. - The default is None. - :rtype: ~azure.communication.administration.CreateSearchResponse + A parameter for defining the search options. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return self._phone_number_administration_client.phone_number_administration.create_search( + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPolling( + is_terminated=lambda status: status in [ + SearchStatus.Reserved, + SearchStatus.Expired, + SearchStatus.Success, + SearchStatus.Cancelled, + SearchStatus.Error + ] + ) + + if cont_token is not None: + return LROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + if "body" not in kwargs: + raise ValueError("Either kwarg 'body' or 'continuation_token' needs to be specified") + + create_search_response = self._phone_number_administration_client.phone_number_administration.create_search( **kwargs ) + initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=create_search_response.search_id + ) + return LROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) @distributed_trace def list_all_searches( @@ -440,37 +474,96 @@ def list_all_searches( ) @distributed_trace - def cancel_search( + def begin_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 + # type: (...) -> LROPoller + """Begins the phone number search cancellation. + Caller must provide either search_id, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword search_id will be ignored. + + :keyword str search_id: The search id to be canceled. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return self._phone_number_administration_client.phone_number_administration.cancel_search( + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPolling( + is_terminated=lambda status: status in [ + SearchStatus.Expired, + SearchStatus.Cancelled, + SearchStatus.Error + ] + ) + + if cont_token is not None: + return LROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + search_id = kwargs.pop('search_id', None) # type: str + if search_id is None: + raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") + + self._phone_number_administration_client.phone_number_administration.cancel_search( search_id, **kwargs ) + initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=search_id + ) + return LROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) @distributed_trace - def purchase_search( - self, - search_id, # type: str - **kwargs # type: Any + def begin_purchase_search( + self, + **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 + # type: (...) -> LROPoller + """Begins the phone number search purchase. + Caller must provide either search_id, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword search_id will be ignored. + + :keyword str search_id: The search id to be purchased. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return self._phone_number_administration_client.phone_number_administration.purchase_search( + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPolling( + is_terminated=lambda status: status in [ + SearchStatus.Success, + SearchStatus.Expired, + SearchStatus.Cancelled, + SearchStatus.Error + ] + ) + + if cont_token is not None: + return LROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + search_id = kwargs.pop('search_id') # type: str + + self._phone_number_administration_client.phone_number_administration.purchase_search( search_id, **kwargs ) + initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=search_id + ) + return LROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py new file mode 100644 index 0000000000000..05555abc171ef --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py @@ -0,0 +1,76 @@ +# pylint: disable=W0231 +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import base64 +import time +from typing import Union +from functools import partial +import pickle + +from azure.core.polling import ( + PollingMethod +) +from ._phonenumber._generated.models import ( + PhoneNumberSearch, + PhoneNumberRelease +) + +class PhoneNumberPolling(PollingMethod): + def __init__(self, is_terminated, interval=5): + self._response = None + self._client = None + self._query_status = None + self._is_terminated = is_terminated + self._polling_interval = interval + + def _update_status(self): + # type: () -> None + if self._query_status is None: + raise Exception("this poller has not been initialized") + self._response = self._query_status() + + def initialize(self, client, initial_response, _): + # type: (Any, Any, Callable) -> None + self._client = client + self._response = initial_response + self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.search_id) + + def run(self): + # type: () -> None + while not self.finished(): + self._update_status() + if not self.finished(): + time.sleep(self._polling_interval) + + def finished(self): + # type: () -> bool + if self._response.status is None: + return False + return self._is_terminated(self._response.status) + + def resource(self): + # type: () -> Union[PhoneNumberSearch, PhoneNumberRelease] + if not self.finished(): + return None + return self._response + + def status(self): + # type: () -> str + return self._response.status + + def get_continuation_token(self): + # type() -> str + return base64.b64encode(pickle.dumps(self._response)).decode('ascii') + + @classmethod + def from_continuation_token(cls, continuation_token, **kwargs): + # type(str, Any) -> Tuple + try: + client = kwargs["client"] + except KeyError: + raise ValueError("Kwarg 'client' needs to be specified") + initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec + return client, initial_response, None 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 f647dfa8f5060..dc793b7fa747a 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,7 +1,9 @@ from ._communication_identity_client_async import CommunicationIdentityClient from ._phone_number_administration_client_async import PhoneNumberAdministrationClient +from ._polling_async import PhoneNumberPollingAsync __all__ = [ 'CommunicationIdentityClient', - 'PhoneNumberAdministrationClient' + 'PhoneNumberAdministrationClient', + 'PhoneNumberPollingAsync' ] 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 index 50637b8ce7298..8cfd19cb7a0fe 100644 --- 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 @@ -5,10 +5,14 @@ # 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 azure.core.polling import AsyncLROPoller + from .._version import SDK_MONIKER +from ._polling_async import PhoneNumberPollingAsync from .._phonenumber._generated.aio._phone_number_administration_service_async\ import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen @@ -16,7 +20,6 @@ from .._phonenumber._generated.models import ( AcquiredPhoneNumbers, AreaCodes, - CreateSearchResponse, LocationOptionsResponse, NumberConfigurationResponse, NumberUpdateCapabilities, @@ -28,6 +31,7 @@ PhonePlansResponse, PstnConfiguration, ReleaseResponse, + SearchStatus, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse ) @@ -412,22 +416,55 @@ async def get_search_by_id( ) @distributed_trace_async - async def create_search( + async def begin_create_search( self, **kwargs # type: Any ): - # type: (...) -> CreateSearchResponse - """Creates a phone number search. + # type: (...) -> AsyncLROPoller + """Begins creating a phone number search. + Caller must provide either body, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword body will be ignored. :keyword azure.communication.administration.CreateSearchOptions body: - An optional parameter for defining the search options. - The default is None. - :rtype: ~azure.communication.administration.CreateSearchResponse + A parameter for defining the search options. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return await self._phone_number_administration_client.phone_number_administration.create_search( - **kwargs + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPollingAsync( + is_terminated=lambda status: status in [ + SearchStatus.Reserved, + SearchStatus.Expired, + SearchStatus.Success, + SearchStatus.Cancelled, + SearchStatus.Error + ] ) + if cont_token is not None: + return AsyncLROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + if "body" not in kwargs: + raise ValueError("Either kwarg 'body' or 'continuation_token' needs to be specified") + + create_search_response = await self._phone_number_administration_client.\ + phone_number_administration.create_search( + **kwargs + ) + initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=create_search_response.search_id + ) + return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) + @distributed_trace def list_all_searches( self, @@ -447,40 +484,102 @@ def list_all_searches( ) @distributed_trace_async - async def cancel_search( + async def begin_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 + # type: (...) -> AsyncLROPoller + """Begins the phone number search cancellation. + Caller must provide either search_id, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword search_id will be ignored. + + :keyword str search_id: The search id to be canceled. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return await self._phone_number_administration_client.phone_number_administration.cancel_search( + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPollingAsync( + is_terminated=lambda status: status in [ + SearchStatus.Expired, + SearchStatus.Cancelled, + SearchStatus.Error + ] + ) + + if cont_token is not None: + return AsyncLROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + search_id = kwargs.pop('search_id', None) # type: str + if search_id is None: + raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") + + await self._phone_number_administration_client.phone_number_administration.cancel_search( search_id, **kwargs ) + initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=search_id + ) + return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) @distributed_trace_async - async def purchase_search( + async def begin_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 + # type: (...) -> AsyncLROPoller + """Begins the phone number search purchase. + Caller must provide either search_id, or continuation_token keywords to use the method. + If both body and continuation_token are specified, only continuation_token will be used to + restart a poller from a saved state, and keyword search_id will be ignored. + + :keyword str search_id: The search id to be purchased. + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] """ - return await self._phone_number_administration_client.phone_number_administration.purchase_search( + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + search_polling = PhoneNumberPollingAsync( + is_terminated=lambda status: status in [ + SearchStatus.Success, + SearchStatus.Expired, + SearchStatus.Cancelled, + SearchStatus.Error + ] + ) + + if cont_token is not None: + return AsyncLROPoller.from_continuation_token( + polling_method=search_polling, + continuation_token=cont_token, + client=self._phone_number_administration_client.phone_number_administration + ) + + search_id = kwargs.pop('search_id', None) # type: str + if search_id is None: + raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") + + await self._phone_number_administration_client.phone_number_administration.purchase_search( search_id, **kwargs ) + initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( + search_id=search_id + ) + return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, + initial_response=initial_state, + deserialization_callback=None, + polling_method=search_polling) async def __aenter__(self) -> "PhoneNumberAdministrationClient": await self._phone_number_administration_client.__aenter__() diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py new file mode 100644 index 0000000000000..06000f10040bd --- /dev/null +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py @@ -0,0 +1,76 @@ +# pylint: disable=W0231 +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import asyncio +from typing import Union +import base64 +from functools import partial + +from azure.core.polling import AsyncPollingMethod + +from .._phonenumber._generated.models import ( + PhoneNumberSearch, + PhoneNumberRelease +) + +class PhoneNumberPollingAsync(AsyncPollingMethod): + def __init__(self, is_terminated, interval=5): + self._response = None + self._client = None + self._query_status = None + self._is_terminated = is_terminated + self._polling_interval = interval + + async def _update_status(self): + # type: () -> None + if self._query_status is None: + raise Exception("this poller has not been initialized") + self._response = await self._query_status() + + def initialize(self, client, initial_response, _): + # type: (Any, Any, Callable) -> None + self._client = client + self._response = initial_response + self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.search_id) + + async def run(self): + # type: () -> None + while not self.finished(): + await self._update_status() + if not self.finished(): + await asyncio.sleep(self._polling_interval) + + def finished(self): + # type: () -> bool + if self._response.status is None: + return False + return self._is_terminated(self._response.status) + + def resource(self): + # type: () -> Union[PhoneNumberSearch, PhoneNumberRelease] + if not self.finished(): + return None + return self._response + + def status(self): + # type: () -> str + return self._response.status + + def get_continuation_token(self): + # type() -> str + import pickle + return base64.b64encode(pickle.dumps(self._response)).decode('ascii') + + @classmethod + def from_continuation_token(cls, continuation_token, **kwargs): + # type(str, Any) -> Tuple + try: + client = kwargs["client"] + except KeyError: + raise ValueError("Kwarg 'client' needs to be specified") + import pickle + initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec + return client, initial_response, None From d09d5afcb9759c3a1695771748ac181510271f93 Mon Sep 17 00:00:00 2001 From: Heli Wang Date: Thu, 1 Oct 2020 13:11:27 -0700 Subject: [PATCH 04/11] refresh swagger and auto generated code (#14182) --- ..._number_administration_operations_async.py | 4 +- .../_phonenumber/_generated/models/_models.py | 4 - .../_generated/models/_models_py3.py | 5 - ..._phone_number_administration_operations.py | 4 +- .../swagger/phone_number_swagger.json | 3694 ++++++++--------- 5 files changed, 1849 insertions(+), 1862 deletions(-) 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 index ece0f7ad680c3..ab0e61661d5c0 100644 --- 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 @@ -522,7 +522,7 @@ async def configure_number( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + 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) @@ -582,7 +582,7 @@ async def unconfigure_number( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + 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) 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 index d42c375ef60f5..fbee8df115569 100644 --- 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 @@ -873,8 +873,6 @@ class PstnConfiguration(msrest.serialization.Model): :type callback_url: str :param application_id: The application id of the application to which to configure. :type application_id: str - :param azure_pstn_target_id: Routable TargetId for the ACS Number. - :type azure_pstn_target_id: str """ _validation = { @@ -884,7 +882,6 @@ class PstnConfiguration(msrest.serialization.Model): _attribute_map = { 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'azure_pstn_target_id': {'key': 'azurePstnTargetId', 'type': 'str'}, } def __init__( @@ -894,7 +891,6 @@ def __init__( super(PstnConfiguration, self).__init__(**kwargs) self.callback_url = kwargs['callback_url'] self.application_id = kwargs.get('application_id', None) - self.azure_pstn_target_id = kwargs.get('azure_pstn_target_id', None) class RateInformation(msrest.serialization.Model): 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 index 75166f982f1dc..b798bad2aceb5 100644 --- 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 @@ -993,8 +993,6 @@ class PstnConfiguration(msrest.serialization.Model): :type callback_url: str :param application_id: The application id of the application to which to configure. :type application_id: str - :param azure_pstn_target_id: Routable TargetId for the ACS Number. - :type azure_pstn_target_id: str """ _validation = { @@ -1004,7 +1002,6 @@ class PstnConfiguration(msrest.serialization.Model): _attribute_map = { 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'azure_pstn_target_id': {'key': 'azurePstnTargetId', 'type': 'str'}, } def __init__( @@ -1012,13 +1009,11 @@ def __init__( *, callback_url: str, application_id: Optional[str] = None, - azure_pstn_target_id: Optional[str] = None, **kwargs ): super(PstnConfiguration, self).__init__(**kwargs) self.callback_url = callback_url self.application_id = application_id - self.azure_pstn_target_id = azure_pstn_target_id class RateInformation(msrest.serialization.Model): 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 index e6e3bbe83f437..f26cdc45f7fb5 100644 --- 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 @@ -533,7 +533,7 @@ def configure_number( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + 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) @@ -594,7 +594,7 @@ def unconfigure_number( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + 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) diff --git a/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json b/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json index c4e9f78440b9a..ef652de3adaaf 100644 --- a/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json +++ b/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json @@ -1,2060 +1,2056 @@ { - "swagger": "2.0", - "info": { - "title": "Phone Number Administration Service", - "description": "Phone Number Administration Service", - "contact": { - "email": "acsdevexdisc@microsoft.com" + "swagger": "2.0", + "info": { + "title": "Phone Number Administration Service", + "description": "Phone Number Administration Service", + "contact": { + "email": "acsdevexdisc@microsoft.com" + }, + "version": "2020-07-20-preview1" }, - "version": "2020-07-20-preview1" - }, - "paths": { - "/administration/phonenumbers/phonenumbers": { - "get": { - "tags": [ - "AcquiredNumbers" - ], - "summary": "Gets the list of the acquired phone numbers.", - "operationId": "PhoneNumberAdministration_GetAllPhoneNumbers", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 + "paths": { + "/administration/phonenumbers/phonenumbers": { + "get": { + "tags": [ + "AcquiredNumbers" + ], + "summary": "Gets the list of the acquired phone numbers.", + "operationId": "PhoneNumberAdministration_GetAllPhoneNumbers", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/AcquiredPhoneNumbers" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phoneNumbers" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "x-ms-examples": { + "List acquired phone numbers": { + "$ref": "./examples/GetAcquiredPhoneNumbersAsync.json" + } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/AcquiredPhoneNumbers" + } + }, + "/administration/phonenumbers/countries/{countryCode}/areacodes": { + "post": { + "tags": [ + "AreaCodes" + ], + "summary": "Gets a list of the supported area codes", + "operationId": "PhoneNumberAdministration_GetAllAreaCodes", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locationType", + "description": "The type of location information required by the plan.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "phonePlanId", + "description": "The plan id from which to search area codes.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Location options for when location type is selection.", + "schema": { + "$ref": "#/definitions/LocationOptionsQueries" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/AreaCodes" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Get area codes": { + "$ref": "./examples/GetAreaCodesAsync.json" } } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phoneNumbers" - }, - "x-ms-examples": { - "List acquired phone numbers": { - "$ref": "./examples/GetAcquiredPhoneNumbersAsync.json" - } } - } - }, - "/administration/phonenumbers/countries/{countryCode}/areacodes": { - "post": { - "tags": [ - "AreaCodes" - ], - "summary": "Gets a list of the supported area codes", - "operationId": "PhoneNumberAdministration_GetAllAreaCodes", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locationType", - "description": "The type of location information required by the plan.", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "phonePlanId", - "description": "The plan id from which to search area codes.", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" + }, + "/administration/phonenumbers/capabilities/{capabilitiesUpdateId}": { + "get": { + "tags": [ + "Capabilities" + ], + "summary": "Get capabilities by capabilities update id.", + "operationId": "PhoneNumberAdministration_GetCapabilitiesUpdate", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "capabilitiesUpdateId", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/UpdatePhoneNumberCapabilitiesResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "body", - "name": "body", - "description": "Location options for when location type is selection.", - "schema": { - "$ref": "#/definitions/LocationOptionsQueries" + "x-ms-examples": { + "Get number capabilities update": { + "$ref": "./examples/GetNumberCapabilitiesUpdateAsync.json" } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/AreaCodes" + } + }, + "/administration/phonenumbers/capabilities": { + "post": { + "tags": [ + "Capabilities" + ], + "summary": "Adds or removes phone number capabilities", + "operationId": "PhoneNumberAdministration_UpdateCapabilities", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "", + "schema": { + "$ref": "#/definitions/UpdateNumberCapabilitiesRequest" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/UpdateNumberCapabilitiesResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Update number capabilities": { + "$ref": "./examples/UpdateNumberCapabilitiesAsync.json" } } - }, - "x-ms-examples": { - "Get area codes": { - "$ref": "./examples/GetAreaCodesAsync.json" - } } - } - }, - "/administration/phonenumbers/capabilities/{capabilitiesUpdateId}": { - "get": { - "tags": [ - "Capabilities" - ], - "summary": "Get capabilities by capabilities update id.", - "operationId": "PhoneNumberAdministration_GetCapabilitiesUpdate", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "capabilitiesUpdateId", - "required": true, - "type": "string" + }, + "/administration/phonenumbers/countries": { + "get": { + "tags": [ + "Countries" + ], + "summary": "Gets a list of supported countries", + "operationId": "PhoneNumberAdministration_GetAllSupportedCountries", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberCountries" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "$ref": "#/parameters/ApiVersionParameter" + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "countries" + }, + "x-ms-examples": { + "Get countries": { + "$ref": "./examples/GetCountriesAsync.json" + } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/UpdatePhoneNumberCapabilitiesResponse" + } + }, + "/administration/phonenumbers/numberconfiguration": { + "post": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for getting number configurations", + "operationId": "PhoneNumberAdministration_GetNumberConfiguration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "The phone number whose configuration is to be fetched", + "schema": { + "$ref": "#/definitions/NumberConfigurationPhoneNumber" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/NumberConfigurationResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Get number configuration for phone number": { + "$ref": "./examples/GetNumberConfigurationAsync.json" } } - }, - "x-ms-examples": { - "Get number capabilities update": { - "$ref": "./examples/GetNumberCapabilitiesUpdateAsync.json" - } } - } - }, - "/administration/phonenumbers/capabilities": { - "post": { - "tags": [ - "Capabilities" - ], - "summary": "Adds or removes phone number capabilities", - "operationId": "PhoneNumberAdministration_UpdateCapabilities", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" + }, + "/administration/phonenumbers/numberconfiguration/configure": { + "patch": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for configuring a pstn number", + "operationId": "PhoneNumberAdministration_ConfigureNumber", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Details of pstn number configuration of the given phoneNumber", + "schema": { + "$ref": "#/definitions/NumberConfiguration" + } + } + ], + "responses": { + "200": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "body", - "name": "body", - "description": "", - "schema": { - "$ref": "#/definitions/UpdateNumberCapabilitiesRequest" + "x-ms-examples": { + "Configure phone number": { + "$ref": "./examples/ConfigurePhoneNumberAsync.json" } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/UpdateNumberCapabilitiesResponse" + } + }, + "/administration/phonenumbers/numberconfiguration/unconfigure": { + "patch": { + "tags": [ + "NumberConfiguration" + ], + "summary": "Endpoint for unconfiguring a pstn number by removing the configuration", + "operationId": "PhoneNumberAdministration_UnconfigureNumber", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "The phone number to un-configure", + "schema": { + "$ref": "#/definitions/NumberConfigurationPhoneNumber" + } + } + ], + "responses": { + "200": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Unconfigure phone number": { + "$ref": "./examples/UnconfigurePhoneNumberAsync.json" } } - }, - "x-ms-examples": { - "Update number capabilities": { - "$ref": "./examples/UpdateNumberCapabilitiesAsync.json" - } } - } - }, - "/administration/phonenumbers/countries": { - "get": { - "tags": [ - "Countries" - ], - "summary": "Gets a list of supported countries", - "operationId": "PhoneNumberAdministration_GetAllSupportedCountries", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of phone plan groups for the given country", + "operationId": "PhoneNumberAdministration_GetPhonePlanGroups", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "includeRateInformation", + "type": "boolean", + "default": false + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhonePlanGroups" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phonePlanGroups" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetPhonePlanGroupsAsync.json" + } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberCountries" + } + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of phone plans for a phone plan group", + "operationId": "PhoneNumberAdministration_GetPhonePlans", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanGroupId", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhonePlansResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "phonePlans" + }, + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetPhonePlansAsync.json" } } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "countries" - }, - "x-ms-examples": { - "Get countries": { - "$ref": "./examples/GetCountriesAsync.json" - } } - } - }, - "/administration/phonenumbers/numberconfiguration": { - "post": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for getting number configurations", - "operationId": "PhoneNumberAdministration_GetNumberConfiguration", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "The phone number whose configuration is to be fetched", - "schema": { - "$ref": "#/definitions/NumberConfigurationPhoneNumber" + }, + "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions": { + "get": { + "tags": [ + "Plans" + ], + "summary": "Gets a list of location options for a phone plan", + "operationId": "PhoneNumberAdministration_GetPhonePlanLocationOptions", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "countryCode", + "description": "The ISO 3166-2 country code.", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanGroupId", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "phonePlanId", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "locale", + "description": "A language-locale pairing which will be used to localise the names of countries", + "type": "string", + "default": "en-US" + }, + { + "$ref": "#/parameters/ApiVersionParameter" } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/NumberConfigurationResponse" + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/LocationOptionsResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Get plans": { + "$ref": "./examples/GetLocationOptionsAsync.json" } } - }, - "x-ms-examples": { - "Get number configuration for phone number": { - "$ref": "./examples/GetNumberConfigurationAsync.json" - } } - } - }, - "/administration/phonenumbers/numberconfiguration/configure": { - "patch": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for configuring a pstn number", - "operationId": "PhoneNumberAdministration_ConfigureNumber", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" + }, + "/administration/phonenumbers/releases/{releaseId}": { + "get": { + "tags": [ + "Release" + ], + "summary": "Gets a release by a release id", + "operationId": "PhoneNumberAdministration_GetReleaseById", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "releaseId", + "description": "Represents the release id", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberRelease" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "body", - "name": "body", - "description": "Details of pstn number configuration of the given phoneNumber", - "schema": { - "$ref": "#/definitions/NumberConfiguration" + "x-ms-examples": { + "Get release by id": { + "$ref": "./examples/GetReleaseByIdAsync.json" } } - ], - "responses": { - "202": { - "description": "Success" + } + }, + "/administration/phonenumbers/releases": { + "post": { + "tags": [ + "Release" + ], + "summary": "Creates a release for the given phone numbers", + "operationId": "PhoneNumberAdministration_ReleasePhoneNumbers", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Config api Release request", + "schema": { + "$ref": "#/definitions/ReleaseRequest" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/ReleaseResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Get release": { + "$ref": "./examples/CreateReleaseAsync.json" } } }, - "x-ms-examples": { - "Configure phone number": { - "$ref": "./examples/ConfigurePhoneNumberAsync.json" + "get": { + "tags": [ + "Release" + ], + "summary": "Gets a list of all releases", + "operationId": "PhoneNumberAdministration_GetAllReleases", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberEntities" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "entities" + }, + "x-ms-examples": { + "Get all releases": { + "$ref": "./examples/GetAllReleasesAsync.json" + } } } - } - }, - "/administration/phonenumbers/numberconfiguration/unconfigure": { - "patch": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for unconfiguring a pstn number by removing the configuration", - "operationId": "PhoneNumberAdministration_UnconfigureNumber", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" + }, + "/administration/phonenumbers/searches/{searchId}": { + "get": { + "tags": [ + "Search" + ], + "summary": "Get search by search id", + "operationId": "PhoneNumberAdministration_GetSearchById", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be searched for", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberSearch" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "body", - "name": "body", - "description": "The phone number to un-configure", - "schema": { - "$ref": "#/definitions/NumberConfigurationPhoneNumber" + "x-ms-examples": { + "Get search by search id": { + "$ref": "./examples/GetSearchByIdAsync.json" } } - ], - "responses": { - "202": { - "description": "Success" + } + }, + "/administration/phonenumbers/searches": { + "post": { + "tags": [ + "Search" + ], + "summary": "Creates a phone number search", + "operationId": "PhoneNumberAdministration_CreateSearch", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Defines the search options", + "schema": { + "$ref": "#/definitions/CreateSearchOptions" + } + } + ], + "responses": { + "201": { + "description": "Success", + "schema": { + "$ref": "#/definitions/CreateSearchResponse" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Create search": { + "$ref": "./examples/CreateSearchAsync.json" } } }, - "x-ms-examples": { - "Unconfigure phone number": { - "$ref": "./examples/UnconfigurePhoneNumberAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of phone plan groups for the given country", - "operationId": "PhoneNumberAdministration_GetPhonePlanGroups", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "includeRateInformation", - "type": "boolean", - "default": false - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 + "get": { + "tags": [ + "Search" + ], + "summary": "Gets a list of all searches", + "operationId": "PhoneNumberAdministration_GetAllSearches", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "description": "An optional parameter for how many entries to skip, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "take", + "description": "An optional parameter for how many entries to return, for pagination purposes.", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PhoneNumberEntities" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "entities" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "x-ms-examples": { + "Get all searches": { + "$ref": "./examples/GetAllSearchesAsync.json" + } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhonePlanGroups" + } + }, + "/administration/phonenumbers/searches/{searchId}/cancel": { + "post": { + "tags": [ + "Search" + ], + "summary": "Cancels the search. This means existing numbers in the search will be made available.", + "operationId": "PhoneNumberAdministration_CancelSearch", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be canceled", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "x-ms-examples": { + "Cancel phone number search": { + "$ref": "./examples/CancelSearchAsync.json" } } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phonePlanGroups" - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetPhonePlanGroupsAsync.json" + } + }, + "/administration/phonenumbers/searches/{searchId}/purchase": { + "post": { + "tags": [ + "Search" + ], + "summary": "Purchases the phone number search.", + "operationId": "PhoneNumberAdministration_PurchaseSearch", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "searchId", + "description": "The search id to be purchased", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "202": { + "description": "Success" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Purchase phone number search": { + "$ref": "./examples/PurchaseSearchAsync.json" + } } } } }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of phone plans for a phone plan group", - "operationId": "PhoneNumberAdministration_GetPhonePlans", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, + "definitions": { + "AcquiredPhoneNumber": { + "description": "Represents an acquired phone number.", + "required": [ + "acquiredCapabilities", + "availableCapabilities", + "phoneNumber" + ], + "type": "object", + "properties": { + "phoneNumber": { + "description": "String of the E.164 format of the phone number", "type": "string" }, - { - "in": "path", - "name": "phonePlanGroupId", - "required": true, - "type": "string" + "acquiredCapabilities": { + "description": "The set of all acquired capabilities of the phone number.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" + "availableCapabilities": { + "description": "The set of all available capabilities that can be acquired for this phone number.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 + "assignmentStatus": { + "description": "The assignment status of the phone number. Conveys what type of entity the number is assigned to.", + "enum": [ + "Unassigned", + "Unknown", + "UserAssigned", + "ConferenceAssigned", + "FirstPartyAppAssigned", + "ThirdPartyAppAssigned" + ], + "type": "string", + "x-ms-enum": { + "name": "AssignmentStatus", + "modelAsString": true + } }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 + "placeName": { + "description": "The name of the place of the phone number.", + "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "activationState": { + "description": "The activation state of the phone number. Can be \"Activated\", \"AssignmentPending\", \"AssignmentFailed\", \"UpdatePending\", \"UpdateFailed\"", + "enum": [ + "Activated", + "AssignmentPending", + "AssignmentFailed", + "UpdatePending", + "UpdateFailed" + ], + "type": "string", + "x-ms-enum": { + "name": "ActivationState", + "modelAsString": true + } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhonePlansResponse" + } + }, + "AcquiredPhoneNumbers": { + "description": "A wrapper of list of phone numbers", + "type": "object", + "properties": { + "phoneNumbers": { + "description": "Represents a list of phone numbers", + "type": "array", + "items": { + "$ref": "#/definitions/AcquiredPhoneNumber" } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phonePlans" - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetPhonePlansAsync.json" + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" } } - } - }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of location options for a phone plan", - "operationId": "PhoneNumberAdministration_GetPhonePlanLocationOptions", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "phonePlanGroupId", - "required": true, + }, + "ErrorBody": { + "description": "Represents a service error response body.", + "type": "object", + "properties": { + "code": { + "description": "The error code in the error response.", "type": "string" }, - { - "in": "path", - "name": "phonePlanId", - "required": true, + "message": { + "description": "The error message in the error response.", "type": "string" - }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/LocationOptionsResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } } - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetLocationOptionsAsync.json" + } + }, + "ErrorResponse": { + "description": "Represents a service error response.", + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/ErrorBody" } } - } - }, - "/administration/phonenumbers/releases/{releaseId}": { - "get": { - "tags": [ - "Release" - ], - "summary": "Gets a release by a release id", - "operationId": "PhoneNumberAdministration_GetReleaseById", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "releaseId", - "description": "Represents the release id", - "required": true, + }, + "LocationOptionsQuery": { + "description": "Represents a location options parameter, used for fetching area codes.", + "type": "object", + "properties": { + "labelId": { + "description": "Represents the location option label id, returned from the GetLocationOptions API.", "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberRelease" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get release by id": { - "$ref": "./examples/GetReleaseByIdAsync.json" + "optionsValue": { + "description": "Represents the location options value, returned from the GetLocationOptions API.", + "type": "string" } } - } - }, - "/administration/phonenumbers/releases": { - "post": { - "tags": [ - "Release" - ], - "summary": "Creates a release for the given phone numbers", - "operationId": "PhoneNumberAdministration_ReleasePhoneNumbers", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "Config api Release request", - "schema": { - "$ref": "#/definitions/ReleaseRequest" + }, + "LocationOptionsQueries": { + "description": "Represents a list of location option queries, used for fetching area codes.", + "type": "object", + "properties": { + "locationOptions": { + "description": "Represents the underlying list of countries.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsQuery" } } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/ReleaseResponse" + } + }, + "AreaCodes": { + "description": "Represents a list of area codes.", + "type": "object", + "properties": { + "primaryAreaCodes": { + "description": "Represents the list of primary area codes.", + "type": "array", + "items": { + "type": "string" } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "secondaryAreaCodes": { + "description": "Represents the list of secondary area codes.", + "type": "array", + "items": { + "type": "string" } - } - }, - "x-ms-examples": { - "Get release": { - "$ref": "./examples/CreateReleaseAsync.json" + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" } } }, - "get": { - "tags": [ - "Release" - ], - "summary": "Gets a list of all releases", - "operationId": "PhoneNumberAdministration_GetAllReleases", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberEntities" + "NumberUpdateCapabilities": { + "description": "Represents an individual number capabilities update request", + "type": "object", + "properties": { + "add": { + "description": "Capabilities to be added to a phone number", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "remove": { + "description": "Capabilities to be removed from a phone number", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } } } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "entities" - }, - "x-ms-examples": { - "Get all releases": { - "$ref": "./examples/GetAllReleasesAsync.json" - } } - } - }, - "/administration/phonenumbers/searches/{searchId}": { - "get": { - "tags": [ - "Search" - ], - "summary": "Get search by search id", - "operationId": "PhoneNumberAdministration_GetSearchById", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be searched for", - "required": true, + }, + "UpdatePhoneNumberCapabilitiesResponse": { + "description": "Response for getting a phone number update capabilities.", + "type": "object", + "properties": { + "capabilitiesUpdateId": { + "description": "The id of the phone number capabilties update", "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberSearch" - } + "createdAt": { + "format": "date-time", + "description": "The time the capabilities update was created", + "type": "string" }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "capabilitiesUpdateStatus": { + "description": "Status of the capabilities update.", + "enum": [ + "Pending", + "InProgress", + "Complete", + "Error" + ], + "type": "string", + "x-ms-enum": { + "name": "CapabilitiesUpdateStatus", + "modelAsString": true } - } - }, - "x-ms-examples": { - "Get search by search id": { - "$ref": "./examples/GetSearchByIdAsync.json" - } - } - } - }, - "/administration/phonenumbers/searches": { - "post": { - "tags": [ - "Search" - ], - "summary": "Creates a phone number search", - "operationId": "PhoneNumberAdministration_CreateSearch", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" }, - { - "in": "body", - "name": "body", - "description": "Defines the search options", - "schema": { - "$ref": "#/definitions/CreateSearchOptions" + "phoneNumberCapabilitiesUpdates": { + "description": "The capabilities update for each of a set of phone numbers.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NumberUpdateCapabilities" } } - ], - "responses": { - "201": { - "description": "Success", - "schema": { - "$ref": "#/definitions/CreateSearchResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + } + }, + "UpdateNumberCapabilitiesRequest": { + "description": "Represents a numbers capabilities update request", + "required": [ + "phoneNumberCapabilitiesUpdate" + ], + "type": "object", + "properties": { + "phoneNumberCapabilitiesUpdate": { + "description": "The map of phone numbers to the capabilities update applied to the phone number.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/NumberUpdateCapabilities" } } - }, - "x-ms-examples": { - "Create search": { - "$ref": "./examples/CreateSearchAsync.json" + } + }, + "UpdateNumberCapabilitiesResponse": { + "description": "Represents a number capability update response.", + "required": [ + "capabilitiesUpdateId" + ], + "type": "object", + "properties": { + "capabilitiesUpdateId": { + "description": "The capabilities id", + "type": "string" } } }, - "get": { - "tags": [ - "Search" - ], - "summary": "Gets a list of all searches", - "operationId": "PhoneNumberAdministration_GetAllSearches", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 + "PhoneNumberCountry": { + "description": "Represents a country.", + "required": [ + "countryCode", + "localizedName" + ], + "type": "object", + "properties": { + "localizedName": { + "description": "Represents the name of the country.", + "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "countryCode": { + "description": "Represents the abbreviated name of the country.", + "type": "string" } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberEntities" + } + }, + "PhoneNumberCountries": { + "description": "Represents a wrapper around a list of countries.", + "type": "object", + "properties": { + "countries": { + "description": "Represents the underlying list of countries.", + "type": "array", + "items": { + "$ref": "#/definitions/PhoneNumberCountry" } }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "entities" - }, - "x-ms-examples": { - "Get all searches": { - "$ref": "./examples/GetAllSearchesAsync.json" + } + }, + "NumberConfigurationPhoneNumber": { + "description": "The phone number wrapper representing a number configuration request", + "required": [ + "phoneNumber" + ], + "type": "object", + "properties": { + "phoneNumber": { + "description": "The phone number in the E.164 format", + "type": "string" } } - } - }, - "/administration/phonenumbers/searches/{searchId}/cancel": { - "post": { - "tags": [ - "Search" - ], - "summary": "Cancels the search. This means existing numbers in the search will be made available.", - "operationId": "PhoneNumberAdministration_CancelSearch", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be canceled", - "required": true, + }, + "PstnConfiguration": { + "description": "Definition for pstn number configuration", + "required": [ + "callbackUrl" + ], + "type": "object", + "properties": { + "callbackUrl": { + "description": "The webhook URL on the phone number configuration.", "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "applicationId": { + "description": "The application id of the application to which to configure", + "type": "string" } + } + }, + "NumberConfigurationResponse": { + "description": "Definition for number configuration", + "required": [ + "pstnConfiguration" ], - "responses": { - "202": { - "description": "Success" - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } + "type": "object", + "properties": { + "pstnConfiguration": { + "$ref": "#/definitions/PstnConfiguration" } - }, - "x-ms-examples": { - "Cancel phone number search": { - "$ref": "./examples/CancelSearchAsync.json" + } + }, + "NumberConfiguration": { + "description": "Definition for number configuration", + "required": [ + "phoneNumber", + "pstnConfiguration" + ], + "type": "object", + "properties": { + "pstnConfiguration": { + "$ref": "#/definitions/PstnConfiguration" + }, + "phoneNumber": { + "description": "The phone number to configure", + "type": "string" } } - } - }, - "/administration/phonenumbers/searches/{searchId}/purchase": { - "post": { - "tags": [ - "Search" - ], - "summary": "Purchases the phone number search.", - "operationId": "PhoneNumberAdministration_PurchaseSearch", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be purchased", - "required": true, + }, + "CarrierDetails": { + "description": "Represents carrier details.", + "type": "object", + "properties": { + "name": { + "description": "Name of carrier details", "type": "string" }, - { - "$ref": "#/parameters/ApiVersionParameter" + "localizedName": { + "description": "Display name of carrier details", + "type": "string" } - ], - "responses": { - "202": { - "description": "Success" + } + }, + "RateInformation": { + "description": "Represents a wrapper of rate information", + "type": "object", + "properties": { + "monthlyRate": { + "format": "double", + "description": "The monthly rate of a phone plan group", + "type": "number" }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" + "currencyType": { + "description": "The currency of a phone plan group", + "enum": [ + "USD" + ], + "type": "string", + "x-ms-enum": { + "name": "CurrencyType", + "modelAsString": true } - } - }, - "x-ms-examples": { - "Purchase phone number search": { - "$ref": "./examples/PurchaseSearchAsync.json" + }, + "rateErrorMessage": { + "description": "The error code of a phone plan group", + "type": "string" } } - } - } - }, - "definitions": { - "AcquiredPhoneNumber": { - "description": "Represents an acquired phone number.", - "required": [ - "acquiredCapabilities", - "availableCapabilities", - "phoneNumber" - ], - "type": "object", - "properties": { - "phoneNumber": { - "description": "String of the E.164 format of the phone number", - "type": "string" - }, - "acquiredCapabilities": { - "description": "The set of all acquired capabilities of the phone number.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", + }, + "PhonePlanGroup": { + "description": "Represents a plan group.", + "required": [ + "localizedDescription", + "localizedName", + "phonePlanGroupId" + ], + "type": "object", + "properties": { + "phonePlanGroupId": { + "description": "The id of the plan group", + "type": "string" + }, + "phoneNumberType": { + "description": "The phone number type of the plan group", "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", + "Unknown", "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" + "Indirect" ], "type": "string", "x-ms-enum": { - "name": "Capability", + "name": "PhoneNumberType", "modelAsString": true } + }, + "localizedName": { + "description": "The name of the plan group.", + "type": "string" + }, + "localizedDescription": { + "description": "The description of the plan group.", + "type": "string" + }, + "carrierDetails": { + "$ref": "#/definitions/CarrierDetails" + }, + "rateInformation": { + "$ref": "#/definitions/RateInformation" } - }, - "availableCapabilities": { - "description": "The set of all available capabilities that can be acquired for this phone number.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", + } + }, + "PhonePlanGroups": { + "description": "Represents a wrapper of list of plan groups.", + "type": "object", + "properties": { + "phonePlanGroups": { + "description": "The underlying list of phone plan groups.", + "type": "array", + "items": { + "$ref": "#/definitions/PhonePlanGroup" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "PhonePlan": { + "description": "Represents a phone plan.", + "required": [ + "localizedName", + "locationType", + "phonePlanId" + ], + "type": "object", + "properties": { + "phonePlanId": { + "description": "The phone plan id", + "type": "string" + }, + "localizedName": { + "description": "The name of the phone plan", + "type": "string" + }, + "locationType": { + "description": "The location type of the phone plan.", "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" + "CivicAddress", + "NotRequired", + "Selection" ], "type": "string", "x-ms-enum": { - "name": "Capability", + "name": "LocationType", "modelAsString": true } - } - }, - "assignmentStatus": { - "description": "The assignment status of the phone number. Conveys what type of entity the number is assigned to.", - "enum": [ - "Unassigned", - "Unknown", - "UserAssigned", - "ConferenceAssigned", - "FirstPartyAppAssigned", - "ThirdPartyAppAssigned" - ], - "type": "string", - "x-ms-enum": { - "name": "AssignmentStatus", - "modelAsString": true - } - }, - "placeName": { - "description": "The name of the place of the phone number.", - "type": "string" - }, - "activationState": { - "description": "The activation state of the phone number. Can be \"Activated\", \"AssignmentPending\", \"AssignmentFailed\", \"UpdatePending\", \"UpdateFailed\"", - "enum": [ - "Activated", - "AssignmentPending", - "AssignmentFailed", - "UpdatePending", - "UpdateFailed" - ], - "type": "string", - "x-ms-enum": { - "name": "ActivationState", - "modelAsString": true + }, + "areaCodes": { + "description": "The list of available area codes in the phone plan.", + "type": "array", + "items": { + "type": "string" + } + }, + "capabilities": { + "description": "Capabilities of the phone plan.", + "type": "array", + "items": { + "description": "Represents the capabilities of a phone number.", + "enum": [ + "UserAssignment", + "FirstPartyVoiceAppAssignment", + "ConferenceAssignment", + "P2PSmsEnabled", + "Geographic", + "NonGeographic", + "TollCalling", + "TollFreeCalling", + "Premium", + "P2PSmsCapable", + "A2PSmsCapable", + "A2PSmsEnabled", + "Calling", + "TollFree", + "FirstPartyAppAssignment", + "ThirdPartyAppAssignment", + "Azure", + "Office365", + "InboundCalling", + "OutboundCalling", + "InboundA2PSms", + "OutboundA2PSms", + "InboundP2PSms", + "OutboundP2PSms" + ], + "type": "string", + "x-ms-enum": { + "name": "Capability", + "modelAsString": true + } + } + }, + "maximumSearchSize": { + "format": "int32", + "description": "The maximum number of phone numbers one can acquire in a search in this phone plan.", + "type": "integer" } } - } - }, - "AcquiredPhoneNumbers": { - "description": "A wrapper of list of phone numbers", - "type": "object", - "properties": { - "phoneNumbers": { - "description": "Represents a list of phone numbers", - "type": "array", - "items": { - "$ref": "#/definitions/AcquiredPhoneNumber" + }, + "PhonePlansResponse": { + "description": "Represents a wrapper around a list of countries.", + "type": "object", + "properties": { + "phonePlans": { + "description": "Represents the underlying list of phone plans.", + "type": "array", + "items": { + "$ref": "#/definitions/PhonePlan" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" } - } - }, - "ErrorBody": { - "description": "Represents a service error response body.", - "type": "object", - "properties": { - "code": { - "description": "The error code in the error response.", - "type": "string" - }, - "message": { - "description": "The error message in the error response.", - "type": "string" - } - } - }, - "ErrorResponse": { - "description": "Represents a service error response.", - "type": "object", - "properties": { - "error": { - "$ref": "#/definitions/ErrorBody" - } - } - }, - "LocationOptionsQuery": { - "description": "Represents a location options parameter, used for fetching area codes.", - "type": "object", - "properties": { - "labelId": { - "description": "Represents the location option label id, returned from the GetLocationOptions API.", - "type": "string" - }, - "optionsValue": { - "description": "Represents the location options value, returned from the GetLocationOptions API.", - "type": "string" - } - } - }, - "LocationOptionsQueries": { - "description": "Represents a list of location option queries, used for fetching area codes.", - "type": "object", - "properties": { - "locationOptions": { - "description": "Represents the underlying list of countries.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsQuery" + }, + "LocationOptionsDetails": { + "description": "Represents location options deatils.", + "type": "object", + "properties": { + "name": { + "description": "The name of the location options", + "type": "string" + }, + "value": { + "description": "The abbreviated name of the location options", + "type": "string" + }, + "locationOptions": { + "description": "The underlying location options", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptions" + } } } - } - }, - "AreaCodes": { - "description": "Represents a list of area codes.", - "type": "object", - "properties": { - "primaryAreaCodes": { - "description": "Represents the list of primary area codes.", - "type": "array", - "items": { + }, + "LocationOptions": { + "description": "Represents a location options.", + "type": "object", + "properties": { + "labelId": { + "description": "The label id of the location.", "type": "string" - } - }, - "secondaryAreaCodes": { - "description": "Represents the list of secondary area codes.", - "type": "array", - "items": { + }, + "labelName": { + "description": "The display name of the location.", "type": "string" + }, + "options": { + "description": "The underlying location option details.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" } - } - }, - "NumberUpdateCapabilities": { - "description": "Represents an individual number capabilities update request", - "type": "object", - "properties": { - "add": { - "description": "Capabilities to be added to a phone number", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", + }, + "LocationOptionsResponse": { + "description": "Represents a wrapper around a list of location options.", + "type": "object", + "properties": { + "locationOptions": { + "$ref": "#/definitions/LocationOptions" + } + } + }, + "PhoneNumberReleaseDetails": { + "type": "object", + "properties": { + "status": { + "description": "The release status of a phone number.", "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" + "Pending", + "Success", + "Error", + "InProgress" ], "type": "string", "x-ms-enum": { - "name": "Capability", + "name": "PhoneNumberReleaseStatus", "modelAsString": true } + }, + "errorCode": { + "format": "int32", + "description": "The error code in the case the status is error.", + "type": "integer" } - }, - "remove": { - "description": "Capabilities to be removed from a phone number", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", + } + }, + "PhoneNumberRelease": { + "description": "Represents a release", + "type": "object", + "properties": { + "releaseId": { + "description": "The id of the release.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "The creation time of the release.", + "type": "string" + }, + "status": { + "description": "The release status.", "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" + "Pending", + "InProgress", + "Complete", + "Failed", + "Expired" ], "type": "string", "x-ms-enum": { - "name": "Capability", + "name": "ReleaseStatus", "modelAsString": true } + }, + "errorMessage": { + "description": "The underlying error message of a release.", + "type": "string" + }, + "phoneNumberReleaseStatusDetails": { + "description": "The list of phone numbers in the release, mapped to its individual statuses.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/PhoneNumberReleaseDetails" + } } } - } - }, - "UpdatePhoneNumberCapabilitiesResponse": { - "description": "Response for getting a phone number update capabilities.", - "type": "object", - "properties": { - "capabilitiesUpdateId": { - "description": "The id of the phone number capabilties update", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The time the capabilities update was created", - "type": "string" - }, - "capabilitiesUpdateStatus": { - "description": "Status of the capabilities update.", - "enum": [ - "Pending", - "InProgress", - "Complete", - "Error" - ], - "type": "string", - "x-ms-enum": { - "name": "CapabilitiesUpdateStatus", - "modelAsString": true - } - }, - "phoneNumberCapabilitiesUpdates": { - "description": "The capabilities update for each of a set of phone numbers.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NumberUpdateCapabilities" - } - } - } - }, - "UpdateNumberCapabilitiesRequest": { - "description": "Represents a numbers capabilities update request", - "required": [ - "phoneNumberCapabilitiesUpdate" - ], - "type": "object", - "properties": { - "phoneNumberCapabilitiesUpdate": { - "description": "The map of phone numbers to the capabilities update applied to the phone number.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NumberUpdateCapabilities" - } - } - } - }, - "UpdateNumberCapabilitiesResponse": { - "description": "Represents a number capability update response.", - "required": [ - "capabilitiesUpdateId" - ], - "type": "object", - "properties": { - "capabilitiesUpdateId": { - "description": "The capabilities id", - "type": "string" - } - } - }, - "PhoneNumberCountry": { - "description": "Represents a country.", - "required": [ - "countryCode", - "localizedName" - ], - "type": "object", - "properties": { - "localizedName": { - "description": "Represents the name of the country.", - "type": "string" - }, - "countryCode": { - "description": "Represents the abbreviated name of the country.", - "type": "string" - } - } - }, - "PhoneNumberCountries": { - "description": "Represents a wrapper around a list of countries.", - "type": "object", - "properties": { - "countries": { - "description": "Represents the underlying list of countries.", - "type": "array", - "items": { - "$ref": "#/definitions/PhoneNumberCountry" + }, + "ReleaseRequest": { + "description": "Represents a release request.", + "required": [ + "phoneNumbers" + ], + "type": "object", + "properties": { + "phoneNumbers": { + "description": "The list of phone numbers in the release request.", + "type": "array", + "items": { + "type": "string" + } } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "NumberConfigurationPhoneNumber": { - "description": "The phone number wrapper representing a number configuration request", - "required": [ - "phoneNumber" - ], - "type": "object", - "properties": { - "phoneNumber": { - "description": "The phone number in the E.164 format", - "type": "string" } - } - }, - "PstnConfiguration": { - "description": "Definition for pstn number configuration", - "required": [ - "callbackUrl" - ], - "type": "object", - "properties": { - "callbackUrl": { - "description": "The webhook URL on the phone number configuration.", - "type": "string" - }, - "applicationId": { - "description": "The application id of the application to which to configure", - "type": "string" - }, - "azurePstnTargetId": { - "description": "Routable TargetId for the ACS Number", - "type": "string" - } - } - }, - "NumberConfigurationResponse": { - "description": "Definition for number configuration", - "required": [ - "pstnConfiguration" - ], - "type": "object", - "properties": { - "pstnConfiguration": { - "$ref": "#/definitions/PstnConfiguration" - } - } - }, - "NumberConfiguration": { - "description": "Definition for number configuration", - "required": [ - "phoneNumber", - "pstnConfiguration" - ], - "type": "object", - "properties": { - "pstnConfiguration": { - "$ref": "#/definitions/PstnConfiguration" - }, - "phoneNumber": { - "description": "The phone number to configure", - "type": "string" - } - } - }, - "CarrierDetails": { - "description": "Represents carrier details.", - "type": "object", - "properties": { - "name": { - "description": "Name of carrier details", - "type": "string" - }, - "localizedName": { - "description": "Display name of carrier details", - "type": "string" - } - } - }, - "RateInformation": { - "description": "Represents a wrapper of rate information", - "type": "object", - "properties": { - "monthlyRate": { - "format": "double", - "description": "The monthly rate of a phone plan group", - "type": "number" - }, - "currencyType": { - "description": "The currency of a phone plan group", - "enum": [ - "USD" - ], - "type": "string", - "x-ms-enum": { - "name": "CurrencyType", - "modelAsString": true + }, + "ReleaseResponse": { + "description": "Represents a release response.", + "required": [ + "releaseId" + ], + "type": "object", + "properties": { + "releaseId": { + "description": "The release id of a created release.", + "type": "string" } - }, - "rateErrorMessage": { - "description": "The error code of a phone plan group", - "type": "string" } - } - }, - "PhonePlanGroup": { - "description": "Represents a plan group.", - "required": [ - "localizedDescription", - "localizedName", - "phonePlanGroupId" - ], - "type": "object", - "properties": { - "phonePlanGroupId": { - "description": "The id of the plan group", - "type": "string" - }, - "phoneNumberType": { - "description": "The phone number type of the plan group", - "enum": [ - "Unknown", - "Geographic", - "TollFree", - "Indirect" - ], - "type": "string", - "x-ms-enum": { - "name": "PhoneNumberType", - "modelAsString": true + }, + "PhoneNumberEntity": { + "description": "Represents a phone number entity, as part of the response when calling get all searches or releases.", + "type": "object", + "properties": { + "id": { + "description": "The id of the entity. It is the search id of a searc. It is the release id of a release.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "Date and time the entity is created.", + "type": "string" + }, + "displayName": { + "description": "Name of the entity.", + "type": "string" + }, + "quantity": { + "format": "int32", + "description": "Quantity of requested phone numbers in the entity.", + "type": "integer" + }, + "quantityObtained": { + "format": "int32", + "description": "Quantity of acquired phone numbers in the entity.", + "type": "integer" + }, + "status": { + "description": "Status of the entity.", + "type": "string" + }, + "focDate": { + "format": "date-time", + "description": "The Firm Order Confirmation date of the phone number entity.", + "type": "string" } - }, - "localizedName": { - "description": "The name of the plan group.", - "type": "string" - }, - "localizedDescription": { - "description": "The description of the plan group.", - "type": "string" - }, - "carrierDetails": { - "$ref": "#/definitions/CarrierDetails" - }, - "rateInformation": { - "$ref": "#/definitions/RateInformation" } - } - }, - "PhonePlanGroups": { - "description": "Represents a wrapper of list of plan groups.", - "type": "object", - "properties": { - "phonePlanGroups": { - "description": "The underlying list of phone plan groups.", - "type": "array", - "items": { - "$ref": "#/definitions/PhonePlanGroup" + }, + "PhoneNumberEntities": { + "description": "Represents a list of searchs or releases, as part of the response when fetching all searches or releases.", + "type": "object", + "properties": { + "entities": { + "description": "The underlying list of entities.", + "type": "array", + "items": { + "$ref": "#/definitions/PhoneNumberEntity" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" } - } - }, - "PhonePlan": { - "description": "Represents a phone plan.", - "required": [ - "localizedName", - "locationType", - "phonePlanId" - ], - "type": "object", - "properties": { - "phonePlanId": { - "description": "The phone plan id", - "type": "string" - }, - "localizedName": { - "description": "The name of the phone plan", - "type": "string" - }, - "locationType": { - "description": "The location type of the phone plan.", - "enum": [ - "CivicAddress", - "NotRequired", - "Selection" - ], - "type": "string", - "x-ms-enum": { - "name": "LocationType", - "modelAsString": true - } - }, - "areaCodes": { - "description": "The list of available area codes in the phone plan.", - "type": "array", - "items": { + }, + "PhoneNumberSearch": { + "description": "Represents a phone number search", + "type": "object", + "properties": { + "searchId": { + "description": "The id of the search.", "type": "string" - } - }, - "capabilities": { - "description": "Capabilities of the phone plan.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", + }, + "displayName": { + "description": "The name of the search.", + "type": "string" + }, + "createdAt": { + "format": "date-time", + "description": "The creation time of the search.", + "type": "string" + }, + "description": { + "description": "The description of the search.", + "type": "string" + }, + "phonePlanIds": { + "description": "The phone plan ids of the search.", + "type": "array", + "items": { + "type": "string" + } + }, + "areaCode": { + "description": "The area code of the search.", + "type": "string" + }, + "quantity": { + "format": "int32", + "description": "The quantity of phone numbers in the search.", + "type": "integer" + }, + "locationOptions": { + "description": "The location options of the search.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } + }, + "status": { + "description": "The status of the search.", "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" + "Pending", + "InProgress", + "Reserved", + "Expired", + "Expiring", + "Completing", + "Refreshing", + "Success", + "Manual", + "Cancelled", + "Cancelling", + "Error", + "PurchasePending" ], "type": "string", "x-ms-enum": { - "name": "Capability", + "name": "SearchStatus", "modelAsString": true } - } - }, - "maximumSearchSize": { - "format": "int32", - "description": "The maximum number of phone numbers one can acquire in a search in this phone plan.", - "type": "integer" - } - } - }, - "PhonePlansResponse": { - "description": "Represents a wrapper around a list of countries.", - "type": "object", - "properties": { - "phonePlans": { - "description": "Represents the underlying list of phone plans.", - "type": "array", - "items": { - "$ref": "#/definitions/PhonePlan" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "LocationOptionsDetails": { - "description": "Represents location options deatils.", - "type": "object", - "properties": { - "name": { - "description": "The name of the location options", - "type": "string" - }, - "value": { - "description": "The abbreviated name of the location options", - "type": "string" - }, - "locationOptions": { - "description": "The underlying location options", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptions" - } - } - } - }, - "LocationOptions": { - "description": "Represents a location options.", - "type": "object", - "properties": { - "labelId": { - "description": "The label id of the location.", - "type": "string" - }, - "labelName": { - "description": "The display name of the location.", - "type": "string" - }, - "options": { - "description": "The underlying location option details.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } - } - } - }, - "LocationOptionsResponse": { - "description": "Represents a wrapper around a list of location options.", - "type": "object", - "properties": { - "locationOptions": { - "$ref": "#/definitions/LocationOptions" - } - } - }, - "PhoneNumberReleaseDetails": { - "type": "object", - "properties": { - "status": { - "description": "The release status of a phone number.", - "enum": [ - "Pending", - "Success", - "Error", - "InProgress" - ], - "type": "string", - "x-ms-enum": { - "name": "PhoneNumberReleaseStatus", - "modelAsString": true - } - }, - "errorCode": { - "format": "int32", - "description": "The error code in the case the status is error.", - "type": "integer" - } - } - }, - "PhoneNumberRelease": { - "description": "Represents a release", - "type": "object", - "properties": { - "releaseId": { - "description": "The id of the release.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The creation time of the release.", - "type": "string" - }, - "status": { - "description": "The release status.", - "enum": [ - "Pending", - "InProgress", - "Complete", - "Failed", - "Expired" - ], - "type": "string", - "x-ms-enum": { - "name": "ReleaseStatus", - "modelAsString": true - } - }, - "errorMessage": { - "description": "The underlying error message of a release.", - "type": "string" - }, - "phoneNumberReleaseStatusDetails": { - "description": "The list of phone numbers in the release, mapped to its individual statuses.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/PhoneNumberReleaseDetails" - } - } - } - }, - "ReleaseRequest": { - "description": "Represents a release request.", - "required": [ - "phoneNumbers" - ], - "type": "object", - "properties": { - "phoneNumbers": { - "description": "The list of phone numbers in the release request.", - "type": "array", - "items": { + }, + "phoneNumbers": { + "description": "The list of phone numbers in the search, in the case the status is reserved or success.", + "type": "array", + "items": { + "type": "string" + } + }, + "reservationExpiryDate": { + "format": "date-time", + "description": "The date that search expires and the numbers become available.", "type": "string" + }, + "errorCode": { + "format": "int32", + "description": "The error code of the search.", + "type": "integer" } } - } - }, - "ReleaseResponse": { - "description": "Represents a release response.", - "required": [ - "releaseId" - ], - "type": "object", - "properties": { - "releaseId": { - "description": "The release id of a created release.", - "type": "string" - } - } - }, - "PhoneNumberEntity": { - "description": "Represents a phone number entity, as part of the response when calling get all searches or releases.", - "type": "object", - "properties": { - "id": { - "description": "The id of the entity. It is the search id of a searc. It is the release id of a release.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "Date and time the entity is created.", - "type": "string" - }, - "displayName": { - "description": "Name of the entity.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "Quantity of requested phone numbers in the entity.", - "type": "integer" - }, - "quantityObtained": { - "format": "int32", - "description": "Quantity of acquired phone numbers in the entity.", - "type": "integer" - }, - "status": { - "description": "Status of the entity.", - "type": "string" - }, - "focDate": { - "format": "date-time", - "description": "The Firm Order Confirmation date of the phone number entity.", - "type": "string" - } - } - }, - "PhoneNumberEntities": { - "description": "Represents a list of searchs or releases, as part of the response when fetching all searches or releases.", - "type": "object", - "properties": { - "entities": { - "description": "The underlying list of entities.", - "type": "array", - "items": { - "$ref": "#/definitions/PhoneNumberEntity" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "PhoneNumberSearch": { - "description": "Represents a phone number search", - "type": "object", - "properties": { - "searchId": { - "description": "The id of the search.", - "type": "string" - }, - "displayName": { - "description": "The name of the search.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The creation time of the search.", - "type": "string" - }, - "description": { - "description": "The description of the search.", - "type": "string" - }, - "phonePlanIds": { - "description": "The phone plan ids of the search.", - "type": "array", - "items": { + }, + "CreateSearchOptions": { + "description": "Represents a search creation option.", + "required": [ + "areaCode", + "description", + "displayName", + "phonePlanIds" + ], + "type": "object", + "properties": { + "displayName": { + "description": "Display name of the search.", + "maxLength": 255, "type": "string" - } - }, - "areaCode": { - "description": "The area code of the search.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "The quantity of phone numbers in the search.", - "type": "integer" - }, - "locationOptions": { - "description": "The location options of the search.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } - }, - "status": { - "description": "The status of the search.", - "enum": [ - "Pending", - "InProgress", - "Reserved", - "Expired", - "Expiring", - "Completing", - "Refreshing", - "Success", - "Manual", - "Cancelled", - "Cancelling", - "Error", - "PurchasePending" - ], - "type": "string", - "x-ms-enum": { - "name": "SearchStatus", - "modelAsString": true - } - }, - "phoneNumbers": { - "description": "The list of phone numbers in the search, in the case the status is reserved or success.", - "type": "array", - "items": { + }, + "description": { + "description": "Description of the search.", + "maxLength": 255, + "type": "string" + }, + "phonePlanIds": { + "description": "The plan subtype ids from which to create the search.", + "type": "array", + "items": { + "type": "string" + } + }, + "areaCode": { + "description": "The area code from which to create the search.", "type": "string" + }, + "quantity": { + "format": "int32", + "description": "The quantity of phone numbers to request.", + "maximum": 2147483647, + "minimum": 1, + "type": "integer" + }, + "locationOptions": { + "description": "The location options of the search.", + "type": "array", + "items": { + "$ref": "#/definitions/LocationOptionsDetails" + } } - }, - "reservationExpiryDate": { - "format": "date-time", - "description": "The date that search expires and the numbers become available.", - "type": "string" - }, - "errorCode": { - "format": "int32", - "description": "The error code of the search.", - "type": "integer" } - } - }, - "CreateSearchOptions": { - "description": "Represents a search creation option.", - "required": [ - "areaCode", - "description", - "displayName", - "phonePlanIds" - ], - "type": "object", - "properties": { - "displayName": { - "description": "Display name of the search.", - "maxLength": 255, - "type": "string" - }, - "description": { - "description": "Description of the search.", - "maxLength": 255, - "type": "string" - }, - "phonePlanIds": { - "description": "The plan subtype ids from which to create the search.", - "type": "array", - "items": { + }, + "CreateSearchResponse": { + "description": "Represents a search creation response.", + "required": [ + "searchId" + ], + "type": "object", + "properties": { + "searchId": { + "description": "The search id of the search that was created.", "type": "string" } - }, - "areaCode": { - "description": "The area code from which to create the search.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "The quantity of phone numbers to request.", - "maximum": 2147483647, - "minimum": 1, - "type": "integer" - }, - "locationOptions": { - "description": "The location options of the search.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } } } }, - "CreateSearchResponse": { - "description": "Represents a search creation response.", - "required": [ - "searchId" - ], - "type": "object", - "properties": { - "searchId": { - "description": "The search id of the search that was created.", - "type": "string" - } + "parameters": { + "ApiVersionParameter": { + "in": "query", + "name": "api-version", + "description": "Version of API to invoke", + "required": true, + "type": "string" + }, + "Endpoint": { + "in": "path", + "name": "endpoint", + "description": "The endpoint of the Azure Communication resource.", + "required": true, + "type": "string", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client" } - } - }, - "parameters": { - "ApiVersionParameter": { - "in": "query", - "name": "api-version", - "description": "Version of API to invoke", - "required": true, - "type": "string" }, - "Endpoint": { - "in": "path", - "name": "endpoint", - "description": "The endpoint of the Azure Communication resource.", - "required": true, - "type": "string", - "x-ms-skip-url-encoding": true, - "x-ms-parameter-location": "client" - } - }, - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "impersonate your user account" - }, - "description": "Azure Active Directory OAuth2 Flow" - } - }, - "x-ms-parameterized-host": { - "hostTemplate": "{endpoint}", - "useSchemePrefix": false, - "parameters": [ - { - "$ref": "#/parameters/Endpoint" + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + }, + "description": "Azure Active Directory OAuth2 Flow" } - ] - } -} \ No newline at end of file + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + } + } \ No newline at end of file From 6905ac33a64f4b09943e087d3f0694a1a367f287 Mon Sep 17 00:00:00 2001 From: Eason Date: Fri, 2 Oct 2020 00:51:01 -0700 Subject: [PATCH 05/11] Azure Communication Service - Phone Number Administration - Samples (#14162) * add tnm samples v0 * address comments * update samples with long run operation * add basic readme for phone number description * add e=code example to tnm readme * update admin setup.py with long_description_content_type Co-authored-by: Eason Yang --- .../README.md | 153 ++++++++++++++++++ .../samples/phone_number_area_codes_sample.py | 45 ++++++ .../phone_number_area_codes_sample_async.py | 50 ++++++ .../phone_number_capabilities_sample.py | 71 ++++++++ .../phone_number_capabilities_sample_async.py | 82 ++++++++++ .../phone_number_configuration_sample.py | 58 +++++++ ...phone_number_configuration_sample_async.py | 63 ++++++++ .../samples/phone_number_orders_sample.py | 110 +++++++++++++ .../phone_number_orders_sample_async.py | 124 ++++++++++++++ .../samples/phone_number_plans_sample.py | 72 +++++++++ .../phone_number_plans_sample_async.py | 81 ++++++++++ ...phone_number_supported_countries_sample.py | 39 +++++ ...number_supported_countries_sample_async.py | 43 +++++ .../setup.py | 1 + 14 files changed, 992 insertions(+) create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_area_codes_sample_async.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_capabilities_sample_async.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_configuration_sample_async.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_orders_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_orders_sample_async.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_plans_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_plans_sample_async.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_sample.py create mode 100644 sdk/communication/azure-communication-administration/samples/phone_number_supported_countries_sample_async.py diff --git a/sdk/communication/azure-communication-administration/README.md b/sdk/communication/azure-communication-administration/README.md index 2eb861105c872..ebab042214b2b 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,135 @@ 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 +def list_all_supported_countries(): + 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 +def list_phone_plan_groups(): + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") + + phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups( + country_code=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 +def list_phone_plans(): + 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_plans_response = phone_number_administration_client.list_phone_plans( + country_code=country_code, + phone_plan_group_id=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 +def get_phone_plan_location_options(): + 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") + + 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 + ) + 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 +def get_all_area_codes(): + 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") + + 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 + ) + print(all_area_codes) +``` + +### Create Search + +```python +def create_search(): + from azure.communication.administration import CreateSearchOptions + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") + area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH', "area-code") + + 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.begin_create_search( + body=searchOptions + ) + print(search_response.status()) +``` + +### Get search by id +```python +def get_search_by_id(): + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID', "search-id") + + phone_number_search_response = phone_number_administration_client.get_search_by_id( + search_id=search_id + ) + print(phone_number_search_response) +``` + +### Purchase Search + +```python +def purchase_search(): + phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) + search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE', "search-id") + + phone_number_administration_client.begin_purchase_search( + search_id=search_id_to_purchase + ) +``` + # Troubleshooting The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. 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 0000000000000..009c008abcea2 --- /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 0000000000000..0cc953b9d1e15 --- /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 0000000000000..44b9dcb1a8796 --- /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 0000000000000..f45c6a430f04f --- /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 0000000000000..d66dea3258f17 --- /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 0000000000000..917d3992bd8cb --- /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 0000000000000..1a64a3950cbba --- /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.begin_create_search( + body=searchOptions + ) + # [END create_search] + print('search_response status:') + print(search_response.status()) + + +def cancel_search(): + # [START cancel_search] + phone_number_administration_client.begin_cancel_search( + search_id=search_id_to_cancel + ) + # [START cancel_search] + + +def purchase_search(): + # [START cancel_search] + phone_number_administration_client.begin_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 0000000000000..ec5b1e851a2dc --- /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.begin_create_search( + body=searchOptions + ) + print('search_response status:') + print(search_response.status()) + # [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.begin_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.begin_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 0000000000000..360c07f099a63 --- /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 0000000000000..4460686c8bcea --- /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 0000000000000..40489c488c845 --- /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 0000000000000..0069bbe5ec4fc --- /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/setup.py b/sdk/communication/azure-communication-administration/setup.py index a2e8164380940..ca5aac5ec0156 100644 --- a/sdk/communication/azure-communication-administration/setup.py +++ b/sdk/communication/azure-communication-administration/setup.py @@ -36,6 +36,7 @@ # ensure that these are updated to reflect the package owners' information long_description=long_description, + long_description_content_type='text/markdown', url='https://github.com/Azure/azure-sdk-for-python', author='Microsoft Corporation', author_email='azuresdkengsysadmins@microsoft.com', From 1acce650f158bae29038ea05d3bec75afc727c89 Mon Sep 17 00:00:00 2001 From: Heli Wang Date: Fri, 2 Oct 2020 11:25:48 -0700 Subject: [PATCH 06/11] Revert "Azure Communication Services - Phone Number Admin - Implementing long running operations for phone number search (#14157)" (#14208) This reverts commit fd7191de8705d4d06e141209bd6a2b9ab1d92fbb. --- .../communication/administration/__init__.py | 10 +- .../_phone_number_administration_client.py | 149 ++++------------- .../communication/administration/_polling.py | 76 --------- .../administration/aio/__init__.py | 4 +- ...hone_number_administration_client_async.py | 151 +++--------------- .../administration/aio/_polling_async.py | 76 --------- 6 files changed, 58 insertions(+), 408 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py 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 ecd289cb703fc..2864e79e5e5e0 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -6,7 +6,6 @@ from ._communication_identity_client import CommunicationIdentityClient from ._phone_number_administration_client import PhoneNumberAdministrationClient -from ._polling import PhoneNumberPolling from ._identity._generated.models import ( CommunicationTokenRequest, @@ -17,7 +16,6 @@ AcquiredPhoneNumber, AcquiredPhoneNumbers, AreaCodes, - CreateSearchOptions, CreateSearchResponse, LocationOptionsQuery, LocationOptionsResponse, @@ -33,7 +31,7 @@ ReleaseResponse, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse, - SearchStatus + CreateSearchOptions ) from ._shared.models import ( @@ -45,7 +43,6 @@ __all__ = [ 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', - 'PhoneNumberPolling', # from _identity 'CommunicationTokenRequest', @@ -55,7 +52,6 @@ 'AcquiredPhoneNumber', 'AcquiredPhoneNumbers', 'AreaCodes', - 'CreateSearchOptions', 'CreateSearchResponse', 'LocationOptionsQuery', 'LocationOptionsResponse', @@ -63,15 +59,15 @@ 'NumberUpdateCapabilities', 'PhoneNumberCountries', 'PhoneNumberEntities', - 'PhoneNumberSearch', 'PhoneNumberRelease', + 'PhoneNumberSearch', 'PhonePlanGroups', 'PhonePlansResponse', 'PstnConfiguration', 'ReleaseResponse', - 'SearchStatus', 'UpdateNumberCapabilitiesResponse', 'UpdatePhoneNumberCapabilitiesResponse', + 'CreateSearchOptions', # from _shared 'CommunicationUser', 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 index ee393fac84aed..edc0a5657235f 100644 --- 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 @@ -6,8 +6,6 @@ # ------------------------------------ from azure.core.tracing.decorator import distributed_trace from azure.core.paging import ItemPaged -from azure.core.polling import LROPoller -from ._polling import PhoneNumberPolling from ._phonenumber._generated._phone_number_administration_service\ import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen @@ -15,6 +13,7 @@ from ._phonenumber._generated.models import ( AcquiredPhoneNumbers, AreaCodes, + CreateSearchResponse, LocationOptionsResponse, NumberConfigurationResponse, NumberUpdateCapabilities, @@ -26,7 +25,6 @@ PhonePlansResponse, PstnConfiguration, ReleaseResponse, - SearchStatus, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse ) @@ -407,53 +405,21 @@ def get_search_by_id( ) @distributed_trace - def begin_create_search( + def create_search( self, **kwargs # type: Any ): - # type: (...) -> LROPoller - """Begins creating a phone number search. - Caller must provide either body, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword body will be ignored. + # type: (...) -> CreateSearchResponse + """Creates a phone number search. :keyword azure.communication.administration.CreateSearchOptions body: - A parameter for defining the search options. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] + An optional parameter for defining the search options. + The default is None. + :rtype: ~azure.communication.administration.CreateSearchResponse """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPolling( - is_terminated=lambda status: status in [ - SearchStatus.Reserved, - SearchStatus.Expired, - SearchStatus.Success, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "body" not in kwargs: - raise ValueError("Either kwarg 'body' or 'continuation_token' needs to be specified") - - create_search_response = self._phone_number_administration_client.phone_number_administration.create_search( + return self._phone_number_administration_client.phone_number_administration.create_search( **kwargs ) - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=create_search_response.search_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) @distributed_trace def list_all_searches( @@ -474,96 +440,37 @@ def list_all_searches( ) @distributed_trace - def begin_cancel_search( + def cancel_search( self, + search_id, # type: str **kwargs # type: Any ): - # type: (...) -> LROPoller - """Begins the phone number search cancellation. - Caller must provide either search_id, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword search_id will be ignored. - - :keyword str search_id: The search id to be canceled. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPolling( - is_terminated=lambda status: status in [ - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - search_id = kwargs.pop('search_id', None) # type: str - if search_id is None: - raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") + # type: (...) -> None + """Cancels the search. This means existing numbers in the search will be made available. - self._phone_number_administration_client.phone_number_administration.cancel_search( + :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 ) - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=search_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) @distributed_trace - def begin_purchase_search( - self, - **kwargs # type: Any + def purchase_search( + self, + search_id, # type: str + **kwargs # type: Any ): - # type: (...) -> LROPoller - """Begins the phone number search purchase. - Caller must provide either search_id, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword search_id will be ignored. - - :keyword str search_id: The search id to be purchased. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.LROPoller[~azure.communication.administration.PhoneNumberSearch] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPolling( - is_terminated=lambda status: status in [ - SearchStatus.Success, - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return LROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - search_id = kwargs.pop('search_id') # type: str + # type: (...) -> None + """Purchases the phone number search. - self._phone_number_administration_client.phone_number_administration.purchase_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 ) - initial_state = self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=search_id - ) - return LROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py deleted file mode 100644 index 05555abc171ef..0000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_polling.py +++ /dev/null @@ -1,76 +0,0 @@ -# pylint: disable=W0231 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import base64 -import time -from typing import Union -from functools import partial -import pickle - -from azure.core.polling import ( - PollingMethod -) -from ._phonenumber._generated.models import ( - PhoneNumberSearch, - PhoneNumberRelease -) - -class PhoneNumberPolling(PollingMethod): - def __init__(self, is_terminated, interval=5): - self._response = None - self._client = None - self._query_status = None - self._is_terminated = is_terminated - self._polling_interval = interval - - def _update_status(self): - # type: () -> None - if self._query_status is None: - raise Exception("this poller has not been initialized") - self._response = self._query_status() - - def initialize(self, client, initial_response, _): - # type: (Any, Any, Callable) -> None - self._client = client - self._response = initial_response - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.search_id) - - def run(self): - # type: () -> None - while not self.finished(): - self._update_status() - if not self.finished(): - time.sleep(self._polling_interval) - - def finished(self): - # type: () -> bool - if self._response.status is None: - return False - return self._is_terminated(self._response.status) - - def resource(self): - # type: () -> Union[PhoneNumberSearch, PhoneNumberRelease] - if not self.finished(): - return None - return self._response - - def status(self): - # type: () -> str - return self._response.status - - def get_continuation_token(self): - # type() -> str - return base64.b64encode(pickle.dumps(self._response)).decode('ascii') - - @classmethod - def from_continuation_token(cls, continuation_token, **kwargs): - # type(str, Any) -> Tuple - try: - client = kwargs["client"] - except KeyError: - raise ValueError("Kwarg 'client' needs to be specified") - initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec - return client, initial_response, None 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 dc793b7fa747a..f647dfa8f5060 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,9 +1,7 @@ from ._communication_identity_client_async import CommunicationIdentityClient from ._phone_number_administration_client_async import PhoneNumberAdministrationClient -from ._polling_async import PhoneNumberPollingAsync __all__ = [ 'CommunicationIdentityClient', - 'PhoneNumberAdministrationClient', - 'PhoneNumberPollingAsync' + '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 index 8cfd19cb7a0fe..50637b8ce7298 100644 --- 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 @@ -5,14 +5,10 @@ # 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 azure.core.polling import AsyncLROPoller - from .._version import SDK_MONIKER -from ._polling_async import PhoneNumberPollingAsync from .._phonenumber._generated.aio._phone_number_administration_service_async\ import PhoneNumberAdministrationService as PhoneNumberAdministrationClientGen @@ -20,6 +16,7 @@ from .._phonenumber._generated.models import ( AcquiredPhoneNumbers, AreaCodes, + CreateSearchResponse, LocationOptionsResponse, NumberConfigurationResponse, NumberUpdateCapabilities, @@ -31,7 +28,6 @@ PhonePlansResponse, PstnConfiguration, ReleaseResponse, - SearchStatus, UpdateNumberCapabilitiesResponse, UpdatePhoneNumberCapabilitiesResponse ) @@ -416,54 +412,21 @@ async def get_search_by_id( ) @distributed_trace_async - async def begin_create_search( + async def create_search( self, **kwargs # type: Any ): - # type: (...) -> AsyncLROPoller - """Begins creating a phone number search. - Caller must provide either body, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword body will be ignored. + # type: (...) -> CreateSearchResponse + """Creates a phone number search. :keyword azure.communication.administration.CreateSearchOptions body: - A parameter for defining the search options. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] + An optional parameter for defining the search options. + The default is None. + :rtype: ~azure.communication.administration.CreateSearchResponse """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPollingAsync( - is_terminated=lambda status: status in [ - SearchStatus.Reserved, - SearchStatus.Expired, - SearchStatus.Success, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - if "body" not in kwargs: - raise ValueError("Either kwarg 'body' or 'continuation_token' needs to be specified") - - create_search_response = await self._phone_number_administration_client.\ - phone_number_administration.create_search( - **kwargs - ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=create_search_response.search_id + return await self._phone_number_administration_client.phone_number_administration.create_search( + **kwargs ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) @distributed_trace def list_all_searches( @@ -484,102 +447,40 @@ def list_all_searches( ) @distributed_trace_async - async def begin_cancel_search( + async def cancel_search( self, + search_id, # type: str **kwargs # type: Any ): - # type: (...) -> AsyncLROPoller - """Begins the phone number search cancellation. - Caller must provide either search_id, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword search_id will be ignored. - - :keyword str search_id: The search id to be canceled. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] - """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPollingAsync( - is_terminated=lambda status: status in [ - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - search_id = kwargs.pop('search_id', None) # type: str - if search_id is None: - raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") + # type: (...) -> None + """Cancels the search. This means existing numbers in the search will be made available. - await self._phone_number_administration_client.phone_number_administration.cancel_search( + :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 ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=search_id - ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) @distributed_trace_async - async def begin_purchase_search( + async def purchase_search( self, + search_id, # type: str **kwargs # type: Any ): + # type: (...) -> None + """Purchases the phone number search. - # type: (...) -> AsyncLROPoller - """Begins the phone number search purchase. - Caller must provide either search_id, or continuation_token keywords to use the method. - If both body and continuation_token are specified, only continuation_token will be used to - restart a poller from a saved state, and keyword search_id will be ignored. - - :keyword str search_id: The search id to be purchased. - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.communication.administration.PhoneNumberSearch] + :param search_id: The search id to be purchased. + :type search_id: str + :rtype: None """ - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - - search_polling = PhoneNumberPollingAsync( - is_terminated=lambda status: status in [ - SearchStatus.Success, - SearchStatus.Expired, - SearchStatus.Cancelled, - SearchStatus.Error - ] - ) - - if cont_token is not None: - return AsyncLROPoller.from_continuation_token( - polling_method=search_polling, - continuation_token=cont_token, - client=self._phone_number_administration_client.phone_number_administration - ) - - search_id = kwargs.pop('search_id', None) # type: str - if search_id is None: - raise ValueError("Either kwarg 'search_id' or 'continuation_token' needs to be specified") - - await self._phone_number_administration_client.phone_number_administration.purchase_search( + return await self._phone_number_administration_client.phone_number_administration.purchase_search( search_id, **kwargs ) - initial_state = await self._phone_number_administration_client.phone_number_administration.get_search_by_id( - search_id=search_id - ) - return AsyncLROPoller(client=self._phone_number_administration_client.phone_number_administration, - initial_response=initial_state, - deserialization_callback=None, - polling_method=search_polling) async def __aenter__(self) -> "PhoneNumberAdministrationClient": await self._phone_number_administration_client.__aenter__() diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py deleted file mode 100644 index 06000f10040bd..0000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_polling_async.py +++ /dev/null @@ -1,76 +0,0 @@ -# pylint: disable=W0231 -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import asyncio -from typing import Union -import base64 -from functools import partial - -from azure.core.polling import AsyncPollingMethod - -from .._phonenumber._generated.models import ( - PhoneNumberSearch, - PhoneNumberRelease -) - -class PhoneNumberPollingAsync(AsyncPollingMethod): - def __init__(self, is_terminated, interval=5): - self._response = None - self._client = None - self._query_status = None - self._is_terminated = is_terminated - self._polling_interval = interval - - async def _update_status(self): - # type: () -> None - if self._query_status is None: - raise Exception("this poller has not been initialized") - self._response = await self._query_status() - - def initialize(self, client, initial_response, _): - # type: (Any, Any, Callable) -> None - self._client = client - self._response = initial_response - self._query_status = partial(self._client.get_search_by_id, search_id=initial_response.search_id) - - async def run(self): - # type: () -> None - while not self.finished(): - await self._update_status() - if not self.finished(): - await asyncio.sleep(self._polling_interval) - - def finished(self): - # type: () -> bool - if self._response.status is None: - return False - return self._is_terminated(self._response.status) - - def resource(self): - # type: () -> Union[PhoneNumberSearch, PhoneNumberRelease] - if not self.finished(): - return None - return self._response - - def status(self): - # type: () -> str - return self._response.status - - def get_continuation_token(self): - # type() -> str - import pickle - return base64.b64encode(pickle.dumps(self._response)).decode('ascii') - - @classmethod - def from_continuation_token(cls, continuation_token, **kwargs): - # type(str, Any) -> Tuple - try: - client = kwargs["client"] - except KeyError: - raise ValueError("Kwarg 'client' needs to be specified") - import pickle - initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec - return client, initial_response, None From daa4caa253ad43f7bb3a8c3a26c021caf183df9d Mon Sep 17 00:00:00 2001 From: Eason Date: Fri, 2 Oct 2020 11:53:50 -0700 Subject: [PATCH 07/11] revert LRO from TNM samples (#14211) Co-authored-by: Eason Yang --- .../samples/phone_number_orders_sample.py | 10 +++++----- .../samples/phone_number_orders_sample_async.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) 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 index 1a64a3950cbba..82489f73e916c 100644 --- a/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample.py +++ b/sdk/communication/azure-communication-administration/samples/phone_number_orders_sample.py @@ -77,17 +77,17 @@ def create_search(): phone_plan_ids=[phone_plan_id], quantity=1 ) - search_response = phone_number_administration_client.begin_create_search( + search_response = phone_number_administration_client.create_search( body=searchOptions ) # [END create_search] - print('search_response status:') - print(search_response.status()) + print('search_response:') + print(search_response) def cancel_search(): # [START cancel_search] - phone_number_administration_client.begin_cancel_search( + phone_number_administration_client.cancel_search( search_id=search_id_to_cancel ) # [START cancel_search] @@ -95,7 +95,7 @@ def cancel_search(): def purchase_search(): # [START cancel_search] - phone_number_administration_client.begin_purchase_search( + phone_number_administration_client.purchase_search( search_id=search_id_to_purchase ) # [END cancel_search] 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 index ec5b1e851a2dc..88aae29b372ba 100644 --- 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 @@ -83,11 +83,11 @@ async def create_search(): quantity=1 ) async with phone_number_administration_client: - search_response = await phone_number_administration_client.begin_create_search( + search_response = await phone_number_administration_client.create_search( body=searchOptions ) - print('search_response status:') - print(search_response.status()) + print('search_response:') + print(search_response) # [END create_search] @@ -95,7 +95,7 @@ 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.begin_cancel_search( + await phone_number_administration_client.cancel_search( search_id=search_id_to_cancel ) # [END cancel_search] @@ -105,7 +105,7 @@ 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.begin_purchase_search( + await phone_number_administration_client.purchase_search( search_id=search_id_to_purchase ) # [END purchase_search] From 5317abe1502ea8828601b0eacfd2f649ee2284cc Mon Sep 17 00:00:00 2001 From: Heli Wang Date: Fri, 2 Oct 2020 12:19:39 -0700 Subject: [PATCH 08/11] refresh swagger link and auto generated code (#14210) --- ..._number_administration_operations_async.py | 10 +- .../_phonenumber/_generated/models/_models.py | 8 +- .../_generated/models/_models_py3.py | 8 +- ..._phone_number_administration_operations.py | 10 +- .../swagger/PHONE_NUMBER_SWAGGER.md | 2 +- .../swagger/phone_number_swagger.json | 2056 ----------------- 6 files changed, 19 insertions(+), 2075 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json 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 index ab0e61661d5c0..2e4075a2f4bc3 100644 --- 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 @@ -51,7 +51,7 @@ def get_all_phone_numbers( Gets the list of the acquired phone numbers. - :param locale: A language-locale pairing which will be used to localise the names of 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 @@ -331,7 +331,7 @@ def get_all_supported_countries( Gets a list of supported countries. - :param locale: A language-locale pairing which will be used to localise the names of 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 @@ -607,7 +607,7 @@ def get_phone_plan_groups( :param country_code: The ISO 3166-2 country code. :type country_code: str - :param locale: A language-locale pairing which will be used to localise the names of countries. + :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 @@ -704,7 +704,7 @@ def get_phone_plans( :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 localise the names of 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 @@ -800,7 +800,7 @@ async def get_phone_plan_location_options( :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 localise the names of countries. + :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) 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 index fbee8df115569..0f9531291baef 100644 --- 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 @@ -281,7 +281,7 @@ def __init__( class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options deatils. + """Represents location options details. :param name: The name of the location options. :type name: str @@ -527,7 +527,7 @@ def __init__( class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searchs or releases, as part of the response when fetching all searches or releases. + """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] @@ -552,7 +552,7 @@ def __init__( 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 searc. It is the release id of a + :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. @@ -1025,7 +1025,7 @@ def __init__( class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): """Response for getting a phone number update capabilities. - :param capabilities_update_id: The id of the phone number capabilties update. + :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 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 index b798bad2aceb5..78a269c7f21c9 100644 --- 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 @@ -321,7 +321,7 @@ def __init__( class LocationOptionsDetails(msrest.serialization.Model): - """Represents location options deatils. + """Represents location options details. :param name: The name of the location options. :type name: str @@ -594,7 +594,7 @@ def __init__( class PhoneNumberEntities(msrest.serialization.Model): - """Represents a list of searchs or releases, as part of the response when fetching all searches or releases. + """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] @@ -622,7 +622,7 @@ def __init__( 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 searc. It is the release id of a + :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. @@ -1160,7 +1160,7 @@ def __init__( class UpdatePhoneNumberCapabilitiesResponse(msrest.serialization.Model): """Response for getting a phone number update capabilities. - :param capabilities_update_id: The id of the phone number capabilties update. + :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 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 index f26cdc45f7fb5..9357db8f92802 100644 --- 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 @@ -56,7 +56,7 @@ def get_all_phone_numbers( Gets the list of the acquired phone numbers. - :param locale: A language-locale pairing which will be used to localise the names of 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 @@ -340,7 +340,7 @@ def get_all_supported_countries( Gets a list of supported countries. - :param locale: A language-locale pairing which will be used to localise the names of 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 @@ -620,7 +620,7 @@ def get_phone_plan_groups( :param country_code: The ISO 3166-2 country code. :type country_code: str - :param locale: A language-locale pairing which will be used to localise the names of countries. + :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 @@ -718,7 +718,7 @@ def get_phone_plans( :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 localise the names of 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 @@ -815,7 +815,7 @@ def get_phone_plan_location_options( :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 localise the names of countries. + :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) diff --git a/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md b/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md index 0948bd41e91b3..328a5058cf13b 100644 --- a/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md +++ b/sdk/communication/azure-communication-administration/swagger/PHONE_NUMBER_SWAGGER.md @@ -10,7 +10,7 @@ autorest ./PHONE_NUMBER_SWAGGER.md ### Settings ``` yaml -input-file: ./phone_number_swagger.json +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 diff --git a/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json b/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json deleted file mode 100644 index ef652de3adaaf..0000000000000 --- a/sdk/communication/azure-communication-administration/swagger/phone_number_swagger.json +++ /dev/null @@ -1,2056 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Phone Number Administration Service", - "description": "Phone Number Administration Service", - "contact": { - "email": "acsdevexdisc@microsoft.com" - }, - "version": "2020-07-20-preview1" - }, - "paths": { - "/administration/phonenumbers/phonenumbers": { - "get": { - "tags": [ - "AcquiredNumbers" - ], - "summary": "Gets the list of the acquired phone numbers.", - "operationId": "PhoneNumberAdministration_GetAllPhoneNumbers", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/AcquiredPhoneNumbers" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phoneNumbers" - }, - "x-ms-examples": { - "List acquired phone numbers": { - "$ref": "./examples/GetAcquiredPhoneNumbersAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries/{countryCode}/areacodes": { - "post": { - "tags": [ - "AreaCodes" - ], - "summary": "Gets a list of the supported area codes", - "operationId": "PhoneNumberAdministration_GetAllAreaCodes", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locationType", - "description": "The type of location information required by the plan.", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "phonePlanId", - "description": "The plan id from which to search area codes.", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "Location options for when location type is selection.", - "schema": { - "$ref": "#/definitions/LocationOptionsQueries" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/AreaCodes" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get area codes": { - "$ref": "./examples/GetAreaCodesAsync.json" - } - } - } - }, - "/administration/phonenumbers/capabilities/{capabilitiesUpdateId}": { - "get": { - "tags": [ - "Capabilities" - ], - "summary": "Get capabilities by capabilities update id.", - "operationId": "PhoneNumberAdministration_GetCapabilitiesUpdate", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "capabilitiesUpdateId", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/UpdatePhoneNumberCapabilitiesResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get number capabilities update": { - "$ref": "./examples/GetNumberCapabilitiesUpdateAsync.json" - } - } - } - }, - "/administration/phonenumbers/capabilities": { - "post": { - "tags": [ - "Capabilities" - ], - "summary": "Adds or removes phone number capabilities", - "operationId": "PhoneNumberAdministration_UpdateCapabilities", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "", - "schema": { - "$ref": "#/definitions/UpdateNumberCapabilitiesRequest" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/UpdateNumberCapabilitiesResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Update number capabilities": { - "$ref": "./examples/UpdateNumberCapabilitiesAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries": { - "get": { - "tags": [ - "Countries" - ], - "summary": "Gets a list of supported countries", - "operationId": "PhoneNumberAdministration_GetAllSupportedCountries", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberCountries" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "countries" - }, - "x-ms-examples": { - "Get countries": { - "$ref": "./examples/GetCountriesAsync.json" - } - } - } - }, - "/administration/phonenumbers/numberconfiguration": { - "post": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for getting number configurations", - "operationId": "PhoneNumberAdministration_GetNumberConfiguration", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "The phone number whose configuration is to be fetched", - "schema": { - "$ref": "#/definitions/NumberConfigurationPhoneNumber" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/NumberConfigurationResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get number configuration for phone number": { - "$ref": "./examples/GetNumberConfigurationAsync.json" - } - } - } - }, - "/administration/phonenumbers/numberconfiguration/configure": { - "patch": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for configuring a pstn number", - "operationId": "PhoneNumberAdministration_ConfigureNumber", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "Details of pstn number configuration of the given phoneNumber", - "schema": { - "$ref": "#/definitions/NumberConfiguration" - } - } - ], - "responses": { - "200": { - "description": "Success" - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Configure phone number": { - "$ref": "./examples/ConfigurePhoneNumberAsync.json" - } - } - } - }, - "/administration/phonenumbers/numberconfiguration/unconfigure": { - "patch": { - "tags": [ - "NumberConfiguration" - ], - "summary": "Endpoint for unconfiguring a pstn number by removing the configuration", - "operationId": "PhoneNumberAdministration_UnconfigureNumber", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "The phone number to un-configure", - "schema": { - "$ref": "#/definitions/NumberConfigurationPhoneNumber" - } - } - ], - "responses": { - "200": { - "description": "Success" - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Unconfigure phone number": { - "$ref": "./examples/UnconfigurePhoneNumberAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of phone plan groups for the given country", - "operationId": "PhoneNumberAdministration_GetPhonePlanGroups", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "includeRateInformation", - "type": "boolean", - "default": false - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhonePlanGroups" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phonePlanGroups" - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetPhonePlanGroupsAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of phone plans for a phone plan group", - "operationId": "PhoneNumberAdministration_GetPhonePlans", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "phonePlanGroupId", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhonePlansResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "phonePlans" - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetPhonePlansAsync.json" - } - } - } - }, - "/administration/phonenumbers/countries/{countryCode}/phoneplangroups/{phonePlanGroupId}/phoneplans/{phonePlanId}/locationoptions": { - "get": { - "tags": [ - "Plans" - ], - "summary": "Gets a list of location options for a phone plan", - "operationId": "PhoneNumberAdministration_GetPhonePlanLocationOptions", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "countryCode", - "description": "The ISO 3166-2 country code.", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "phonePlanGroupId", - "required": true, - "type": "string" - }, - { - "in": "path", - "name": "phonePlanId", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "locale", - "description": "A language-locale pairing which will be used to localise the names of countries", - "type": "string", - "default": "en-US" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/LocationOptionsResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get plans": { - "$ref": "./examples/GetLocationOptionsAsync.json" - } - } - } - }, - "/administration/phonenumbers/releases/{releaseId}": { - "get": { - "tags": [ - "Release" - ], - "summary": "Gets a release by a release id", - "operationId": "PhoneNumberAdministration_GetReleaseById", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "releaseId", - "description": "Represents the release id", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberRelease" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get release by id": { - "$ref": "./examples/GetReleaseByIdAsync.json" - } - } - } - }, - "/administration/phonenumbers/releases": { - "post": { - "tags": [ - "Release" - ], - "summary": "Creates a release for the given phone numbers", - "operationId": "PhoneNumberAdministration_ReleasePhoneNumbers", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "Config api Release request", - "schema": { - "$ref": "#/definitions/ReleaseRequest" - } - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/ReleaseResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get release": { - "$ref": "./examples/CreateReleaseAsync.json" - } - } - }, - "get": { - "tags": [ - "Release" - ], - "summary": "Gets a list of all releases", - "operationId": "PhoneNumberAdministration_GetAllReleases", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberEntities" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "entities" - }, - "x-ms-examples": { - "Get all releases": { - "$ref": "./examples/GetAllReleasesAsync.json" - } - } - } - }, - "/administration/phonenumbers/searches/{searchId}": { - "get": { - "tags": [ - "Search" - ], - "summary": "Get search by search id", - "operationId": "PhoneNumberAdministration_GetSearchById", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be searched for", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberSearch" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Get search by search id": { - "$ref": "./examples/GetSearchByIdAsync.json" - } - } - } - }, - "/administration/phonenumbers/searches": { - "post": { - "tags": [ - "Search" - ], - "summary": "Creates a phone number search", - "operationId": "PhoneNumberAdministration_CreateSearch", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "in": "body", - "name": "body", - "description": "Defines the search options", - "schema": { - "$ref": "#/definitions/CreateSearchOptions" - } - } - ], - "responses": { - "201": { - "description": "Success", - "schema": { - "$ref": "#/definitions/CreateSearchResponse" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Create search": { - "$ref": "./examples/CreateSearchAsync.json" - } - } - }, - "get": { - "tags": [ - "Search" - ], - "summary": "Gets a list of all searches", - "operationId": "PhoneNumberAdministration_GetAllSearches", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "query", - "name": "skip", - "description": "An optional parameter for how many entries to skip, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 0 - }, - { - "in": "query", - "name": "take", - "description": "An optional parameter for how many entries to return, for pagination purposes.", - "type": "integer", - "format": "int32", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/PhoneNumberEntities" - } - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink", - "itemName": "entities" - }, - "x-ms-examples": { - "Get all searches": { - "$ref": "./examples/GetAllSearchesAsync.json" - } - } - } - }, - "/administration/phonenumbers/searches/{searchId}/cancel": { - "post": { - "tags": [ - "Search" - ], - "summary": "Cancels the search. This means existing numbers in the search will be made available.", - "operationId": "PhoneNumberAdministration_CancelSearch", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be canceled", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "202": { - "description": "Success" - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Cancel phone number search": { - "$ref": "./examples/CancelSearchAsync.json" - } - } - } - }, - "/administration/phonenumbers/searches/{searchId}/purchase": { - "post": { - "tags": [ - "Search" - ], - "summary": "Purchases the phone number search.", - "operationId": "PhoneNumberAdministration_PurchaseSearch", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "searchId", - "description": "The search id to be purchased", - "required": true, - "type": "string" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "202": { - "description": "Success" - }, - "default": { - "description": "Failure", - "schema": { - "$ref": "#/definitions/ErrorResponse" - } - } - }, - "x-ms-examples": { - "Purchase phone number search": { - "$ref": "./examples/PurchaseSearchAsync.json" - } - } - } - } - }, - "definitions": { - "AcquiredPhoneNumber": { - "description": "Represents an acquired phone number.", - "required": [ - "acquiredCapabilities", - "availableCapabilities", - "phoneNumber" - ], - "type": "object", - "properties": { - "phoneNumber": { - "description": "String of the E.164 format of the phone number", - "type": "string" - }, - "acquiredCapabilities": { - "description": "The set of all acquired capabilities of the phone number.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", - "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" - ], - "type": "string", - "x-ms-enum": { - "name": "Capability", - "modelAsString": true - } - } - }, - "availableCapabilities": { - "description": "The set of all available capabilities that can be acquired for this phone number.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", - "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" - ], - "type": "string", - "x-ms-enum": { - "name": "Capability", - "modelAsString": true - } - } - }, - "assignmentStatus": { - "description": "The assignment status of the phone number. Conveys what type of entity the number is assigned to.", - "enum": [ - "Unassigned", - "Unknown", - "UserAssigned", - "ConferenceAssigned", - "FirstPartyAppAssigned", - "ThirdPartyAppAssigned" - ], - "type": "string", - "x-ms-enum": { - "name": "AssignmentStatus", - "modelAsString": true - } - }, - "placeName": { - "description": "The name of the place of the phone number.", - "type": "string" - }, - "activationState": { - "description": "The activation state of the phone number. Can be \"Activated\", \"AssignmentPending\", \"AssignmentFailed\", \"UpdatePending\", \"UpdateFailed\"", - "enum": [ - "Activated", - "AssignmentPending", - "AssignmentFailed", - "UpdatePending", - "UpdateFailed" - ], - "type": "string", - "x-ms-enum": { - "name": "ActivationState", - "modelAsString": true - } - } - } - }, - "AcquiredPhoneNumbers": { - "description": "A wrapper of list of phone numbers", - "type": "object", - "properties": { - "phoneNumbers": { - "description": "Represents a list of phone numbers", - "type": "array", - "items": { - "$ref": "#/definitions/AcquiredPhoneNumber" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "ErrorBody": { - "description": "Represents a service error response body.", - "type": "object", - "properties": { - "code": { - "description": "The error code in the error response.", - "type": "string" - }, - "message": { - "description": "The error message in the error response.", - "type": "string" - } - } - }, - "ErrorResponse": { - "description": "Represents a service error response.", - "type": "object", - "properties": { - "error": { - "$ref": "#/definitions/ErrorBody" - } - } - }, - "LocationOptionsQuery": { - "description": "Represents a location options parameter, used for fetching area codes.", - "type": "object", - "properties": { - "labelId": { - "description": "Represents the location option label id, returned from the GetLocationOptions API.", - "type": "string" - }, - "optionsValue": { - "description": "Represents the location options value, returned from the GetLocationOptions API.", - "type": "string" - } - } - }, - "LocationOptionsQueries": { - "description": "Represents a list of location option queries, used for fetching area codes.", - "type": "object", - "properties": { - "locationOptions": { - "description": "Represents the underlying list of countries.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsQuery" - } - } - } - }, - "AreaCodes": { - "description": "Represents a list of area codes.", - "type": "object", - "properties": { - "primaryAreaCodes": { - "description": "Represents the list of primary area codes.", - "type": "array", - "items": { - "type": "string" - } - }, - "secondaryAreaCodes": { - "description": "Represents the list of secondary area codes.", - "type": "array", - "items": { - "type": "string" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "NumberUpdateCapabilities": { - "description": "Represents an individual number capabilities update request", - "type": "object", - "properties": { - "add": { - "description": "Capabilities to be added to a phone number", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", - "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" - ], - "type": "string", - "x-ms-enum": { - "name": "Capability", - "modelAsString": true - } - } - }, - "remove": { - "description": "Capabilities to be removed from a phone number", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", - "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" - ], - "type": "string", - "x-ms-enum": { - "name": "Capability", - "modelAsString": true - } - } - } - } - }, - "UpdatePhoneNumberCapabilitiesResponse": { - "description": "Response for getting a phone number update capabilities.", - "type": "object", - "properties": { - "capabilitiesUpdateId": { - "description": "The id of the phone number capabilties update", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The time the capabilities update was created", - "type": "string" - }, - "capabilitiesUpdateStatus": { - "description": "Status of the capabilities update.", - "enum": [ - "Pending", - "InProgress", - "Complete", - "Error" - ], - "type": "string", - "x-ms-enum": { - "name": "CapabilitiesUpdateStatus", - "modelAsString": true - } - }, - "phoneNumberCapabilitiesUpdates": { - "description": "The capabilities update for each of a set of phone numbers.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NumberUpdateCapabilities" - } - } - } - }, - "UpdateNumberCapabilitiesRequest": { - "description": "Represents a numbers capabilities update request", - "required": [ - "phoneNumberCapabilitiesUpdate" - ], - "type": "object", - "properties": { - "phoneNumberCapabilitiesUpdate": { - "description": "The map of phone numbers to the capabilities update applied to the phone number.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NumberUpdateCapabilities" - } - } - } - }, - "UpdateNumberCapabilitiesResponse": { - "description": "Represents a number capability update response.", - "required": [ - "capabilitiesUpdateId" - ], - "type": "object", - "properties": { - "capabilitiesUpdateId": { - "description": "The capabilities id", - "type": "string" - } - } - }, - "PhoneNumberCountry": { - "description": "Represents a country.", - "required": [ - "countryCode", - "localizedName" - ], - "type": "object", - "properties": { - "localizedName": { - "description": "Represents the name of the country.", - "type": "string" - }, - "countryCode": { - "description": "Represents the abbreviated name of the country.", - "type": "string" - } - } - }, - "PhoneNumberCountries": { - "description": "Represents a wrapper around a list of countries.", - "type": "object", - "properties": { - "countries": { - "description": "Represents the underlying list of countries.", - "type": "array", - "items": { - "$ref": "#/definitions/PhoneNumberCountry" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "NumberConfigurationPhoneNumber": { - "description": "The phone number wrapper representing a number configuration request", - "required": [ - "phoneNumber" - ], - "type": "object", - "properties": { - "phoneNumber": { - "description": "The phone number in the E.164 format", - "type": "string" - } - } - }, - "PstnConfiguration": { - "description": "Definition for pstn number configuration", - "required": [ - "callbackUrl" - ], - "type": "object", - "properties": { - "callbackUrl": { - "description": "The webhook URL on the phone number configuration.", - "type": "string" - }, - "applicationId": { - "description": "The application id of the application to which to configure", - "type": "string" - } - } - }, - "NumberConfigurationResponse": { - "description": "Definition for number configuration", - "required": [ - "pstnConfiguration" - ], - "type": "object", - "properties": { - "pstnConfiguration": { - "$ref": "#/definitions/PstnConfiguration" - } - } - }, - "NumberConfiguration": { - "description": "Definition for number configuration", - "required": [ - "phoneNumber", - "pstnConfiguration" - ], - "type": "object", - "properties": { - "pstnConfiguration": { - "$ref": "#/definitions/PstnConfiguration" - }, - "phoneNumber": { - "description": "The phone number to configure", - "type": "string" - } - } - }, - "CarrierDetails": { - "description": "Represents carrier details.", - "type": "object", - "properties": { - "name": { - "description": "Name of carrier details", - "type": "string" - }, - "localizedName": { - "description": "Display name of carrier details", - "type": "string" - } - } - }, - "RateInformation": { - "description": "Represents a wrapper of rate information", - "type": "object", - "properties": { - "monthlyRate": { - "format": "double", - "description": "The monthly rate of a phone plan group", - "type": "number" - }, - "currencyType": { - "description": "The currency of a phone plan group", - "enum": [ - "USD" - ], - "type": "string", - "x-ms-enum": { - "name": "CurrencyType", - "modelAsString": true - } - }, - "rateErrorMessage": { - "description": "The error code of a phone plan group", - "type": "string" - } - } - }, - "PhonePlanGroup": { - "description": "Represents a plan group.", - "required": [ - "localizedDescription", - "localizedName", - "phonePlanGroupId" - ], - "type": "object", - "properties": { - "phonePlanGroupId": { - "description": "The id of the plan group", - "type": "string" - }, - "phoneNumberType": { - "description": "The phone number type of the plan group", - "enum": [ - "Unknown", - "Geographic", - "TollFree", - "Indirect" - ], - "type": "string", - "x-ms-enum": { - "name": "PhoneNumberType", - "modelAsString": true - } - }, - "localizedName": { - "description": "The name of the plan group.", - "type": "string" - }, - "localizedDescription": { - "description": "The description of the plan group.", - "type": "string" - }, - "carrierDetails": { - "$ref": "#/definitions/CarrierDetails" - }, - "rateInformation": { - "$ref": "#/definitions/RateInformation" - } - } - }, - "PhonePlanGroups": { - "description": "Represents a wrapper of list of plan groups.", - "type": "object", - "properties": { - "phonePlanGroups": { - "description": "The underlying list of phone plan groups.", - "type": "array", - "items": { - "$ref": "#/definitions/PhonePlanGroup" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "PhonePlan": { - "description": "Represents a phone plan.", - "required": [ - "localizedName", - "locationType", - "phonePlanId" - ], - "type": "object", - "properties": { - "phonePlanId": { - "description": "The phone plan id", - "type": "string" - }, - "localizedName": { - "description": "The name of the phone plan", - "type": "string" - }, - "locationType": { - "description": "The location type of the phone plan.", - "enum": [ - "CivicAddress", - "NotRequired", - "Selection" - ], - "type": "string", - "x-ms-enum": { - "name": "LocationType", - "modelAsString": true - } - }, - "areaCodes": { - "description": "The list of available area codes in the phone plan.", - "type": "array", - "items": { - "type": "string" - } - }, - "capabilities": { - "description": "Capabilities of the phone plan.", - "type": "array", - "items": { - "description": "Represents the capabilities of a phone number.", - "enum": [ - "UserAssignment", - "FirstPartyVoiceAppAssignment", - "ConferenceAssignment", - "P2PSmsEnabled", - "Geographic", - "NonGeographic", - "TollCalling", - "TollFreeCalling", - "Premium", - "P2PSmsCapable", - "A2PSmsCapable", - "A2PSmsEnabled", - "Calling", - "TollFree", - "FirstPartyAppAssignment", - "ThirdPartyAppAssignment", - "Azure", - "Office365", - "InboundCalling", - "OutboundCalling", - "InboundA2PSms", - "OutboundA2PSms", - "InboundP2PSms", - "OutboundP2PSms" - ], - "type": "string", - "x-ms-enum": { - "name": "Capability", - "modelAsString": true - } - } - }, - "maximumSearchSize": { - "format": "int32", - "description": "The maximum number of phone numbers one can acquire in a search in this phone plan.", - "type": "integer" - } - } - }, - "PhonePlansResponse": { - "description": "Represents a wrapper around a list of countries.", - "type": "object", - "properties": { - "phonePlans": { - "description": "Represents the underlying list of phone plans.", - "type": "array", - "items": { - "$ref": "#/definitions/PhonePlan" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "LocationOptionsDetails": { - "description": "Represents location options deatils.", - "type": "object", - "properties": { - "name": { - "description": "The name of the location options", - "type": "string" - }, - "value": { - "description": "The abbreviated name of the location options", - "type": "string" - }, - "locationOptions": { - "description": "The underlying location options", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptions" - } - } - } - }, - "LocationOptions": { - "description": "Represents a location options.", - "type": "object", - "properties": { - "labelId": { - "description": "The label id of the location.", - "type": "string" - }, - "labelName": { - "description": "The display name of the location.", - "type": "string" - }, - "options": { - "description": "The underlying location option details.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } - } - } - }, - "LocationOptionsResponse": { - "description": "Represents a wrapper around a list of location options.", - "type": "object", - "properties": { - "locationOptions": { - "$ref": "#/definitions/LocationOptions" - } - } - }, - "PhoneNumberReleaseDetails": { - "type": "object", - "properties": { - "status": { - "description": "The release status of a phone number.", - "enum": [ - "Pending", - "Success", - "Error", - "InProgress" - ], - "type": "string", - "x-ms-enum": { - "name": "PhoneNumberReleaseStatus", - "modelAsString": true - } - }, - "errorCode": { - "format": "int32", - "description": "The error code in the case the status is error.", - "type": "integer" - } - } - }, - "PhoneNumberRelease": { - "description": "Represents a release", - "type": "object", - "properties": { - "releaseId": { - "description": "The id of the release.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The creation time of the release.", - "type": "string" - }, - "status": { - "description": "The release status.", - "enum": [ - "Pending", - "InProgress", - "Complete", - "Failed", - "Expired" - ], - "type": "string", - "x-ms-enum": { - "name": "ReleaseStatus", - "modelAsString": true - } - }, - "errorMessage": { - "description": "The underlying error message of a release.", - "type": "string" - }, - "phoneNumberReleaseStatusDetails": { - "description": "The list of phone numbers in the release, mapped to its individual statuses.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/PhoneNumberReleaseDetails" - } - } - } - }, - "ReleaseRequest": { - "description": "Represents a release request.", - "required": [ - "phoneNumbers" - ], - "type": "object", - "properties": { - "phoneNumbers": { - "description": "The list of phone numbers in the release request.", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "ReleaseResponse": { - "description": "Represents a release response.", - "required": [ - "releaseId" - ], - "type": "object", - "properties": { - "releaseId": { - "description": "The release id of a created release.", - "type": "string" - } - } - }, - "PhoneNumberEntity": { - "description": "Represents a phone number entity, as part of the response when calling get all searches or releases.", - "type": "object", - "properties": { - "id": { - "description": "The id of the entity. It is the search id of a searc. It is the release id of a release.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "Date and time the entity is created.", - "type": "string" - }, - "displayName": { - "description": "Name of the entity.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "Quantity of requested phone numbers in the entity.", - "type": "integer" - }, - "quantityObtained": { - "format": "int32", - "description": "Quantity of acquired phone numbers in the entity.", - "type": "integer" - }, - "status": { - "description": "Status of the entity.", - "type": "string" - }, - "focDate": { - "format": "date-time", - "description": "The Firm Order Confirmation date of the phone number entity.", - "type": "string" - } - } - }, - "PhoneNumberEntities": { - "description": "Represents a list of searchs or releases, as part of the response when fetching all searches or releases.", - "type": "object", - "properties": { - "entities": { - "description": "The underlying list of entities.", - "type": "array", - "items": { - "$ref": "#/definitions/PhoneNumberEntity" - } - }, - "nextLink": { - "description": "Represents the URL link to the next page", - "type": "string" - } - } - }, - "PhoneNumberSearch": { - "description": "Represents a phone number search", - "type": "object", - "properties": { - "searchId": { - "description": "The id of the search.", - "type": "string" - }, - "displayName": { - "description": "The name of the search.", - "type": "string" - }, - "createdAt": { - "format": "date-time", - "description": "The creation time of the search.", - "type": "string" - }, - "description": { - "description": "The description of the search.", - "type": "string" - }, - "phonePlanIds": { - "description": "The phone plan ids of the search.", - "type": "array", - "items": { - "type": "string" - } - }, - "areaCode": { - "description": "The area code of the search.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "The quantity of phone numbers in the search.", - "type": "integer" - }, - "locationOptions": { - "description": "The location options of the search.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } - }, - "status": { - "description": "The status of the search.", - "enum": [ - "Pending", - "InProgress", - "Reserved", - "Expired", - "Expiring", - "Completing", - "Refreshing", - "Success", - "Manual", - "Cancelled", - "Cancelling", - "Error", - "PurchasePending" - ], - "type": "string", - "x-ms-enum": { - "name": "SearchStatus", - "modelAsString": true - } - }, - "phoneNumbers": { - "description": "The list of phone numbers in the search, in the case the status is reserved or success.", - "type": "array", - "items": { - "type": "string" - } - }, - "reservationExpiryDate": { - "format": "date-time", - "description": "The date that search expires and the numbers become available.", - "type": "string" - }, - "errorCode": { - "format": "int32", - "description": "The error code of the search.", - "type": "integer" - } - } - }, - "CreateSearchOptions": { - "description": "Represents a search creation option.", - "required": [ - "areaCode", - "description", - "displayName", - "phonePlanIds" - ], - "type": "object", - "properties": { - "displayName": { - "description": "Display name of the search.", - "maxLength": 255, - "type": "string" - }, - "description": { - "description": "Description of the search.", - "maxLength": 255, - "type": "string" - }, - "phonePlanIds": { - "description": "The plan subtype ids from which to create the search.", - "type": "array", - "items": { - "type": "string" - } - }, - "areaCode": { - "description": "The area code from which to create the search.", - "type": "string" - }, - "quantity": { - "format": "int32", - "description": "The quantity of phone numbers to request.", - "maximum": 2147483647, - "minimum": 1, - "type": "integer" - }, - "locationOptions": { - "description": "The location options of the search.", - "type": "array", - "items": { - "$ref": "#/definitions/LocationOptionsDetails" - } - } - } - }, - "CreateSearchResponse": { - "description": "Represents a search creation response.", - "required": [ - "searchId" - ], - "type": "object", - "properties": { - "searchId": { - "description": "The search id of the search that was created.", - "type": "string" - } - } - } - }, - "parameters": { - "ApiVersionParameter": { - "in": "query", - "name": "api-version", - "description": "Version of API to invoke", - "required": true, - "type": "string" - }, - "Endpoint": { - "in": "path", - "name": "endpoint", - "description": "The endpoint of the Azure Communication resource.", - "required": true, - "type": "string", - "x-ms-skip-url-encoding": true, - "x-ms-parameter-location": "client" - } - }, - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "impersonate your user account" - }, - "description": "Azure Active Directory OAuth2 Flow" - } - }, - "x-ms-parameterized-host": { - "hostTemplate": "{endpoint}", - "useSchemePrefix": false, - "parameters": [ - { - "$ref": "#/parameters/Endpoint" - } - ] - } - } \ No newline at end of file From 577f7ced8ba74a2691915415a34871973d9d1ef2 Mon Sep 17 00:00:00 2001 From: Eason Date: Fri, 2 Oct 2020 17:54:31 -0700 Subject: [PATCH 09/11] remove duplicate long_description_content_type (#14230) Co-authored-by: Eason Yang --- sdk/communication/azure-communication-administration/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/communication/azure-communication-administration/setup.py b/sdk/communication/azure-communication-administration/setup.py index ca5aac5ec0156..a2e8164380940 100644 --- a/sdk/communication/azure-communication-administration/setup.py +++ b/sdk/communication/azure-communication-administration/setup.py @@ -36,7 +36,6 @@ # ensure that these are updated to reflect the package owners' information long_description=long_description, - long_description_content_type='text/markdown', url='https://github.com/Azure/azure-sdk-for-python', author='Microsoft Corporation', author_email='azuresdkengsysadmins@microsoft.com', From 77d90fe0eec58fb0ede7776b1c9411cc8f108bc0 Mon Sep 17 00:00:00 2001 From: Eason Date: Fri, 2 Oct 2020 18:14:32 -0700 Subject: [PATCH 10/11] add readme changes (#14222) Co-authored-by: Eason Yang --- .../README.md | 142 ++++++++---------- 1 file changed, 61 insertions(+), 81 deletions(-) diff --git a/sdk/communication/azure-communication-administration/README.md b/sdk/communication/azure-communication-administration/README.md index ebab042214b2b..a5c953dc67722 100644 --- a/sdk/communication/azure-communication-administration/README.md +++ b/sdk/communication/azure-communication-administration/README.md @@ -55,16 +55,15 @@ The following section provides several code snippets covering some of the most c [Create/revoke scoped user access tokens][identitysamples] -##Communication Phone number +## Communication Phone number ### Get Countries ```python -def list_all_supported_countries(): - 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) +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 @@ -72,15 +71,13 @@ def list_all_supported_countries(): Phone plan groups come in two types, Geographic and Toll-Free. ```python -def list_phone_plan_groups(): - phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) - country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_COUNTRY_CODE', "US") - - phone_plan_groups_response = phone_number_administration_client.list_phone_plan_groups( - country_code=country_code - ) - for phone_plan_group in phone_plan_groups_response: - print(phone_plan_group) +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 @@ -88,17 +85,14 @@ def list_phone_plan_groups(): Unlike Toll-Free phone plans, area codes for Geographic Phone Plans are empty. Area codes are found in the Area Codes API. ```python -def list_phone_plans(): - 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_plans_response = phone_number_administration_client.list_phone_plans( - country_code=country_code, - phone_plan_group_id=phone_plan_group_id - ) - for phone_plan in phone_plans_response: - print(phone_plan) +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 @@ -106,18 +100,14 @@ def list_phone_plans(): 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 -def get_phone_plan_location_options(): - 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") - - 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 - ) - print(location_options_response) +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 @@ -125,63 +115,53 @@ def get_phone_plan_location_options(): 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 -def get_all_area_codes(): - 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") - - 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 - ) - print(all_area_codes) +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 -def create_search(): - from azure.communication.administration import CreateSearchOptions - phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) - phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_PHONE_PLAN_ID', "phone-plan-id") - area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_AREA_CODE_FOR_SEARCH', "area-code") - - 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.begin_create_search( - body=searchOptions - ) - print(search_response.status()) +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 -def get_search_by_id(): - phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) - search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID', "search-id") - - phone_number_search_response = phone_number_administration_client.get_search_by_id( - search_id=search_id - ) - print(phone_number_search_response) +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 -def purchase_search(): - phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) - search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_PHONENUMBERS_SEARCH_ID_TO_PURCHASE', "search-id") +phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string(connection_str) - phone_number_administration_client.begin_purchase_search( - search_id=search_id_to_purchase - ) +phone_number_administration_client.purchase_search( + search_id='' +) ``` # Troubleshooting From 1055b67d0bc1f53b5d01c86099a878535d0eefc3 Mon Sep 17 00:00:00 2001 From: Eason Date: Fri, 2 Oct 2020 18:23:39 -0700 Subject: [PATCH 11/11] Azure Communication Service - Phone Number Administration - Add release phone number to live tests (#14227) * Azure Communication Service - Phone Number Administration - Samples (#14162) * add tnm samples v0 * address comments * update samples with long run operation * add basic readme for phone number description * add e=code example to tnm readme * update admin setup.py with long_description_content_type Co-authored-by: Eason Yang * rename live tests variables * add release phone numbers * remove extra lines readme Co-authored-by: Eason Yang --- ...ion_client.test_release_phone_numbers.yaml | 39 +++++++++++++++ ...ient_async.test_release_phone_numbers.yaml | 31 ++++++++++++ ...test_phone_number_administration_client.py | 50 ++++++++++++------- ...hone_number_administration_client_async.py | 48 +++++++++++------- 4 files changed, 132 insertions(+), 36 deletions(-) create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client.test_release_phone_numbers.yaml create mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_phone_number_administration_client_async.test_release_phone_numbers.yaml 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 0000000000000..6523c0d0d697c --- /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_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 0000000000000..555ece0bf35d6 --- /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/test_phone_number_administration_client.py b/sdk/communication/azure-communication-administration/tests/test_phone_number_administration_client.py index 90b6b50f35ecf..2f09606584aef 100644 --- 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 @@ -33,21 +33,22 @@ def setUp(self): self._phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string( self.connection_str) if self.is_live: - self.country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_COUNTRY_CODE') - self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_LOCALE') - self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_GROUP_ID') - self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID') - self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID_AREA_CODES') - self.area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_AREA_CODE_FOR_SEARCH') - self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID') - self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_PURCHASE') - self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_CANCEL') - self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_CONFIGURE') - self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_GET_CONFIG') - self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_UNCONFIGURE') - self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_FOR_CAPABILITIES') - self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_CAPABILITIES_ID') - self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_RELEASE_ID') + 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" @@ -92,6 +93,10 @@ def setUp(self): 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" @@ -115,6 +120,7 @@ def setUp(self): 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" @@ -160,7 +166,7 @@ def test_list_all_supported_countries(self): @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_unconfigure + phone_number=self.phonenumber_to_get_config ) assert phone_number_response.pstn_configuration @@ -168,12 +174,11 @@ def test_get_number_configuration(self): def test_configure_number(self): pstnConfig = PstnConfiguration( callback_url="https://callbackurl", - application_id="ApplicationId", - azure_pstn_target_id="AzurePstnTargetId" + application_id="ApplicationId" ) configure_number_response = self._phone_number_administration_client.configure_number( pstn_configuration=pstnConfig, - phone_number=self.phonenumber_to_unconfigure + phone_number=self.phonenumber_to_configure ) assert not configure_number_response @@ -213,6 +218,13 @@ 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( 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 index 178515f52e047..f831124390d04 100644 --- 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 @@ -34,21 +34,22 @@ def setUp(self): self._phone_number_administration_client = PhoneNumberAdministrationClient.from_connection_string( self.connection_str) if self.is_live: - self.country_code = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_COUNTRY_CODE') - self.locale = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_LOCALE') - self.phone_plan_group_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_GROUP_ID') - self.phone_plan_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID') - self.phone_plan_id_area_codes = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONE_PLAN_ID_AREA_CODES') - self.area_code_for_search = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_AREA_CODE_FOR_SEARCH') - self.search_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID') - self.search_id_to_purchase = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_PURCHASE') - self.search_id_to_cancel = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_SEARCH_ID_TO_CANCEL') - self.phonenumber_to_configure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_CONFIGURE') - self.phonenumber_to_get_config = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_GET_CONFIG') - self.phonenumber_to_unconfigure = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_TO_UNCONFIGURE') - self.phonenumber_for_capabilities = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_PHONENUMBER_FOR_CAPABILITIES') - self.capabilities_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_CAPABILITIES_ID') - self.release_id = os.getenv('AZURE_COMMUNICATION_SERVICE_TNM_RELEASE_ID') + 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" @@ -93,6 +94,10 @@ def setUp(self): 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" @@ -116,6 +121,7 @@ def setUp(self): 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" @@ -190,8 +196,7 @@ async def test_get_number_configuration(self): async def test_configure_number(self): pstnConfig = PstnConfiguration( callback_url="https://callbackurl", - application_id="ApplicationId", - azure_pstn_target_id="AzurePstnTargetId" + application_id="ApplicationId" ) async with self._phone_number_administration_client: configure_number_response = await self._phone_number_administration_client.configure_number( @@ -261,6 +266,15 @@ async def test_list_all_releases(self): 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):